Skip to content

Commit

Permalink
MDL-28109 - allow adming to decide which scorm settings are advanced,…
Browse files Browse the repository at this point in the history
… tidy up order of settings
  • Loading branch information
danmarsden committed Jul 9, 2011
1 parent f6f6138 commit 0ffaa76
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 87 deletions.
2 changes: 2 additions & 0 deletions mod/scorm/lang/en/scorm.php
Expand Up @@ -182,6 +182,8 @@
$string['optattemptsonly'] = 'users with attempts only';
$string['optnoattemptsonly'] = 'users with no attempts only';
$string['options'] = 'Options (Prevented by some browsers)';
$string['optionsadv'] = 'Options (Advanced)';
$string['optionsadv_desc'] = 'If checked the window options below will be set as advanced options in the form';
$string['organization'] = 'Organization';
$string['organizations'] = 'Organizations';
$string['othersettings'] = 'Additional settings';
Expand Down
142 changes: 74 additions & 68 deletions mod/scorm/mod_form.php
Expand Up @@ -92,13 +92,75 @@ function definition() {
$mform->addElement('date_time_selector', 'timeopen', get_string("scormopen", "scorm"), array('optional' => true));
$mform->addElement('date_time_selector', 'timeclose', get_string("scormclose", "scorm"), array('optional' => true));
//-------------------------------------------------------------------------------
// Other Settings
$mform->addElement('header', 'advanced', get_string('othersettings', 'form'));
// display Settings
$mform->addElement('header', 'advanced', get_string('displaysettings', 'scorm'));
// Framed / Popup Window
$mform->addElement('select', 'popup', get_string('display', 'scorm'), scorm_get_popup_display_array());
$mform->setDefault('popup', $cfg_scorm->popup);
$mform->setAdvanced('popup', $cfg_scorm->popup_adv);

// Width
$mform->addElement('text', 'width', get_string('width', 'scorm'), 'maxlength="5" size="5"');
$mform->setDefault('width', $cfg_scorm->framewidth);
$mform->setType('width', PARAM_INT);
$mform->setAdvanced('width', $cfg_scorm->framewidth_adv);
$mform->disabledIf('width', 'popup', 'eq', 0);

// Height
$mform->addElement('text', 'height', get_string('height', 'scorm'), 'maxlength="5" size="5"');
$mform->setDefault('height', $cfg_scorm->frameheight);
$mform->setType('height', PARAM_INT);
$mform->setAdvanced('height', $cfg_scorm->frameheight_adv);
$mform->disabledIf('height', 'popup', 'eq', 0);

// Window Options
$winoptgrp = array();
foreach (scorm_get_popup_options_array() as $key => $value) {
$winoptgrp[] = &$mform->createElement('checkbox', $key, '', get_string($key, 'scorm'));
$mform->setDefault($key, $value);
}
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options', 'scorm'), '<br />', false);
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);
$mform->setAdvanced('winoptgrp', $cfg_scorm->winoptgrp_adv);

// Skip view page
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), scorm_get_skip_view_array());
$mform->addHelpButton('skipview', 'skipview', 'scorm');
$mform->setDefault('skipview', $cfg_scorm->skipview);
$mform->setAdvanced('skipview', $cfg_scorm->skipview_adv);

// Hide Browse
$mform->addElement('selectyesno', 'hidebrowse', get_string('hidebrowse', 'scorm'));
$mform->addHelpButton('hidebrowse', 'hidebrowse', 'scorm');
$mform->setDefault('hidebrowse', $cfg_scorm->hidebrowse);
$mform->setAdvanced('hidebrowse', $cfg_scorm->hidebrowse_adv);

// Display course structure
$mform->addElement('selectyesno', 'displaycoursestructure', get_string('displaycoursestructure', 'scorm'));
$mform->addHelpButton('displaycoursestructure', 'displaycoursestructure', 'scorm');
$mform->setDefault('displaycoursestructure', $cfg_scorm->displaycoursestructure);
$mform->setAdvanced('displaycoursestructure', $cfg_scorm->displaycoursestructure_adv);

