MDL-50015 mod_imscp: New WS mod_imscp_view_imscp
[moodle.git] / mod / assignment / view.php
1 <?php
3 require_once("../../config.php");
5 $id = optional_param('id', 0, PARAM_INT);  // Course Module ID.
6 $a  = optional_param('a', 0, PARAM_INT);   // Assignment ID.
8 require_login();
9 $PAGE->set_context(context_system::instance());
11 if (!$id && !$a) {
12     print_error('invalidcoursemodule');
13 }
15 $mapping = null;
16 if ($id) {
17     $mapping = $DB->get_record('assignment_upgrade', array('oldcmid' => $id), '*', IGNORE_MISSING);
18 } else {
19     $mapping = $DB->get_record('assignment_upgrade', array('oldinstance' => $a), '*', IGNORE_MISSING);
20 }
22 if (!$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);
28 }
30 $url = new moodle_url('/mod/assign/view.php', array('id' => $mapping->newcmid));
31 redirect($url);