MDL-62244 Resource: label view redirects to label, not course

This commit is contained in:
Alison Blomenberg 2021-01-19 11:12:32 -07:00
parent f0eb6a5729
commit 2f8a102da7

View File

@ -30,7 +30,7 @@ $l = optional_param('l',0,PARAM_INT); // Label ID
if ($id) {
$PAGE->set_url('/mod/label/index.php', array('id'=>$id));
if (! $cm = get_coursemodule_from_id('label', $id)) {
if (! $cm = get_coursemodule_from_id('label', $id, 0, true)) {
print_error('invalidcoursemodule');
}
@ -50,13 +50,15 @@ if ($id) {
if (! $course = $DB->get_record("course", array("id"=>$label->course)) ){
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance("label", $label->id, $course->id)) {
if (! $cm = get_coursemodule_from_instance("label", $label->id, $course->id, true)) {
print_error('invalidcoursemodule');
}
}
require_login($course, true, $cm);
redirect("$CFG->wwwroot/course/view.php?id=$course->id");
$url = course_get_url($course, $cm->sectionnum, []);
$url->set_anchor('module-' . $id);
redirect($url);