Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This page displays the user data from a single attempt 19 * 20 * @package mod_scorm 21 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once("../../../config.php"); 26 require_once($CFG->dirroot.'/mod/scorm/locallib.php'); 27 require_once($CFG->libdir.'/tablelib.php'); 28 29 $id = required_param('id', PARAM_INT); // Course Module ID. 30 $userid = required_param('user', PARAM_INT); // User ID. 31 $scoid = required_param('scoid', PARAM_INT); // SCO ID. 32 $attempt = optional_param('attempt', 1, PARAM_INT); // attempt number. 33 $download = optional_param('download', '', PARAM_ALPHA); 34 35 // Building the url to use for links.+ data details buildup. 36 $url = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $id, 37 'user' => $userid, 38 'attempt' => $attempt, 39 'scoid' => $scoid)); 40 $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); 41 $course = get_course($cm->course); 42 $scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST); 43 $user = $DB->get_record('user', array('id' => $userid), implode(',', \core_user\fields::get_picture_fields()), MUST_EXIST); 44 $selsco = $DB->get_record('scorm_scoes', array('id' => $scoid), '*', MUST_EXIST); 45 46 $PAGE->set_url($url); 47 // END of url setting + data buildup. 48 49 // Checking login +logging +getting context. 50 require_login($course, false, $cm); 51 $contextmodule = context_module::instance($cm->id); 52 require_capability('mod/scorm:viewreport', $contextmodule); 53 54 // Check user has group access. 55 if (!groups_user_groups_visible($course, $userid, $cm)) { 56 throw new moodle_exception('nopermissiontoshow'); 57 } 58 59 // Trigger a tracks viewed event. 60 $event = \mod_scorm\event\tracks_viewed::create(array( 61 'context' => $contextmodule, 62 'relateduserid' => $userid, 63 'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id, 'scoid' => $scoid) 64 )); 65 $event->add_record_snapshot('course_modules', $cm); 66 $event->add_record_snapshot('scorm', $scorm); 67 $event->trigger(); 68 69 // Print the page header. 70 $strreport = get_string('report', 'scorm'); 71 $strattempt = get_string('attempt', 'scorm'); 72 73 $PAGE->set_title("$course->shortname: ".format_string($scorm->name)); 74 $PAGE->set_heading($course->fullname); 75 $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id))); 76 $PAGE->navbar->add("$strattempt $attempt - ".fullname($user), 77 new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id, 'user' => $userid, 'attempt' => $attempt))); 78 $PAGE->navbar->add($selsco->title . ' - '. get_string('details', 'scorm')); 79 80 if ($trackdata = scorm_get_tracks($selsco->id, $userid, $attempt)) { 81 if ($trackdata->status == '') { 82 $trackdata->status = 'notattempted'; 83 } 84 } else { 85 $trackdata = new stdClass(); 86 $trackdata->status = 'notattempted'; 87 $trackdata->total_time = ''; 88 } 89 90 $courseshortname = format_string($course->shortname, true, 91 array('context' => context_course::instance($course->id))); 92 $exportfilename = $courseshortname . '-' . format_string($scorm->name, true) . '-' . get_string('details', 'scorm'); 93 94 $table = new flexible_table('mod_scorm-userreporttracks'); 95 96 if (!$table->is_downloading($download, $exportfilename)) { 97 echo $OUTPUT->header(); 98 echo $OUTPUT->heading(format_string($scorm->name)); 99 $currenttab = ''; 100 require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php'); 101 echo $OUTPUT->box_start('generalbox boxaligncenter'); 102 echo $OUTPUT->heading("$strattempt $attempt - ". fullname($user).': '. 103 format_string($selsco->title). ' - '. get_string('details', 'scorm'), 3); 104 } 105 $table->define_baseurl($PAGE->url); 106 $table->define_columns(array('element', 'value')); 107 $table->define_headers(array(get_string('element', 'scorm'), get_string('value', 'scorm'))); 108 $table->set_attribute('class', 'generaltable generalbox boxaligncenter scormtrackreport'); 109 $table->show_download_buttons_at(array(TABLE_P_BOTTOM)); 110 $table->setup(); 111 112 foreach ($trackdata as $element => $value) { 113 if (substr($element, 0, 3) == 'cmi') { 114 $existelements = true; 115 $row = array(); 116 $string = false; 117 if (stristr($element, '.id') !== false) { 118 $string = "trackid"; 119 } else if (stristr($element, '.result') !== false) { 120 $string = "trackresult"; 121 } else if (stristr($element, '.student_response') !== false or // SCORM 1.2 value. 122 stristr($element, '.learner_response') !== false) { // SCORM 2004 value. 123 $string = "trackresponse"; 124 } else if (stristr($element, '.type') !== false) { 125 $string = "tracktype"; 126 } else if (stristr($element, '.weighting') !== false) { 127 $string = "trackweight"; 128 } else if (stristr($element, '.time') !== false) { 129 $string = "tracktime"; 130 } else if (stristr($element, '.correct_responses._count') !== false) { 131 $string = "trackcorrectcount"; 132 } else if (stristr($element, '.score.min') !== false) { 133 $string = "trackscoremin"; 134 } else if (stristr($element, '.score.max') !== false) { 135 $string = "trackscoremax"; 136 } else if (stristr($element, '.score.raw') !== false) { 137 $string = "trackscoreraw"; 138 } else if (stristr($element, '.latency') !== false) { 139 $string = "tracklatency"; 140 } else if (stristr($element, '.pattern') !== false) { 141 $string = "trackpattern"; 142 } else if (stristr($element, '.suspend_data') !== false) { 143 $string = "tracksuspenddata"; 144 } 145 146 if (empty($string) || $table->is_downloading()) { 147 $row[] = s($element); 148 } else { 149 $row[] = s($element) . $OUTPUT->help_icon($string, 'scorm'); 150 } 151 if (strpos($element, '_time') === false) { 152 $row[] = s($value); 153 } else { 154 $row[] = s(scorm_format_duration($value)); 155 } 156 $table->add_data($row); 157 } 158 } 159 $table->finish_output(); 160 if (!$table->is_downloading()) { 161 echo $OUTPUT->box_end(); 162 echo $OUTPUT->footer(); 163 } 164
title
Description
Body
title
Description
Body
title
Description
Body
title
Body