[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 28 $id = required_param('id', PARAM_INT); // Course Module ID. 29 $userid = required_param('user', PARAM_INT); // User ID. 30 $attempt = optional_param('attempt', 1, PARAM_INT); // attempt number. 31 32 // Building the url to use for links.+ data details buildup. 33 $url = new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id, 34 'user' => $userid, 35 'attempt' => $attempt)); 36 $tracksurl = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $id, 37 'user' => $userid, 38 'attempt' => $attempt)); 39 $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); 40 $course = get_course($cm->course); 41 $scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST); 42 $user = $DB->get_record('user', array('id' => $userid), user_picture::fields(), MUST_EXIST); 43 // Get list of attempts this user has made. 44 $attemptids = scorm_get_all_attempts($scorm->id, $userid); 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 // Trigger a user report viewed event. 55 $event = \mod_scorm\event\user_report_viewed::create(array( 56 'context' => $contextmodule, 57 'relateduserid' => $userid, 58 'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id) 59 )); 60 $event->add_record_snapshot('course_modules', $cm); 61 $event->add_record_snapshot('scorm', $scorm); 62 $event->trigger(); 63 64 // Print the page header. 65 $strreport = get_string('report', 'scorm'); 66 $strattempt = get_string('attempt', 'scorm'); 67 68 $PAGE->set_title("$course->shortname: ".format_string($scorm->name)); 69 $PAGE->set_heading($course->fullname); 70 $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id))); 71 $PAGE->navbar->add(fullname($user). " - $strattempt $attempt"); 72 73 echo $OUTPUT->header(); 74 echo $OUTPUT->heading(format_string($scorm->name)); 75 // End of Print the page header. 76 $currenttab = 'scoes'; 77 require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php'); 78 79 // Printing user details. 80 $output = $PAGE->get_renderer('mod_scorm'); 81 echo $output->view_user_heading($user, $course, $PAGE->url, $attempt, $attemptids); 82 83 if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id), 'sortorder, id')) { 84 // Print general score data. 85 $table = new html_table(); 86 $table->head = array( 87 get_string('title', 'scorm'), 88 get_string('status', 'scorm'), 89 get_string('time', 'scorm'), 90 get_string('score', 'scorm'), 91 ''); 92 $table->align = array('left', 'center', 'center', 'right', 'left'); 93 $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); 94 $table->width = '80%'; 95 $table->size = array('*', '*', '*', '*', '*'); 96 foreach ($scoes as $sco) { 97 if ($sco->launch != '') { 98 $row = array(); 99 $score = ' '; 100 if ($trackdata = scorm_get_tracks($sco->id, $userid, $attempt)) { 101 if ($trackdata->score_raw != '') { 102 $score = $trackdata->score_raw; 103 } 104 if ($trackdata->status == '') { 105 if (!empty($trackdata->progress)) { 106 $trackdata->status = $trackdata->progress; 107 } else { 108 $trackdata->status = 'notattempted'; 109 } 110 } 111 $tracksurl->param('scoid', $sco->id); 112 $detailslink = html_writer::link($tracksurl, get_string('details', 'scorm')); 113 } else { 114 $trackdata = new stdClass(); 115 $trackdata->status = 'notattempted'; 116 $trackdata->total_time = ' '; 117 $detailslink = ' '; 118 } 119 $strstatus = get_string($trackdata->status, 'scorm'); 120 $row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status, 'scorm').'" alt="'.$strstatus.'" title="'. 121 $strstatus.'" /> '.format_string($sco->title); 122 $row[] = get_string($trackdata->status, 'scorm'); 123 $row[] = scorm_format_duration($trackdata->total_time); 124 $row[] = $score; 125 $row[] = $detailslink; 126 } else { 127 $row = array(format_string($sco->title), ' ', ' ', ' ', ' '); 128 } 129 $table->data[] = $row; 130 } 131 echo html_writer::table($table); 132 } 133 134 // Print footer. 135 136 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |