MDL-16184 - revert earlier work for x.start.time, and apply patch from valerian ...
authorPiers Harding <piers@ompka.net>
Tue, 9 Feb 2010 18:43:15 +0000 (18:43 +0000)
committerPiers Harding <piers@ompka.net>
Tue, 9 Feb 2010 18:43:15 +0000 (18:43 +0000)
mod/scorm/lib.php
mod/scorm/loaddatamodel.php
mod/scorm/locallib.php
mod/scorm/report.php

index 2d7c304..11e4416 100755 (executable)
@@ -320,7 +320,13 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
     $lastmodify = 0;
     $sometoreport = false;
     $report = '';
-
+    
+    // First Access and Last Access dates for SCOs
+    require_once("locallib.php");
+    $timetracks = scorm_get_sco_runtime($scorm->id, false, $user->id);
+    $firstmodify = $timetracks->start;
+    $lastmodify = $timetracks->finish;
+    
     $grades = grade_get_grades($course->id, 'mod', 'scorm', $scorm->id, $user->id);
     if (!empty($grades->items[0]->grades)) {
         $grade = reset($grades->items[0]->grades);
@@ -387,7 +393,6 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
                     }
 
                     if ($sco->launch) {
-                        require_once('locallib.php');
                         $score = '';
                         $totaltime = '';
                         if ($usertrack=scorm_get_tracks($sco->id,$user->id)) {
@@ -396,14 +401,6 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
                             }
                             $strstatus = get_string($usertrack->status,'scorm');
                             $report .= "<img src='".$OUTPUT->pix_url('pix/'.$usertrack->status, 'scorm')."' alt='$strstatus' title='$strstatus' />";
-                            if ($usertrack->timemodified != 0) {
-                                if ($usertrack->timemodified > $lastmodify) {
-                                    $lastmodify = $usertrack->timemodified;
-                                }
-                                if ($usertrack->timemodified < $firstmodify) {
-                                    $firstmodify = $usertrack->timemodified;
-                                }
-                            }
                         } else {
                             if ($sco->scormtype == 'sco') {
                                 $report .= '<img src="'.$OUTPUT->pix_url('pix/notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
index 6f61066..6e9173a 100644 (file)
@@ -86,9 +86,6 @@
     } else {
         include($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php');
     }
-
-    // set the start time of this SCO
-    scorm_insert_track($USER->id,$scorm->id,$scoid,$attempt,'x.start.time',time());
 ?>
 
 var errorCode = "0";
index 500c5f8..c7af2d8 100755 (executable)
@@ -412,9 +412,6 @@ function scorm_get_tracks($scoid,$userid,$attempt='') {
             $track->value = stripslashes($track->value);
             $usertrack->{$element} = $track->value;
             switch ($element) {
-                case 'x.start.time':
-                    $usertrack->x_start_time = $track->value;
-                    break;
                 case 'cmi.core.lesson_status':
                 case 'cmi.completion_status':
                     if ($track->value == 'not attempted') {
@@ -469,11 +466,7 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) {
         $tracks = array_values($tracks);
     }
 
-    if ($start_track = $DB->get_records_select('scorm_scoes_track',"$sql AND element='x.start.time' ORDER BY scoid ASC")) {
-        $start_track = array_values($start_track);
-        $timedata->start = $start_track[0]->value;
-    }
-    else if ($tracks) {
+    if ($tracks) {
         $timedata->start = $tracks[0]->timemodified;
     }
     else {
index 2da0b43..c05aa72 100755 (executable)
                             $row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid . ':' . $a . '" />';
                         }
                         //TODO: fetch the user details elsewhere - this is a performance problem!!
-                        $user = (object)array('id'=>$scouser->id);
+                        $user = (object)array('id'=>$scouser->userid);
                         $row[] = $OUTPUT->user_picture($user, array('courseid'=>$course->id));
                         $row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&amp;course='.$course->id.'">'.
                                  fullname($userdata).'</a>';
                     if (!empty($userdata)) {
                         echo $OUTPUT->box_start('generalbox boxaligncenter');
                         echo '<div class="mdl-align">'."\n";
-                        echo $OUTPUT->user_picture($user, array('courseid'=>$course->id));
+                        $userrec = (object)array('id'=>$user);
+                        echo $OUTPUT->user_picture($userrec, array('courseid'=>$course->id));
                         echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&amp;course=$course->id\">".
                              "$userdata->firstname $userdata->lastname</a><br />";
                         echo get_string('attempt','scorm').': '.$attempt;
             //print_heading(format_string($sco->title));
             echo $OUTPUT->heading('<a href="'.$CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;mode=browse&amp;scoid='.$sco->id.'" target="_new">'.format_string($sco->title).'</a>');
             echo '<div class="mdl-align">'."\n";
-            echo $OUTPUT->user_picture($user, array('courseid'=>$course->id));
+            $userrec = (object)array('id'=>$user);
+            echo $OUTPUT->user_picture($userrec, array('courseid'=>$course->id));
             echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&amp;course=$course->id\">".
                  "$userdata->firstname $userdata->lastname</a><br />";
             $scoreview = '';