From d860e4f8e62cc396cfc159ef705e35afb86259d7 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 24 Jun 2010 13:14:51 +0000 Subject: [PATCH] SCORM MDL-21442 add Scorms with due dates to My Moodle page --- mod/scorm/lang/en/scorm.php | 1 + mod/scorm/lib.php | 58 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/mod/scorm/lang/en/scorm.php b/mod/scorm/lang/en/scorm.php index 72a67c50523..906cd168522 100644 --- a/mod/scorm/lang/en/scorm.php +++ b/mod/scorm/lang/en/scorm.php @@ -71,6 +71,7 @@ $string['displaycoursestructure_help'] = 'If enabled, the table of contents is d $string['displaycoursestructuredesc'] = 'This preference sets the default value for the display course structure on entry page setting'; $string['displaydesc'] = 'This preference sets the default of whether to display the package or not for an activity'; $string['domxml'] = 'DOMXML external library'; +$string['duedate'] = 'Due date'; $string['element'] = 'Element'; $string['enter'] = 'Enter'; $string['entercourse'] = 'Enter course'; diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 5061d022fcf..8366e546c27 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -986,3 +986,61 @@ function scorm_write_log($type, $text, $scoid) { @file_put_contents($logfile, date('Y/m/d H:i:s O')." DEBUG $text\r\n", FILE_APPEND); } } +/** + * writes overview info for course_overview block - displays upcoming scorm objects that have a due date + * + * @param object $type - type of log(aicc,scorm12,scorm13) used as prefix for filename + * @param array $htmlarray + * @return mixed + */ +function scorm_print_overview($courses, &$htmlarray) { + global $USER, $CFG, $DB; + + if (empty($courses) || !is_array($courses) || count($courses) == 0) { + return array(); + } + + if (!$scorms = get_all_instances_in_courses('scorm',$courses)) { + 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($isopen) || empty($scorm->timeclose)) { + unset($scorms[$key]); + }else{ + $scormids[] = $scorm->id; + } + } + + if(empty($scormids)){ + // no assigments to look at - we're done + return true; + } + $strscorm = get_string('modulename', 'scorm'); + $strduedate = get_string('duedate', 'scorm'); + + foreach ($scorms as $scorm) { + $str = '
'; + if ($scorm->timeclose) { + $str .= '
'.$strduedate.': '.userdate($scorm->timeclose).'
'; + } + + $str .= '
'; + if (empty($htmlarray[$scorm->course]['scorm'])) { + $htmlarray[$scorm->course]['scorm'] = $str; + } else { + $htmlarray[$scorm->course]['scorm'] .= $str; + } + } +}