Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34848 SCORM: add extra flexibiltiy to attempt status

  • Loading branch information...
commit da92e3b05a7f00d0297f5bc09d6ba6de7a430307 1 parent c8ac480
Dan Marsden danmarsden authored
5 mod/scorm/lang/en/scorm.php
View
@@ -47,6 +47,9 @@
$string['assetlaunched'] = 'Asset - Viewed';
$string['attempt'] = 'Attempt';
$string['attempts'] = 'Attempts';
+$string['attemptstatusall'] = 'My home and entry page';
+$string['attemptstatusmy'] = 'My home only';
+$string['attemptstatusentry'] = 'Entry page only';
$string['attemptsx'] = '{$a} attempts';
$string['attempt1'] = '1 attempt';
$string['attr_error'] = 'Bad value for attribute ({$a->attr}) in tag {$a->tag}.';
@@ -85,7 +88,7 @@
$string['disabled'] = 'Disabled';
$string['display'] = 'Display package';
$string['displayattemptstatus'] = 'Display attempt status';
-$string['displayattemptstatus_help'] = 'If enabled, scores and grades for attempts are displayed on the SCORM outline page.';
+$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'] = 'This preference sets the default value for the display attempt status setting';
$string['displaycoursestructure'] = 'Display course structure on entry page';
$string['displaycoursestructure_help'] = 'If enabled, the table of contents is displayed on the SCORM outline page.';
9 mod/scorm/lib.php
View
@@ -41,6 +41,12 @@
define('SCORM_13', 2);
define('SCORM_AICC', 3);
+// List of possible attemptstatusdisplay options.
+define('SCORM_DISPLAY_ATTEMPTSTATUS_NO', 0);
+define('SCORM_DISPLAY_ATTEMPTSTATUS_ALL', 1);
+define('SCORM_DISPLAY_ATTEMPTSTATUS_MY', 2);
+define('SCORM_DISPLAY_ATTEMPTSTATUS_ENTRY', 3);
+
/**
* Return an array of status options
*
@@ -1104,7 +1110,8 @@ function scorm_print_overview($courses, &$htmlarray) {
if ($scorm->timeclose) {
$str .= '<div class="info">'.$strduedate.': '.userdate($scorm->timeclose).'</div>';
}
- if ($scorm->displayattemptstatus == 1) {
+ if ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL ||
+ $scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_MY) {
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$str .= '<div class="details">'.scorm_get_attempt_status($USER, $scorm).'</div>';
}
13 mod/scorm/locallib.php
View
@@ -166,6 +166,19 @@ function scorm_get_attempts_array() {
return $attempts;
}
+
+/**
+ * Returns an array of the attempt status options
+ *
+ * @return array an array of attempt status options
+ */
+function scorm_get_attemptstatus_array() {
+ return array(SCORM_DISPLAY_ATTEMPTSTATUS_NO => get_string('no'),
+ SCORM_DISPLAY_ATTEMPTSTATUS_ALL => get_string('attemptstatusall', 'scorm'),
+ SCORM_DISPLAY_ATTEMPTSTATUS_MY => get_string('attemptstatusmy', 'scorm'),
+ SCORM_DISPLAY_ATTEMPTSTATUS_ENTRY => get_string('attemptstatusentry', 'scorm'));
+}
+
/**
* Extracts scrom package, sets up all variables.
* Called whenever scorm changes
2  mod/scorm/mod_form.php
View
@@ -195,7 +195,7 @@ function definition() {
$mform->setAdvanced('whatgrade', $cfg_scorm->whatgrade_adv);
// Display attempt status
- $mform->addElement('selectyesno', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'));
+ $mform->addElement('select', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'), scorm_get_attemptstatus_array());
$mform->addHelpButton('displayattemptstatus', 'displayattemptstatus', 'scorm');
$mform->setDefault('displayattemptstatus', $cfg_scorm->displayattemptstatus);
$mform->setAdvanced('displayattemptstatus', $cfg_scorm->displayattemptstatus_adv);
3  mod/scorm/view.php
View
@@ -137,7 +137,8 @@
// Print the main part of the page
echo $OUTPUT->heading(format_string($scorm->name));
$attemptstatus = '';
-if ($scorm->displayattemptstatus == 1 && empty($launch)) {
+if (empty($launch) && ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL ||
+ $scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ENTRY)) {
$attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
Please sign in to comment.
Something went wrong with that request. Please try again.