Skip to content
Browse files

MDL-31652 SCORM - hide updatefreq setting and remove it if not required.

  • Loading branch information...
1 parent ad52027 commit dc71212c3c4f1079258badf16c38ea49da8bc493 @danmarsden danmarsden committed Feb 16, 2012
Showing with 27 additions and 23 deletions.
  1. +1 −0 mod/scorm/lang/en/scorm.php
  2. +1 −1 mod/scorm/lib.php
  3. +8 −10 mod/scorm/locallib.php
  4. +17 −12 mod/scorm/mod_form.php
View
1 mod/scorm/lang/en/scorm.php
@@ -310,6 +310,7 @@
$string['typelocalsync'] = 'Downloaded package';
$string['unziperror'] = 'An error occurs during package unzip';
$string['updatefreq'] = 'Auto-update frequency';
+$string['updatefreq_help'] = 'This allows the external package to be automatically downloaded and updated';
$string['updatefreqdesc'] = 'This preference sets the default auto-update frequency of an activity';
$string['validateascorm'] = 'Validate a package';
$string['validation'] = 'Validation result';
View
2 mod/scorm/lib.php
@@ -502,7 +502,7 @@ function scorm_cron () {
mtrace('Updating scorm packages which require daily update');//We are updating
- $scormsupdate = $DB->get_records('scorm', array('updatefreq'=>UPDATE_EVERYDAY));
+ $scormsupdate = $DB->get_records_select('scorm', 'updatefreq = ? AND scormtype <> ?', array(SCORM_UPDATE_EVERYDAY, SCORM_TYPE_LOCAL));
foreach ($scormsupdate as $scormupdate) {
scorm_parse($scormupdate, true);
}
View
18 mod/scorm/locallib.php
@@ -18,10 +18,9 @@
require_once("$CFG->libdir/filelib.php");
/// Constants and settings for module scorm
-define('UPDATE_NEVER', '0');
-define('UPDATE_ONCHANGE', '1');
-define('UPDATE_EVERYDAY', '2');
-define('UPDATE_EVERYTIME', '3');
+define('SCORM_UPDATE_NEVER', '0');
+define('SCORM_UPDATE_EVERYDAY', '2');
+define('SCORM_UPDATE_EVERYTIME', '3');
define('SCO_ALL', 0);
define('SCO_DATA', 1);
@@ -133,10 +132,9 @@ function scorm_get_hidetoc_array() {
* @return array an array of update frequency options
*/
function scorm_get_updatefreq_array() {
- return array(0 => get_string('never'),
- 1 => get_string('onchanges', 'scorm'),
- 2 => get_string('everyday', 'scorm'),
- 3 => get_string('everytime', 'scorm'));
+ return array(SCORM_UPDATE_NEVER => get_string('never'),
+ SCORM_UPDATE_EVERYDAY => get_string('everyday', 'scorm'),
+ SCORM_UPDATE_EVERYTIME => get_string('everytime', 'scorm'));
}
/**
@@ -729,7 +727,7 @@ function scorm_course_format_display($user, $course) {
function scorm_view_display ($user, $scorm, $action, $cm) {
global $CFG, $DB, $PAGE, $OUTPUT;
- if ($scorm->updatefreq == UPDATE_EVERYTIME) {
+ if ($scorm->scormtype != SCORM_TYPE_LOCAL && $scorm->updatefreq == SCORM_UPDATE_EVERYTIME) {
scorm_parse($scorm, false);
}
@@ -823,7 +821,7 @@ function scorm_simple_play($scorm, $user, $context, $cmid) {
$result = false;
- if ($scorm->updatefreq == UPDATE_EVERYTIME) {
+ if ($scorm->scormtype != SCORM_TYPE_LOCAL && $scorm->updatefreq == SCORM_UPDATE_EVERYTIME) {
scorm_parse($scorm, false);
}
if (has_capability('mod/scorm:viewreport', $context)) { //if this user can view reports, don't skipview so they can see links to reports.
View
29 mod/scorm/mod_form.php
@@ -48,27 +48,27 @@ function definition() {
$this->add_intro_editor(true);
// Scorm types
- $options = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
+ $scormtypes = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
if ($cfg_scorm->allowtypeexternal) {
- $options[SCORM_TYPE_EXTERNAL] = get_string('typeexternal', 'scorm');
+ $scormtypes[SCORM_TYPE_EXTERNAL] = get_string('typeexternal', 'scorm');
}
if ($cfg_scorm->allowtypelocalsync) {
- $options[SCORM_TYPE_LOCALSYNC] = get_string('typelocalsync', 'scorm');
+ $scormtypes[SCORM_TYPE_LOCALSYNC] = get_string('typelocalsync', 'scorm');
}
if (!empty($CFG->repositoryactivate) and $cfg_scorm->allowtypeimsrepository) {
- $options[SCORM_TYPE_IMSREPOSITORY] = get_string('typeimsrepository', 'scorm');
+ $scormtypes[SCORM_TYPE_IMSREPOSITORY] = get_string('typeimsrepository', 'scorm');
}
if ($cfg_scorm->allowtypeexternalaicc) {
- $options[SCORM_TYPE_AICCURL] = get_string('typeaiccurl', 'scorm');
+ $scormtypes[SCORM_TYPE_AICCURL] = get_string('typeaiccurl', 'scorm');
}
// Reference
- if (count($options) > 1) {
- $mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $options);
+ if (count($scormtypes) > 1) {
+ $mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $scormtypes);
$mform->addHelpButton('scormtype', 'scormtype', 'scorm');
$mform->addElement('text', 'packageurl', get_string('packageurl', 'scorm'), array('size'=>60));
$mform->setType('packageurl', PARAM_RAW);
@@ -237,11 +237,16 @@ function definition() {
$mform->setDefault('auto', $cfg_scorm->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', $cfg_scorm->updatefreq_adv);
-
+ if (count($scormtypes) > 1) {
+ // Update packages timing
+ $mform->addElement('select', 'updatefreq', get_string('updatefreq', 'scorm'), scorm_get_updatefreq_array());
+ $mform->setDefault('updatefreq', $cfg_scorm->updatefreq);
+ $mform->setAdvanced('updatefreq', $cfg_scorm->updatefreq_adv);
+ $mform->addHelpButton('updatefreq', 'updatefreq', 'scorm');
+ $mform->disabledIf('updatefreq', 'scormtype', 'eq', SCORM_TYPE_LOCAL);
+ } else {
+ $mform->addElement('hidden', 'updatefreq', 0);
+ }
//-------------------------------------------------------------------------------
// Hidden Settings
$mform->addElement('hidden', 'datadir', null);

0 comments on commit dc71212

Please sign in to comment.
Something went wrong with that request. Please try again.