MDL-34374 SCORM prevent skipview being set to always when used inside a SCORM course format.

This commit is contained in:
Dan Marsden
2012-07-19 09:05:07 +12:00
parent 3b52187e25
commit fece4fd648
2 changed files with 15 additions and 4 deletions
+7 -3
View File
@@ -22,6 +22,10 @@ define('SCORM_UPDATE_NEVER', '0');
define('SCORM_UPDATE_EVERYDAY', '2');
define('SCORM_UPDATE_EVERYTIME', '3');
define('SCORM_SKIPVIEW_NEVER', '0');
define('SCORM_SKIPVIEW_FIRST', '1');
define('SCORM_SKIPVIEW_ALWAYS', '2');
define('SCO_ALL', 0);
define('SCO_DATA', 1);
define('SCO_ONLY', 2);
@@ -109,9 +113,9 @@ function scorm_get_what_grade_array() {
* @return array an array of skip view options
*/
function scorm_get_skip_view_array() {
return array(0 => get_string('never'),
1 => get_string('firstaccess', 'scorm'),
2 => get_string('always'));
return array(SCORM_SKIPVIEW_NEVER => get_string('never'),
SCORM_SKIPVIEW_FIRST => get_string('firstaccess', 'scorm'),
SCORM_SKIPVIEW_ALWAYS => get_string('always'));
}
/**
+8 -1
View File
@@ -124,7 +124,14 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->setAdvanced('winoptgrp', $cfg_scorm->winoptgrp_adv);
// Skip view page
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), scorm_get_skip_view_array());
$skipviewoptions = scorm_get_skip_view_array();
if ($COURSE->format == 'scorm') { // Remove option that would cause a constant redirect.
unset($skipviewoptions[SCORM_SKIPVIEW_ALWAYS]);
if ($cfg_scorm->skipview == SCORM_SKIPVIEW_ALWAYS) {
$cfg_scorm->skipview = SCORM_SKIPVIEW_FIRST;
}
}
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), $skipviewoptions);
$mform->addHelpButton('skipview', 'skipview', 'scorm');
$mform->setDefault('skipview', $cfg_scorm->skipview);
$mform->setAdvanced('skipview', $cfg_scorm->skipview_adv);