MDL-44905 mod_scorm: Skip view page on a Single activity course

Allow 'Student skip content structure page: Always' option with 'Single
activity' course format, and redirect 'Exit activity' back to site home
if user has no report access.
This commit is contained in:
Arto Nieminen
2017-05-29 20:32:40 +03:00
parent 9e7afbbc6c
commit 81d7b77d6f
2 changed files with 8 additions and 8 deletions
-6
View File
@@ -137,12 +137,6 @@ class mod_scorm_mod_form extends moodleform_mod {
// Skip view page.
$skipviewoptions = scorm_get_skip_view_array();
if ($COURSE->format == 'singleactivity') { // Remove option that would cause a constant redirect.
unset($skipviewoptions[SCORM_SKIPVIEW_ALWAYS]);
if ($cfgscorm->skipview == SCORM_SKIPVIEW_ALWAYS) {
$cfgscorm->skipview = SCORM_SKIPVIEW_FIRST;
}
}
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), $skipviewoptions);
$mform->addHelpButton('skipview', 'skipview', 'scorm');
$mform->setDefault('skipview', $cfgscorm->skipview);
+8 -2
View File
@@ -160,8 +160,14 @@ $completion->set_module_viewed($cm);
// Print the page header.
if (empty($scorm->popup) || $displaymode == 'popup') {
// Redirect back to the correct section if one section per page is being used.
$exiturl = course_get_url($course, $cm->sectionnum);
if ($course->format == 'singleactivity' && $scorm->skipview == SCORM_SKIPVIEW_ALWAYS
&& !has_capability('mod/scorm:viewreport', context_module::instance($cm->id))) {
// Redirect students back to site home to avoid redirect loop.
$exiturl = $CFG->wwwroot;
} else {
// Redirect back to the correct section if one section per page is being used.
$exiturl = course_get_url($course, $cm->sectionnum);
}
$exitlink = html_writer::link($exiturl, $strexit, array('title' => $strexit));
$PAGE->set_button($exitlink);