Permalink
Browse files

MDL-16810 - Allow site configuration of scorm settings. Thanks Jason …

…Hardin. Backport 1.9.
  • Loading branch information...
1 parent b40bf0b commit 9e7f70ddab30c956821ae8822603d6c151426d9d piers committed Nov 14, 2008
Showing with 182 additions and 94 deletions.
  1. +13 −0 lang/en_utf8/scorm.php
  2. +3 −2 mod/scorm/lib.php
  3. +100 −29 mod/scorm/locallib.php
  4. +30 −62 mod/scorm/mod_form.php
  5. +3 −0 mod/scorm/player.php
  6. +33 −1 mod/scorm/settings.php
View
13 lang/en_utf8/scorm.php
@@ -12,6 +12,7 @@
$string['attemptsx'] = '$a attempts';
$string['attr_error'] = 'Bad value for attribute ($a->attr) in tag $a->tag.';
$string['autocontinue'] = 'Auto-Continue';
+$string['autocontinuedesc'] = 'This preference sets the default auto continue for the activity';
$string['averageattempt'] = 'Average attempts';
$string['badmanifest'] = 'Some manifest errors: see errors log';
$string['badpackage'] = 'The specified package/manifest is not valid. Check it and try again.';
@@ -30,6 +31,7 @@
$string['details'] = 'Track details';
$string['directories'] = 'Show the directory links';
$string['display'] = 'Display package';
+$string['displaydesc'] = 'This preference sets the default of whether to display the package or not for an activity';
$string['domxml'] = 'DOMXML external library';
$string['element'] = 'Element';
$string['entercourse'] = 'Enter course';
@@ -52,15 +54,19 @@
$string['gradeaverage'] = 'Average grade';
$string['gradehighest'] = 'Highest grade';
$string['grademethod'] = 'Grading method';
+$string['grademethoddesc'] = 'This preference sets the default grade method for an activity';
$string['gradescoes'] = 'Learning Objects';
$string['gradesum'] = 'Sum grade';
$string['height'] = 'Height';
$string['hidden'] = 'Hidden';
$string['hidebrowse'] = 'Disable preview mode';
+$string['hidebrowsedesc'] = 'This preference sets the default or whether to disable or enable the preview mode';
$string['hideexit'] = 'Hide exit link';
$string['hidenav'] = 'Hide navigation buttons';
+$string['hidenavdesc'] = 'This preference sets the default or whether to show or hide the navigation buttons';
$string['hidereview'] = 'Hide review button';
$string['hidetoc'] = 'Course structure display (TOC)';
+$string['hidetocdesc'] = 'This preference sets the default for whether to show or hide the course structure display (TOC)';
$string['highestattempt'] = 'Highest attempt';
$string['identifier'] = 'Question Identifier';
$string['iframe'] = 'Current window';
@@ -73,6 +79,8 @@
$string['location'] = 'Show the location bar';
$string['max'] = 'Max score';
$string['maximumattempts'] = 'Number of attempts';
+$string['maximumattemptsdesc'] = 'This preference sets the default number of maximum attempts for an activity';
+$string['maximumgradedesc'] = 'This preferences sets the default maximum grade for an activity';
$string['menubar'] = 'Show the menu bar';
$string['min'] = 'Min score';
$string['missing_attribute'] = 'Missing attribute $a->attr in tag $a->tag';
@@ -104,6 +112,8 @@
$string['passed'] = 'Passed';
$string['php5'] = 'PHP 5 (DOMXML native library)';
$string['popup'] = 'New window';
+$string['popupblocked'] = 'If a new windows does not apprear click $a to launch the activity';
+$string['popupblockedlinkname'] = 'here';
$string['popupmenu'] = 'In a drop down menu';
$string['popupopen'] = 'Open package in a new window';
$string['position_error'] = 'The $a->tag tag can\'t be child of $a->parent tag';
@@ -126,6 +136,7 @@
$string['scrollbars'] = 'Allow the window to be scrolled';
$string['sided'] = 'On the left side';
$string['skipview'] = 'Student skip content structure page';
+$string['skipviewdesc'] = 'This preference sets the default of when to skip content structure for a page';
$string['slashargs'] = 'WARNING: slash arguments is disabled on this site and objects may not function as expected!';
$string['stagesize'] = 'Stage size';
$string['started'] = 'Started on';
@@ -151,10 +162,12 @@
$string['viewallreports'] = 'View reports for $a attempts';
$string['viewalluserreports'] = 'View reports for $a users';
$string['whatgrade'] = 'Attempts grading';
+$string['whatgradedesc'] = 'This preference sets the default attempts grading';
$string['width'] = 'Width';
$string['window'] = 'Window';
$string['unziperror'] = 'An error occurs during package unzip';
$string['othersettings'] = 'Additional settings';
+$string['updatefreqdesc'] = 'This preference sets the default auto-update frequency of an activity';
$string['updatefreq'] = 'Auto-update frequency';
$string['options'] = 'Options';
$string['activityloading'] = "You will be automatically redirected to the activity in"; // used in conjunction with numseconds
View
5 mod/scorm/lib.php
@@ -545,11 +545,12 @@ function scorm_get_post_actions() {
}
function scorm_option2text($scorm) {
- global $SCORM_POPUP_OPTIONS;
+ $scorm_popoup_options = scorm_get_popup_options_array();
+
if (isset($scorm->popup)) {
if ($scorm->popup == 1) {
$optionlist = array();
- foreach ($SCORM_POPUP_OPTIONS as $name => $option) {
+ foreach ($scorm_popoup_options as $name => $option) {
if (isset($scorm->$name)) {
$optionlist[] = $name.'='.$scorm->$name;
} else {
View
129 mod/scorm/locallib.php
@@ -14,47 +14,36 @@
define('GRADEHIGHEST', '1');
define('GRADEAVERAGE', '2');
define('GRADESUM', '3');
-$SCORM_GRADE_METHOD = array (GRADESCOES => get_string('gradescoes', 'scorm'),
- GRADEHIGHEST => get_string('gradehighest', 'scorm'),
- GRADEAVERAGE => get_string('gradeaverage', 'scorm'),
- GRADESUM => get_string('gradesum', 'scorm'));
define('HIGHESTATTEMPT', '0');
define('AVERAGEATTEMPT', '1');
define('FIRSTATTEMPT', '2');
define('LASTATTEMPT', '3');
-$SCORM_WHAT_GRADE = array (HIGHESTATTEMPT => get_string('highestattempt', 'scorm'),
- AVERAGEATTEMPT => get_string('averageattempt', 'scorm'),
- FIRSTATTEMPT => get_string('firstattempt', 'scorm'),
- LASTATTEMPT => get_string('lastattempt', 'scorm'));
-
-$SCORM_POPUP_OPTIONS = array('resizable'=>1,
- 'scrollbars'=>1,
- 'directories'=>0,
- 'location'=>0,
- 'menubar'=>0,
- 'toolbar'=>0,
- 'status'=>0);
+
+/**
+ * Returns an array of the popup options for SCORM and each options default value
+ *
+ * @return array an array of popup options as the key and their defaults as the value
+ */
+function scorm_get_popup_options_array(){
+ global $CFG;
+ return array('resizable'=> isset($CFG->scorm_resizable) ? $CFG->scorm_resizable : 0,
+ 'scrollbars'=> isset($CFG->scorm_scrollbars) ? $CFG->scorm_scrollbars : 0,
+ 'directories'=> isset($CFG->scorm_directories) ? $CFG->scorm_directories : 0,
+ 'location'=> isset($CFG->scorm_location) ? $CFG->scorm_location : 0,
+ 'menubar'=> isset($CFG->scorm_menubar) ? $CFG->scorm_menubar : 0,
+ 'toolbar'=> isset($CFG->scorm_toolbar) ? $CFG->scorm_toolbar : 0,
+ 'status'=> isset($CFG->scorm_status) ? $CFG->scorm_status : 0);
+}
+
$stdoptions = '';
-foreach ($SCORM_POPUP_OPTIONS as $popupopt => $value) {
+foreach (scorm_get_popup_options_array() as $popupopt => $value) {
$stdoptions .= $popupopt.'='.$value;
if ($popupopt != 'status') {
$stdoptions .= ',';
}
}
-if (!isset($CFG->scorm_maxattempts)) {
- set_config('scorm_maxattempts','6');
-}
-
-if (!isset($CFG->scorm_frameheight)) {
- set_config('scorm_frameheight','500');
-}
-
-if (!isset($CFG->scorm_framewidth)) {
- set_config('scorm_framewidth','100%');
-}
-
if (!isset($CFG->scorm_updatetime)) {
set_config('scorm_updatetime','2');
}
@@ -68,6 +57,88 @@
}
/// Local Library of functions for module scorm
+/**
+ * Returns an array of the array of what grade options
+ *
+ * @return array an array of what grade options
+ */
+function scorm_get_grade_method_array(){
+ return array (GRADESCOES => get_string('gradescoes', 'scorm'),
+ GRADEHIGHEST => get_string('gradehighest', 'scorm'),
+ GRADEAVERAGE => get_string('gradeaverage', 'scorm'),
+ GRADESUM => get_string('gradesum', 'scorm'));
+}
+
+/**
+ * Returns an array of the array of what grade options
+ *
+ * @return array an array of what grade options
+ */
+function scorm_get_what_grade_array(){
+ return array (HIGHESTATTEMPT => get_string('highestattempt', 'scorm'),
+ AVERAGEATTEMPT => get_string('averageattempt', 'scorm'),
+ FIRSTATTEMPT => get_string('firstattempt', 'scorm'),
+ LASTATTEMPT => get_string('lastattempt', 'scorm'));
+}
+
+/**
+ * Returns an array of the array of skip view options
+ *
+ * @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'));
+}
+
+/**
+ * Returns an array of the array of hide table of contents options
+ *
+ * @return array an array of hide table of contents options
+ */
+function scorm_get_hidetoc_array(){
+ return array(0 =>get_string('sided','scorm'),
+ 1 => get_string('hidden','scorm'),
+ 2 => get_string('popupmenu','scorm'));
+}
+
+/**
+ * Returns an array of the array of update frequency options
+ *
+ * @return array an array of update frequency options
+ */
+function scorm_get_updatefreq_array(){
+ return array(0 => get_string('never'),
+ 1 => get_string('everyday','scorm'),
+ 2 => get_string('everytime','scorm'));
+}
+
+/**
+ * Returns an array of the array of popup display options
+ *
+ * @return array an array of popup display options
+ */
+function scorm_get_popup_display_array(){
+ return array(0 => get_string('iframe', 'scorm'),
+ 1 => get_string('popup', 'scorm'));
+}
+
+/**
+ * Returns an array of the array of attempt options
+ *
+ * @return array an array of attempt options
+ */
+function scorm_get_attempts_array(){
+ $attempts = array(0 => get_string('nolimit','scorm'),
+ 1 => get_string('attempt1','scorm'));
+
+ for ($i=2; $i<=6; $i++) {
+ $attempts[$i] = get_string('attemptsx','scorm', $i);
+ }
+
+ return $attempts;
+}
/**
* This function will permanently delete the given
View
92 mod/scorm/mod_form.php
@@ -6,7 +6,7 @@ class mod_scorm_mod_form extends moodleform_mod {
function definition() {
- global $CFG, $COURSE, $SCORM_GRADE_METHOD, $SCORM_WHAT_GRADE;
+ global $CFG, $COURSE;
$mform =& $this->_form;
if (isset($CFG->slasharguments) && !$CFG->slasharguments) {
$mform->addElement('static', '', '',notify(get_string('slashargs', 'scorm'), 'notifyproblem', 'center', true));
@@ -44,39 +44,31 @@ function definition() {
$mform->addElement('header', 'advanced', get_string('othersettings', 'form'));
// Grade Method
- $mform->addElement('select', 'grademethod', get_string('grademethod', 'scorm'), $SCORM_GRADE_METHOD);
+ $mform->addElement('select', 'grademethod', get_string('grademethod', 'scorm'), scorm_get_grade_method_array());
$mform->setHelpButton('grademethod', array('grademethod',get_string('grademethod', 'scorm'),'scorm'));
- $mform->setDefault('grademethod', 0);
+ $mform->setDefault('grademethod', $CFG->scorm_grademethod);
// Maximum Grade
for ($i=0; $i<=100; $i++) {
$grades[$i] = "$i";
}
$mform->addElement('select', 'maxgrade', get_string('maximumgrade'), $grades);
- $mform->setDefault('maxgrade', 0);
+ $mform->setDefault('maxgrade', $CFG->scorm_maxgrade);
$mform->disabledIf('maxgrade', 'grademethod','eq',GRADESCOES);
// Attempts
$mform->addElement('static', '', '' ,'<hr />');
// Max Attempts
- $attempts = array(0 => get_string('nolimit','scorm'));
- for ($i=1; $i<=$CFG->scorm_maxattempts; $i++) {
- if ($i == 1) {
- $attempts[$i] = get_string('attempt1','scorm');
- } else {
- $attempts[$i] = get_string('attemptsx','scorm', $i);
- }
- }
- $mform->addElement('select', 'maxattempt', get_string('maximumattempts', 'scorm'), $attempts);
+ $mform->addElement('select', 'maxattempt', get_string('maximumattempts', 'scorm'), scorm_get_attempts_array());
$mform->setHelpButton('maxattempt', array('maxattempt',get_string('maximumattempts', 'scorm'), 'scorm'));
- $mform->setDefault('maxattempt', 1);
+ $mform->setDefault('maxattempt', $CFG->scorm_maxattempts);
// What Grade
- $mform->addElement('select', 'whatgrade', get_string('whatgrade', 'scorm'), $SCORM_WHAT_GRADE);
+ $mform->addElement('select', 'whatgrade', get_string('whatgrade', 'scorm'), scorm_get_what_grade_array());
$mform->disabledIf('whatgrade', 'maxattempt','eq',1);
$mform->setHelpButton('whatgrade', array('whatgrade',get_string('whatgrade', 'scorm'), 'scorm'));
- $mform->setDefault('whatgrade', 0);
+ $mform->setDefault('whatgrade', $CFG->scorm_whatgrade);
$mform->setAdvanced('whatgrade');
// Activation period
@@ -113,77 +105,51 @@ function definition() {
$mform->setType('height', PARAM_INT);
// Framed / Popup Window
- $options = array();
- $options[0] = get_string('iframe', 'scorm');
- $options[1] = get_string('popup', 'scorm');
- $mform->addElement('select', 'popup', get_string('display','scorm'), $options);
- $mform->setDefault('popup', 0);
+ $mform->addElement('select', 'popup', get_string('display','scorm'), scorm_get_popup_display_array());
+ $mform->setDefault('popup', $CFG->scorm_popup);
$mform->setAdvanced('popup');
// Window Options
$winoptgrp = array();
- $winoptgrp[] = &$mform->createElement('checkbox', 'resizable', '', get_string('resizable', 'scorm'));
- $winoptgrp[] = &$mform->createElement('checkbox', 'scrollbars', '', get_string('scrollbars', 'scorm'));
- $winoptgrp[] = &$mform->createElement('checkbox', 'directories', '', get_string('directories', 'scorm'));
- $winoptgrp[] = &$mform->createElement('checkbox', 'location', '', get_string('location', 'scorm'));
- $winoptgrp[] = &$mform->createElement('checkbox', 'menubar', '', get_string('menubar', 'scorm'));
- $winoptgrp[] = &$mform->createElement('checkbox', 'toolbar', '', get_string('toolbar', 'scorm'));
- $winoptgrp[] = &$mform->createElement('checkbox', 'status', '', get_string('status', 'scorm'));
+ 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->setDefault('resizable', 1);
- $mform->setDefault('scrollbars', 1);
- $mform->setDefault('directories', 0);
- $mform->setDefault('location', 0);
- $mform->setDefault('menubar', 0);
- $mform->setDefault('toolbar', 0);
- $mform->setDefault('status', 0);
$mform->setAdvanced('winoptgrp');
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);
// Skip view page
- $options = array();
- $options[0]=get_string('never');
- $options[1]=get_string('firstaccess','scorm');
- $options[2]=get_string('always');
- $mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), $options);
+ $mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), scorm_get_skip_view_array());
$mform->setHelpButton('skipview', array('skipview',get_string('skipview', 'scorm'), 'scorm'));
- $mform->setDefault('skipview', 1);
+ $mform->setDefault('skipview', $CFG->scorm_skipview);
$mform->setAdvanced('skipview');
// Hide Browse
$mform->addElement('selectyesno', 'hidebrowse', get_string('hidebrowse', 'scorm'));
$mform->setHelpButton('hidebrowse', array('hidebrowse',get_string('hidebrowse', 'scorm'), 'scorm'));
- $mform->setDefault('hidebrowse', 0);
+ $mform->setDefault('hidebrowse', $CFG->scorm_hidebrowse);
$mform->setAdvanced('hidebrowse');
// Toc display
- $options = array();
- $options[1]=get_string('hidden','scorm');
- $options[0]=get_string('sided','scorm');
- $options[2]=get_string('popupmenu','scorm');
- $mform->addElement('select', 'hidetoc', get_string('hidetoc', 'scorm'), $options);
- $mform->setDefault('hidetoc', 0);
+ $mform->addElement('select', 'hidetoc', get_string('hidetoc', 'scorm'), scorm_get_hidetoc_array());
+ $mform->setDefault('hidetoc', $CFG->scorm_hidetoc);
$mform->setAdvanced('hidetoc');
// Hide Navigation panel
$mform->addElement('selectyesno', 'hidenav', get_string('hidenav', 'scorm'));
- $mform->setDefault('hidenav', 0);
+ $mform->setDefault('hidenav', $CFG->scorm_hidenav);
$mform->setAdvanced('hidenav');
// Autocontinue
$mform->addElement('selectyesno', 'auto', get_string('autocontinue', 'scorm'));
$mform->setHelpButton('auto', array('autocontinue',get_string('autocontinue', 'scorm'), 'scorm'));
- $mform->setDefault('auto', 0);
+ $mform->setDefault('auto', $CFG->scorm_auto);
$mform->setAdvanced('auto');
// Update packages timing
- $options = array();
- $options[0]=get_string('never');
- // $options[1]=get_string('onchanges','scorm'); - nolonger required, but dont change the sequence
- $options[2]=get_string('everyday','scorm');
- $options[3]=get_string('everytime','scorm');
- $mform->addElement('select', 'updatefreq', get_string('updatefreq', 'scorm'), $options);
- $mform->setDefault('updatefreq', 0);
+ $mform->addElement('select', 'updatefreq', get_string('updatefreq', 'scorm'), scorm_get_updatefreq_array());
+ $mform->setDefault('updatefreq', $CFG->scorm_updatefreq);
$mform->setAdvanced('updatefreq');
//-------------------------------------------------------------------------------
@@ -211,11 +177,13 @@ function data_preprocessing(&$default_values) {
global $COURSE;
if (isset($default_values['popup']) && ($default_values['popup'] == 1) && isset($default_values['options'])) {
- $options = explode(',',$default_values['options']);
- foreach ($options as $option) {
- list($element,$value) = explode('=',$option);
- $element = trim($element);
- $default_values[$element] = trim($value);
+ if (!empty($default_values['options'])) {
+ $options = explode(',',$default_values['options']);
+ foreach ($options as $option) {
+ list($element,$value) = explode('=',$option);
+ $element = trim($element);
+ $default_values[$element] = trim($value);
+ }
}
}
if (isset($default_values['grademethod'])) {
View
3 mod/scorm/player.php
@@ -319,6 +319,9 @@ function openpopup(url,name,options,width,height) {
</iframe>
</noscript>
<?php
+ //Added incase javascript popups are blocked
+ $link = '<a href="'.$CFG->wwwroot.'/mod/scorm/loadSCO.php?id='.$cm->id.$scoidstr.$modestr.'" target="new">'.get_string('popupblockedlinkname','scorm').'</a>';
+ print_simple_box(get_string('popupblocked','scorm',$link),'center');
}
} else {
print_simple_box(get_string('noprerequisites','scorm'),'center');
View
34 mod/scorm/settings.php
@@ -1,9 +1,41 @@
<?php //$Id$
+require_once('../mod/scorm/locallib.php');
+
+$settings->add(new admin_setting_configselect('scorm_grademethod', get_string('grademethod', 'scorm'),get_string('grademethoddesc', 'scorm'), '', 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'), '', $grades));
+
+$settings->add(new admin_setting_configselect('scorm_maxattempts', get_string('maximumattempts', 'scorm'), get_string('maximumattemptsdesc', 'scorm'), '', scorm_get_attempts_array()));
+
+$settings->add(new admin_setting_configselect('scorm_whatgrade', get_string('whatgrade', 'scorm'), get_string('whatgradedesc', 'scorm'), '', scorm_get_what_grade_array()));
$settings->add(new admin_setting_configtext('scorm_framewidth', get_string('width', 'scorm'),
get_string('framewidth', 'scorm'), '100%'));
$settings->add(new admin_setting_configtext('scorm_frameheight', get_string('height', 'scorm'),
get_string('frameheight', 'scorm'), 500));
+
+$settings->add(new admin_setting_configselect('scorm_popup', get_string('display','scorm'), get_string('displaydesc','scorm'), '', scorm_get_popup_display_array()));
+
+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_configselect('scorm_skipview', get_string('skipview', 'scorm'), get_string('skipviewdesc', 'scorm'), '', scorm_get_skip_view_array()));
+
+$yesno = array(0 => get_string('no'),
+ 1 => get_string('yes'));
+
+$settings->add(new admin_setting_configselect('scorm_hidebrowse', get_string('hidebrowse', 'scorm'), get_string('hidebrowsedesc', 'scorm'), '', $yesno));
+
+$settings->add(new admin_setting_configselect('scorm_hidetoc', get_string('hidetoc', 'scorm'), get_string('hidetocdesc', 'scorm'), '', scorm_get_hidetoc_array()));
+
+$settings->add(new admin_setting_configselect('scorm_hidenav', get_string('hidenav', 'scorm'), get_string('hidenavdesc', 'scorm'), '', $yesno));
+
+$settings->add(new admin_setting_configselect('scorm_auto', get_string('autocontinue', 'scorm'), get_string('autocontinuedesc', 'scorm'), '', $yesno));
-?>
+$settings->add(new admin_setting_configselect('scorm_updatefreq', get_string('updatefreq', 'scorm'), get_string('updatefreqdesc', 'scorm'), '', scorm_get_updatefreq_array()));
+?>

0 comments on commit 9e7f70d

Please sign in to comment.