MDL-50015 mod_imscp: New WS mod_imscp_view_imscp
[moodle.git] / mod / assignment / view.php
CommitLineData
81625028 1<?php
2
3require_once("../../config.php");
81625028 4
40cb4879
DW
5$id = optional_param('id', 0, PARAM_INT); // Course Module ID.
6$a = optional_param('a', 0, PARAM_INT); // Assignment ID.
81625028 7
40cb4879
DW
8require_login();
9$PAGE->set_context(context_system::instance());
81625028 10
40cb4879
DW
11if (!$id && !$a) {
12 print_error('invalidcoursemodule');
13}
81625028 14
40cb4879
DW
15$mapping = null;
16if ($id) {
17 $mapping = $DB->get_record('assignment_upgrade', array('oldcmid' => $id), '*', IGNORE_MISSING);
81625028 18} else {
40cb4879 19 $mapping = $DB->get_record('assignment_upgrade', array('oldinstance' => $a), '*', IGNORE_MISSING);
81625028 20}
d699cd1e 21
40cb4879
DW
22if (!$mapping) {
23 $url = '';
24 if (has_capability('moodle/site:config', context_system::instance())) {
25 $url = new moodle_url('/admin/tool/assignmentupgrade/listnotupgraded.php');
26 }
27 print_error('assignmentneedsupgrade', 'assignment', $url);
79547e52 28}
d699cd1e 29
40cb4879
DW
30$url = new moodle_url('/mod/assign/view.php', array('id' => $mapping->newcmid));
31redirect($url);