course)) { error('Course is misconfigured'); } if (! $scorm = get_record('scorm', 'id', $cm->instance)) { error('Course module is incorrect'); } } else { if (!empty($b)) { if (! $sco = get_record('scorm_scoes', 'id', $b)) { error('Scorm activity is incorrect'); } $a = $sco->scorm; } if (!empty($a)) { if (! $scorm = get_record('scorm', 'id', $a)) { error('Course module is incorrect'); } if (! $course = get_record('course', 'id', $scorm->course)) { error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) { error('Course Module ID was incorrect'); } } } require_login($course->id, false, $cm); $contextmodule = get_context_instance(CONTEXT_MODULE,$cm->id); require_capability('mod/scorm:viewreport', $contextmodule); add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id, $cm->id); if (!empty($user)) { $userdata = scorm_get_user_data($user); } else { $userdata = null; } /// Print the page header if (empty($noheader)) { $strscorms = get_string('modulenameplural', 'scorm'); $strscorm = get_string('modulename', 'scorm'); $strreport = get_string('report', 'scorm'); $strattempt = get_string('attempt', 'scorm'); $strname = get_string('name'); if (empty($b)) { if (empty($a)) { $navigation = build_navigation($strreport, $cm); print_header("$course->shortname: ".format_string($scorm->name), $course->fullname,$navigation, '', '', true); } else { $navlinks = array(); $navlinks[] = array('name' => $strreport, 'link' => "report.php?id=$cm->id", 'type' => 'title'); $navlinks[] = array('name' => "$strattempt $attempt - ".fullname($userdata), 'link' => '', 'type' => 'title'); $navigation = build_navigation($navlinks, $cm); print_header("$course->shortname: ".format_string($scorm->name), $course->fullname, $navigation, '', '', true); } } else { $navlinks = array(); $navlinks[] = array('name' => $strreport, 'link' => "report.php?id=$cm->id", 'type' => 'title'); $navlinks[] = array('name' => "$strattempt $attempt - ".fullname($userdata), 'link' => "report.php?a=$a&user=$user&attempt=$attempt", 'type' => 'title'); $navlinks[] = array('name' => $sco->title, 'link' => '', 'type' => 'title'); $navigation = build_navigation($navlinks, $cm); print_header("$course->shortname: ".format_string($scorm->name), $course->fullname, $navigation, '', '', true); } print_heading(format_string($scorm->name)); } if ($action == 'delete' && has_capability('mod/scorm:deleteresponses',$contextmodule)) { if (scorm_delete_responses($attemptids, $scorm->id)) { //delete responses. notify(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess'); } } $scormpixdir = $CFG->modpixpath.'/scorm/pix'; if (empty($b)) { if (empty($a)) { // No options, show the global scorm report if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) { $sql = "SELECT st.userid, st.scormid FROM {$CFG->prefix}scorm_scoes_track st INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid WHERE st.scormid = {$scorm->id} AND gg.groupingid = {$cm->groupingid} GROUP BY st.userid,st.scormid "; } else { $sql = "SELECT st.userid, st.scormid FROM {$CFG->prefix}scorm_scoes_track st WHERE st.scormid = {$scorm->id} GROUP BY st.userid,st.scormid "; } if ($scousers=get_records_sql($sql)) { $table = new stdClass(); $table->head = array(); $table->width = '100%'; if (has_capability('mod/scorm:deleteresponses',$contextmodule)) { $table->head[] = ' '; $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '10'; } $table->head[] = ' '; $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '10'; $table->head[] = get_string('name'); $table->align[] = 'left'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; $table->head[]= get_string('attempt','scorm'); $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; $table->head[]= get_string('started','scorm'); $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; $table->head[]= get_string('last','scorm'); $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; $table->head[]= get_string('score','scorm'); $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; foreach($scousers as $scouser){ $userdata = scorm_get_user_data($scouser->userid); $attempt = scorm_get_last_attempt($scorm->id,$scouser->userid); for ($a = 1; $a<=$attempt; $a++) { $row = array(); if (has_capability('mod/scorm:deleteresponses',$contextmodule)) { $row[] = ''; } $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); $row[] = ''. fullname($userdata).''; $row[] = ''.$a.''; $select = 'scormid = '.$scorm->id.' and userid = '.$scouser->userid.' and attempt = '.$a; // $timetracks = get_record_select('scorm_scoes_track', $select,'min(timemodified) as started, max(timemodified) as last'); $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $a); // jump out here if this attempt doesnt exist // if (!$timetracks->started) { if (!$timetracks->start) { continue; } // $row[] = userdate($timetracks->started, get_string('strftimedaydatetime')); // $row[] = userdate($timetracks->last, get_string('strftimedaydatetime')); $row[] = userdate($timetracks->start, get_string('strftimedaydatetime')); $row[] = userdate($timetracks->finish, get_string('strftimedaydatetime')); $row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $a); $table->data[] = $row; } } echo '
'.format_string($sco->title);
$row[] = get_string($trackdata->status,'scorm');
$row[] = $trackdata->total_time;
$row[] = $score;
$row[] = $detailslink;
} else {
$row = array(format_string($sco->title), ' ', ' ', ' ', ' ');
}
$table->data[] = $row;
}
print_table($table);
}
}
} else {
notice('No users to report');
}
}
} else {
// User SCO report
if (!empty($userdata)) {
print_simple_box_start('center');
//print_heading(format_string($sco->title));
print_heading(''.format_string($sco->title).'');
echo '
'.$trackdata->total_time.'