// Toc display
$mform->addElement('select', 'hidetoc', get_string('hidetoc', 'scorm'), scorm_get_hidetoc_array());
$mform->addHelpButton('hidetoc', 'hidetoc', 'scorm');
$mform->setDefault('hidetoc', $cfg_scorm->hidetoc);
$mform->setAdvanced('hidetoc', $cfg_scorm->hidetoc_adv);

// Hide Navigation panel
$mform->addElement('selectyesno', 'hidenav', get_string('hidenav', 'scorm'));
$mform->setDefault('hidenav', $cfg_scorm->hidenav);
$mform->setAdvanced('hidenav', $cfg_scorm->hidenav_adv);

//-------------------------------------------------------------------------------
// grade Settings
$mform->addElement('header', 'advanced', get_string('gradesettings', 'scorm'));

// Grade Method
$mform->addElement('select', 'grademethod', get_string('grademethod', 'scorm'), scorm_get_grade_method_array());
$mform->addHelpButton('grademethod', 'grademethod', 'scorm');
$mform->setDefault('grademethod', $cfg_scorm->grademethod);
$mform->setAdvanced('grademethod', $cfg_scorm->grademethod_adv);

// Maximum Grade
for ($i=0; $i<=100; $i++) {
Expand All @@ -107,44 +169,46 @@ function definition() {
$mform->addElement('select', 'maxgrade', get_string('maximumgrade'), $grades);
$mform->setDefault('maxgrade', $cfg_scorm->maxgrade);
$mform->disabledIf('maxgrade', 'grademethod', 'eq', GRADESCOES);
$mform->setAdvanced('maxgrade', $cfg_scorm->maxgrade_adv);

// Attempts
$mform->addElement('static', '', '' , '<hr />');
$mform->addElement('header', 'advanced', get_string('othersettings', 'scorm'));

// Max Attempts
$mform->addElement('select', 'maxattempt', get_string('maximumattempts', 'scorm'), scorm_get_attempts_array());
$mform->addHelpButton('maxattempt', 'maximumattempts', 'scorm');
$mform->setDefault('maxattempt', $cfg_scorm->maxattempts);
$mform->setAdvanced('maxattempt', $cfg_scorm->maxattempts_adv);

// What Grade
$mform->addElement('select', 'whatgrade', get_string('whatgrade', 'scorm'), scorm_get_what_grade_array());
$mform->disabledIf('whatgrade', 'maxattempt', 'eq', 1);
$mform->addHelpButton('whatgrade', 'whatgrade', 'scorm');
$mform->setDefault('whatgrade', $cfg_scorm->whatgrade);
$mform->setAdvanced('whatgrade');
$mform->setAdvanced('whatgrade', $cfg_scorm->whatgrade_adv);

// Display attempt status
$mform->addElement('selectyesno', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'));
$mform->addHelpButton('displayattemptstatus', 'displayattemptstatus', 'scorm');
$mform->setDefault('displayattemptstatus', $cfg_scorm->displayattemptstatus);
$mform->setAdvanced('displayattemptstatus', $cfg_scorm->displayattemptstatus_adv);

// Force completed
$mform->addElement('selectyesno', 'forcecompleted', get_string('forcecompleted', 'scorm'));
$mform->addHelpButton('forcecompleted', 'forcecompleted', 'scorm');
$mform->setDefault('forcecompleted', $cfg_scorm->forcecompleted);
$mform->setAdvanced('forcecompleted');
$mform->setAdvanced('forcecompleted', $cfg_scorm->forcecompleted_adv);

// Force new attempt
$mform->addElement('selectyesno', 'forcenewattempt', get_string('forcenewattempt', 'scorm'));
$mform->addHelpButton('forcenewattempt', 'forcenewattempt', 'scorm');
$mform->setDefault('forcenewattempt', $cfg_scorm->forcenewattempt);
$mform->setAdvanced('forcenewattempt');
$mform->setAdvanced('forcenewattempt', $cfg_scorm->forcenewattempt_adv);

// Last attempt lock - lock the enter button after the last available attempt has been made
$mform->addElement('selectyesno', 'lastattemptlock', get_string('lastattemptlock', 'scorm'));
$mform->addHelpButton('lastattemptlock', 'lastattemptlock', 'scorm');
$mform->setDefault('lastattemptlock', $cfg_scorm->lastattemptlock);
$mform->setAdvanced('lastattemptlock');
$mform->setAdvanced('lastattemptlock', $cfg_scorm->lastattemptlock_adv);

// Activation period
/* $mform->addElement('static', '', '' ,'<hr />');
Expand All @@ -166,74 +230,16 @@ function definition() {
$mform->disabledIf('dateendgrp', 'enddisabled', 'checked');
*/

// Framed / Popup Window
$mform->addElement('select', 'popup', get_string('display', 'scorm'), scorm_get_popup_display_array());
$mform->setDefault('popup', $cfg_scorm->popup);
$mform->setAdvanced('popup');

// Width
$mform->addElement('text', 'width', get_string('width', 'scorm'), 'maxlength="5" size="5"');
$mform->setDefault('width', $cfg_scorm->framewidth);
$mform->setType('width', PARAM_INT);
$mform->setAdvanced('width');
$mform->disabledIf('width', 'popup', 'eq', 0);

// Height
$mform->addElement('text', 'height', get_string('height', 'scorm'), 'maxlength="5" size="5"');
$mform->setDefault('height', $cfg_scorm->frameheight);
$mform->setType('height', PARAM_INT);
$mform->setAdvanced('height');
$mform->disabledIf('height', 'popup', 'eq', 0);

// Window Options
$winoptgrp = array();
foreach (scorm_get_popup_options_array() as $key => $value) {
$winoptgrp[] = &$mform->createElement('checkbox', $key, '', get_string($key, 'scorm'));
$mform->setDefault($key, $value);
}
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options', 'scorm'), '<br />', false);
$mform->setAdvanced('winoptgrp');
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);

// Skip view page
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), scorm_get_skip_view_array());
$mform->addHelpButton('skipview', 'skipview', 'scorm');
$mform->setDefault('skipview', $cfg_scorm->skipview);
$mform->setAdvanced('skipview');

