diff --git a/mod/scorm/lang/en/scorm.php b/mod/scorm/lang/en/scorm.php
index 240d91ad51f..2cdee95df71 100644
--- a/mod/scorm/lang/en/scorm.php
+++ b/mod/scorm/lang/en/scorm.php
@@ -65,6 +65,7 @@ $string['browse'] = 'Preview';
$string['browsed'] = 'Browsed';
$string['browsemode'] = 'Preview mode';
$string['browserepository'] = 'Browse repository';
+$string['calculatedweight'] = 'Calculated weight';
$string['cannotfindsco'] = 'Could not find SCO';
$string['compatibilitysettings'] = 'Compatibility settings';
$string['completed'] = 'Completed';
@@ -102,7 +103,6 @@ $string['dnduploadscorm'] = 'Add a SCORM package';
$string['domxml'] = 'DOMXML external library';
$string['duedate'] = 'Due date';
$string['element'] = 'Element';
-$string['elementdefinition'] = 'Element definition';
$string['enter'] = 'Enter';
$string['entercourse'] = 'Enter course';
$string['errorlogs'] = 'Errors log';
@@ -167,20 +167,32 @@ $string['identifier'] = 'Question identifier';
$string['incomplete'] = 'Incomplete';
$string['info'] = 'Info';
$string['interactions'] = 'Interactions';
-$string['interactionsid'] = 'Id of the element';
-$string['interactionscorrectcount'] = 'Number of correct results for the question';
-$string['interactionspattern'] = 'Pattern of correct response';
-$string['interactionslatency'] = 'The time elapsed between the time the interaction was made available to the learner for a response and the time of the first response.';
-$string['interactionsresponse'] = 'Student\'s response';
-$string['interactionsresult'] = 'Result based on student\'s response and correct result';
-$string['interactionsscoremin'] = 'Minimum value in the range for the raw score';
-$string['interactionsscoremax'] = 'Maximum value in the range for the raw score';
-$string['interactionsscoreraw'] = 'Number that reflects the performance of the learner relative to the range bounded by the values of min and max';
-$string['interactionssuspenddata'] = 'Provides space to store and retrieve data between learner sessions';
-$string['interactionstime'] = 'Time at which the attempt was started';
-$string['interactionstype'] = 'Type of question';
-$string['interactionsweight'] = 'Weight assigned to the element';
-$string['interactionslearnerresponse'] = 'Learner\'s response';
+$string['trackid'] = 'Id';
+$string['trackid_help'] = 'This is the identifier set by your SCORM package for this question, the SCORM specification doesn\'t allow the full question text to be provided.';
+$string['trackcorrectcount'] = 'Correct count';
+$string['trackcorrectcount_help'] = 'Number of correct results for the question';
+$string['trackpattern'] = 'Pattern';
+$string['trackpattern_help'] = 'This is what a correct response to this question would be, it does not show the learners response.';
+$string['tracklatency'] = 'Latency';
+$string['tracklatency_help'] = 'The time elapsed between the time the question was made available to the learner for a response and the time of the first response.';
+$string['trackresponse'] = 'Response';
+$string['trackresponse_help'] = 'This is the response made by the learner for this question';
+$string['trackresult'] = 'Result';
+$string['trackresult_help'] = 'Shows if the learner entered a correct response.';
+$string['trackscoremin'] = 'Minimum score';
+$string['trackscoremin_help'] = 'Minimum value that can be assigned for the raw score';
+$string['trackscoremax'] = 'Maximum score';
+$string['trackscoremax_help'] = 'Maximum value that can be assigned for the raw score';
+$string['trackscoreraw'] = 'Raw score';
+$string['trackscoreraw_help'] = 'Number that reflects the performance of the learner relative to the range bounded by the values of min and max';
+$string['tracksuspenddata'] = 'Suspend data';
+$string['tracksuspenddata_help'] = 'Provides space to store and retrieve data between learner sessions';
+$string['tracktime'] = 'Time';
+$string['tracktime_help'] = 'Time at which the attempt was started';
+$string['tracktype'] = 'Type';
+$string['tracktype_help'] = 'Type of the question, for example "choice" or "shortanswer".';
+$string['trackweight'] = 'Weight';
+$string['trackweight_help'] = 'Weight assigned to the question when calculating score.';
$string['invalidactivity'] = 'SCORM activity is incorrect';
$string['invalidurl'] = 'Invalid URL specified';
$string['invalidurlhttpcheck'] = 'Invalid URL specified. Debug message:
{$a->cmsg}';
@@ -241,7 +253,6 @@ $string['optionsadv_desc'] = 'If checked the width and height will be listed as
$string['organization'] = 'Organisation';
$string['organizations'] = 'Organisations';
$string['othersettings'] = 'Additional settings';
-$string['othertracks'] = 'Other tracks';
$string['page-mod-scorm-x'] = 'Any SCORM module page';
$string['pagesize'] = 'Page size';
$string['package'] = 'Package file';
@@ -270,10 +281,12 @@ $string['reports'] = 'Reports';
$string['reportcountallattempts'] = '{$a->nbattempts} attempts for {$a->nbusers} users, out of {$a->nbresults} results';
$string['reportcountattempts'] = '{$a->nbresults} results ({$a->nbusers} users)';
$string['resizable'] = 'Allow the window to be resized';
+$string['response'] = 'Response';
$string['result'] = 'Result';
$string['results'] = 'Results';
$string['review'] = 'Review';
$string['reviewmode'] = 'Review mode';
+$string['rightanswer'] = 'Right answer';
$string['scoes'] = 'Learning objects';
$string['score'] = 'Score';
$string['scorm:addinstance'] = 'Add a new SCORM package';
diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php
index 7c8c43ae19a..8287314c9ca 100644
--- a/mod/scorm/locallib.php
+++ b/mod/scorm/locallib.php
@@ -517,8 +517,8 @@ function scorm_has_tracks($scormid, $userid) {
}
function scorm_get_tracks($scoid, $userid, $attempt='') {
- /// Gets all tracks of specified sco and user
- global $CFG, $DB;
+ // Gets all tracks of specified sco and user.
+ global $DB;
if (empty($attempt)) {
if ($scormid = $DB->get_field('scorm_scoes', 'scorm', array('id'=>$scoid))) {
@@ -527,54 +527,64 @@ function scorm_get_tracks($scoid, $userid, $attempt='') {
$attempt = 1;
}
}
- if ($tracks = $DB->get_records('scorm_scoes_track', array('userid'=>$userid, 'scoid'=>$scoid, 'attempt'=>$attempt), 'element ASC')) {
- $usertrack = new stdClass();
+ if ($tracks = $DB->get_records('scorm_scoes_track', array('userid'=>$userid, 'scoid'=>$scoid,
+ 'attempt'=>$attempt), 'element ASC')) {
+ $usertrack = scorm_format_interactions($tracks);
$usertrack->userid = $userid;
$usertrack->scoid = $scoid;
- // Defined in order to unify scorm1.2 and scorm2004
- $usertrack->score_raw = '';
- $usertrack->status = '';
- $usertrack->total_time = '00:00:00';
- $usertrack->session_time = '00:00:00';
- $usertrack->timemodified = 0;
- foreach ($tracks as $track) {
- $element = $track->element;
- $usertrack->{$element} = $track->value;
- switch ($element) {
- case 'cmi.core.lesson_status':
- case 'cmi.completion_status':
- if ($track->value == 'not attempted') {
- $track->value = 'notattempted';
- }
- $usertrack->status = $track->value;
- break;
- case 'cmi.core.score.raw':
- case 'cmi.score.raw':
- $usertrack->score_raw = (float) sprintf('%2.2f', $track->value);
- break;
- case 'cmi.core.session_time':
- case 'cmi.session_time':
- $usertrack->session_time = $track->value;
- break;
- case 'cmi.core.total_time':
- case 'cmi.total_time':
- $usertrack->total_time = $track->value;
- break;
- }
- if (isset($track->timemodified) && ($track->timemodified > $usertrack->timemodified)) {
- $usertrack->timemodified = $track->timemodified;
- }
- }
- if (is_array($usertrack)) {
- ksort($usertrack);
- }
+
return $usertrack;
} else {
return false;
}
}
+/**
+ * helper function to return a formatted list of interactions for reports.
+ *
+ * @param array $trackdata the records from scorm_scoes_track table
+ * @return object formatted list of interactions
+ */
+function scorm_format_interactions($trackdata) {
+ $usertrack = new stdClass();
+ // Defined in order to unify scorm1.2 and scorm2004.
+ $usertrack->score_raw = '';
+ $usertrack->status = '';
+ $usertrack->total_time = '00:00:00';
+ $usertrack->session_time = '00:00:00';
+ $usertrack->timemodified = 0;
+ foreach ($trackdata as $track) {
+ $element = $track->element;
+ $usertrack->{$element} = $track->value;
+ switch ($element) {
+ case 'cmi.core.lesson_status':
+ case 'cmi.completion_status':
+ if ($track->value == 'not attempted') {
+ $track->value = 'notattempted';
+ }
+ $usertrack->status = $track->value;
+ break;
+ case 'cmi.core.score.raw':
+ case 'cmi.score.raw':
+ $usertrack->score_raw = (float) sprintf('%2.2f', $track->value);
+ break;
+ case 'cmi.core.session_time':
+ case 'cmi.session_time':
+ $usertrack->session_time = $track->value;
+ break;
+ case 'cmi.core.total_time':
+ case 'cmi.total_time':
+ $usertrack->total_time = $track->value;
+ break;
+ }
+ if (isset($track->timemodified) && ($track->timemodified > $usertrack->timemodified)) {
+ $usertrack->timemodified = $track->timemodified;
+ }
+ }
+
+ return $usertrack;
+}
/* Find the start and finsh time for a a given SCO attempt
*
* @param int $scormid SCORM Id
@@ -608,15 +618,6 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) {
return $timedata;
}
-
-function scorm_get_user_data($userid) {
- global $DB;
- /// Gets user info required to display the table of scorm results
- /// for report.php
-
- return $DB->get_record('user', array('id'=>$userid), user_picture::fields());
-}
-
function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
global $DB;
$attemptscore = new stdClass();
@@ -773,6 +774,25 @@ function scorm_get_last_completed_attempt($scormid, $userid) {
}
}
+/**
+ * Returns the full list of attempts a user has made.
+ *
+ * @param int $scormid the id of the scorm.
+ * @param int $userid the id of the user.
+ *
+ * @return array array of attemptids
+ */
+function scorm_get_all_attempts($scormid, $userid) {
+ global $DB;
+ $attemptids = array();
+ $sql = "SELECT DISTINCT attempt FROM {scorm_scoes_track} WHERE userid = ? AND scormid = ? ORDER BY attempt";
+ $attempts = $DB->get_records_sql($sql, array($userid, $scormid));
+ foreach ($attempts as $attempt) {
+ $attemptids[] = $attempt->attempt;
+ }
+ return $attemptids;
+}
+
function scorm_view_display ($user, $scorm, $action, $cm) {
global $CFG, $DB, $PAGE, $OUTPUT, $COURSE;
diff --git a/mod/scorm/renderer.php b/mod/scorm/renderer.php
new file mode 100644
index 00000000000..a0cc7ccfa80
--- /dev/null
+++ b/mod/scorm/renderer.php
@@ -0,0 +1,202 @@
+.
+
+/**
+ * Defines the renderer for the scorm module.
+ *
+ * @package mod_scorm
+ * @copyright 2013 Dan Marsden
+ * @author Dan Marsden
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * The renderer for the scorm module.
+ *
+ * @copyright 2013 Dan Marsden
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class mod_scorm_renderer extends plugin_renderer_base {
+ public function view_user_heading($user, $course, $baseurl, $attempt, $attemptids) {
+ $output = '';
+ $output .= $this->box_start('generalbox boxaligncenter');
+ $output .= html_writer::start_tag('div', array('class' => 'mdl-align'));
+ $output .= $this->user_picture($user, array('courseid'=>$course->id, 'link' => true));
+ $url = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
+ $output .= html_writer::link($url, fullname($user));
+ $baseurl->param('attempt', '');
+ $pb = new mod_scorm_attempt_bar($attemptids, $attempt, $baseurl, 'attempt');
+ $output .= $this->render($pb);
+ $output .= html_writer::end_tag('div');
+ $output .= $this->box_end();
+ return $output;
+ }
+ /**
+ * scorm attempt bar renderer
+ *
+ * @param mod_scorm_attempt_bar $attemptbar
+ * @return string
+ */
+ protected function render_mod_scorm_attempt_bar(mod_scorm_attempt_bar $attemptbar) {
+ $output = '';
+ $attemptbar = clone($attemptbar);
+ $attemptbar->prepare($this, $this->page, $this->target);
+
+ if (count($attemptbar->attemptids) > 1) {
+ $output .= get_string('attempt', 'scorm') . ':';
+
+ if (!empty($attemptbar->previouslink)) {
+ $output .= ' (' . $attemptbar->previouslink . ') ';
+ }
+
+ foreach ($attemptbar->attemptlinks as $link) {
+ $output .= " $link";
+ }
+
+ if (!empty($attemptbar->nextlink)) {
+ $output .= ' (' . $attemptbar->nextlink . ')';
+ }
+ }
+
+ return html_writer::tag('div', $output, array('class' => 'paging'));
+ }
+
+}
+
+/**
+ * Component representing a SCORM attempts bar.
+ *
+ * @copyright 2013 Dan Marsden
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package mod_scorm
+ */
+class mod_scorm_attempt_bar implements renderable {
+
+ /**
+ * @var array An array of the attemptids
+ */
+ public $attemptids;
+
+ /**
+ * @var int The attempt you are currently viewing.
+ */
+ public $attempt;
+
+ /**
+ * @var string|moodle_url If this is a string then it is the url which will be appended with $pagevar,
+ * an equals sign and the attempt number.
+ * If this is a moodle_url object then the pagevar param will be replaced by
+ * the attempt no, for each attempt.
+ */
+ public $baseurl;
+
+ /**
+ * @var string This is the variable name that you use for the attempt in your
+ * code (ie. 'tablepage', 'blogpage', etc)
+ */
+ public $pagevar;
+
+ /**
+ * @var string A HTML link representing the "previous" attempt.
+ */
+ public $previouslink = null;
+
+ /**
+ * @var string A HTML link representing the "next" attempt.
+ */
+ public $nextlink = null;
+
+ /**
+ * @var array An array of strings. One of them is just a string: the current attempt
+ */
+ public $attemptlinks = array();
+
+ /**
+ * Constructor mod_scorm_attempt_bar with only the required params.
+ *
+ * @param array $attemptids an array of attempts the user has made
+ * @param int $attempt The attempt you are currently viewing
+ * @param string|moodle_url $baseurl url of the current page, the $pagevar parameter is added
+ * @param string $pagevar name of page parameter that holds the attempt number
+ */
+ public function __construct($attemptids, $attempt, $baseurl, $pagevar = 'page') {
+ $this->attemptids = $attemptids;
+ $this->attempt = $attempt;
+ $this->baseurl = $baseurl;
+ $this->pagevar = $pagevar;
+ }
+
+ /**
+ * Prepares the scorm attempt bar for output.
+ *
+ * This method validates the arguments set up for the scorm attempt bar and then
+ * produces fragments of HTML to assist display later on.
+ *
+ * @param renderer_base $output
+ * @param moodle_page $page
+ * @param string $target
+ * @throws coding_exception
+ */
+ public function prepare(renderer_base $output, moodle_page $page, $target) {
+ if (empty($this->attemptids)) {
+ throw new coding_exception('mod_scorm_attempt_bar requires a attemptids value.');
+ }
+ if (!isset($this->attempt) || is_null($this->attempt)) {
+ throw new coding_exception('mod_scorm_attempt_bar requires a attempt value.');
+ }
+ if (empty($this->baseurl)) {
+ throw new coding_exception('mod_scorm_attempt_bar requires a baseurl value.');
+ }
+
+ if (count($this->attemptids) > 1) {
+ $lastattempt = end($this->attemptids); // Get last attempt.
+ $firstattempt = reset($this->attemptids); // get first attempt.
+
+ $nextattempt = 0;
+ $prevattempt = null;
+ $previous = 0;
+ foreach ($this->attemptids as $attemptid) {
+ if ($this->attempt == $attemptid) {
+ $this->attemptlinks[] = $attemptid;
+ $prevattempt = $previous;
+ } else {
+ $attemptlink = html_writer::link(
+ new moodle_url($this->baseurl, array($this->pagevar=>$attemptid)), $attemptid);
+ $this->attemptlinks[] = $attemptlink;
+ if (empty($nextattempt) && $prevattempt !== null) {
+ // Set the nextattempt var as we have set previous attempt earlier.
+ $nextattempt = $attemptid;
+ }
+ }
+ $previous = $attemptid; // Store this attempt as previous in case we need it.
+ }
+
+ if ($this->attempt != $firstattempt) {
+ $this->previouslink = html_writer::link(
+ new moodle_url($this->baseurl, array($this->pagevar=>$prevattempt)),
+ get_string('previous'), array('class'=>'previous'));
+ }
+
+ if ($this->attempt != $lastattempt) {
+ $this->nextlink = html_writer::link(
+ new moodle_url($this->baseurl, array($this->pagevar=>$nextattempt)),
+ get_string('next'), array('class'=>'next'));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/mod/scorm/report/basic/report.php b/mod/scorm/report/basic/report.php
index aac8d1cc3b3..c4bb765b230 100644
--- a/mod/scorm/report/basic/report.php
+++ b/mod/scorm/report/basic/report.php
@@ -405,7 +405,7 @@ class scorm_basic_report extends scorm_default_report {
$row[] = '-';
} else {
if (!$download) {
- $row[] = ''.$scouser->attempt.'';
+ $row[] = ''.$scouser->attempt.'';
} else {
$row[] = $scouser->attempt;
}
@@ -448,8 +448,8 @@ class scorm_basic_report extends scorm_default_report {
}
if (!$download) {
$row[] = '.')
- '.$score.'';
+ '.$score.'';
} else {
$row[] = $score;
}
diff --git a/mod/scorm/report/default.php b/mod/scorm/report/default.php
index de1c7f16649..018ccf99b8a 100644
--- a/mod/scorm/report/default.php
+++ b/mod/scorm/report/default.php
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
/**
- * @package mod
- * @subpackage scorm
+ * @package mod_scorm
* @author Ankit Kumar Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
diff --git a/mod/scorm/report/interactions/report.php b/mod/scorm/report/interactions/report.php
index 7b3ebb473b8..2550a9f0bd4 100644
--- a/mod/scorm/report/interactions/report.php
+++ b/mod/scorm/report/interactions/report.php
@@ -440,7 +440,8 @@ class scorm_interactions_report extends scorm_default_report {
$row[] = '-';
} else {
if (!$download) {
- $row[] = ''.$scouser->attempt.'';
+ $row[] = ''.$scouser->attempt.'';
} else {
$row[] = $scouser->attempt;
}
@@ -477,8 +478,8 @@ class scorm_interactions_report extends scorm_default_report {
}
if (!$download) {
$row[] = '.')
- '.$score.'';
+ '.$score.'';
} else {
$row[] = $score;
}
diff --git a/mod/scorm/report/objectives/report.php b/mod/scorm/report/objectives/report.php
index 39444d72d13..d5a2000367c 100644
--- a/mod/scorm/report/objectives/report.php
+++ b/mod/scorm/report/objectives/report.php
@@ -445,8 +445,8 @@ class scorm_objectives_report extends scorm_default_report {
$row[] = '-';
} else {
if (!$download) {
- $row[] = ''.$scouser->attempt.'';
+ $row[] = ''.$scouser->attempt.'';
} else {
$row[] = $scouser->attempt;
}
@@ -483,7 +483,8 @@ class scorm_objectives_report extends scorm_default_report {
}
if (!$download) {
$row[] = '.')
+ '.$score.'';
} else {
diff --git a/mod/scorm/report/reportlib.php b/mod/scorm/report/reportlib.php
index 2b16607e9bd..22503e8b0e5 100644
--- a/mod/scorm/report/reportlib.php
+++ b/mod/scorm/report/reportlib.php
@@ -16,8 +16,7 @@
/**
* Returns an array of reports to which are currently readable.
- * @package mod
- * @subpackage scorm
+ * @package mod_scorm
* @author Ankit Kumar Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
diff --git a/mod/scorm/report/userreport.php b/mod/scorm/report/userreport.php
new file mode 100644
index 00000000000..d4a2ff4a462
--- /dev/null
+++ b/mod/scorm/report/userreport.php
@@ -0,0 +1,128 @@
+.
+
+/**
+ * This page displays the user data from a single attempt
+ *
+ * @package mod_scorm
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once("../../../config.php");
+require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+
+$id = required_param('id', PARAM_INT); // Course Module ID.
+$userid = required_param('user', PARAM_INT); // User ID.
+$attempt = optional_param('attempt', 1, PARAM_INT); // attempt number.
+
+// Building the url to use for links.+ data details buildup.
+$url = new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id,
+ 'user' => $userid,
+ 'attempt' => $attempt));
+$tracksurl = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $id,
+ 'user' => $userid,
+ 'attempt' => $attempt));
+$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
+$course = get_course($cm->course);
+$scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
+$user = $DB->get_record('user', array('id' => $userid), user_picture::fields(), MUST_EXIST);
+// Get list of attempts this user has made.
+$attemptids = scorm_get_all_attempts($scorm->id, $userid);
+
+$PAGE->set_url($url);
+// END of url setting + data buildup.
+
+// Checking login +logging +getting context.
+require_login($course, false, $cm);
+$contextmodule = context_module::instance($cm->id);
+require_capability('mod/scorm:viewreport', $contextmodule);
+
+add_to_log($course->id, 'scorm', 'userreport', 'userreport.php?id='.$id, $scorm->id, $id);
+
+// Print the page header.
+$strreport = get_string('report', 'scorm');
+$strattempt = get_string('attempt', 'scorm');
+
+$PAGE->set_title("$course->shortname: ".format_string($scorm->name));
+$PAGE->set_heading($course->fullname);
+$PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id)));
+$PAGE->navbar->add(fullname($user). " - $strattempt $attempt");
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading(format_string($scorm->name));
+// End of Print the page header.
+$currenttab = 'scoes';
+require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php');
+
+// Printing user details.
+$output = $PAGE->get_renderer('mod_scorm');
+echo $output->view_user_heading($user, $course, $PAGE->url, $attempt, $attemptids);
+
+if ($scoes = $DB->get_records_select('scorm_scoes', "scorm = ? ORDER BY id", array($scorm->id))) {
+ // Print general score data.
+ $table = new html_table();
+ $table->head = array(
+ get_string('title', 'scorm'),
+ get_string('status', 'scorm'),
+ get_string('time', 'scorm'),
+ get_string('score', 'scorm'),
+ '');
+ $table->align = array('left', 'center', 'center', 'right', 'left');
+ $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
+ $table->width = '80%';
+ $table->size = array('*', '*', '*', '*', '*');
+ foreach ($scoes as $sco) {
+ if ($sco->launch!='') {
+ $row = array();
+ $score = ' ';
+ if ($trackdata = scorm_get_tracks($sco->id, $userid, $attempt)) {
+ if ($trackdata->score_raw != '') {
+ $score = $trackdata->score_raw;
+ }
+ if ($trackdata->status == '') {
+ if (!empty($trackdata->progress)) {
+ $trackdata->status = $trackdata->progress;
+ } else {
+ $trackdata->status = 'notattempted';
+ }
+ }
+ $tracksurl->param('scoid', $sco->id);
+ $detailslink = html_writer::link($tracksurl, get_string('details', 'scorm'));
+ } else {
+ $trackdata = new stdClass();
+ $trackdata->status = 'notattempted';
+ $trackdata->total_time = ' ';
+ $detailslink = ' ';
+ }
+ $strstatus = get_string($trackdata->status, 'scorm');
+ $row[] = '
'.format_string($sco->title);
+ $row[] = get_string($trackdata->status, 'scorm');
+ $row[] = scorm_format_duration($trackdata->total_time);
+ $row[] = $score;
+ $row[] = $detailslink;
+ } else {
+ $row = array(format_string($sco->title), ' ', ' ', ' ', ' ');
+ }
+ $table->data[] = $row;
+ }
+ echo html_writer::table($table);
+}
+
+// Print footer.
+
+echo $OUTPUT->footer();
diff --git a/mod/scorm/report/userreportinteractions.php b/mod/scorm/report/userreportinteractions.php
new file mode 100644
index 00000000000..16f06906a3d
--- /dev/null
+++ b/mod/scorm/report/userreportinteractions.php
@@ -0,0 +1,156 @@
+.
+
+/**
+ * This page displays the user data from a single attempt
+ *
+ * @package mod
+ * @subpackage scorm
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once("../../../config.php");
+require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+require_once($CFG->dirroot.'/mod/scorm/report/reportlib.php');
+require_once($CFG->libdir . '/tablelib.php');
+
+$id = required_param('id', PARAM_INT); // Course Module ID.
+$userid = required_param('user', PARAM_INT); // User ID.
+$attempt = optional_param('attempt', 1, PARAM_INT); // attempt number.
+$download = optional_param('download', '', PARAM_ALPHA);
+
+// Building the url to use for links.+ data details buildup.
+$url = new moodle_url('/mod/scorm/report/userreportinteractions.php', array('id' => $id,
+ 'user' => $userid,
+ 'attempt' => $attempt));
+
+$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
+$course = get_course($cm->course);
+$scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
+$user = $DB->get_record('user', array('id' => $userid), user_picture::fields(), MUST_EXIST);
+// Get list of attempts this user has made.
+$attemptids = scorm_get_all_attempts($scorm->id, $userid);
+
+$PAGE->set_url($url);
+// END of url setting + data buildup.
+
+// Checking login +logging +getting context.
+require_login($course, false, $cm);
+$contextmodule = context_module::instance($cm->id);
+require_capability('mod/scorm:viewreport', $contextmodule);
+
+add_to_log($course->id, 'scorm', 'userreportinteractions', 'userreportinteractions.php?id='.$cm->id, $scorm->id, $cm->id);
+
+
+$trackdata = $DB->get_records('scorm_scoes_track', array('userid' => $user->id, 'scormid' => $scorm->id,
+ 'attempt' => $attempt));
+$usertrack = scorm_format_interactions($trackdata);
+
+$questioncount = get_scorm_question_count($scorm->id);
+
+$courseshortname = format_string($course->shortname, true,
+ array('context' => context_course::instance($course->id)));
+$exportfilename = $courseshortname . '-' . format_string($scorm->name, true) . '-' . get_string('interactions', 'scorm');
+
+
+// Set up the table.
+$table = new flexible_table('mod-scorm-userreport-interactions');
+if (!$table->is_downloading($download, $exportfilename)) {
+
+ // Print the page header.
+ $strattempt = get_string('attempt', 'scorm');
+ $strreport = get_string('report', 'scorm');
+
+ $PAGE->set_title("$course->shortname: ".format_string($scorm->name));
+ $PAGE->set_heading($course->fullname);
+ $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id)));
+
+ $PAGE->navbar->add(fullname($user). " - $strattempt $attempt");
+
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(format_string($scorm->name));
+ // End of Print the page header.
+ $currenttab = 'interactions';
+ require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php');
+
+ // Printing user details.
+ $output = $PAGE->get_renderer('mod_scorm');
+ echo $output->view_user_heading($user, $course, $PAGE->url, $attempt, $attemptids);
+
+}
+$table->define_baseurl($PAGE->url);
+$table->define_columns(array('id', 'studentanswer', 'correctanswer', 'result', 'calcweight'));
+$table->define_headers(array(get_string('trackid', 'scorm'), get_string('response', 'scorm'),
+ get_string('rightanswer', 'scorm'), get_string('result', 'scorm'),
+ get_string('calculatedweight', 'scorm')));
+$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+
+$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
+$table->setup();
+
+for ($i=0; $i < $questioncount; $i++) {
+ $row = array();
+ $element = 'cmi.interactions_'.$i.'.id';
+ if (isset($usertrack->$element)) {
+ $row[] = s($usertrack->$element);
+
+ $element = 'cmi.interactions_'.$i.'.student_response';
+ if (isset($usertrack->$element)) {
+ $row[] = s($usertrack->$element);
+ } else {
+ $row[] = ' ';
+ }
+
+ $j=0;
+ $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern';
+ $rightans = '';
+ if (isset($usertrack->$element)) {
+ while (isset($usertrack->$element)) {
+ if ($j>0) {
+ $rightans .= ',';
+ }
+ $rightans .= s($usertrack->$element);
+ $j++;
+ $element = 'cmi.interactions_'.$i.'.correct_responses_'.$j.'.pattern';
+ }
+ $row[] = $rightans;
+ } else {
+ $row[] = ' ';
+ }
+ $element = 'cmi.interactions_'.$i.'.result';
+ $weighting = 'cmi.interactions_'.$i.'.weighting';
+ if (isset($usertrack->$element)) {
+ $row[] = s($usertrack->$element);
+ if ($usertrack->$element == 'correct' &&
+ isset($usertrack->$weighting)) {
+ $row[] = s($usertrack->$weighting);
+ } else {
+ $row[] = '0';
+ }
+ } else {
+ $row[] = ' ';
+ }
+ $table->add_data($row);
+ }
+}
+
+$table->finish_output();
+
+if (!$table->is_downloading()) {
+ echo $OUTPUT->footer();
+}
+
diff --git a/mod/scorm/report/userreporttabs.php b/mod/scorm/report/userreporttabs.php
new file mode 100644
index 00000000000..1cf2e1752b5
--- /dev/null
+++ b/mod/scorm/report/userreporttabs.php
@@ -0,0 +1,47 @@
+.
+
+/**
+ * Sets up the tabs used by the scorm pages based on the users capabilities.
+ *
+ * @author Dan Marsden and others.
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package mod_scorm
+ */
+
+if (empty($scorm)) {
+ error('You cannot call this script in that way');
+}
+if (!isset($currenttab)) {
+ $currenttab = '';
+}
+$tabs = array();
+$row = array();
+$inactive = array();
+$activated = array();
+
+$scoesurl = new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id,
+ 'user' => $userid,
+ 'attempt' => $attempt));
+
+$interactionssurl = new moodle_url('/mod/scorm/report/userreportinteractions.php', array('id' => $id,
+ 'user' => $userid,
+ 'attempt' => $attempt));
+$row[] = new tabobject('scoes', $scoesurl, get_string('scoes', 'scorm'));
+$row[] = new tabobject('interactions', $interactionssurl, get_string('interactions', 'scorm'));
+
+$tabs[] = $row;
+print_tabs($tabs, $currenttab, $inactive, $activated);
diff --git a/mod/scorm/report/userreporttracks.php b/mod/scorm/report/userreporttracks.php
new file mode 100644
index 00000000000..4d7228db265
--- /dev/null
+++ b/mod/scorm/report/userreporttracks.php
@@ -0,0 +1,151 @@
+.
+
+/**
+ * This page displays the user data from a single attempt
+ *
+ * @package mod_scorm
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once("../../../config.php");
+require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+require_once($CFG->libdir.'/tablelib.php');
+
+$id = required_param('id', PARAM_INT); // Course Module ID.
+$userid = required_param('user', PARAM_INT); // User ID.
+$scoid = required_param('scoid', PARAM_INT); // SCO ID.
+$attempt = optional_param('attempt', 1, PARAM_INT); // attempt number.
+$download = optional_param('download', '', PARAM_ALPHA);
+
+// Building the url to use for links.+ data details buildup.
+$url = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $id,
+ 'user' => $userid,
+ 'attempt' => $attempt,
+ 'scoid' => $scoid));
+$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
+$course = get_course($cm->course);
+$scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
+$user = $DB->get_record('user', array('id' => $userid), user_picture::fields(), MUST_EXIST);
+$selsco = $DB->get_record('scorm_scoes', array('id' => $scoid), '*', MUST_EXIST);
+
+$PAGE->set_url($url);
+// END of url setting + data buildup.
+
+// Checking login +logging +getting context.
+require_login($course, false, $cm);
+$contextmodule = context_module::instance($cm->id);
+require_capability('mod/scorm:viewreport', $contextmodule);
+
+add_to_log($course->id, 'scorm', 'userreporttracks', 'userreporttracks.php?id='.$id, $scorm->id, $id);
+
+// Print the page header.
+$strreport = get_string('report', 'scorm');
+$strattempt = get_string('attempt', 'scorm');
+
+$PAGE->set_title("$course->shortname: ".format_string($scorm->name));
+$PAGE->set_heading($course->fullname);
+$PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id)));
+$PAGE->navbar->add("$strattempt $attempt - ".fullname($user),
+ new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id, 'user' => $userid, 'attempt' => $attempt)));
+$PAGE->navbar->add($selsco->title . ' - '. get_string('details', 'scorm'));
+
+if ($trackdata = scorm_get_tracks($selsco->id, $userid, $attempt)) {
+ if ($trackdata->status == '') {
+ $trackdata->status = 'notattempted';
+ }
+} else {
+ $trackdata = new stdClass();
+ $trackdata->status = 'notattempted';
+ $trackdata->total_time = '';
+}
+
+$courseshortname = format_string($course->shortname, true,
+ array('context' => context_course::instance($course->id)));
+$exportfilename = $courseshortname . '-' . format_string($scorm->name, true) . '-' . get_string('details', 'scorm');
+
+$table = new flexible_table('mod_scorm-userreporttracks');
+
+if (!$table->is_downloading($download, $exportfilename)) {
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(format_string($scorm->name));
+ $currenttab = '';
+ require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
+ echo $OUTPUT->heading("$strattempt $attempt - ". fullname($user).': '.
+ format_string($selsco->title). ' - '. get_string('details', 'scorm'));
+}
+$table->define_baseurl($PAGE->url);
+$table->define_columns(array('element', 'value'));
+$table->define_headers(array(get_string('element', 'scorm'), get_string('value', 'scorm')));
+$table->set_attribute('class', 'generaltable generalbox boxaligncenter scormtrackreport');
+$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
+$table->setup();
+
+foreach ($trackdata as $element => $value) {
+ if (substr($element, 0, 3) == 'cmi') {
+ $existelements = true;
+ $row = array();
+ $string = false;
+ if (stristr($element, '.id') !== false) {
+ $string = "trackid";
+ } else if (stristr($element, '.result') !== false) {
+ $string = "trackresult";
+ } else if (stristr($element, '.student_response') !== false or // SCORM 1.2 value.
+ stristr($element, '.learner_response') !== false) { // SCORM 2004 value.
+ $string = "trackresponse";
+ } else if (stristr($element, '.type') !== false) {
+ $string = "tracktype";
+ } else if (stristr($element, '.weighting') !== false) {
+ $string = "trackweight";
+ } else if (stristr($element, '.time') !== false) {
+ $string = "tracktime";
+ } else if (stristr($element, '.correct_responses._count') !== false) {
+ $string = "trackcorrectcount";
+ } else if (stristr($element, '.score.min') !== false) {
+ $string = "trackscoremin";
+ } else if (stristr($element, '.score.max') !== false) {
+ $string = "trackscoremax";
+ } else if (stristr($element, '.score.raw') !== false) {
+ $string = "trackscoreraw";
+ } else if (stristr($element, '.latency') !== false) {
+ $string = "tracklatency";
+ } else if (stristr($element, '.pattern') !== false) {
+ $string = "trackpattern";
+ } else if (stristr($element, '.suspend_data') !== false) {
+ $string = "tracksuspenddata";
+ }
+
+ if (empty($string) || $table->is_downloading()) {
+ $row[] = $element;
+ } else {
+ $row[] = $element.$OUTPUT->help_icon($string, 'scorm');
+ }
+ if (strpos($element, '_time') === false) {
+ $row[] = s($value);
+ } else {
+ $row[] = s(scorm_format_duration($value));
+ }
+ $table->add_data($row);
+ }
+}
+$table->finish_output();
+if (!$table->is_downloading()) {
+ echo $OUTPUT->box_end();
+ echo $OUTPUT->footer();
+}
+
diff --git a/mod/scorm/styles.css b/mod/scorm/styles.css
index e77f988db4f..c36fe31b6eb 100644
--- a/mod/scorm/styles.css
+++ b/mod/scorm/styles.css
@@ -40,4 +40,8 @@
.path-mod-scorm.jsenabled .scorm-center { display:block;}
.path-mod-scorm.jsenabled .toc { display:block;}
.path-mod-scorm.jsenabled #scormpage #tocbox { display:block;}
+#page-mod-scorm-report-userreporttracks table .c1 {
+ word-wrap:break-word;
+ word-break: break-all;
+}
diff --git a/mod/scorm/userreport.php b/mod/scorm/userreport.php
deleted file mode 100644
index 5a02c4279f2..00000000000
--- a/mod/scorm/userreport.php
+++ /dev/null
@@ -1,386 +0,0 @@
-.
-
-/**
- * This page displays the user data from a single attempt
- *
- * @package mod
- * @subpackage scorm
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once("../../config.php");
-require_once($CFG->dirroot.'/mod/scorm/locallib.php');
-
-$user = required_param('user', PARAM_INT); // User ID
-
-$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
-$a = optional_param('a', '', PARAM_INT); // SCORM ID
-$b = optional_param('b', '', PARAM_INT); // SCO ID
-$attempt = optional_param('attempt', '1', PARAM_INT); // attempt number
-
-// Building the url to use for links.+ data details buildup
-$url = new moodle_url('/mod/scorm/userreport.php');
-$url->param('user', $user);
-
-if ($attempt !== '1') {
- $url->param('attempt', $attempt);
-}
-
-if (!empty($id)) {
- $url->param('id', $id);
- $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
- $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
- $scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
-} else {
- if (!empty($b)) {
- $url->param('b', $b);
- $selsco = $DB->get_record('scorm_scoes', array('id' => $b), '*', MUST_EXIST);
- $a = $selsco->scorm;
- }
- if (!empty($a)) {
- $url->param('a', $a);
- $scorm = $DB->get_record('scorm', array('id' => $a), '*', MUST_EXIST);
- $course = $DB->get_record('course', array('id' => $scorm->course), '*', MUST_EXIST);
- $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id, false, MUST_EXIST);
- }
-}
-$PAGE->set_url($url);
-//END of url setting + data buildup
-
-// checking login +logging +getting context
-require_login($course, false, $cm);
-$contextmodule = context_module::instance($cm->id);
-require_capability('mod/scorm:viewreport', $contextmodule);
-
-add_to_log($course->id, 'scorm', 'userreport', 'userreport.php?id='.$cm->id, $scorm->id, $cm->id);
-$userdata = scorm_get_user_data($user);
-
-// Print the page header
-$strreport = get_string('report', 'scorm');
-$strattempt = get_string('attempt', 'scorm');
-
-$PAGE->set_title("$course->shortname: ".format_string($scorm->name));
-$PAGE->set_heading($course->fullname);
-$PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id'=>$cm->id)));
-
-if (empty($b)) {
- if (!empty($a)) {
- $PAGE->navbar->add("$strattempt $attempt - ".fullname($userdata));
- }
-} else {
- $PAGE->navbar->add("$strattempt $attempt - ".fullname($userdata), new moodle_url('/mod/scorm/userreport.php', array('a'=>$a, 'user'=>$user, 'attempt'=>$attempt)));
- $PAGE->navbar->add($selsco->title);
-}
-echo $OUTPUT->header();
-echo $OUTPUT->heading(format_string($scorm->name));
-// End of Print the page header
-
-//Parameter Checking
-if (empty ($userdata)) {
- print_error('missingparameter');
-}
-
-//printing user details
-echo $OUTPUT->box_start('generalbox boxaligncenter');
-echo ''."\n";
-echo $OUTPUT->box_end();
-
-if ($scoes = $DB->get_records_select('scorm_scoes', "scorm=? ORDER BY id", array($scorm->id))) {
- // Print general score data
- $table = new html_table();
- $table->head = array(
- get_string('title', 'scorm'),
- get_string('status', 'scorm'),
- get_string('time', 'scorm'),
- get_string('score', 'scorm'),
- '');
- $table->align = array('left', 'center', 'center', 'right', 'left');
- $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
- $table->width = '80%';
- $table->size = array('*', '*', '*', '*', '*');
- foreach ($scoes as $sco) {
- if ($sco->launch!='') {
- $row = array();
- $score = ' ';
- if ($trackdata = scorm_get_tracks($sco->id, $user, $attempt)) {
- if ($trackdata->score_raw != '') {
- $score = $trackdata->score_raw;
- }
- if ($trackdata->status == '') {
- if (!empty($trackdata->progress)) {
- $trackdata->status = $trackdata->progress;
- } else {
- $trackdata->status = 'notattempted';
- }
- }
- $detailslink = ''.get_string('details', 'scorm').'';
- } else {
- $trackdata = new stdClass();
- $trackdata->status = 'notattempted';
- $trackdata->total_time = ' ';
- $detailslink = ' ';
- }
- $strstatus = get_string($trackdata->status, 'scorm');
- $row[] = '
'.format_string($sco->title);
- $row[] = get_string($trackdata->status, 'scorm');
- $row[] = scorm_format_duration($trackdata->total_time);
- $row[] = $score;
- $row[] = $detailslink;
- } else {
- $row = array(format_string($sco->title), ' ', ' ', ' ', ' ');
- }
- $table->data[] = $row;
- }
- echo html_writer::table($table);
-}
-
-if (!empty($b)) {
- echo $OUTPUT->box_start('generalbox boxaligncenter');
- echo $OUTPUT->heading(''.format_string($selsco->title).'');
- echo ''."\n";
- $scoreview = '';
- if ($trackdata = scorm_get_tracks($selsco->id, $user, $attempt)) {
- if ($trackdata->score_raw != '') {
- $scoreview = get_string('score', 'scorm').': '.$trackdata->score_raw;
- }
- if ($trackdata->status == '') {
- $trackdata->status = 'notattempted';
- }
- } else {
- $trackdata->status = 'notattempted';
- $trackdata->total_time = '';
- }
- $strstatus = get_string($trackdata->status, 'scorm');
- echo '
.')
'.scorm_format_duration($trackdata->total_time).'
'.$scoreview.'
';
- echo '
'."\n";
- echo '
'.get_string('details', 'scorm').'
';
- // Print general score data
- $table = new html_table();
- $table->head = array(get_string('element', 'scorm'), get_string('value', 'scorm'));
- $table->align = array('left', 'left');
- $table->wrap = array('nowrap', 'nowrap');
- $table->width = '100%';
- $table->size = array('*', '*');
- $existelements = false;
- $elements = array(
- 'min' => 'score_min',
- 'raw' => 'score_raw',
- 'max' => 'score_max',
- 'status' => 'status',
- 'time' => 'total_time');
- $printedelements = array();
- foreach ($elements as $key => $element) {
- if (isset($trackdata->$element)) {
- $existelements = true;
- $printedelements[]=$element;
- $row = array();
- $row[] = get_string($key, 'scorm');
- switch ($key) {
- case 'status':
- $row[] = $strstatus;
- break;
- case 'time':
- $row[] = s(scorm_format_duration($trackdata->$element));
- break;
- default:
- $row[] = s($trackdata->$element);
- break;
- }
- $table->data[] = $row;
- }
- }
- if ($existelements) {
- echo ''.get_string('general', 'scorm').'
';
- echo html_writer::table($table);
- }
- // Print Interactions data
- $table = new html_table();
- $table->head = array(
- get_string('identifier', 'scorm'),
- get_string('type', 'scorm'),
- get_string('result', 'scorm'),
- get_string('student_response', 'scorm'));
- $table->align = array('center', 'center', 'center', 'center');
- $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
- $table->width = '100%';
- $table->size = array('*', '*', '*', '*', '*');
- $existinteraction = false;
- $i = 0;
- $interactionid = 'cmi.interactions.'.$i.'.id';
-
- while (isset($trackdata->$interactionid)) {
- $existinteraction = true;
- $printedelements[]=$interactionid;
- $elements = array(
- $interactionid,
- 'cmi.interactions.'.$i.'.type',
- 'cmi.interactions.'.$i.'.result',
- 'cmi.interactions.'.$i.'.learner_response');
- $row = array();
- foreach ($elements as $element) {
- if (isset($trackdata->$element)) {
- $row[] = s($trackdata->$element);
- $printedelements[]=$element;
- } else {
- $row[] = ' ';
- }
- }
- $table->data[] = $row;
- $i++;
- $interactionid = 'cmi.interactions.'.$i.'.id';
- }
- if ($existinteraction) {
- echo ''.get_string('interactions', 'scorm').'
';
- echo html_writer::table($table);
- }
-
- // Print Objectives data
- $table = new html_table();
- $table->head = array(
- get_string('identifier', 'scorm'),
- get_string('status', 'scorm'),
- get_string('raw', 'scorm'),
- get_string('min', 'scorm'),
- get_string('max', 'scorm'));
- $table->align = array('center', 'center', 'center', 'center', 'center');
- $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
- $table->width = '100%';
- $table->size = array('*', '*', '*', '*', '*');
- $existobjective = false;
-
- $i = 0;
- $objectiveid = 'cmi.objectives.'.$i.'.id';
-
- while (isset($trackdata->$objectiveid)) {
- $existobjective = true;
- $printedelements[]=$objectiveid;
-
- // Merge 2004 and 1.2 SCORM formats
- if (scorm_version_check($scorm->version, SCORM_13)) {
- $sucstatuskey = 'cmi.objectives.'.$i.'.success_status';
- $progstatuskey = 'cmi.objectives.'.$i.'.progress_measure';
- $compstatuskey = 'cmi.objectives.'.$i.'.completion_status';
- $statuskey = 'cmi.objectives.'.$i.'.status';
- if (isset($trackdata->$sucstatuskey)) {
- $trackdata->$statuskey = $trackdata->$sucstatuskey;
- } elseif (isset($trackdata->$progstatuskey)) {
- $trackdata->$statuskey = $trackdata->$progstatuskey;
- } elseif (isset($trackdata->$compstatuskey)) {
- $trackdata->$statuskey = $trackdata->$compstatuskey;
- }
- }
- $elements = array(
- $objectiveid,
- 'cmi.objectives.'.$i.'.status',
- 'cmi.objectives.'.$i.'.score.min',
- 'cmi.objectives.'.$i.'.score.raw',
- 'cmi.objectives.'.$i.'.score.max');
- $row = array();
- foreach ($elements as $element) {
- if (isset($trackdata->$element)) {
- $row[] = s($trackdata->$element);
- $printedelements[]=$element;
- } else {
- $row[] = ' ';
- }
- }
- $table->data[] = $row;
-
- $i++;
- $objectiveid = 'cmi.objectives.'.$i.'.id';
- }
- if ($existobjective) {
- echo ''.get_string('objectives', 'scorm').'
';
- echo html_writer::table($table);
- }
- $table = new html_table();
- $table->head = array(get_string('element', 'scorm'), get_string('elementdefinition', 'scorm'), get_string('value', 'scorm'));
- $table->align = array('left', 'left');
- $table->wrap = array('nowrap', 'wrap');
- $table->width = '100%';
- $table->size = array('*', '*');
-
- $existelements = false;
-
- foreach ($trackdata as $element => $value) {
- if (substr($element, 0, 3) == 'cmi') {
- if (!(in_array ($element, $printedelements))) {
- $existelements = true;
- $row = array();
- $string=false;
- if (stristr($element, '.id') !== false) {
- $string="interactionsid";
- } else if (stristr($element, '.result') !== false) {
- $string="interactionsresult";
- } else if (stristr($element, '.student_response') !== false) {
- $string="interactionsresponse";
- } else if (stristr($element, '.type') !== false) {
- $string="interactionstype";
- } else if (stristr($element, '.weighting') !== false) {
- $string="interactionsweight";
- } else if (stristr($element, '.time') !== false) {
- $string="interactionstime";
- } else if (stristr($element, '.correct_responses._count') !== false) {
- $string="interactionscorrectcount";
- } else if (stristr($element, '.learner_response') !== false) {
- $string="interactionslearnerresponse";
- } else if (stristr($element, '.score.min') !== false) {
- $string="interactionsscoremin";
- } else if (stristr($element, '.score.max') !== false) {
- $string="interactionsscoremax";
- } else if (stristr($element, '.score.raw') !== false) {
- $string="interactionsscoreraw";
- } else if (stristr($element, '.latency') !== false) {
- $string="interactionslatency";
- } else if (stristr($element, '.pattern') !== false) {
- $string="interactionspattern";
- } else if (stristr($element, '.suspend_data') !== false) {
- $string="interactionssuspenddata";
- }
- $row[]=$element;
- if (empty($string)) {
- $row[]=null;
- } else {
- $row[] = get_string($string, 'scorm');
- }
- if (strpos($element, '_time') === false) {
- $row[] = s($value);
- } else {
- $row[] = s(scorm_format_duration($value));
- }
- $table->data[] = $row;
- }
- }
- }
- if ($existelements) {
- echo ''.get_string('othertracks', 'scorm').'
';
- echo html_writer::table($table);
- }
- echo $OUTPUT->box_end();
-}
-// Print footer
-
-echo $OUTPUT->footer();