Permalink
Browse files

Merge branch 'master_MDL-34848' of git://github.com/danmarsden/moodle

  • Loading branch information...
2 parents be205a8 + 828b692 commit f6bfcaf6b3599e78b6ad3fc21bdd0c2bef8e9cd1 @stronk7 stronk7 committed Oct 10, 2012
Showing with 25 additions and 34 deletions.
  1. +25 −34 mod/scorm/lib.php
View
@@ -1058,7 +1058,7 @@ function scorm_debug_log_remove($type, $scoid) {
* @return mixed
*/
function scorm_print_overview($courses, &$htmlarray) {
- global $USER, $CFG, $DB;
+ global $USER, $CFG;
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return array();
@@ -1068,47 +1068,38 @@ function scorm_print_overview($courses, &$htmlarray) {
return;
}
- $scormids = array();
-
- // Do scorm::isopen() here without loading the whole thing for speed
- foreach ($scorms as $key => $scorm) {
- $time = time();
- if ($scorm->timeopen) {
- $isopen = ($scorm->timeopen <= $time && $time <= $scorm->timeclose);
- }
- if (empty($scorm->displayattemptstatus) && (empty($isopen) || empty($scorm->timeclose))) {
- unset($scorms[$key]);
- } else {
- $scormids[] = $scorm->id;
- }
- }
-
- if (empty($scormids)) {
- // no scorms to look at - we're done
- return true;
- }
$strscorm = get_string('modulename', 'scorm');
$strduedate = get_string('duedate', 'scorm');
foreach ($scorms as $scorm) {
- $str = '<div class="scorm overview"><div class="name">'.$strscorm. ': '.
- '<a '.($scorm->visible ? '':' class="dimmed"').
- 'title="'.$strscorm.'" href="'.$CFG->wwwroot.
- '/mod/scorm/view.php?id='.$scorm->coursemodule.'">'.
- $scorm->name.'</a></div>';
- if ($scorm->timeclose) {
- $str .= '<div class="info">'.$strduedate.': '.userdate($scorm->timeclose).'</div>';
+ $time = time();
+ $showattemptstatus = false;
+ if ($scorm->timeopen) {
+ $isopen = ($scorm->timeopen <= $time && $time <= $scorm->timeclose);
}
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>';
+ $showattemptstatus = true;
}
- $str .= '</div>';
- if (empty($htmlarray[$scorm->course]['scorm'])) {
- $htmlarray[$scorm->course]['scorm'] = $str;
- } else {
- $htmlarray[$scorm->course]['scorm'] .= $str;
+ if ($showattemptstatus || !empty($isopen) || !empty($scorm->timeclose)) {
+ $str = '<div class="scorm overview"><div class="name">'.$strscorm. ': '.
+ '<a '.($scorm->visible ? '':' class="dimmed"').
+ 'title="'.$strscorm.'" href="'.$CFG->wwwroot.
+ '/mod/scorm/view.php?id='.$scorm->coursemodule.'">'.
+ $scorm->name.'</a></div>';
+ if ($scorm->timeclose) {
+ $str .= '<div class="info">'.$strduedate.': '.userdate($scorm->timeclose).'</div>';
+ }
+ if ($showattemptstatus) {
+ require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+ $str .= '<div class="details">'.scorm_get_attempt_status($USER, $scorm).'</div>';
+ }
+ $str .= '</div>';
+ if (empty($htmlarray[$scorm->course]['scorm'])) {
+ $htmlarray[$scorm->course]['scorm'] = $str;
+ } else {
+ $htmlarray[$scorm->course]['scorm'] .= $str;
+ }
}
}
}

0 comments on commit f6bfcaf

Please sign in to comment.