// Hide Browse
$mform->addElement('selectyesno', 'hidebrowse', get_string('hidebrowse', 'scorm'));
$mform->addHelpButton('hidebrowse', 'hidebrowse', 'scorm');
$mform->setDefault('hidebrowse', $cfg_scorm->hidebrowse);
$mform->setAdvanced('hidebrowse');

// Display course structure
$mform->addElement('selectyesno', 'displaycoursestructure', get_string('displaycoursestructure', 'scorm'));
$mform->addHelpButton('displaycoursestructure', 'displaycoursestructure', 'scorm');
$mform->setDefault('displaycoursestructure', $cfg_scorm->displaycoursestructure);
$mform->setAdvanced('displaycoursestructure');

// Toc display
$mform->addElement('select', 'hidetoc', get_string('hidetoc', 'scorm'), scorm_get_hidetoc_array());
$mform->addHelpButton('hidetoc', 'hidetoc', 'scorm');
$mform->setDefault('hidetoc', $cfg_scorm->hidetoc);
$mform->setAdvanced('hidetoc');

// Hide Navigation panel
$mform->addElement('selectyesno', 'hidenav', get_string('hidenav', 'scorm'));
$mform->setDefault('hidenav', $cfg_scorm->hidenav);
$mform->setAdvanced('hidenav');

// Autocontinue
$mform->addElement('selectyesno', 'auto', get_string('autocontinue', 'scorm'));
$mform->addHelpButton('auto', 'autocontinue', 'scorm');
$mform->setDefault('auto', $cfg_scorm->auto);
$mform->setAdvanced('auto');
$mform->setAdvanced('auto', $cfg_scorm->auto_adv);

// Update packages timing
$mform->addElement('select', 'updatefreq', get_string('updatefreq', 'scorm'), scorm_get_updatefreq_array());
$mform->setDefault('updatefreq', $cfg_scorm->updatefreq);
$mform->setAdvanced('updatefreq');
$mform->setAdvanced('updatefreq', $cfg_scorm->updatefreq_adv);

//-------------------------------------------------------------------------------
// Hidden Settings
Expand Down
83 changes: 64 additions & 19 deletions mod/scorm/settings.php
Expand Up @@ -21,49 +21,94 @@
$yesno = array(0 => get_string('no'),
1 => get_string('yes'));

