Skip to content

Commit

Permalink
MDL-42588 mod_scorm: display activity name
Browse files Browse the repository at this point in the history
Added option to display or hide activity name on SCORM player. Added default admin setting and amended generator accordingly.
  • Loading branch information
Jetha Chan committed Mar 25, 2014
2 parents 9b8555f + 74ecabb commit 74d2a9d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 9 deletions.
3 changes: 2 additions & 1 deletion mod/scorm/backup/moodle2/backup_scorm_stepslib.php
Expand Up @@ -45,7 +45,8 @@ protected function define_structure() {
'skipview', 'hidebrowse', 'hidetoc', 'nav', 'navpositionleft', 'navpositiontop',
'auto', 'popup', 'options', 'width',
'height', 'timeopen', 'timeclose', 'timemodified',
'completionstatusrequired', 'completionscorerequired'));
'completionstatusrequired', 'completionscorerequired',
'displayactivityname'));

$scoes = new backup_nested_element('scoes');

Expand Down
3 changes: 3 additions & 0 deletions mod/scorm/backup/moodle2/restore_scorm_stepslib.php
Expand Up @@ -65,6 +65,9 @@ protected function process_scorm($data) {
$data->timeclose = $this->apply_date_offset($data->timeclose);
$data->timemodified = $this->apply_date_offset($data->timemodified);

if(!isset($data->displayactivityname))
$data->displayactivityname = true;

// insert the scorm record
$newitemid = $DB->insert_record('scorm', $data);
// immediately after inserting "activity" record, call this
Expand Down
3 changes: 2 additions & 1 deletion mod/scorm/db/install.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/scorm/db" VERSION="20130924" COMMENT="XMLDB file for Moodle mod/scorm"
<XMLDB PATH="mod/scorm/db" VERSION="20140317" COMMENT="XMLDB file for Moodle mod/scorm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
Expand Down Expand Up @@ -44,6 +44,7 @@
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="completionstatusrequired" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="completionscorerequired" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="displayactivityname" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Expand Down
24 changes: 24 additions & 0 deletions mod/scorm/db/upgrade.php
Expand Up @@ -251,6 +251,30 @@ function xmldb_scorm_upgrade($oldversion) {

upgrade_mod_savepoint(true, 2014021700, 'scorm');
}

if ($oldversion < 2014031700) {
// Define field displayactivityname to be added to scorm.
$table = new xmldb_table('scorm');
$field = new xmldb_field(
'displayactivityname',
XMLDB_TYPE_INTEGER,
'4',
null,
XMLDB_NOTNULL,
null,
'1',
'completionscorerequired'
);

// Conditionally launch add field displayactivityname.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// Scorm savepoint reached.
upgrade_mod_savepoint(true, 2014031700, 'scorm');
}

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions mod/scorm/lang/en/scorm.php
Expand Up @@ -94,6 +94,8 @@
$string['directories'] = 'Show the directory links';
$string['disabled'] = 'Disabled';
$string['display'] = 'Display package';
$string['displayactivityname'] = 'Display activity name';
$string['displayactivityname_help'] = 'Whether or not to display the activity name above the SCORM player.';
$string['displayattemptstatus'] = 'Display attempt status';
$string['displayattemptstatus_help'] = 'This preference allows a summary of the users attempts to show in the course overview block in My home and/or the SCORM entry page.';
$string['displayattemptstatusdesc'] = 'Whether a summary of the user\'s attempts is shown in the course overview block in My home and/or the SCORM entry page.';
Expand Down
6 changes: 5 additions & 1 deletion mod/scorm/mod_form.php
Expand Up @@ -130,6 +130,11 @@ public function definition() {
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);
$mform->setAdvanced('winoptgrp', $cfgscorm->winoptgrp_adv);

// Display activity name.
$mform->addElement('advcheckbox', 'displayactivityname', get_string('displayactivityname', 'scorm'));
$mform->addHelpButton('displayactivityname', 'displayactivityname', 'scorm');
$mform->setDefault('displayactivityname', $cfgscorm->displayactivityname);

// Skip view page.
$skipviewoptions = scorm_get_skip_view_array();
if ($COURSE->format == 'singleactivity') { // Remove option that would cause a constant redirect.
Expand Down Expand Up @@ -337,7 +342,6 @@ public function data_preprocessing(&$defaultvalues) {
if (!isset($defaultvalues['completionscorerequired']) || !strlen($defaultvalues['completionscorerequired'])) {
$defaultvalues['completionscoredisabled'] = 1;
}

}

public function validation($data, $files) {
Expand Down
4 changes: 3 additions & 1 deletion mod/scorm/player.php
Expand Up @@ -166,7 +166,9 @@
$PAGE->requires->js('/mod/scorm/request.js', true);
$PAGE->requires->js('/lib/cookies.js', true);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($scorm->name));
if (!empty($scorm->displayactivityname)) {
echo $OUTPUT->heading(format_string($scorm->name));
}

$PAGE->requires->string_for_js('navigation', 'scorm');
$PAGE->requires->string_for_js('toc', 'scorm');
Expand Down
3 changes: 3 additions & 0 deletions mod/scorm/settings.php
Expand Up @@ -32,6 +32,9 @@
get_string('display', 'scorm'), get_string('displaydesc', 'scorm'),
array('value' => 0, 'adv' => false), scorm_get_popup_display_array()));

$settings->add(new admin_setting_configcheckbox('scorm/displayactivityname',
get_string('displayactivityname', 'scorm'), get_string('displayactivityname_help', 'scorm'), 1));

$settings->add(new admin_setting_configtext_with_advanced('scorm/framewidth',
get_string('width', 'scorm'), get_string('framewidth', 'scorm'),
array('value' => '100', 'adv' => true)));
Expand Down
3 changes: 2 additions & 1 deletion mod/scorm/tests/generator/lib.php
Expand Up @@ -68,7 +68,8 @@ public function create_instance($record = null, array $options = null) {
'forcenewattempt' => $cfgscorm->forcenewattempt,
'lastattemptlock' => $cfgscorm->lastattemptlock,
'forcecompleted' => $cfgscorm->forcecompleted,
'auto' => $cfgscorm->auto
'auto' => $cfgscorm->auto,
'displayactivityname' => $cfgscorm->displayactivityname
);

// The 'packagefile' value corresponds to the draft file area ID. If not specified, create from packagefilepath.
Expand Down
8 changes: 4 additions & 4 deletions mod/scorm/version.php
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2014021701; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 300;
$module->version = 2014032500; // The current module version (Date: YYYYMMDDXX).
$module->requires = 2013110500; // Requires this Moodle version.
$module->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics).
$module->cron = 300;

0 comments on commit 74d2a9d

Please sign in to comment.