Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SCORM MDL-28111 tidy up formatting of code

  • Loading branch information...
commit f7b5c6aae6aef30ccf29adac76bdafd8b3432498 1 parent 81f8e0f
@danmarsden danmarsden authored
Showing with 1,796 additions and 1,485 deletions.
  1. +0 −84 mod/scorm/README.txt
  2. +365 −346 mod/scorm/aicc.php
  3. +88 −74 mod/scorm/api.php
  4. +0 −1  mod/scorm/backup/moodle1/lib.php
  5. +1 −2  mod/scorm/backup/moodle2/backup_scorm_activity_task.class.php
  6. +0 −1  mod/scorm/backup/moodle2/backup_scorm_stepslib.php
  7. +0 −1  mod/scorm/backup/moodle2/restore_scorm_activity_task.class.php
  8. +0 −1  mod/scorm/backup/moodle2/restore_scorm_stepslib.php
  9. +84 −72 mod/scorm/datamodel.php
  10. +52 −37 mod/scorm/datamodels/aicc.js.php
  11. +101 −90 mod/scorm/datamodels/aicclib.php
  12. +17 −1 mod/scorm/datamodels/callback.js.php
  13. +22 −4 mod/scorm/datamodels/debug.js.php
  14. +31 −24 mod/scorm/datamodels/scorm_12.js.php
  15. +52 −31 mod/scorm/datamodels/scorm_12lib.php
  16. +27 −13 mod/scorm/datamodels/scorm_13.js.php
  17. +36 −21 mod/scorm/datamodels/scorm_13lib.php
  18. +137 −127 mod/scorm/datamodels/scormlib.php
  19. +15 −0 mod/scorm/datamodels/sequencinglib.php
  20. +19 −25 mod/scorm/db/access.php
  21. +0 −1  mod/scorm/db/log.php
  22. +21 −17 mod/scorm/db/upgrade.php
  23. +0 −1  mod/scorm/db/upgradelib.php
  24. +31 −17 mod/scorm/grade.php
  25. +105 −94 mod/scorm/index.php
  26. +0 −1  mod/scorm/lang/en/scorm.php
  27. +34 −36 mod/scorm/lib.php
  28. +121 −109 mod/scorm/loadSCO.php
  29. +89 −75 mod/scorm/loaddatamodel.php
  30. +14 −0 mod/scorm/locallib.php
  31. +15 −0 mod/scorm/mod_form.php
  32. +15 −0 mod/scorm/player.js
  33. +15 −1 mod/scorm/player.php
  34. +60 −48 mod/scorm/prereqs.php
  35. +20 −8 mod/scorm/report.php
  36. +19 −5 mod/scorm/reportsettings_form.php
  37. +25 −11 mod/scorm/settings.php
  38. +20 −5 mod/scorm/simpletest/test_formatduration.php
  39. +16 −1 mod/scorm/tabs.php
  40. +2 −3 mod/scorm/userreport.php
  41. +22 −5 mod/scorm/version.php
  42. +105 −92 mod/scorm/view.php