$settings->add(new admin_setting_configselect('scorm/grademethod', get_string('grademethod', 'scorm'), get_string('grademethoddesc', 'scorm'), GRADEHIGHEST, scorm_get_grade_method_array()));
//default grade settings
$settings->add(new admin_setting_configselect_with_advanced('scorm/grademethod',
get_string('grademethod', 'scorm'), get_string('grademethoddesc', 'scorm'),
array('value' => GRADEHIGHEST, 'adv' => false), scorm_get_grade_method_array()));

for ($i=0; $i<=100; $i++) {
$grades[$i] = "$i";
}
$settings->add(new admin_setting_configselect('scorm/maxgrade', get_string('maximumgrade'), get_string('maximumgradedesc', 'scorm'), 100, $grades));

$settings->add(new admin_setting_configtext('scorm/maxattempts', get_string('maximumattempts', 'scorm'), '', 0, PARAM_INT));
$settings->add(new admin_setting_configselect_with_advanced('scorm/maxgrade',
get_string('maximumgrade'), get_string('maximumgradedesc', 'scorm'),
array('value' => 100, 'adv' => false), $grades));

$settings->add(new admin_setting_configselect('scorm/displayattemptstatus', get_string('displayattemptstatus', 'scorm'), get_string('displayattemptstatusdesc', 'scorm'), 0, $yesno));
//default attempts settings.
$settings->add(new admin_setting_configselect_with_advanced('scorm/maxattempts',
get_string('maximumattempts', 'scorm'), '',
array('value' => '0', 'adv' => false), scorm_get_attempts_array()));

