3 // This script uses installed report plugins to print quiz reports
5 require_once("../../config.php");
6 require_once($CFG->libdir
.'/tablelib.php');
7 require_once($CFG->dirroot
.'/mod/scorm/locallib.php');
8 require_once($CFG->dirroot
.'/mod/scorm/reportsettings_form.php');
9 require_once($CFG->libdir
.'/formslib.php');
10 define('SCORM_REPORT_DEFAULT_PAGE_SIZE', 20);
11 define('SCORM_REPORT_ATTEMPTS_ALL_STUDENTS', 0);
12 define('SCORM_REPORT_ATTEMPTS_STUDENTS_WITH', 1);
13 define('SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO', 2);
15 $id = optional_param('id', '', PARAM_INT
); // Course Module ID, or
16 $a = optional_param('a', '', PARAM_INT
); // SCORM ID
17 $b = optional_param('b', '', PARAM_INT
); // SCO ID
18 $user = optional_param('user', '', PARAM_INT
); // User ID
19 $attempt = optional_param('attempt', '1', PARAM_INT
); // attempt number
20 $action = optional_param('action', '', PARAM_ALPHA
);
21 $attemptids = optional_param('attemptid', array(), PARAM_RAW
);
22 $download = optional_param('download', '', PARAM_RAW
);
24 $url = new moodle_url('/mod/scorm/report.php');
26 $url->param('user', $user);
28 if ($attempt !== '1') {
29 $url->param('attempt', $attempt);
32 $url->param('action', $action);
36 $url->param('id', $id);
37 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
38 print_error('invalidcoursemodule');
40 if (! $course = $DB->get_record('course', array('id'=>$cm->course
))) {
41 print_error('coursemisconf');
43 if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance
))) {
44 print_error('invalidcoursemodule');
49 if (! $sco = $DB->get_record('scorm_scoes', array('id'=>$b))) {
50 print_error('invalidactivity', 'scorm');
56 if (! $scorm = $DB->get_record('scorm', array('id'=>$a))) {
57 print_error('invalidcoursemodule');
59 if (! $course = $DB->get_record('course', array('id'=>$scorm->course
))) {
60 print_error('coursemisconf');
62 if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id
, $course->id
)) {
63 print_error('invalidcoursemodule');
69 require_login($course->id
, false, $cm);
71 $contextmodule = get_context_instance(CONTEXT_MODULE
,$cm->id
);
73 require_capability('mod/scorm:viewreport', $contextmodule);
75 add_to_log($course->id
, 'scorm', 'report', 'report.php?id='.$cm->id
, $scorm->id
, $cm->id
);
78 $userdata = scorm_get_user_data($user);
82 if (!empty($download)) {
85 /// Print the page header
86 if (empty($noheader)) {
88 $strscorms = get_string('modulenameplural', 'scorm');
89 $strscorm = get_string('modulename', 'scorm');
90 $strreport = get_string('report', 'scorm');
91 $strattempt = get_string('attempt', 'scorm');
92 $strname = get_string('name');
94 $PAGE->set_title("$course->shortname: ".format_string($scorm->name
));
95 $PAGE->set_heading($course->fullname
);
96 $PAGE->navbar
->add($strreport, new moodle_url('/mod/scorm/report.php', array('id'=>$cm->id
)));
100 $PAGE->navbar
->add("$strattempt $attempt - ".fullname($userdata));
103 $PAGE->navbar
->add("$strattempt $attempt - ".fullname($userdata), new moodle_url('/mod/scorm/report.php', array('a'=>$a, 'user'=>$user, 'attempt'=>$attempt)));
104 $PAGE->navbar
->add($sco->title
);
106 echo $OUTPUT->header();
107 $currenttab = 'reports';
108 require($CFG->dirroot
. '/mod/scorm/tabs.php');
109 echo $OUTPUT->heading(format_string($scorm->name
));
112 if ($action == 'delete' && has_capability('mod/scorm:deleteresponses',$contextmodule) && confirm_sesskey()) {
113 if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
114 add_to_log($course->id
, 'scorm', 'delete attempts', 'report.php?id=' . $cm->id
, implode(",", $attemptids), $cm->id
);
115 echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
121 // No options, show the global scorm report
122 $pageoptions = array();
123 $pageoptions['id'] = $cm->id
;
124 $reporturl = new moodle_url($CFG->wwwroot
.'/mod/scorm/report.php', $pageoptions);
126 // find out current groups mode
127 $currentgroup = groups_get_activity_group($cm, true);
130 $mform = new mod_scorm_report_settings( $reporturl, compact('currentgroup') );
131 if ($fromform = $mform->get_data()) {
132 $detailedrep = $fromform->detailedrep
;
133 $pagesize = $fromform->pagesize
;
134 $attemptsmode = $fromform->attemptsmode
;
135 set_user_preference('scorm_report_detailed', $detailedrep);
136 set_user_preference('scorm_report_pagesize', $pagesize);
138 $detailedrep = get_user_preferences('scorm_report_detailed', false);
139 $pagesize = get_user_preferences('scorm_report_pagesize', 0);
140 $attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_STUDENTS_WITH
, PARAM_INT
);
143 $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE
;
147 $displayoptions = array();
148 $displayoptions['id'] = $cm->id
;
149 $displayoptions['attemptsmode'] = $attemptsmode;
150 $reporturlwithdisplayoptions = new moodle_url($CFG->wwwroot
.'/mod/scorm/report.php', $displayoptions);
152 if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
154 groups_print_activity_menu($cm, $reporturlwithdisplayoptions->out());
158 // We only want to show the checkbox to delete attempts
159 // if the user has permissions and if the report mode is showing attempts.
160 $candelete = has_capability('mod/scorm:deleteresponses',$contextmodule)
161 && ($attemptsmode!= SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO
);
162 // select the students
165 if (empty($currentgroup)) {
166 // all users who can attempt scoes
167 if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack','','','','','','',false)){
168 echo $OUTPUT->notification(get_string('nostudentsyet'));
172 $allowedlist = join(',',array_keys($students));
175 // all users who can attempt scoes and who are in the currently selected group
176 if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack','','','','',$currentgroup,'',false)){
177 echo $OUTPUT->notification(get_string('nostudentsingroup'));
179 $groupstudents = array();
181 $allowedlist = join(',', array_keys($groupstudents));
186 // Now check if asked download of data
188 $filename = clean_filename("$course->shortname ".format_string($scorm->name
,true));
191 // Define table columns
194 if (!$download && $candelete) {
195 $columns[]= 'checkbox';
198 if (!$download && $CFG->grade_report_showuserimage
) {
199 $columns[]= 'picture';
202 $columns[]= 'fullname';
203 $headers[]= get_string('name');
204 if ($CFG->grade_report_showuseridnumber
) {
205 $columns[]= 'idnumber';
206 $headers[]= get_string('idnumber');
208 $columns[]= 'attempt';
209 $headers[]= get_string('attempt', 'scorm');
211 $headers[]= get_string('started','scorm');
212 $columns[]= 'finish';
213 $headers[]= get_string('last','scorm');
215 $headers[]= get_string('score','scorm');
216 if ($detailedrep && $scoes = $DB->get_records('scorm_scoes',array("scorm"=>$scorm->id
),'id')) {
217 foreach ($scoes as $sco) {
218 if ($sco->launch
!='') {
219 $columns[]= 'scograde'.$sco->id
;
220 $headers[]= format_string($sco->title
);
221 $table->head
[]= format_string($sco->title
);
229 $table = new flexible_table('mod-scorm-report');
231 $table->define_columns($columns);
232 $table->define_headers($headers);
233 $table->define_baseurl($reporturlwithdisplayoptions->out());
235 $table->sortable(true);
236 $table->collapsible(true);
238 $table->column_suppress('picture');
239 $table->column_suppress('fullname');
240 $table->column_suppress('idnumber');
242 $table->no_sorting('start');
243 $table->no_sorting('finish');
244 $table->no_sorting('score');
246 foreach ($scoes as $sco) {
247 if ($sco->launch
!='') {
248 $table->no_sorting('scograde'.$sco->id
);
253 $table->column_class('picture', 'picture');
254 $table->column_class('fullname', 'bold');
255 $table->column_class('score', 'bold');
257 $table->set_attribute('cellspacing', '0');
258 $table->set_attribute('id', 'attempts');
259 $table->set_attribute('class', 'generaltable generalbox');
261 // Start working -- this is necessary as soon as the niceties are over
263 } else if ($download =='ODS') {
264 require_once("$CFG->libdir/odslib.class.php");
267 // Creating a workbook
268 $workbook = new MoodleODSWorkbook("-");
269 // Sending HTTP headers
270 $workbook->send($filename);
271 // Creating the first worksheet
272 $sheettitle = get_string('report','scorm');
273 $myxls =& $workbook->add_worksheet($sheettitle);
275 $format =& $workbook->add_format();
276 $format->set_bold(0);
277 $formatbc =& $workbook->add_format();
278 $formatbc->set_bold(1);
279 $formatbc->set_align('center');
280 $formatb =& $workbook->add_format();
281 $formatb->set_bold(1);
282 $formaty =& $workbook->add_format();
283 $formaty->set_bg_color('yellow');
284 $formatc =& $workbook->add_format();
285 $formatc->set_align('center');
286 $formatr =& $workbook->add_format();
287 $formatr->set_bold(1);
288 $formatr->set_color('red');
289 $formatr->set_align('center');
290 $formatg =& $workbook->add_format();
291 $formatg->set_bold(1);
292 $formatg->set_color('green');
293 $formatg->set_align('center');
294 // Here starts workshhet headers
297 foreach ($headers as $item) {
298 $myxls->write(0,$colnum,$item,$formatbc);
302 } else if ($download =='Excel') {
303 require_once("$CFG->libdir/excellib.class.php");
306 // Creating a workbook
307 $workbook = new MoodleExcelWorkbook("-");
308 // Sending HTTP headers
309 $workbook->send($filename);
310 // Creating the first worksheet
311 $sheettitle = get_string('report','scorm');
312 $myxls =& $workbook->add_worksheet($sheettitle);
314 $format =& $workbook->add_format();
315 $format->set_bold(0);
316 $formatbc =& $workbook->add_format();
317 $formatbc->set_bold(1);
318 $formatbc->set_align('center');
319 $formatb =& $workbook->add_format();
320 $formatb->set_bold(1);
321 $formaty =& $workbook->add_format();
322 $formaty->set_bg_color('yellow');
323 $formatc =& $workbook->add_format();
324 $formatc->set_align('center');
325 $formatr =& $workbook->add_format();
326 $formatr->set_bold(1);
327 $formatr->set_color('red');
328 $formatr->set_align('center');
329 $formatg =& $workbook->add_format();
330 $formatg->set_bold(1);
331 $formatg->set_color('green');
332 $formatg->set_align('center');
335 foreach ($headers as $item) {
336 $myxls->write(0,$colnum,$item,$formatbc);
340 } else if ($download=='CSV') {
342 header("Content-Type: application/download\n");
343 header("Content-Disposition: attachment; filename=\"$filename\"");
344 header("Expires: 0");
345 header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
346 header("Pragma: public");
347 echo implode("\t", $headers)." \n";
351 $select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
352 $select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
353 'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email ';
355 // This part is the same for all cases - join users and scorm_scoes_track tables
356 $from = 'FROM {user} u ';
357 $from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id
;
358 switch ($attemptsmode){
359 case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH
:
360 // Show only students with attempts
361 $where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NOT NULL';
363 case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO
:
364 // Show only students without attempts
365 $where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NULL';
367 case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS
:
368 // Show all students with or without attempts
369 $where = ' WHERE u.id IN (' .$allowedlist. ') AND (st.userid IS NOT NULL OR st.userid IS NULL)';
373 $countsql = 'SELECT COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').')) AS nbresults, ';
374 $countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'','st.attempt').')) AS nbattempts, ';
375 $countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers ';
376 $countsql .= $from.$where;
380 $sort = $table->get_sql_sort();
385 // Fix some wired sorting
387 $sort = ' ORDER BY uniqueid';
389 $sort = ' ORDER BY '.$sort;
393 // Add extra limits due to initials bar
394 list($twhere, $tparams) = $table->get_sql_where();
396 $where .= ' AND '.$twhere; //initial bar
397 $params = array_merge($params, $tparams);
400 if (!empty($countsql)) {
401 $count = $DB->get_record_sql($countsql);
402 $totalinitials = $count->nbresults
;
404 $countsql .= ' AND '.$twhere;
406 $count = $DB->get_record_sql($countsql, $params);
407 $total = $count->nbresults
;
410 $table->pagesize($pagesize, $total);
412 echo '<div class="quizattemptcounts">';
413 if ( $count->nbresults
== $count->nbattempts
) {
414 echo get_string('reportcountattempts','scorm', $count);
415 } else if( $count->nbattempts
>0 ) {
416 echo get_string('reportcountallattempts','scorm', $count);
418 echo $count->nbusers
.' '.get_string('users');
423 // Fetch the attempts
425 $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
426 $table->get_page_start(), $table->get_page_size());
427 echo '<div id="scormtablecontainer">';
430 $strreallydel = addslashes_js(get_string('deleteattemptcheck','scorm'));
431 echo '<form id="attemptsform" method="post" action="' . $reporturlwithdisplayoptions->out(true) .
432 '" onsubmit="return confirm(\''.$strreallydel.'\');">';
433 echo '<input type="hidden" name="action" value="delete"/>';
434 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
435 echo '<div style="display: none;">';
436 echo html_writer
::input_hidden_params($reporturlwithdisplayoptions);
440 $table->initialbars($totalinitials>20); // Build table rows
442 $attempts = $DB->get_records_sql($select.$from.$where.$sort, $params);
446 foreach($attempts as $scouser){
448 if (!empty($scouser->attempt
)) {
449 $timetracks = scorm_get_sco_runtime($scorm->id
, false, $scouser->userid
, $scouser->attempt
);
451 if (in_array('checkbox', $columns)){
452 if ($candelete && !empty($timetracks->start
)) {
453 $row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid
. ':' . $scouser->attempt
. '" />';
454 } else if($candelete) {
458 if (in_array('picture', $columns)){
459 $user = (object)array('id'=>$scouser->userid
,
460 'picture'=>$scouser->picture
,
461 'imagealt'=>$scouser->imagealt
,
462 'email'=>$scouser->email
,
463 'firstname'=>$scouser->firstname
,
464 'lastname'=>$scouser->lastname
);
465 $row[] = $OUTPUT->user_picture($user, array('courseid'=>$course->id
));
468 $row[] = '<a href="'.$CFG->wwwroot
.'/user/view.php?id='.$scouser->userid
.'&course='.$course->id
.'">'.fullname($scouser).'</a>';
470 $row[] = fullname($scouser);
472 if (in_array('idnumber', $columns)){
473 $row[] = $scouser->idnumber
;
475 if (empty($timetracks->start
)) {
481 if (!$download) $row[] = '<a href="report.php?a='.$scorm->id
.'&user='.$scouser->userid
.'&attempt='.$scouser->attempt
.'">'.$scouser->attempt
.'</a>';
482 else $row[] = $scouser->attempt
;
483 if ($download =='ODS' ||
$download =='Excel' ) $row[] = userdate($timetracks->start
, get_string("strftimedatetime", "langconfig"));
484 else $row[] = userdate($timetracks->start
);
485 if ($download =='ODS' ||
$download =='Excel' ) $row[] = userdate($timetracks->finish
, get_string('strftimedatetime', 'langconfig'));
486 else $row[] = userdate($timetracks->finish
);
488 $row[] = scorm_grade_user_attempt($scorm, $scouser->userid
, $scouser->attempt
);
490 // print out all scores of attempt
492 foreach ($scoes as $sco) {
493 if ($sco->launch
!='') {
494 if ($trackdata = scorm_get_tracks($sco->id
,$scouser->userid
,$scouser->attempt
)) {
495 if ($trackdata->status
== '') {
496 $trackdata->status
= 'notattempted';
498 $strstatus = get_string($trackdata->status
, 'scorm');
499 // if raw score exists, print it
500 if ($trackdata->score_raw
!= '') {
501 $score = $trackdata->score_raw
;
502 // add max score if it exists
503 if ($scorm->version
== 'SCORM_1.3') {
504 $maxkey = 'cmi.score.max';
506 $maxkey = 'cmi.core.score.max';
508 if (isset($trackdata->$maxkey)) {
509 $score .= '/'.$trackdata->$maxkey;
511 // else print out status
516 $row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status
, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>
517 <a href="report.php?b='.$sco->id
.'&user='.$scouser->userid
.'&attempt='.$scouser->attempt
.
518 '" title="'.get_string('details','scorm').'">'.$score.'</a>';
523 // if we don't have track data, we haven't attempted yet
524 $strstatus = get_string('notattempted', 'scorm');
526 $row[] = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>'.$strstatus;
536 $table->add_data($row);
537 } else if ($download == 'Excel' or $download == 'ODS') {
539 foreach($row as $item){
540 $myxls->write($rownum,$colnum,$item,$format);
544 } else if ($download=='CSV') {
545 $text = implode("\t", $row);
550 $table->finish_output();
552 echo '<table id="commands">';
554 echo '<a href="javascript:select_all_in(\'DIV\',null,\'scormtablecontainer\');">'.
555 get_string('selectall', 'scorm').'</a> / ';
556 echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'scormtablecontainer\');">'.
557 get_string('selectnone', 'scorm').'</a> ';
559 echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>';
560 echo '</td></tr></table>';
566 if (!empty($attempts)) {
567 echo '<table class="boxaligncenter"><tr>';
569 echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions +
$displayoptions +
array('download' => 'ODS')), get_string('downloadods'));
572 echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions +
$displayoptions +
array('download' => 'Excel')), get_string('downloadexcel'));
575 echo $OUTPUT->single_button(new moodle_url('/mod/scorm/report.php', $pageoptions +
$displayoptions +
array('download' => 'CSV')), get_string('downloadtext'));
579 echo '</tr></table>';
583 $mform->set_data($displayoptions +
compact('detailedrep', 'pagesize'));
587 echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
589 if ($download == 'Excel' or $download == 'ODS') {
592 } else if ($download == 'CSV') {
596 echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
601 if ($scoes = $DB->get_records_select('scorm_scoes',"scorm=? ORDER BY id", array($scorm->id
))) {
602 if (!empty($userdata)) {
603 echo $OUTPUT->box_start('generalbox boxaligncenter');
604 echo '<div class="mdl-align">'."\n";
605 $userrec = (object)array('id'=>$user);
606 echo $OUTPUT->user_picture($userrec, array('courseid'=>$course->id
));
607 echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
608 "$userdata->firstname $userdata->lastname</a><br />";
609 echo get_string('attempt','scorm').': '.$attempt;
611 echo $OUTPUT->box_end();
613 // Print general score data
614 $table = new html_table();
615 $table->head
= array(get_string('title','scorm'),
616 get_string('status','scorm'),
617 get_string('time','scorm'),
618 get_string('score','scorm'),
620 $table->align
= array('left', 'center','center','right','left');
621 $table->wrap
= array('nowrap', 'nowrap','nowrap','nowrap','nowrap');
622 $table->width
= '80%';
623 $table->size
= array('*', '*', '*', '*', '*');
624 foreach ($scoes as $sco) {
625 if ($sco->launch
!='') {
628 if ($trackdata = scorm_get_tracks($sco->id
,$user,$attempt)) {
629 if ($trackdata->score_raw
!= '') {
630 $score = $trackdata->score_raw
;
632 if ($trackdata->status
== '') {
633 $trackdata->status
= 'notattempted';
635 $detailslink = '<a href="report.php?b='.$sco->id
.'&user='.$user.'&attempt='.$attempt.'" title="'.
636 get_string('details','scorm').'">'.get_string('details','scorm').'</a>';
638 $trackdata->status
= 'notattempted';
639 $trackdata->total_time
= ' ';
640 $detailslink = ' ';
642 $strstatus = get_string($trackdata->status
,'scorm');
643 $row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status
, 'scorm').'" alt="'.$strstatus.'" title="'.
644 $strstatus.'" /> '.format_string($sco->title
);
645 $row[] = get_string($trackdata->status
,'scorm');
646 $row[] = scorm_format_duration($trackdata->total_time
);
648 $row[] = $detailslink;
650 $row = array(format_string($sco->title
), ' ', ' ', ' ', ' ');
652 $table->data
[] = $row;
654 echo html_writer
::table($table);
658 notice('No users to report');
663 if (!empty($userdata)) {
664 echo $OUTPUT->box_start('generalbox boxaligncenter');
665 //print_heading(format_string($sco->title));
666 echo $OUTPUT->heading('<a href="'.$CFG->wwwroot
.'/mod/scorm/player.php?a='.$scorm->id
.'&mode=browse&scoid='.$sco->id
.'" target="_new">'.format_string($sco->title
).'</a>');
667 echo '<div class="mdl-align">'."\n";
668 $userrec = (object)array('id'=>$user);
669 echo $OUTPUT->user_picture($userrec, array('courseid'=>$course->id
));
670 echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
671 "$userdata->firstname $userdata->lastname</a><br />";
673 if ($trackdata = scorm_get_tracks($sco->id
,$user,$attempt)) {
674 if ($trackdata->score_raw
!= '') {
675 $scoreview = get_string('score','scorm').': '.$trackdata->score_raw
;
677 if ($trackdata->status
== '') {
678 $trackdata->status
= 'notattempted';
681 $trackdata->status
= 'notattempted';
682 $trackdata->total_time
= '';
684 $strstatus = get_string($trackdata->status
,'scorm');
685 echo '<img src="'.$OUTPUT->pix_url($trackdata->status
, 'scorm').'" alt="'.$strstatus.'" title="'.
686 $strstatus.'" /> '.scorm_format_duration($trackdata->total_time
).'<br />'.$scoreview.'<br />';
688 echo '<hr /><h2>'.get_string('details','scorm').'</h2>';
690 // Print general score data
691 $table = new html_table();
692 $table->head
= array(get_string('element','scorm'), get_string('value','scorm'));
693 $table->align
= array('left', 'left');
694 $table->wrap
= array('nowrap', 'nowrap');
695 $table->width
= '100%';
696 $table->size
= array('*', '*');
698 $existelements = false;
699 if ($scorm->version
== 'SCORM_1.3') {
700 $elements = array('raw' => 'cmi.score.raw',
701 'min' => 'cmi.score.min',
702 'max' => 'cmi.score.max',
703 'status' => 'cmi.completion_status',
704 'time' => 'cmi.total_time');
706 $elements = array('raw' => 'cmi.core.score.raw',
707 'min' => 'cmi.core.score.min',
708 'max' => 'cmi.core.score.max',
709 'status' => 'cmi.core.lesson_status',
710 'time' => 'cmi.core.total_time');
712 $printedelements = array();
713 foreach ($elements as $key => $element) {
714 if (isset($trackdata->$element)) {
715 $existelements = true;
716 $printedelements[]=$element;
718 $row[] = get_string($key,'scorm');
724 $row[] = s(scorm_format_duration($trackdata->$element));
727 s($trackdata->$element);
730 $table->data
[] = $row;
733 if ($existelements) {
734 echo '<h3>'.get_string('general','scorm').'</h3>';
735 echo html_writer
::table($table);
738 // Print Interactions data
739 $table = new html_table();
740 $table->head
= array(get_string('identifier','scorm'),
741 get_string('type','scorm'),
742 get_string('result','scorm'),
743 get_string('student_response','scorm'));
744 $table->align
= array('center', 'center', 'center', 'center');
745 $table->wrap
= array('nowrap', 'nowrap', 'nowrap', 'nowrap');
746 $table->width
= '100%';
747 $table->size
= array('*', '*', '*', '*', '*');
749 $existinteraction = false;
752 $interactionid = 'cmi.interactions.'.$i.'.id';
754 while (isset($trackdata->$interactionid)) {
755 $existinteraction = true;
756 $printedelements[]=$interactionid;
757 $elements = array($interactionid,
758 'cmi.interactions.'.$i.'.type',
759 'cmi.interactions.'.$i.'.result',
760 'cmi.interactions.'.$i.'.learner_response');
762 foreach ($elements as $element) {
763 if (isset($trackdata->$element)) {
764 $row[] = s($trackdata->$element);
765 $printedelements[]=$element;
770 $table->data
[] = $row;
773 $interactionid = 'cmi.interactions.'.$i.'.id';
775 if ($existinteraction) {
776 echo '<h3>'.get_string('interactions','scorm').'</h3>';
777 echo html_writer
::table($table);
780 // Print Objectives data
781 $table = new html_table();
782 $table->head
= array(get_string('identifier','scorm'),
783 get_string('status','scorm'),
784 get_string('raw','scorm'),
785 get_string('min','scorm'),
786 get_string('max','scorm'));
787 $table->align
= array('center', 'center', 'center', 'center', 'center');
788 $table->wrap
= array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
789 $table->width
= '100%';
790 $table->size
= array('*', '*', '*', '*', '*');
792 $existobjective = false;
795 $objectiveid = 'cmi.objectives.'.$i.'.id';
797 while (isset($trackdata->$objectiveid)) {
798 $existobjective = true;
799 $printedelements[]=$objectiveid;
800 $elements = array($objectiveid,
801 'cmi.objectives.'.$i.'.status',
802 'cmi.objectives.'.$i.'.score.raw',
803 'cmi.objectives.'.$i.'.score.min',
804 'cmi.objectives.'.$i.'.score.max');
806 foreach ($elements as $element) {
807 if (isset($trackdata->$element)) {
808 $row[] = s($trackdata->$element);
809 $printedelements[]=$element;
814 $table->data
[] = $row;
817 $objectiveid = 'cmi.objectives.'.$i.'.id';
819 if ($existobjective) {
820 echo '<h3>'.get_string('objectives','scorm').'</h3>';
821 echo html_writer
::table($table);
823 $table = new html_table();
824 $table->head
= array(get_string('element','scorm'), get_string('value','scorm'));
825 $table->align
= array('left', 'left');
826 $table->wrap
= array('nowrap', 'wrap');
827 $table->width
= '100%';
828 $table->size
= array('*', '*');
830 $existelements = false;
832 foreach($trackdata as $element => $value) {
833 if (substr($element,0,3) == 'cmi') {
834 if (!(in_array ($element, $printedelements))) {
835 $existelements = true;
837 $row[] = get_string($element,'scorm') != '[['.$element.']]' ?
get_string($element,'scorm') : $element;
838 if (strpos($element, '_time') === false) {
841 $row[] = s(scorm_format_duration($value));
843 $table->data
[] = $row;
847 if ($existelements) {
848 echo '<h3>'.get_string('othertracks','scorm').'</h3>';
849 echo html_writer
::table($table);
851 echo $OUTPUT->box_end();
853 print_error('missingparameter');
858 if (empty($noheader)) {
859 echo $OUTPUT->footer();