PageRenderTime 62ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/scorm/report/userreporttracks.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 151 lines | 110 code | 16 blank | 25 comment | 38 complexity | 8086b77f19d542b218b6f9480e69d524 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, Apache-2.0, BSD-3-Clause, AGPL-3.0
  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. * This page displays the user data from a single attempt
  18. *
  19. * @package mod_scorm
  20. * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. require_once("../../../config.php");
  24. require_once($CFG->dirroot.'/mod/scorm/locallib.php');
  25. require_once($CFG->libdir.'/tablelib.php');
  26. $id = required_param('id', PARAM_INT); // Course Module ID.
  27. $userid = required_param('user', PARAM_INT); // User ID.
  28. $scoid = required_param('scoid', PARAM_INT); // SCO ID.
  29. $attempt = optional_param('attempt', 1, PARAM_INT); // attempt number.
  30. $download = optional_param('download', '', PARAM_ALPHA);
  31. // Building the url to use for links.+ data details buildup.
  32. $url = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $id,
  33. 'user' => $userid,
  34. 'attempt' => $attempt,
  35. 'scoid' => $scoid));
  36. $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
  37. $course = get_course($cm->course);
  38. $scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
  39. $user = $DB->get_record('user', array('id' => $userid), user_picture::fields(), MUST_EXIST);
  40. $selsco = $DB->get_record('scorm_scoes', array('id' => $scoid), '*', MUST_EXIST);
  41. $PAGE->set_url($url);
  42. // END of url setting + data buildup.
  43. // Checking login +logging +getting context.
  44. require_login($course, false, $cm);
  45. $contextmodule = context_module::instance($cm->id);
  46. require_capability('mod/scorm:viewreport', $contextmodule);
  47. add_to_log($course->id, 'scorm', 'userreporttracks', 'userreporttracks.php?id='.$id, $scorm->id, $id);
  48. // Print the page header.
  49. $strreport = get_string('report', 'scorm');
  50. $strattempt = get_string('attempt', 'scorm');
  51. $PAGE->set_title("$course->shortname: ".format_string($scorm->name));
  52. $PAGE->set_heading($course->fullname);
  53. $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id)));
  54. $PAGE->navbar->add("$strattempt $attempt - ".fullname($user),
  55. new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id, 'user' => $userid, 'attempt' => $attempt)));
  56. $PAGE->navbar->add($selsco->title . ' - '. get_string('details', 'scorm'));
  57. if ($trackdata = scorm_get_tracks($selsco->id, $userid, $attempt)) {
  58. if ($trackdata->status == '') {
  59. $trackdata->status = 'notattempted';
  60. }
  61. } else {
  62. $trackdata = new stdClass();
  63. $trackdata->status = 'notattempted';
  64. $trackdata->total_time = '';
  65. }
  66. $courseshortname = format_string($course->shortname, true,
  67. array('context' => context_course::instance($course->id)));
  68. $exportfilename = $courseshortname . '-' . format_string($scorm->name, true) . '-' . get_string('details', 'scorm');
  69. $table = new flexible_table('mod_scorm-userreporttracks');
  70. if (!$table->is_downloading($download, $exportfilename)) {
  71. echo $OUTPUT->header();
  72. echo $OUTPUT->heading(format_string($scorm->name));
  73. $currenttab = '';
  74. require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php');
  75. echo $OUTPUT->box_start('generalbox boxaligncenter');
  76. echo $OUTPUT->heading("$strattempt $attempt - ". fullname($user).': '.
  77. format_string($selsco->title). ' - '. get_string('details', 'scorm'), 3);
  78. }
  79. $table->define_baseurl($PAGE->url);
  80. $table->define_columns(array('element', 'value'));
  81. $table->define_headers(array(get_string('element', 'scorm'), get_string('value', 'scorm')));
  82. $table->set_attribute('class', 'generaltable generalbox boxaligncenter scormtrackreport');
  83. $table->show_download_buttons_at(array(TABLE_P_BOTTOM));
  84. $table->setup();
  85. foreach ($trackdata as $element => $value) {
  86. if (substr($element, 0, 3) == 'cmi') {
  87. $existelements = true;
  88. $row = array();
  89. $string = false;
  90. if (stristr($element, '.id') !== false) {
  91. $string = "trackid";
  92. } else if (stristr($element, '.result') !== false) {
  93. $string = "trackresult";
  94. } else if (stristr($element, '.student_response') !== false or // SCORM 1.2 value.
  95. stristr($element, '.learner_response') !== false) { // SCORM 2004 value.
  96. $string = "trackresponse";
  97. } else if (stristr($element, '.type') !== false) {
  98. $string = "tracktype";
  99. } else if (stristr($element, '.weighting') !== false) {
  100. $string = "trackweight";
  101. } else if (stristr($element, '.time') !== false) {
  102. $string = "tracktime";
  103. } else if (stristr($element, '.correct_responses._count') !== false) {
  104. $string = "trackcorrectcount";
  105. } else if (stristr($element, '.score.min') !== false) {
  106. $string = "trackscoremin";
  107. } else if (stristr($element, '.score.max') !== false) {
  108. $string = "trackscoremax";
  109. } else if (stristr($element, '.score.raw') !== false) {
  110. $string = "trackscoreraw";
  111. } else if (stristr($element, '.latency') !== false) {
  112. $string = "tracklatency";
  113. } else if (stristr($element, '.pattern') !== false) {
  114. $string = "trackpattern";
  115. } else if (stristr($element, '.suspend_data') !== false) {
  116. $string = "tracksuspenddata";
  117. }
  118. if (empty($string) || $table->is_downloading()) {
  119. $row[] = $element;
  120. } else {
  121. $row[] = $element.$OUTPUT->help_icon($string, 'scorm');
  122. }
  123. if (strpos($element, '_time') === false) {
  124. $row[] = s($value);
  125. } else {
  126. $row[] = s(scorm_format_duration($value));
  127. }
  128. $table->add_data($row);
  129. }
  130. }
  131. $table->finish_output();
  132. if (!$table->is_downloading()) {
  133. echo $OUTPUT->box_end();
  134. echo $OUTPUT->footer();
  135. }