$settings->add(new admin_setting_configselect('scorm/displaycoursestructure', get_string('displaycoursestructure', 'scorm'), get_string('displaycoursestructuredesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect_with_advanced('scorm/whatgrade',
get_string('whatgrade', 'scorm'), get_string('whatgradedesc', 'scorm'),
array('value' => HIGHESTATTEMPT, 'adv' => false), scorm_get_what_grade_array()));

$settings->add(new admin_setting_configselect('scorm/forcecompleted', get_string('forcecompleted', 'scorm'), get_string('forcecompleteddesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect_with_advanced('scorm/displayattemptstatus',
get_string('displayattemptstatus', 'scorm'), get_string('displayattemptstatusdesc', 'scorm'),
array('value' => 1, 'adv' => false), $yesno));

$settings->add(new admin_setting_configselect('scorm/forcenewattempt', get_string('forcenewattempt', 'scorm'), get_string('forcenewattemptdesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect_with_advanced('scorm/forcecompleted',
get_string('forcecompleted', 'scorm'), get_string('forcecompleteddesc', 'scorm'),
array('value' => 0, 'adv' => true), $yesno));

$settings->add(new admin_setting_configselect('scorm/lastattemptlock', get_string('lastattemptlock', 'scorm'), get_string('lastattemptlockdesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect_with_advanced('scorm/forcenewattempt',
get_string('forcenewattempt', 'scorm'), get_string('forcenewattemptdesc', 'scorm'),
array('value' => 0, 'adv' => true), $yesno));

$settings->add(new admin_setting_configselect('scorm/whatgrade', get_string('whatgrade', 'scorm'), get_string('whatgradedesc', 'scorm'), HIGHESTATTEMPT, scorm_get_what_grade_array()));
$settings->add(new admin_setting_configselect_with_advanced('scorm/lastattemptlock',
get_string('lastattemptlock', 'scorm'), get_string('lastattemptlockdesc', 'scorm'),
array('value' => 0, 'adv' => true), $yesno));

$settings->add(new admin_setting_configtext('scorm/framewidth', get_string('width', 'scorm'), get_string('framewidth', 'scorm'), 100));
//default display settings
$settings->add(new admin_setting_configselect_with_advanced('scorm/displaycoursestructure',
get_string('displaycoursestructure', 'scorm'), get_string('displaycoursestructuredesc', 'scorm'),
array('value' => 0, 'adv' => false), $yesno));

$settings->add(new admin_setting_configtext('scorm/frameheight', get_string('height', 'scorm'), get_string('frameheight', 'scorm'), 500));
$settings->add(new admin_setting_configselect_with_advanced('scorm/popup',
get_string('display', 'scorm'), get_string('displaydesc', 'scorm'),
array('value' => 0, 'adv' => false), scorm_get_popup_display_array()));

$settings->add(new admin_setting_configselect('scorm/popup', get_string('display', 'scorm'), get_string('displaydesc', 'scorm'), 0, scorm_get_popup_display_array()));
$settings->add(new admin_setting_configtext_with_advanced('scorm/framewidth',
get_string('width', 'scorm'), get_string('framewidth', 'scorm'),
array('value' => '100', 'adv' => true)));

$settings->add(new admin_setting_configtext_with_advanced('scorm/frameheight',
get_string('height', 'scorm'), get_string('frameheight', 'scorm'),
array('value' => '500', 'adv' => true)));

$settings->add(new admin_setting_configcheckbox('scorm/winoptgrp_adv',
get_string('optionsadv', 'scorm'), get_string('optionsadv_desc', 'scorm'), 1));

foreach (scorm_get_popup_options_array() as $key => $value) {
$settings->add(new admin_setting_configcheckbox('scorm/'.$key, get_string($key, 'scorm'), '', $value));
$settings->add(new admin_setting_configcheckbox('scorm/'.$key,
get_string($key, 'scorm'), '', $value));
}

$settings->add(new admin_setting_configselect('scorm/skipview', get_string('skipview', 'scorm'), get_string('skipviewdesc', 'scorm'), 0, scorm_get_skip_view_array()));
$settings->add(new admin_setting_configselect_with_advanced('scorm/skipview',
get_string('skipview', 'scorm'), get_string('skipviewdesc', 'scorm'),
array('value' => 0, 'adv' => true), scorm_get_skip_view_array()));

$settings->add(new admin_setting_configselect('scorm/hidebrowse', get_string('hidebrowse', 'scorm'), get_string('hidebrowsedesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect_with_advanced('scorm/hidebrowse',
get_string('hidebrowse', 'scorm'), get_string('hidebrowsedesc', 'scorm'),
array('value' => 0, 'adv' => true), $yesno));

$settings->add(new admin_setting_configselect('scorm/hidetoc', get_string('hidetoc', 'scorm'), get_string('hidetocdesc', 'scorm'), 0, scorm_get_hidetoc_array()));
$settings->add(new admin_setting_configselect_with_advanced('scorm/hidetoc',
get_string('hidetoc', 'scorm'), get_string('hidetocdesc', 'scorm'),
array('value' => 0, 'adv' => true), scorm_get_hidetoc_array()));

$settings->add(new admin_setting_configselect('scorm/hidenav', get_string('hidenav', 'scorm'), get_string('hidenavdesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect_with_advanced('scorm/hidenav',
get_string('hidenav', 'scorm'), get_string('hidenavdesc', 'scorm'),
array('value' => 0, 'adv' => false), $yesno));

$settings->add(new admin_setting_configselect('scorm/auto', get_string('autocontinue', 'scorm'), get_string('autocontinuedesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect_with_advanced('scorm/auto',
get_string('autocontinue', 'scorm'), get_string('autocontinuedesc', 'scorm'),
array('value' => 0, 'adv' => true), $yesno));

$settings->add(new admin_setting_configselect('scorm/updatefreq', get_string('updatefreq', 'scorm'), get_string('updatefreqdesc', 'scorm'), 0, scorm_get_updatefreq_array()));
$settings->add(new admin_setting_configselect_with_advanced('scorm/updatefreq',
get_string('updatefreq', 'scorm'), get_string('updatefreqdesc', 'scorm'),
array('value' => 0, 'adv' => true), scorm_get_updatefreq_array()));

//admin level settings.
$settings->add(new admin_setting_configtext('scorm/updatetime', get_string('updatetime', 'scorm'), '', 2, PARAM_INT));

$settings->add(new admin_setting_configcheckbox('scorm/allowtypeexternal', get_string('allowtypeexternal', 'scorm'), '', 0));
Expand Down

0 comments on commit 0ffaa76

Please sign in to comment.