Skip to content

Commit

Permalink
MDL-34848 SCORM: add extra flexibiltiy to attempt status
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Sep 19, 2012
1 parent c8ac480 commit da92e3b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
5 changes: 4 additions & 1 deletion mod/scorm/lang/en/scorm.php
Expand Up @@ -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}.';
Expand Down Expand Up @@ -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.';
Expand Down
9 changes: 8 additions & 1 deletion mod/scorm/lib.php
Expand Up @@ -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
*
Expand Down Expand Up @@ -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>';
}
Expand Down
13 changes: 13 additions & 0 deletions mod/scorm/locallib.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mod/scorm/mod_form.php
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion mod/scorm/view.php
Expand Up @@ -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');
Expand Down

0 comments on commit da92e3b

Please sign in to comment.