Skip to content

Commit

Permalink
MDL-31652 SCORM - hide updatefreq setting and remove it if not required.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Feb 17, 2012
1 parent e0d5a17 commit 6d65790
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
1 change: 1 addition & 0 deletions mod/scorm/lang/en/scorm.php
Expand Up @@ -271,6 +271,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';
Expand Down
4 changes: 2 additions & 2 deletions mod/scorm/lib.php
Expand Up @@ -497,8 +497,8 @@ function scorm_cron () {

mtrace('Updating scorm packages which require daily update');//We are updating

$scormsupdate = $DB->get_records('scorm', array('updatefreq'=>UPDATE_EVERYDAY));
foreach($scormsupdate as $scormupdate) {
$scormsupdate = $DB->get_records_select('scorm', 'updatefreq = ? AND scormtype <> ?', array(SCORM_UPDATE_EVERYDAY, SCORM_TYPE_LOCAL));
foreach ($scormsupdate as $scormupdate) {
scorm_parse($scormupdate, true);
}
}
Expand Down
20 changes: 9 additions & 11 deletions mod/scorm/locallib.php
Expand Up @@ -4,10 +4,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);
Expand Down Expand Up @@ -118,11 +117,10 @@ 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'));
function scorm_get_updatefreq_array() {
return array(SCORM_UPDATE_NEVER => get_string('never'),
SCORM_UPDATE_EVERYDAY => get_string('everyday', 'scorm'),
SCORM_UPDATE_EVERYTIME => get_string('everytime', 'scorm'));
}

/**
Expand Down Expand Up @@ -709,7 +707,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);
}

Expand Down Expand Up @@ -803,7 +801,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.
Expand Down
31 changes: 18 additions & 13 deletions mod/scorm/mod_form.php
Expand Up @@ -32,24 +32,24 @@ function definition() {
// Summary
$this->add_intro_editor(true);

// Scorm types
$options = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
// Scorm types
$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');
}

// Reference
if (count($options) > 1) {
$mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $options);
// Reference
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);
Expand Down Expand Up @@ -212,11 +212,16 @@ function definition() {
$mform->setDefault('auto', $cfg_scorm->auto);
$mform->setAdvanced('auto');

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

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);
Expand Down

0 comments on commit 6d65790

Please sign in to comment.