View
84 mod/scorm/README.txt
@@ -1,84 +0,0 @@
-SCORM Module by Roberto "Bobo" Pinna
-
-This module is a SCORM player that import SCORM packages in .zip or .pif format
-(they are the same thing).
-At this time the SCORM module import packages in SCORM1.2, SCORM1.3 (aka SCORM2004) and AICC.
-The SCORM 1.3 support still under development use it carefully.
-
-Moodle SCORM Module is SCORM Version 1.2 Run-Time Environment Conformant -
-Minimum with All Optional Data Model Elements (LMS-RTE3)
-
-SCORM MODULE IS JAVA FREE.
-
-================================================================
-
-FIX TO DO:
-Autocontinue & nav.event call
-
-================================================================
-
-ROAD MAP
-
-Moodle 1.6
-A popup window display mode. DONE
-New Moodle course format: SCORM. DONE
-Add prerequisites support to SCORM 1.2. DONE
-Customizable player page. DONE
-Multiple attempt management. DONE
-Complete AICC conformance.
-
-
-Moodle 1.7
-Customizable detailed report page.
-Complete conformity to SCORM 2004 RTE.
-Support of SCORM 2004's sequencing and navigation.
-New package validation subsystem.
-
-Moodle 2.0
-The BIG Boh?!
-
-================================================================
-
-SCORM MODULE Schema:
-
-Insert and Update an activity:
-
-mod_edit.php <-- onsubmit --> validate.php (-- include --> validatordomxml.php)
- || \
- || \
- submit load
- || \
- || \
- \/ request.js
-view.php
-
-----------------------------------------------------------------
-
-View an activity:
-
-view.php
- ||
- ||
- submit
- ||
- ||
- \/
-player.php -- load --> request.js
- || api.php -- include --> datamodels/(SCORM1_2.js.php || SCORM1_3.js.php || AICC.js.php)
- || /\
- iframe ||
- "main"<----- XMLHTTP
- load | request
- || | ||
- || | \/
- \/ | datamodel.php
-loadSCO.php |
- | |
- | |
- ---------
- reload itself
- to the right sco
-
-
-================================================================
-Updated January 9th 2006
View
711 mod/scorm/aicc.php
@@ -1,391 +1,410 @@
<?php
- //Prevent Caching Headers
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Cache-Control: no-cache");
- header("Pragma: no-cache");
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
- require_once('../../config.php');
- include_once($CFG->dirroot.'/mod/scorm/lib.php');
- require_once($CFG->dirroot.'/mod/scorm/locallib.php');
- require_once($CFG->dirroot.'/mod/scorm/datamodels/aicclib.php');
+//Prevent Caching Headers
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache");
+header("Pragma: no-cache");
- foreach ($_POST as $key => $value) {
- $tempkey = strtolower($key);
- $_POST[$tempkey] = $value;
- }
+require_once('../../config.php');
+require_once($CFG->dirroot.'/mod/scorm/lib.php');
+require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+require_once($CFG->dirroot.'/mod/scorm/datamodels/aicclib.php');
- $command = required_param('command', PARAM_ALPHA);
- $sessionid = required_param('session_id', PARAM_ALPHANUM);
- $aiccdata = optional_param('aicc_data', '', PARAM_RAW);
+foreach ($_POST as $key => $value) {
+ $tempkey = strtolower($key);
+ $_POST[$tempkey] = $value;
+}
- $url = new moodle_url('/mod/scorm/aicc.php', array('command'=>$command,'session_id'=>$sessionid));
- if ($aiccdata !== 0) {
- $url->param('aicc_data', $aiccdata);
- }
- $PAGE->set_url($url);
+$command = required_param('command', PARAM_ALPHA);
+$sessionid = required_param('session_id', PARAM_ALPHANUM);
+$aiccdata = optional_param('aicc_data', '', PARAM_RAW);
- require_login();
+$url = new moodle_url('/mod/scorm/aicc.php', array('command'=>$command, 'session_id'=>$sessionid));
+if ($aiccdata !== 0) {
+ $url->param('aicc_data', $aiccdata);
+}
+$PAGE->set_url($url);
- if (!empty($command) && confirm_sesskey($sessionid)) {
- $command = strtolower($command);
+require_login();
- if (isset($SESSION->scorm_scoid)) {
- $scoid = $SESSION->scorm_scoid;
- } else {
- print_error('cannotcallscript');
- }
- $mode = 'normal';
- if (isset($SESSION->scorm_mode)) {
- $mode = $SESSION->scorm_mode;
- }
- $status = 'Not Initialized';
- if (isset($SESSION->scorm_status)) {
- $status = $SESSION->scorm_status;
- }
- if (isset($SESSION->scorm_attempt)) {
- $attempt = $SESSION->scorm_attempt;
- } else {
- $attempt = 1;
- }
+if (!empty($command) && confirm_sesskey($sessionid)) {
+ $command = strtolower($command);
- if ($sco = scorm_get_sco($scoid, SCO_ONLY)) {
- if (!$scorm = $DB->get_record('scorm',array('id'=>$sco->scorm))) {
- print_error('cannotcallscript');
- }
- } else {
+ if (isset($SESSION->scorm_scoid)) {
+ $scoid = $SESSION->scorm_scoid;
+ } else {
+ print_error('cannotcallscript');
+ }
+ $mode = 'normal';
+ if (isset($SESSION->scorm_mode)) {
+ $mode = $SESSION->scorm_mode;
+ }
+ $status = 'Not Initialized';
+ if (isset($SESSION->scorm_status)) {
+ $status = $SESSION->scorm_status;
+ }
+ if (isset($SESSION->scorm_attempt)) {
+ $attempt = $SESSION->scorm_attempt;
+ } else {
+ $attempt = 1;
+ }
+
+ if ($sco = scorm_get_sco($scoid, SCO_ONLY)) {
+ if (!$scorm = $DB->get_record('scorm', array('id'=>$sco->scorm))) {
print_error('cannotcallscript');
}
- $aiccrequest = "MOODLE scoid: $scoid"
- . "\r\nMOODLE mode: $mode"
- . "\r\nMOODLE status: $status"
- . "\r\nMOODLE attempt: $attempt"
- . "\r\nAICC sessionid: $sessionid"
- . "\r\nAICC command: $command"
- . "\r\nAICC aiccdata:\r\n$aiccdata";
- scorm_debug_log_write("aicc", "HACP Request:\r\n$aiccrequest", $scoid);
- ob_start();
+ } else {
+ print_error('cannotcallscript');
+ }
+ $aiccrequest = "MOODLE scoid: $scoid"
+ . "\r\nMOODLE mode: $mode"
+ . "\r\nMOODLE status: $status"
+ . "\r\nMOODLE attempt: $attempt"
+ . "\r\nAICC sessionid: $sessionid"
+ . "\r\nAICC command: $command"
+ . "\r\nAICC aiccdata:\r\n$aiccdata";
+ scorm_debug_log_write("aicc", "HACP Request:\r\n$aiccrequest", $scoid);
+ ob_start();
- if ($scorm = $DB->get_record('scorm',array('id'=>$sco->scorm))) {
- switch ($command) {
- case 'getparam':
- if ($status == 'Not Initialized') {
- $SESSION->scorm_status = 'Running';
- $status = 'Running';
+ if ($scorm = $DB->get_record('scorm', array('id'=>$sco->scorm))) {
+ switch ($command) {
+ case 'getparam':
+ if ($status == 'Not Initialized') {
+ $SESSION->scorm_status = 'Running';
+ $status = 'Running';
+ }
+ if ($status != 'Running') {
+ echo "error=101\r\nerror_text=Terminated\r\n";
+ } else {
+ if ($usertrack=scorm_get_tracks($scoid, $USER->id, $attempt)) {
+ $userdata = $usertrack;
+ } else {
+ $userdata->status = '';
+ $userdata->score_raw = '';
}
- if ($status != 'Running') {
- echo "error=101\r\nerror_text=Terminated\r\n";
+ $userdata->student_id = $USER->username;
+ $userdata->student_name = $USER->lastname .', '. $USER->firstname;
+ $userdata->mode = $mode;
+ if ($userdata->mode == 'normal') {
+ $userdata->credit = 'credit';
} else {
- if ($usertrack=scorm_get_tracks($scoid,$USER->id,$attempt)) {
- $userdata = $usertrack;
- } else {
- $userdata->status = '';
- $userdata->score_raw = '';
- }
- $userdata->student_id = $USER->username;
- $userdata->student_name = $USER->lastname .', '. $USER->firstname;
- $userdata->mode = $mode;
- if ($userdata->mode == 'normal') {
- $userdata->credit = 'credit';
- } else {
- $userdata->credit = 'no-credit';
- }
+ $userdata->credit = 'no-credit';
+ }
- if ($sco = scorm_get_sco($scoid)) {
- $userdata->course_id = $sco->identifier;
- $userdata->datafromlms = isset($sco->datafromlms)?$sco->datafromlms:'';
- $userdata->mastery_score = isset($sco->mastery_score) && is_numeric($sco->mastery_score)?trim($sco->mastery_score):'';
- $userdata->max_time_allowed = isset($sco->max_time_allowed)?$sco->max_time_allowed:'';
- $userdata->time_limit_action = isset($sco->time_limit_action)?$sco->time_limit_action:'';
+ if ($sco = scorm_get_sco($scoid)) {
+ $userdata->course_id = $sco->identifier;
+ $userdata->datafromlms = isset($sco->datafromlms)?$sco->datafromlms:'';
+ $userdata->mastery_score = isset($sco->mastery_score) && is_numeric($sco->mastery_score)?trim($sco->mastery_score):'';
+ $userdata->max_time_allowed = isset($sco->max_time_allowed)?$sco->max_time_allowed:'';
+ $userdata->time_limit_action = isset($sco->time_limit_action)?$sco->time_limit_action:'';
- echo "error=0\r\nerror_text=Successful\r\naicc_data=";
- echo "[Core]\r\n";
- echo 'Student_ID='.$userdata->student_id."\r\n";
- echo 'Student_Name='.$userdata->student_name."\r\n";
- if (isset($userdata->{'cmi.core.lesson_location'})) {
- echo 'Lesson_Location='.$userdata->{'cmi.core.lesson_location'}."\r\n";
+ echo "error=0\r\nerror_text=Successful\r\naicc_data=";
+ echo "[Core]\r\n";
+ echo 'Student_ID='.$userdata->student_id."\r\n";
+ echo 'Student_Name='.$userdata->student_name."\r\n";
+ if (isset($userdata->{'cmi.core.lesson_location'})) {
+ echo 'Lesson_Location='.$userdata->{'cmi.core.lesson_location'}."\r\n";
+ } else {
+ echo 'Lesson_Location='."\r\n";
+ }
+ echo 'Credit='.$userdata->credit."\r\n";
+ if (isset($userdata->status)) {
+ if ($userdata->status == '') {
+ $userdata->entry = ', ab-initio';
} else {
- echo 'Lesson_Location='."\r\n";
- }
- echo 'Credit='.$userdata->credit."\r\n";
- if (isset($userdata->status)) {
- if ($userdata->status == '') {
- $userdata->entry = ', ab-initio';
+ if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) {
+ $userdata->entry = ', resume';
} else {
- if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) {
- $userdata->entry = ', resume';
- } else {
- $userdata->entry = '';
- }
+ $userdata->entry = '';
}
}
- if (isset($userdata->{'cmi.core.lesson_status'})) {
- echo 'Lesson_Status='.$userdata->{'cmi.core.lesson_status'}.$userdata->entry."\r\n";
- $SESSION->scorm_lessonstatus = $userdata->{'cmi.core.lesson_status'};
- } else {
- echo 'Lesson_Status=not attempted'.$userdata->entry."\r\n";
- $SESSION->scorm_lessonstatus = 'not attempted';
- }
- if (isset($userdata->{'cmi.core.score.raw'})) {
- $max = '';
- $min = '';
- if (isset($userdata->{'cmi.core.score.max'}) && !empty($userdata->{'cmi.core.score.max'})) {
- $max = ', '.$userdata->{'cmi.core.score.max'};
- if (isset($userdata->{'cmi.core.score.min'}) && !empty($userdata->{'cmi.core.score.min'})) {
- $min = ', '.$userdata->{'cmi.core.score.min'};
- }
+ }
+ if (isset($userdata->{'cmi.core.lesson_status'})) {
+ echo 'Lesson_Status='.$userdata->{'cmi.core.lesson_status'}.$userdata->entry."\r\n";
+ $SESSION->scorm_lessonstatus = $userdata->{'cmi.core.lesson_status'};
+ } else {
+ echo 'Lesson_Status=not attempted'.$userdata->entry."\r\n";
+ $SESSION->scorm_lessonstatus = 'not attempted';
+ }
+ if (isset($userdata->{'cmi.core.score.raw'})) {
+ $max = '';
+ $min = '';
+ if (isset($userdata->{'cmi.core.score.max'}) && !empty($userdata->{'cmi.core.score.max'})) {
+ $max = ', '.$userdata->{'cmi.core.score.max'};
+ if (isset($userdata->{'cmi.core.score.min'}) && !empty($userdata->{'cmi.core.score.min'})) {
+ $min = ', '.$userdata->{'cmi.core.score.min'};
}
- echo 'Score='.$userdata->{'cmi.core.score.raw'}.$max.$min."\r\n";
- } else {
- echo 'Score='."\r\n";
- }
- if (isset($userdata->{'cmi.core.total_time'})) {
- echo 'Time='.$userdata->{'cmi.core.total_time'}."\r\n";
- } else {
- echo 'Time='.'00:00:00'."\r\n";
- }
- echo 'Lesson_Mode='.$userdata->mode."\r\n";
- if (isset($userdata->{'cmi.suspend_data'})) {
- echo "[Core_Lesson]\r\n".rawurldecode($userdata->{'cmi.suspend_data'})."\r\n";
- } else {
- echo "[Core_Lesson]\r\n";
}
- echo "[Core_Vendor]\r\n".$userdata->datafromlms."\r\n";
- echo "[Evaluation]\r\nCourse_ID = {".$userdata->course_id."}\r\n";
- echo "[Student_Data]\r\n";
- echo 'Mastery_Score='.$userdata->mastery_score."\r\n";
- echo 'Max_Time_Allowed='.$userdata->max_time_allowed."\r\n";
- echo 'Time_Limit_Action='.$userdata->time_limit_action."\r\n";
+ echo 'Score='.$userdata->{'cmi.core.score.raw'}.$max.$min."\r\n";
+ } else {
+ echo 'Score='."\r\n";
+ }
+ if (isset($userdata->{'cmi.core.total_time'})) {
+ echo 'Time='.$userdata->{'cmi.core.total_time'}."\r\n";
+ } else {
+ echo 'Time='.'00:00:00'."\r\n";
+ }
+ echo 'Lesson_Mode='.$userdata->mode."\r\n";
+ if (isset($userdata->{'cmi.suspend_data'})) {
+ echo "[Core_Lesson]\r\n".rawurldecode($userdata->{'cmi.suspend_data'})."\r\n";
} else {
- print_error('cannotfindsco', 'scorm');
+ echo "[Core_Lesson]\r\n";
}
+ echo "[Core_Vendor]\r\n".$userdata->datafromlms."\r\n";
+ echo "[Evaluation]\r\nCourse_ID = {".$userdata->course_id."}\r\n";
+ echo "[Student_Data]\r\n";
+ echo 'Mastery_Score='.$userdata->mastery_score."\r\n";
+ echo 'Max_Time_Allowed='.$userdata->max_time_allowed."\r\n";
+ echo 'Time_Limit_Action='.$userdata->time_limit_action."\r\n";
+ } else {
+ print_error('cannotfindsco', 'scorm');
+ }
+ }
+ break;
+ case 'putparam':
+ if ($status == 'Running') {
+ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $scorm->course)) {
+ echo "error=1\r\nerror_text=Unknown\r\n"; // No one must see this error message if not hacked
}
- break;
- case 'putparam':
- if ($status == 'Running') {
- if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $scorm->course)) {
- echo "error=1\r\nerror_text=Unknown\r\n"; // No one must see this error message if not hacked
+ if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ $initlessonstatus = 'not attempted';
+ $lessonstatus = 'not attempted';
+ if (isset($SESSION->scorm_lessonstatus)) {
+ $initlessonstatus = $SESSION->scorm_lessonstatus;
}
- if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
- $initlessonstatus = 'not attempted';
- $lessonstatus = 'not attempted';
- if (isset($SESSION->scorm_lessonstatus)) {
- $initlessonstatus = $SESSION->scorm_lessonstatus;
- }
- $score = '';
- $datamodel['lesson_location'] = 'cmi.core.lesson_location';
- $datamodel['lesson_status'] = 'cmi.core.lesson_status';
- $datamodel['score'] = 'cmi.core.score.raw';
- $datamodel['time'] = 'cmi.core.session_time';
- $datamodel['[core_lesson]'] = 'cmi.suspend_data';
- $datamodel['[comments]'] = 'cmi.comments';
- $datarows = explode("\r\n",$aiccdata);
- reset($datarows);
- while ((list(,$datarow) = each($datarows)) !== false) {
- if (($equal = strpos($datarow, '=')) !== false) {
- $element = strtolower(trim(substr($datarow,0,$equal)));
- $value = trim(substr($datarow,$equal+1));
- if (isset($datamodel[$element])) {
- $element = $datamodel[$element];
- switch ($element) {
- case 'cmi.core.lesson_location':
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
- break;
- case 'cmi.core.lesson_status':
- $statuses = array(
- 'passed' => 'passed',
- 'completed' => 'completed',
- 'failed' => 'failed',
- 'incomplete' => 'incomplete',
- 'browsed' => 'browsed',
- 'not attempted' => 'not attempted',
- 'p' => 'passed',
- 'c' => 'completed',
- 'f' => 'failed',
- 'i' => 'incomplete',
- 'b' => 'browsed',
- 'n' => 'not attempted'
- );
- $exites = array(
- 'logout' => 'logout',
- 'time-out' => 'time-out',
- 'suspend' => 'suspend',
- 'l' => 'logout',
- 't' => 'time-out',
- 's' => 'suspend',
- );
- $values = explode(',',$value);
- $value = '';
- if (count($values) > 1) {
- $value = trim(strtolower($values[1]));
- $value = $value[0];
- if (isset($exites[$value])) {
- $value = $exites[$value];
- }
+ $score = '';
+ $datamodel['lesson_location'] = 'cmi.core.lesson_location';
+ $datamodel['lesson_status'] = 'cmi.core.lesson_status';
+ $datamodel['score'] = 'cmi.core.score.raw';
+ $datamodel['time'] = 'cmi.core.session_time';
+ $datamodel['[core_lesson]'] = 'cmi.suspend_data';
+ $datamodel['[comments]'] = 'cmi.comments';
+ $datarows = explode("\r\n", $aiccdata);
+ reset($datarows);
+ while ((list(, $datarow) = each($datarows)) !== false) {
+ if (($equal = strpos($datarow, '=')) !== false) {
+ $element = strtolower(trim(substr($datarow, 0, $equal)));
+ $value = trim(substr($datarow, $equal+1));
+ if (isset($datamodel[$element])) {
+ $element = $datamodel[$element];
+ switch ($element) {
+ case 'cmi.core.lesson_location':
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+ break;
+ case 'cmi.core.lesson_status':
+ $statuses = array(
+ 'passed' => 'passed',
+ 'completed' => 'completed',
+ 'failed' => 'failed',
+ 'incomplete' => 'incomplete',
+ 'browsed' => 'browsed',
+ 'not attempted' => 'not attempted',
+ 'p' => 'passed',
+ 'c' => 'completed',
+ 'f' => 'failed',
+ 'i' => 'incomplete',
+ 'b' => 'browsed',
+ 'n' => 'not attempted'
+ );
+ $exites = array(
+ 'logout' => 'logout',
+ 'time-out' => 'time-out',
+ 'suspend' => 'suspend',
+ 'l' => 'logout',
+ 't' => 'time-out',
+ 's' => 'suspend',
+ );
+ $values = explode(',', $value);
+ $value = '';
+ if (count($values) > 1) {
+ $value = trim(strtolower($values[1]));
+ $value = $value[0];
+ if (isset($exites[$value])) {
+ $value = $exites[$value];
}
- if (empty($value) || isset($exites[$value])) {
- $subelement = 'cmi.core.exit';
+ }
+ if (empty($value) || isset($exites[$value])) {
+ $subelement = 'cmi.core.exit';
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
+ }
+ $value = trim(strtolower($values[0]));
+ $value = $value[0];
+ if (isset($statuses[$value]) && ($mode == 'normal')) {
+ $value = $statuses[$value];
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+ }
+ $lessonstatus = $value;
+ break;
+ case 'cmi.core.score.raw':
+ $values = explode(',', $value);
+ if ((count($values) > 1) && ($values[1] >= $values[0]) && is_numeric($values[1])) {
+ $subelement = 'cmi.core.score.max';
+ $value = trim($values[1]);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
+ if ((count($values) == 3) && ($values[2] <= $values[0]) && is_numeric($values[2])) {
+ $subelement = 'cmi.core.score.min';
+ $value = trim($values[2]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
}
- $value = trim(strtolower($values[0]));
- $value = $value[0];
- if (isset($statuses[$value]) && ($mode == 'normal')) {
- $value = $statuses[$value];
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
- }
- $lessonstatus = $value;
- break;
- case 'cmi.core.score.raw':
- $values = explode(',',$value);
- if ((count($values) > 1) && ($values[1] >= $values[0]) && is_numeric($values[1])) {
- $subelement = 'cmi.core.score.max';
- $value = trim($values[1]);
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
- if ((count($values) == 3) && ($values[2] <= $values[0]) && is_numeric($values[2])) {
- $subelement = 'cmi.core.score.min';
- $value = trim($values[2]);
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
- }
- }
+ }
- $value = '';
- if (is_numeric($values[0])) {
- $value = trim($values[0]);
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
- }
- $score = $value;
- break;
- case 'cmi.core.session_time':
- $SESSION->scorm_session_time = $value;
- break;
- }
+ $value = '';
+ if (is_numeric($values[0])) {
+ $value = trim($values[0]);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+ }
+ $score = $value;
+ break;
+ case 'cmi.core.session_time':
+ $SESSION->scorm_session_time = $value;
+ break;
}
- } else {
- if (isset($datamodel[strtolower(trim($datarow))])) {
- $element = $datamodel[strtolower(trim($datarow))];
- $value = '';
- while ((($datarow = current($datarows)) !== false) && (substr($datarow,0,1) != '[')) {
- $value .= $datarow."\r\n";
- next($datarows);
- }
- $value = rawurlencode($value);
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+ }
+ } else {
+ if (isset($datamodel[strtolower(trim($datarow))])) {
+ $element = $datamodel[strtolower(trim($datarow))];
+ $value = '';
+ while ((($datarow = current($datarows)) !== false) && (substr($datarow, 0, 1) != '[')) {
+ $value .= $datarow."\r\n";
+ next($datarows);
}
+ $value = rawurlencode($value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
}
- if (($mode == 'browse') && ($initlessonstatus == 'not attempted')){
- $lessonstatus = 'browsed';
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', 'browsed');
- }
- if ($mode == 'normal') {
- if ($sco = scorm_get_sco($scoid)) {
- if (isset($sco->mastery_score) && is_numeric($sco->mastery_score)) {
- if ($score != '') { // $score is correctly initialized w/ an empty string, see above
- if ($score >= trim($sco->mastery_score)) {
- $lessonstatus = 'passed';
- } else {
- $lessonstatus = 'failed';
- }
+ }
+ if (($mode == 'browse') && ($initlessonstatus == 'not attempted')) {
+ $lessonstatus = 'browsed';
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', 'browsed');
+ }
+ if ($mode == 'normal') {
+ if ($sco = scorm_get_sco($scoid)) {
+ if (isset($sco->mastery_score) && is_numeric($sco->mastery_score)) {
+ if ($score != '') { // $score is correctly initialized w/ an empty string, see above
+ if ($score >= trim($sco->mastery_score)) {
+ $lessonstatus = 'passed';
+ } else {
+ $lessonstatus = 'failed';
}
}
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', $lessonstatus);
}
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', $lessonstatus);
}
}
- echo "error=0\r\nerror_text=Successful\r\n";
- } else if ($status == 'Terminated') {
- echo "error=1\r\nerror_text=Terminated\r\n";
- } else {
- echo "error=1\r\nerror_text=Not Initialized\r\n";
- }
- break;
- case 'putcomments':
- if ($status == 'Running') {
- echo "error=0\r\nerror_text=Successful\r\n";
- } else if ($status == 'Terminated') {
- echo "error=1\r\nerror_text=Terminated\r\n";
- } else {
- echo "error=1\r\nerror_text=Not Initialized\r\n";
- }
- break;
- case 'putinteractions':
- if ($status == 'Running') {
- echo "error=0\r\nerror_text=Successful\r\n";
- } else if ($status == 'Terminated') {
- echo "error=1\r\nerror_text=Terminated\r\n";
- } else {
- echo "error=1\r\nerror_text=Not Initialized\r\n";
- }
- break;
- case 'putobjectives':
- if ($status == 'Running') {
- echo "error=0\r\nerror_text=Successful\r\n";
- } else if ($status == 'Terminated') {
- echo "error=1\r\nerror_text=Terminated\r\n";
- } else {
- echo "error=1\r\nerror_text=Not Initialized\r\n";
}
- break;
- case 'putpath':
- if ($status == 'Running') {
- echo "error=0\r\nerror_text=Successful\r\n";
- } else if ($status == 'Terminated') {
- echo "error=1\r\nerror_text=Terminated\r\n";
- } else {
- echo "error=1\r\nerror_text=Not Initialized\r\n";
- }
- break;
- case 'putperformance':
- if ($status == 'Running') {
- echo "error=0\r\nerror_text=Successful\r\n";
- } else if ($status == 'Terminated') {
- echo "error=1\r\nerror_text=Terminated\r\n";
- } else {
- echo "error=1\r\nerror_text=Not Initialized\r\n";
- }
- break;
- case 'exitau':
- if ($status == 'Running') {
- if (isset($SESSION->scorm_session_time) && ($SESSION->scorm_session_time != '')) {
- if ($track = $DB->get_record('scorm_scoes_track',array("userid"=>$USER->id, "scormid"=>$scorm->id,"scoid"=>$sco->id, "attempt"=>$attempt,"element"=>'cmi.core.total_time'))) {
- // Add session_time to total_time
- $value = scorm_add_time($track->value, $SESSION->scorm_session_time);
- $track->value = $value;
- $track->timemodified = time();
- $DB->update_record('scorm_scoes_track',$track);
- } else {
- $track = new stdClass();
- $track->userid = $USER->id;
- $track->scormid = $scorm->id;
- $track->scoid = $sco->id;
- $track->element = 'cmi.core.total_time';
- $track->value = $SESSION->scorm_session_time;
- $track->attempt = $attempt;
- $track->timemodified = time();
- $id = $DB->insert_record('scorm_scoes_track',$track);
- }
- scorm_update_grades($scorm, $USER->id);
+ echo "error=0\r\nerror_text=Successful\r\n";
+ } else if ($status == 'Terminated') {
+ echo "error=1\r\nerror_text=Terminated\r\n";
+ } else {
+ echo "error=1\r\nerror_text=Not Initialized\r\n";
+ }
+ break;
+ case 'putcomments':
+ if ($status == 'Running') {
+ echo "error=0\r\nerror_text=Successful\r\n";
+ } else if ($status == 'Terminated') {
+ echo "error=1\r\nerror_text=Terminated\r\n";
+ } else {
+ echo "error=1\r\nerror_text=Not Initialized\r\n";
+ }
+ break;
+ case 'putinteractions':
+ if ($status == 'Running') {
+ echo "error=0\r\nerror_text=Successful\r\n";
+ } else if ($status == 'Terminated') {
+ echo "error=1\r\nerror_text=Terminated\r\n";
+ } else {
+ echo "error=1\r\nerror_text=Not Initialized\r\n";
+ }
+ break;
+ case 'putobjectives':
+ if ($status == 'Running') {
+ echo "error=0\r\nerror_text=Successful\r\n";
+ } else if ($status == 'Terminated') {
+ echo "error=1\r\nerror_text=Terminated\r\n";
+ } else {
+ echo "error=1\r\nerror_text=Not Initialized\r\n";
+ }
+ break;
+ case 'putpath':
+ if ($status == 'Running') {
+ echo "error=0\r\nerror_text=Successful\r\n";
+ } else if ($status == 'Terminated') {
+ echo "error=1\r\nerror_text=Terminated\r\n";
+ } else {
+ echo "error=1\r\nerror_text=Not Initialized\r\n";
+ }
+ break;
+ case 'putperformance':
+ if ($status == 'Running') {
+ echo "error=0\r\nerror_text=Successful\r\n";
+ } else if ($status == 'Terminated') {
+ echo "error=1\r\nerror_text=Terminated\r\n";
+ } else {
+ echo "error=1\r\nerror_text=Not Initialized\r\n";
+ }
+ break;
+ case 'exitau':
+ if ($status == 'Running') {
+ if (isset($SESSION->scorm_session_time) && ($SESSION->scorm_session_time != '')) {
+ if ($track = $DB->get_record('scorm_scoes_track', array("userid"=>$USER->id,
+ "scormid"=>$scorm->id,
+ "scoid"=>$sco->id,
+ "attempt"=>$attempt,
+ "element"=>'cmi.core.total_time'))) {
+ // Add session_time to total_time
+ $value = scorm_add_time($track->value, $SESSION->scorm_session_time);
+ $track->value = $value;
+ $track->timemodified = time();
+ $DB->update_record('scorm_scoes_track', $track);
+ } else {
+ $track = new stdClass();
+ $track->userid = $USER->id;
+ $track->scormid = $scorm->id;
+ $track->scoid = $sco->id;
+ $track->element = 'cmi.core.total_time';
+ $track->value = $SESSION->scorm_session_time;
+ $track->attempt = $attempt;
+ $track->timemodified = time();
+ $id = $DB->insert_record('scorm_scoes_track', $track);
}
- $SESSION->scorm_status = 'Terminated';
- $SESSION->scorm_session_time = '';
- echo "error=0\r\nerror_text=Successful\r\n";
- } else if ($status == 'Terminated') {
- echo "error=1\r\nerror_text=Terminated\r\n";
- } else {
- echo "error=1\r\nerror_text=Not Initialized\r\n";
+ scorm_update_grades($scorm, $USER->id);
}
- break;
- default:
- echo "error=1\r\nerror_text=Invalid Command\r\n";
- break;
- }
+ $SESSION->scorm_status = 'Terminated';
+ $SESSION->scorm_session_time = '';
+ echo "error=0\r\nerror_text=Successful\r\n";
+ } else if ($status == 'Terminated') {
+ echo "error=1\r\nerror_text=Terminated\r\n";
+ } else {
+ echo "error=1\r\nerror_text=Not Initialized\r\n";
+ }
+ break;
+ default:
+ echo "error=1\r\nerror_text=Invalid Command\r\n";
+ break;
}
+ }
+} else {
+ if (empty($command)) {
+ echo "error=1\r\nerror_text=Invalid Command\r\n";
} else {
- if (empty($command)) {
- echo "error=1\r\nerror_text=Invalid Command\r\n";
- } else {
- echo "error=3\r\nerror_text=Invalid Session ID\r\n";
- }
+ echo "error=3\r\nerror_text=Invalid Session ID\r\n";
}
- $aiccresponse = ob_get_contents();
- scorm_debug_log_write("aicc", "HACP Response:\r\n$aiccresponse", $scoid);
- ob_end_flush();
+}
+$aiccresponse = ob_get_contents();
+scorm_debug_log_write("aicc", "HACP Response:\r\n$aiccresponse", $scoid);
+ob_end_flush();
View
162 mod/scorm/api.php
@@ -1,92 +1,106 @@
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
- require_once("../../config.php");
- require_once('locallib.php');
+require_once("../../config.php");
+require_once('locallib.php');
- $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
- $a = optional_param('a', '', PARAM_INT); // scorm ID
- $scoid = required_param('scoid', PARAM_INT); // sco ID
- $mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
- $attempt = required_param('attempt', PARAM_INT); // new attempt
+$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
+$a = optional_param('a', '', PARAM_INT); // scorm ID
+$scoid = required_param('scoid', PARAM_INT); // sco ID
+$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
+$attempt = required_param('attempt', PARAM_INT); // new attempt
- //IE 6 Bug workaround
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
- @ini_set('zlib.output_compression', 'Off');
- @apache_setenv('no-gzip', 1);
- header( 'Content-Type: application/javascript' );
- }
+//IE 6 Bug workaround
+if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
+ @ini_set('zlib.output_compression', 'Off');
+ @apache_setenv('no-gzip', 1);
+ header( 'Content-Type: application/javascript' );
+}
- if (!empty($id)) {
- if (! $cm = get_coursemodule_from_id('scorm', $id)) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
- print_error('coursemisconf');
- }
- if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
- print_error('invalidcoursemodule');
- }
- } else if (!empty($a)) {
- if (! $scorm = $DB->get_record('scorm', array('id'=>$a))) {
- print_error('coursemisconf');
- }
- if (! $course = $DB->get_record('course', array('id'=>$scorm->course))) {
- print_error('coursemisconf');
- }
- if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
- print_error('invalidcoursemodule');
- }
- } else {
- print_error('missingparameter');
+if (!empty($id)) {
+ if (! $cm = get_coursemodule_from_id('scorm', $id)) {
+ print_error('invalidcoursemodule');
+ }
+ if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
+ print_error('coursemisconf');
+ }
+ if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
+ print_error('invalidcoursemodule');
+ }
+} else if (!empty($a)) {
+ if (! $scorm = $DB->get_record('scorm', array('id'=>$a))) {
+ print_error('coursemisconf');
}
+ if (! $course = $DB->get_record('course', array('id'=>$scorm->course))) {
+ print_error('coursemisconf');
+ }
+ if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
+ print_error('invalidcoursemodule');
+ }
+} else {
+ print_error('missingparameter');
+}
- $PAGE->set_url('/mod/scorm/api.php', array('scoid'=>$scoid, 'id'=>$cm->id));
+$PAGE->set_url('/mod/scorm/api.php', array('scoid'=>$scoid, 'id'=>$cm->id));
- require_login($course->id, false, $cm);
+require_login($course->id, false, $cm);
- if ($usertrack = scorm_get_tracks($scoid,$USER->id,$attempt)) {
- //according to SCORM 2004 spec(RTE V1, 4.2.8), only cmi.exit==suspend should allow previous datamodel elements on re-launch
- if ($scorm->version != "SCORM_1.3" || (isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} == 'suspend'))) {
- foreach ($usertrack as $key => $value) {
- $userdata->$key = addslashes_js($value);
- }
- } else {
- $userdata->status = '';
- $userdata->score_raw = '';
+if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
+ //according to SCORM 2004 spec(RTE V1, 4.2.8), only cmi.exit==suspend should allow previous datamodel elements on re-launch
+ if ($scorm->version != "SCORM_1.3" || (isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} == 'suspend'))) {
+ foreach ($usertrack as $key => $value) {
+ $userdata->$key = addslashes_js($value);
}
} else {
$userdata->status = '';
$userdata->score_raw = '';
}
- $userdata->student_id = addslashes_js($USER->username);
- $userdata->student_name = addslashes_js($USER->lastname .', '. $USER->firstname);
- $userdata->mode = 'normal';
- if (isset($mode)) {
- $userdata->mode = $mode;
- }
- if ($userdata->mode == 'normal') {
- $userdata->credit = 'credit';
- } else {
- $userdata->credit = 'no-credit';
- }
- if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
- foreach ($scodatas as $key => $value) {
- $userdata->$key = addslashes_js($value);
- }
- } else {
- print_error('cannotfindsco', 'scorm');
- }
- if (!$sco = scorm_get_sco($scoid)) {
- print_error('cannotfindsco', 'scorm');
- }
- $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
- if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) {
- include_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php');
- } else {
- include_once($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php');
+} else {
+ $userdata->status = '';
+ $userdata->score_raw = '';
+}
+$userdata->student_id = addslashes_js($USER->username);
+$userdata->student_name = addslashes_js($USER->lastname .', '. $USER->firstname);
+$userdata->mode = 'normal';
+if (isset($mode)) {
+ $userdata->mode = $mode;
+}
+if ($userdata->mode == 'normal') {
+ $userdata->credit = 'credit';
+} else {
+ $userdata->credit = 'no-credit';
+}
+if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
+ foreach ($scodatas as $key => $value) {
+ $userdata->$key = addslashes_js($value);
}
- // set the start time of this SCO
- scorm_insert_track($USER->id,$scorm->id,$scoid,$attempt,'x.start.time',time());
+} else {
+ print_error('cannotfindsco', 'scorm');
+}
+if (!$sco = scorm_get_sco($scoid)) {
+ print_error('cannotfindsco', 'scorm');
+}
+$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
+if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) {
+ include_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php');
+} else {
+ include_once($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php');
+}
+// set the start time of this SCO
+scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, 'x.start.time', time());
?>
View
1  mod/scorm/backup/moodle1/lib.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
3  mod/scorm/backup/moodle2/backup_scorm_activity_task.class.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -52,7 +51,7 @@ protected function define_my_steps() {
static public function encode_content_links($content) {
global $CFG;
- $base = preg_quote($CFG->wwwroot,"/");
+ $base = preg_quote($CFG->wwwroot, "/");
// Link to the list of scorms
$search="/(".$base."\/mod\/scorm\/index.php\?id\=)([0-9]+)/";
View
1  mod/scorm/backup/moodle2/backup_scorm_stepslib.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
1  mod/scorm/backup/moodle2/restore_scorm_activity_task.class.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
1  mod/scorm/backup/moodle2/restore_scorm_stepslib.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
156 mod/scorm/datamodel.php
@@ -1,89 +1,101 @@
<?php
- require_once('../../config.php');
- require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
- $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
- $a = optional_param('a', '', PARAM_INT); // scorm ID
- $scoid = required_param('scoid', PARAM_INT); // sco ID
- $attempt = required_param('attempt', PARAM_INT); // attempt number
-// $attempt = $SESSION->scorm_attempt;
+require_once('../../config.php');
+require_once($CFG->dirroot.'/mod/scorm/locallib.php');
+$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
+$a = optional_param('a', '', PARAM_INT); // scorm ID
+$scoid = required_param('scoid', PARAM_INT); // sco ID
+$attempt = required_param('attempt', PARAM_INT); // attempt number
- if (!empty($id)) {
- if (! $cm = get_coursemodule_from_id('scorm', $id)) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
- print_error('coursemisconf');
- }
- if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
- print_error('invalidcoursemodule');
- }
- } else if (!empty($a)) {
- if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
- print_error('coursemisconf');
- }
- if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
- print_error('invalidcoursemodule');
- }
- } else {
- print_error('missingparameter');
+if (!empty($id)) {
+ if (! $cm = get_coursemodule_from_id('scorm', $id)) {
+ print_error('invalidcoursemodule');
+ }
+ if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+ print_error('coursemisconf');
+ }
+ if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
+ print_error('invalidcoursemodule');
+ }
+} else if (!empty($a)) {
+ if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
+ print_error('invalidcoursemodule');
+ }
+ if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
+ print_error('coursemisconf');
}
+ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
+ print_error('invalidcoursemodule');
+ }
+} else {
+ print_error('missingparameter');
+}
- $PAGE->set_url('/mod/scorm/datamodel.php', array('scoid'=>$scoid,'attempt'=>$attempt, 'id'=>$cm->id));
+$PAGE->set_url('/mod/scorm/datamodel.php', array('scoid'=>$scoid, 'attempt'=>$attempt, 'id'=>$cm->id));
- require_login($course->id, false, $cm);
+require_login($course->id, false, $cm);
- if (confirm_sesskey() && (!empty($scoid))) {
- $result = true;
- $request = null;
- if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) {
- foreach (data_submitted() as $element => $value) {
- $element = str_replace('__','.',$element);
- if (substr($element,0,3) == 'cmi') {
- $netelement = preg_replace('/\.N(\d+)\./',"\.\$1\.",$element);
- $result = scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, $element, $value, $scorm->forcecompleted) && $result;
- }
- if (substr($element,0,15) == 'adl.nav.request') {
- // SCORM 2004 Sequencing Request
- require_once($CFG->dirroot.'/mod/scorm/datamodels/sequencinglib.php');
+if (confirm_sesskey() && (!empty($scoid))) {
+ $result = true;
+ $request = null;
+ if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ foreach (data_submitted() as $element => $value) {
+ $element = str_replace('__', '.', $element);
+ if (substr($element, 0, 3) == 'cmi') {
+ $netelement = preg_replace('/\.N(\d+)\./', "\.\$1\.", $element);
+ $result = scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, $element, $value, $scorm->forcecompleted) && $result;
+ }
+ if (substr($element, 0, 15) == 'adl.nav.request') {
+ // SCORM 2004 Sequencing Request
+ require_once($CFG->dirroot.'/mod/scorm/datamodels/sequencinglib.php');
- $search = array('@continue@', '@previous@', '@\{target=(\S+)\}choice@', '@exit@', '@exitAll@', '@abandon@', '@abandonAll@');
- $replace = array('continue_', 'previous_', '\1', 'exit_', 'exitall_', 'abandon_', 'abandonall');
- $action = preg_replace($search, $replace, $value);
+ $search = array('@continue@', '@previous@', '@\{target=(\S+)\}choice@', '@exit@', '@exitAll@', '@abandon@', '@abandonAll@');
+ $replace = array('continue_', 'previous_', '\1', 'exit_', 'exitall_', 'abandon_', 'abandonall');
+ $action = preg_replace($search, $replace, $value);
- if ($action != $value) {
- // Evaluating navigation request
- $valid = scorm_seq_overall ($scoid,$USER->id,$action,$attempt);
- $valid = 'true';
+ if ($action != $value) {
+ // Evaluating navigation request
+ $valid = scorm_seq_overall ($scoid, $USER->id, $action, $attempt);
+ $valid = 'true';
- // Set valid request
- $search = array('@continue@', '@previous@', '@\{target=(\S+)\}choice@');
- $replace = array('true', 'true', 'true');
- $matched = preg_replace($search, $replace, $value);
- if ($matched == 'true') {
- $request = 'adl.nav.request_valid["'.$action.'"] = "'.$valid.'";';
- }
+ // Set valid request
+ $search = array('@continue@', '@previous@', '@\{target=(\S+)\}choice@');
+ $replace = array('true', 'true', 'true');
+ $matched = preg_replace($search, $replace, $value);
+ if ($matched == 'true') {
+ $request = 'adl.nav.request_valid["'.$action.'"] = "'.$valid.'";';
}
}
- // Log every datamodel update requested
- if (substr($element,0,15) == 'adl.nav.request' || substr($element,0,3) == 'cmi') {
- if (scorm_debugging($scorm)) {
- add_to_log($course->id, 'scorm', 'trk: scoid/'.$scoid.' at: '.$attempt, 'view.php?id='.$cm->id, "$element => $value", $cm->id);
- }
+ }
+ // Log every datamodel update requested
+ if (substr($element, 0, 15) == 'adl.nav.request' || substr($element, 0, 3) == 'cmi') {
+ if (scorm_debugging($scorm)) {
+ add_to_log($course->id, 'scorm', 'trk: scoid/'.$scoid.' at: '.$attempt, 'view.php?id='.$cm->id, "$element => $value", $cm->id);
}
}
}
- if ($result) {
- echo "true\n0";
- } else {
- echo "false\n101";
- }
- if ($request != null) {
- echo "\n".$request;
- }
}
-
+ if ($result) {
+ echo "true\n0";
+ } else {
+ echo "false\n101";
+ }
+ if ($request != null) {
+ echo "\n".$request;
+ }
+}
View
89 mod/scorm/datamodels/aicc.js.php
@@ -1,18 +1,33 @@
<?php
- if (isset($userdata->status)) {
- if ($userdata->status == '') {
- $userdata->entry = 'ab-initio';
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+if (isset($userdata->status)) {
+ if ($userdata->status == '') {
+ $userdata->entry = 'ab-initio';
+ } else {
+ if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) {
+ $userdata->entry = 'resume';
} else {
- if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) {
- $userdata->entry = 'resume';
- } else {
- $userdata->entry = '';
- }
+ $userdata->entry = '';
}
}
- if (!isset($currentorg)) {
- $currentorg = '';
- }
+}
+if (!isset($currentorg)) {
+ $currentorg = '';
+}
?>
//
// SCORM 1.2 API Implementation
@@ -152,31 +167,31 @@ function AICCapi() {
}
<?php
- $current_objective = '';
- $count = 0;
- $objectives = '';
- foreach($userdata as $element => $value){
- if (substr($element,0,14) == 'cmi.objectives') {
- $element = preg_replace('/\.(\d+)\./', "_\$1.", $element);
- preg_match('/\_(\d+)\./', $element, $matches);
- if (count($matches) > 0 && $current_objective != $matches[1]) {
- $current_objective = $matches[1];
- $count++;
- $end = strpos($element,$matches[1])+strlen($matches[1]);
- $subelement = substr($element,0,$end);
- echo ' '.$subelement." = new Object();\n";
- echo ' '.$subelement.".score = new Object();\n";
- echo ' '.$subelement.".score._children = score_children;\n";
- echo ' '.$subelement.".score.raw = '';\n";
- echo ' '.$subelement.".score.min = '';\n";
- echo ' '.$subelement.".score.max = '';\n";
- }
- echo ' '.$element.' = \''.$value."';\n";
+$current_objective = '';
+$count = 0;
+$objectives = '';
+foreach ($userdata as $element => $value) {
+ if (substr($element, 0, 14) == 'cmi.objectives') {
+ $element = preg_replace('/\.(\d+)\./', "_\$1.", $element);
+ preg_match('/\_(\d+)\./', $element, $matches);
+ if (count($matches) > 0 && $current_objective != $matches[1]) {
+ $current_objective = $matches[1];
+ $count++;
+ $end = strpos($element, $matches[1])+strlen($matches[1]);
+ $subelement = substr($element, 0, $end);
+ echo ' '.$subelement." = new Object();\n";
+ echo ' '.$subelement.".score = new Object();\n";
+ echo ' '.$subelement.".score._children = score_children;\n";
+ echo ' '.$subelement.".score.raw = '';\n";
+ echo ' '.$subelement.".score.min = '';\n";
+ echo ' '.$subelement.".score.max = '';\n";
}
+ echo ' '.$element.' = \''.$value."';\n";
}
- if ($count > 0) {
- echo ' cmi.objectives._count = '.$count.";\n";
- }
+}
+if ($count > 0) {
+ echo ' cmi.objectives._count = '.$count.";\n";
+}
?>
if (cmi.core.lesson_status == '') {
@@ -206,9 +221,9 @@ function LMSInitialize (param) {
<?php
- // pull in the TOC callback
- include_once($CFG->dirroot.'/mod/scorm/datamodels/callback.js.php');
- ?>
+// pull in the TOC callback
+require_once($CFG->dirroot.'/mod/scorm/datamodels/callback.js.php');
+?>
function LMSFinish (param) {
View
191 mod/scorm/datamodels/aicclib.php
@@ -1,10 +1,24 @@
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
function scorm_add_time($a, $b) {
- $aes = explode(':',$a);
- $bes = explode(':',$b);
- $aseconds = explode('.',$aes[2]);
- $bseconds = explode('.',$bes[2]);
+ $aes = explode(':', $a);
+ $bes = explode(':', $b);
+ $aseconds = explode('.', $aes[2]);
+ $bseconds = explode('.', $bes[2]);
$change = 0;
$acents = 0; //Cents
@@ -49,16 +63,16 @@ function scorm_add_time($a, $b) {
}
/**
-* Take the header row of an AICC definition file
-* and returns sequence of columns and a pointer to
-* the sco identifier column.
-*
-* @param string $row AICC header row
-* @param string $mastername AICC sco identifier column
-* @return mixed
-*/
-function scorm_get_aicc_columns($row,$mastername='system_id') {
- $tok = strtok(strtolower($row),"\",\n\r");
+ * Take the header row of an AICC definition file
+ * and returns sequence of columns and a pointer to
+ * the sco identifier column.
+ *
+ * @param string $row AICC header row
+ * @param string $mastername AICC sco identifier column
+ * @return mixed
+ */
+function scorm_get_aicc_columns($row, $mastername='system_id') {
+ $tok = strtok(strtolower($row), "\",\n\r");
$result = new stdClass();
$result->columns = array();
$i=0;
@@ -76,19 +90,19 @@ function scorm_get_aicc_columns($row,$mastername='system_id') {
}
/**
-* Given a colums array return a string containing the regular
-* expression to match the columns in a text row.
-*
-* @param array $column The header columns
-* @param string $remodule The regular expression module for a single column
-* @return string
-*/
-function scorm_forge_cols_regexp($columns,$remodule='(".*")?,') {
+ * Given a colums array return a string containing the regular
+ * expression to match the columns in a text row.
+ *
+ * @param array $column The header columns
+ * @param string $remodule The regular expression module for a single column
+ * @return string
+ */
+function scorm_forge_cols_regexp($columns, $remodule='(".*")?,') {
$regexp = '/^';
foreach ($columns as $column) {
$regexp .= $remodule;
}
- $regexp = substr($regexp,0,-1) . '/';
+ $regexp = substr($regexp, 0, -1) . '/';
return $regexp;
}
@@ -106,18 +120,17 @@ function scorm_parse_aicc($scorm) {
$files = $fs->get_area_files($context->id, 'mod_scorm', 'content', 0, '', false);
-
$version = 'AICC';
$ids = array();
$courses = array();
- $extaiccfiles = array('crs','des','au','cst','ort','pre','cmp');
+ $extaiccfiles = array('crs', 'des', 'au', 'cst', 'ort', 'pre', 'cmp');
foreach ($files as $file) {
$filename = $file->get_filename();
- $ext = substr($filename,strrpos($filename,'.'));
- $extension = strtolower(substr($ext,1));
- if (in_array($extension,$extaiccfiles)) {
- $id = strtolower(basename($filename,$ext));
+ $ext = substr($filename, strrpos($filename, '.'));
+ $extension = strtolower(substr($ext, 1));
+ if (in_array($extension, $extaiccfiles)) {
+ $id = strtolower(basename($filename, $ext));
$ids[$id]->$extension = $file;
}
}
@@ -128,7 +141,7 @@ function scorm_parse_aicc($scorm) {
$rows = explode("\r\n", $contents);
if (is_array($rows)) {
foreach ($rows as $row) {
- if (preg_match("/^(.+)=(.+)$/",$row,$matches)) {
+ if (preg_match("/^(.+)=(.+)$/", $row, $matches)) {
switch (strtolower(trim($matches[1]))) {
case 'course_id':
$courses[$courseid]->id = trim($matches[2]);
@@ -149,11 +162,11 @@ function scorm_parse_aicc($scorm) {
$rows = explode("\r\n", $contents);
$columns = scorm_get_aicc_columns($rows[0]);
$regexp = scorm_forge_cols_regexp($columns->columns);
- for ($i=1;$i<count($rows);$i++) {
- if (preg_match($regexp,$rows[$i],$matches)) {
- for ($j=0;$j<count($columns->columns);$j++) {
+ for ($i=1; $i<count($rows); $i++) {
+ if (preg_match($regexp, $rows[$i], $matches)) {
+ for ($j=0; $j<count($columns->columns); $j++) {
$column = $columns->columns[$j];
- $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1);
+ $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]), 1 , -1)]->$column = substr(trim($matches[$j+1]), 1, -1);
}
}
}
@@ -163,11 +176,11 @@ function scorm_parse_aicc($scorm) {
$rows = explode("\r\n", $contents);
$columns = scorm_get_aicc_columns($rows[0]);
$regexp = scorm_forge_cols_regexp($columns->columns);
- for ($i=1;$i<count($rows);$i++) {
- if (preg_match($regexp,$rows[$i],$matches)) {
- for ($j=0;$j<count($columns->columns);$j++) {
+ for ($i=1; $i<count($rows); $i++) {
+ if (preg_match($regexp, $rows[$i], $matches)) {
+ for ($j=0; $j<count($columns->columns); $j++) {
$column = $columns->columns[$j];
- $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1);
+ $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]), 1, -1)]->$column = substr(trim($matches[$j+1]), 1, -1);
}
}
}
@@ -175,13 +188,13 @@ function scorm_parse_aicc($scorm) {
if (isset($id->cst)) {
$contents = $id->cst->get_content();
$rows = explode("\r\n", $contents);
- $columns = scorm_get_aicc_columns($rows[0],'block');
- $regexp = scorm_forge_cols_regexp($columns->columns,'(.+)?,');
- for ($i=1;$i<count($rows);$i++) {
- if (preg_match($regexp,$rows[$i],$matches)) {
- for ($j=0;$j<count($columns->columns);$j++) {
+ $columns = scorm_get_aicc_columns($rows[0], 'block');
+ $regexp = scorm_forge_cols_regexp($columns->columns, '(.+)?,');
+ for ($i=1; $i<count($rows); $i++) {
+ if (preg_match($regexp, $rows[$i], $matches)) {
+ for ($j=0; $j<count($columns->columns); $j++) {
if ($j != $columns->mastercol) {
- $courses[$courseid]->elements[substr(trim($matches[$j+1]),1,-1)]->parent = substr(trim($matches[$columns->mastercol+1]),1,-1);
+ $courses[$courseid]->elements[substr(trim($matches[$j+1]), 1 , -1)]->parent = substr(trim($matches[$columns->mastercol+1]), 1, -1);
}
}
}
@@ -190,13 +203,13 @@ function scorm_parse_aicc($scorm) {
if (isset($id->ort)) {
$contents = $id->ort->get_content();
$rows = explode("\r\n", $contents);
- $columns = scorm_get_aicc_columns($rows[0],'course_element');
- $regexp = scorm_forge_cols_regexp($columns->columns,'(.+)?,');
- for ($i=1;$i<count($rows);$i++) {
- if (preg_match($regexp,$rows[$i],$matches)) {
- for ($j=0;$j<count($matches)-1;$j++) {
+ $columns = scorm_get_aicc_columns($rows[0], 'course_element');
+ $regexp = scorm_forge_cols_regexp($columns->columns, '(.+)?,');
+ for ($i=1; $i<count($rows); $i++) {
+ if (preg_match($regexp, $rows[$i], $matches)) {
+ for ($j=0; $j<count($matches)-1; $j++) {
if ($j != $columns->mastercol) {
- $courses[$courseid]->elements[substr(trim($matches[$j+1]),1,-1)]->parent = substr(trim($matches[$columns->mastercol+1]),1,-1);
+ $courses[$courseid]->elements[substr(trim($matches[$j+1]), 1, -1)]->parent = substr(trim($matches[$columns->mastercol+1]), 1, -1);
}
}
}
@@ -205,11 +218,11 @@ function scorm_parse_aicc($scorm) {
if (isset($id->pre)) {
$contents = $id->pre->get_content();
$rows = explode("\r\n", $contents);
- $columns = scorm_get_aicc_columns($rows[0],'structure_element');
- $regexp = scorm_forge_cols_regexp($columns->columns,'(.+),');
- for ($i=1;$i<count($rows);$i++) {
- if (preg_match($regexp,$rows[$i],$matches)) {
- $courses[$courseid]->elements[$columns->mastercol+1]->prerequisites = substr(trim($matches[1-$columns->mastercol+1]),1,-1);
+ $columns = scorm_get_aicc_columns($rows[0], 'structure_element');
+ $regexp = scorm_forge_cols_regexp($columns->columns, '(.+),');
+ for ($i=1; $i<count($rows); $i++) {
+ if (preg_match($regexp, $rows[$i], $matches)) {
+ $courses[$courseid]->elements[$columns->mastercol+1]->prerequisites = substr(trim($matches[1-$columns->mastercol+1]), 1, -1);
}
}
}
@@ -218,7 +231,6 @@ function scorm_parse_aicc($scorm) {
$rows = explode("\r\n", $contents);
}
}
- //print_r($courses);
$oldscoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id));
@@ -234,20 +246,20 @@ function scorm_parse_aicc($scorm) {
$sco->launch = '';
$sco->scormtype = '';
- //print_r($sco);
- if ($ss = $DB->get_record('scorm_scoes', array('scorm'=>$scorm->id,'identifier'=>$sco->identifier))) {
+ if ($ss = $DB->get_record('scorm_scoes', array('scorm'=>$scorm->id,
+ 'identifier'=>$sco->identifier))) {
$id = $ss->id;
- $DB->update_record('scorm_scoes',$sco);
+ $DB->update_record('scorm_scoes', $sco);
unset($oldscoes[$id]);
} else {
- $id = $DB->insert_record('scorm_scoes',$sco);
+ $id = $DB->insert_record('scorm_scoes', $sco);
}
if ($launch == 0) {
$launch = $id;
}
if (isset($course->elements)) {
- foreach($course->elements as $element) {
+ foreach ($course->elements as $element) {
unset($sco);
$sco->identifier = $element->system_id;
$sco->scorm = $scorm->id;
@@ -265,14 +277,14 @@ function scorm_parse_aicc($scorm) {
$sco->previous = 0;
$sco->next = 0;
$id = null;
- if ($oldscoid = scorm_array_search('identifier',$sco->identifier,$oldscoes)) {
+ if ($oldscoid = scorm_array_search('identifier', $sco->identifier, $oldscoes)) {
$sco->id = $oldscoid;
- $DB->update_record('scorm_scoes',$sco);
+ $DB->update_record('scorm_scoes', $sco);
$id = $oldscoid;
$DB->delete_records('scorm_scoes_data', array('scoid'=>$oldscoid));
unset($oldscoes[$oldscoid]);
} else {
- $id = $DB->insert_record('scorm_scoes',$sco);
+ $id = $DB->insert_record('scorm_scoes', $sco);
}
if (!empty($id)) {
$scodata = new stdClass();
@@ -280,32 +292,32 @@ function scorm_parse_aicc($scorm) {
if (isset($element->web_launch)) {
$scodata->name = 'parameters';
$scodata->value = $element->web_launch;
- $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->prerequisites)) {
$scodata->name = 'prerequisites';
$scodata->value = $element->prerequisites;
- $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->max_time_allowed)) {
$scodata->name = 'max_time_allowed';
$scodata->value = $element->max_time_allowed;
- $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->time_limit_action)) {
$scodata->name = 'time_limit_action';
$scodata->value = $element->time_limit_action;
- $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->mastery_score)) {
$scodata->name = 'mastery_score';
$scodata->value = $element->mastery_score;
- $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->core_vendor)) {
$scodata->name = 'datafromlms';
$scodata->value = preg_replace('/<cr>/i', "\r\n", $element->core_vendor);
- $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
}
if ($launch==0) {
@@ -317,7 +329,7 @@ function scorm_parse_aicc($scorm) {
}
}
if (!empty($oldscoes)) {
- foreach($oldscoes as $oldsco) {
+ foreach ($oldscoes as $oldsco) {
$DB->delete_records('scorm_scoes', array('id'=>$oldsco->id));
$DB->delete_records('scorm_scoes_track', array('scoid'=>$oldsco->id));
}
@@ -330,7 +342,8 @@ function scorm_parse_aicc($scorm) {
return true;
}
-function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
+function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='',
+ $scoid='', $mode='normal', $attempt='', $play=false, $tocheader=false) {
global $CFG, $DB, $PAGE, $OUTPUT;
$modestr = '';
@@ -353,11 +366,10 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
// Get the current organization infos
//
if (!empty($currentorg)) {
- if (($organizationtitle = $DB->get_field('scorm_scoes','title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
+ if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm'=>$scorm->id, 'identifier'=>$currentorg))) != '') {
if ($play) {
$result->toctitle = "$organizationtitle";
- }
- else {
+ } else {
$result->toc .= "\t<li>$organizationtitle</li>\n";
}
$tocmenus[] = $organizationtitle;
@@ -370,7 +382,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
}
$result->attemptleft = $scorm->maxattempt - $attempt;
- if ($scoes = scorm_get_scoes($scorm->id, $currentorg)){
+ if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
//
// Retrieve user tracking data for each learning object
//
@@ -380,7 +392,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
if (empty($scoid)) {
$scoid = $sco->id;
}
- if ($usertrack = scorm_get_tracks($sco->id,$user->id,$attempt)) {
+ if ($usertrack = scorm_get_tracks($sco->id, $user->id, $attempt)) {
if ($usertrack->status == '') {
$usertrack->status = 'notattempted';
}
@@ -403,7 +415,7 @