-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
1.9.3
-
None
-
MOODLE_19_STABLE
the complete activity report shows the last access time in the place the first time access should be.
(e.g. course/user.php?id=3&user=2&mode=complete )
I've resiolved it on my own this way:
in the function below I've added the lines commented as josef:
mod/scorm/locallib.php
function scorm_get_tracks($scoid,$userid,$attempt='') {
/// Gets all tracks of specified sco and user
global $CFG;
if (empty($attempt)) {
if ($scormid = get_field('scorm_scoes','scorm','id',$scoid))
else
{ $attempt = 1; } }
$attemptsql = ' AND attempt=' . $attempt;
if ($tracks = get_records_select('scorm_scoes_track',"userid=$userid AND scoid=$scoid".$attemptsql,'element ASC')) {
$usertrack->userid = $userid;
$usertrack->scoid = $scoid;
// Defined in order to unify scorm1.2 and scorm2004
$usertrack->score_raw = '';
$usertrack->status = '';
$usertrack->total_time = '00:00:00';
$usertrack->session_time = '00:00:00';
$usertrack->timemodified = 0;
$usertrack->firsttimemodified = time(); // josef
foreach ($tracks as $track) {
$element = $track->element;
$usertrack->{$element} = $track->value;
switch ($element) {
case 'cmi.core.lesson_status':
case 'cmi.completion_status':
if ($track->value == 'not attempted')
$usertrack->status = $track->value;
break;
case 'cmi.core.score.raw':
case 'cmi.score.raw':
$usertrack->score_raw = $track->value;
break;
case 'cmi.core.session_time':
case 'cmi.session_time':
$usertrack->session_time = $track->value;
break;
case 'cmi.core.total_time':
case 'cmi.total_time':
$usertrack->total_time = $track->value;
break;
}
if (isset($track->timemodified) && ($track->timemodified > $usertrack->timemodified))
if (isset($track->timemodified) && ($track->timemodified < $usertrack->firsttimemodified))
// josef
}
if (is_array($usertrack))
return $usertrack;
} else
}
mod/scorm/lib.php
function scorm_user_complete($course, $user, $mod, $scorm) {
global $CFG;
$liststyle = 'structlist';
$scormpixdir = $CFG->modpixpath.'/scorm/pix';
$now = time();
$firstmodify = $now;
$lastmodify = 0;
$sometoreport = false;
$report = '';
if ($orgs = get_records_select('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,identifier,title')) {
if (count($orgs) <= 1)
$report .= '<div class="mod-scorm">'."\n";
foreach ($orgs as $org) {
$organizationsql = '';
$currentorg = '';
if (!empty($org->identifier))
$report .= "<ul id='0' class='$liststyle'>";
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
// drop keys so that we can access array sequentially
$scoes = array_values($scoes);
$level=0;
$sublist=1;
$parents[$level]='/';
foreach ($scoes as $pos=>$sco) {
if ($parents[$level]!=$sco->parent) {
if ($level>0 && $parents[$level-1]==$sco->parent)
else {
$i = $level;
$closelist = '';
while (($i > 0) && ($parents[$level] != $sco->parent))
if (($i == 0) && ($sco->parent != $currentorg))
{ $report .= "\t\t<li><ul id='$sublist' class='$liststyle'>\n"; $level++; }else
{ $report .= $closelist; $level = $i; } $parents[$level]=$sco->parent;
}
}
$report .= "\t\t<li>";
if (isset($scoes[$pos+1]))
else
{ $nextsco = false; }if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier))))
{ $sublist++; }else
{ $report .= '<img src="'.$scormpixdir.'/spacer.gif" alt="" />'; } if ($sco->launch) {
require_once('locallib.php');
$score = '';
$totaltime = '';
if ($usertrack=scorm_get_tracks($sco->id,$user->id)) {
if ($usertrack->status == '')
$strstatus = get_string($usertrack->status,'scorm');
$report .= "<img src='".$scormpixdir.'/'.$usertrack->status.".gif' alt='$strstatus' title='$strstatus' />";
if ($usertrack->timemodified != 0) {
if ($usertrack->timemodified > $lastmodify)
if ($usertrack->firsttimemodified < $firstmodify)
{ // josef $firstmodify = $usertrack->firsttimemodified; // josef } }
} else {
if ($sco->scormtype == 'sco')
else
{ $report .= '<img src="'.$scormpixdir.'/'.'asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />'; } }
$report .= " $sco->title $score$totaltime</li>\n";
if ($usertrack !== false) {
$sometoreport = true;
$report .= "\t\t\t<li><ul class='$liststyle'>\n";
foreach($usertrack as $element => $value) {
if (substr($element,0,3) == 'cmi')
}
$report .= "\t\t\t</ul></li>\n";
}
} else
}
for ($i=0;$i<$level;$i++)
}
$report .= "\t</ul><br />\n";
}
$report .= "</div>\n";
}
if ($sometoreport) {
if ($firstmodify < $now)
if ($lastmodify > 0)
{ $timeago = format_time($now - $lastmodify); echo get_string('lastaccess','scorm').': '.userdate($lastmodify).' ('.$timeago.")<br />\n"; } echo get_string('report','scorm').":<br />\n";
echo $report;
} else
return true;
}
- duplicates
-
MDL-16184 First Access and Last Access dates for SCOs are always the same
- Closed