SCORM MDL-21442 add Scorms with due dates to My Moodle page

This commit is contained in:
Dan Marsden
2010-06-24 13:14:51 +00:00
parent 169a204c08
commit d860e4f8e6
2 changed files with 59 additions and 0 deletions
+1
View File
@@ -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';
+58
View File
@@ -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 = '<div class="scorm overview"><div class="name">'.$strscorm. ': '.
'<a '.($scorm->visible ? '':' class="dimmed"').
'title="'.$strscorm.'" href="'.$CFG->wwwroot.
'/mod/assignment/view.php?id='.$scorm->coursemodule.'">'.
$scorm->name.'</a></div>';
if ($scorm->timeclose) {
$str .= '<div class="info">'.$strduedate.': '.userdate($scorm->timeclose).'</div>';
}
$str .= '</div>';
if (empty($htmlarray[$scorm->course]['scorm'])) {
$htmlarray[$scorm->course]['scorm'] = $str;
} else {
$htmlarray[$scorm->course]['scorm'] .= $str;
}
}
}