Merge branch 'master_MDL-28111' of git://github.com/danmarsden/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2011-07-07 02:36:28 +02:00
43 changed files with 2218 additions and 1925 deletions
-84
View File
@@ -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
+400 -381
View File
@@ -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');
foreach ($_POST as $key => $value) {
$tempkey = strtolower($key);
$_POST[$tempkey] = $value;
}
$command = required_param('command', PARAM_ALPHA);
$sessionid = required_param('session_id', PARAM_ALPHANUM);
$aiccdata = optional_param('aicc_data', '', PARAM_RAW);
$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);
require_login();
if (!empty($command) && confirm_sesskey($sessionid)) {
$command = strtolower($command);
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;
}
$command = required_param('command', PARAM_ALPHA);
$sessionid = required_param('session_id', PARAM_ALPHANUM);
$aiccdata = optional_param('aicc_data', '', PARAM_RAW);
$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);
require_login();
if (!empty($command) && confirm_sesskey($sessionid)) {
$command = strtolower($command);
if (isset($SESSION->scorm_scoid)) {
$scoid = $SESSION->scorm_scoid;
} else {
if ($sco = scorm_get_sco($scoid, SCO_ONLY)) {
if (!$scorm = $DB->get_record('scorm', array('id'=>$sco->scorm))) {
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');
}
} 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 ($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 = '';
}
$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';
}
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";
} else {
echo 'Lesson_Location='."\r\n";
}
echo 'Credit='.$userdata->credit."\r\n";
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 {
$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'};
}
}
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";
} 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
}
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];
}
}
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 = '';
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);
}
}
}
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);
}
}
}
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);
}
$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 {
echo "error=3\r\nerror_text=Invalid Session ID\r\n";
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 ($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 = '';
}
$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';
}
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";
} else {
echo 'Lesson_Location='."\r\n";
}
echo 'Credit='.$userdata->credit."\r\n";
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 {
$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'};
}
}
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";
} 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
}
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];
}
}
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 = '';
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);
}
}
}
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);
}
}
}
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);
}
$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;
}
}
$aiccresponse = ob_get_contents();
scorm_debug_log_write("aicc", "HACP Response:\r\n$aiccresponse", $scoid);
ob_end_flush();
} 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";
}
}
$aiccresponse = ob_get_contents();
scorm_debug_log_write("aicc", "HACP Response:\r\n$aiccresponse", $scoid);
ob_end_flush();
+88 -74
View File
@@ -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 (!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 (! $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;
} 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);
}
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');
}
// 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());
?>
-1
View File
@@ -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
@@ -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 @@ class backup_scorm_activity_task extends backup_activity_task {
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]+)/";
@@ -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
@@ -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
@@ -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
+85 -73
View File
@@ -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.'";';
}
}
}
// 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);
// 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.'";';
}
}
}
}
if ($result) {
echo "true\n0";
} else {
echo "false\n101";
}
if ($request != null) {
echo "\n".$request;
// 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;
}
}
+52 -37
View File
@@ -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 AICCapi() {
<?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) {
+101 -90
View File
@@ -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 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$isvisible = true;
}
if ($parents[$level]!=$sco->parent) {
if ($newlevel = array_search($sco->parent,$parents)) {
if ($newlevel = array_search($sco->parent, $parents)) {
for ($i=0; $i<($level-$newlevel); $i++) {
$result->toc .= "\t\t</li></ul></li>\n";
}
@@ -451,11 +463,11 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
$strstatus = get_string($usertrack->status,'scorm');
$strstatus = get_string($usertrack->status, 'scorm');
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$OUTPUT->pix_url($usertrack->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" />';
} else {
$statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched', 'scorm').'" title="'.get_string('assetlaunched', 'scorm').'" />';
}
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
@@ -464,10 +476,10 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$scoid = $sco->id;
}
}
if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE,$cmid))) {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE, $cmid))) {
$score = '('.get_string('score', 'scorm').':&nbsp;'.$usertrack->score_raw.')';
}
$strsuspended = get_string('suspended','scorm');
$strsuspended = get_string('suspended', 'scorm');
if ($incomplete && isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) {
$statusicon = '<img src="'.$OUTPUT->pix_url('suspend', 'scorm').'" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
}
@@ -477,21 +489,21 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
$incomplete = true;
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted', 'scorm').'" title="'.get_string('notattempted', 'scorm').'" />';
} else {
$statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset', 'scorm').'" title="'.get_string('asset', 'scorm').'" />';
}
}
if ($sco->id == $scoid) {
$findnext = true;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (($nextid == 0) && (scorm_count_launchable($scorm->id, $currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
}
}
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) {
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites, $usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
}
@@ -509,7 +521,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
}
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
$tocmenus[$sco->id] = scorm_repeater('&minus;', $level) . '&gt;' . format_string($sco->title);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
@@ -534,7 +546,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
}
}
for ($i=0;$i<$level;$i++) {
for ($i=0; $i<$level; $i++) {
$result->toc .= "\t\t</ul></li>\n";
}
@@ -556,7 +568,6 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$result->toc .= '<div id="scorm_navpanel"></div>';
}
if ($scorm->hidetoc == 0) {
$result->toc .= html_writer::script(js_writer::set_variable('scormdata', array(
'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
+17 -1
View File
@@ -1,5 +1,21 @@
<?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/>.
this.connectPrereqCallback = {
?>
this.connectPrereqCallback = {
success: function(o) {
scorm_tree_node = YAHOO.widget.TreeView.getTree('scorm_tree');
+22 -4
View File
@@ -1,3 +1,21 @@
<?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/>.
?>
<!--// hopefully fool ie IE proof way of getting DOM element
function safeGetElement(doc, el) {
return doc.ids ? doc.ids[el] : doc.getElementById ? doc.getElementById(el) : doc.all[el];
@@ -52,11 +70,11 @@ function toggleLog () {
if (getLoggingActive() == "A") {
AppendToLog("Moodle Logging Deactivated", 0);
setLoggingActive('N');
logButton.innerHTML = '--><?php print_string('scormloggingoff','scorm') ?>';
logButton.innerHTML = '--><?php print_string('scormloggingoff', 'scorm') ?>';
} else {
setLoggingActive('A');
AppendToLog("Moodle Logging Activated", 0);
logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
logButton.innerHTML = '<?php print_string('scormloggingon', 'scorm') ?>';
logPopUpWindow.focus();
}
}
@@ -729,9 +747,9 @@ logButton.id = 'mod-scorm-log-toggle';
logButton.name = 'logToggle';
logButton.href = 'javascript:toggleLog();';
if (getLoggingActive() == "A") {
logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
logButton.innerHTML = '<?php print_string('scormloggingon', 'scorm') ?>';
} else {
logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
logButton.innerHTML = '<?php print_string('scormloggingoff', 'scorm') ?>';
}
var content = safeGetElement(document, 'scormpage');
content.insertBefore(logButton, content.firstChild);
+31 -24
View File
@@ -1,20 +1,35 @@
<?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/>.
if (isset($userdata->status)) {
if ($userdata->status == '') {
$userdata->entry = 'ab-initio';
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
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
@@ -165,7 +180,6 @@ function SCORMapi1_2() {
errorCode = "0";
<?php
if (scorm_debugging($scorm)) {
//echo 'alert("Initialized SCORM 1.2");';
echo 'LogAPICall("LMSInitialize", param, "", errorCode);';
}
?>
@@ -186,8 +200,8 @@ function SCORMapi1_2() {
<?php
// pull in the TOC callback
include_once($CFG->dirroot.'/mod/scorm/datamodels/callback.js.php');
?>
require_once($CFG->dirroot.'/mod/scorm/datamodels/callback.js.php');
?>
function LMSFinish (param) {
errorCode = "0";
@@ -215,7 +229,6 @@ function SCORMapi1_2() {
errorCode = (result == 'true')? '0' : '101';
<?php
if (scorm_debugging($scorm)) {
//echo 'alert("Finished SCORM 1.2");';
echo 'LogAPICall("LMSFinish", "result", result, 0);';
echo 'LogAPICall("LMSFinish", param, "", 0);';
}
@@ -257,7 +270,6 @@ function SCORMapi1_2() {
errorCode = "0";
<?php
if (scorm_debugging($scorm)) {
//echo 'alert(element+": "+eval(element));';
echo 'LogAPICall("LMSGetValue", element, eval(element), 0);';
}
?>
@@ -368,7 +380,6 @@ function SCORMapi1_2() {
<?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
//echo 'alert(element+":= "+value);';
}
?>
return "true";
@@ -385,7 +396,6 @@ function SCORMapi1_2() {
<?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
//echo 'alert(element+":= "+value);';
}
?>
return "true";
@@ -422,7 +432,6 @@ function SCORMapi1_2() {
<?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("Commit", param, "", 0);';
//echo 'alert("Data Commited");';
}
?>
<?php
@@ -434,7 +443,6 @@ function SCORMapi1_2() {
errorCode = (result =='true')? '0' : '101';
<?php
if (scorm_debugging($scorm)) {
//echo 'alert("Finished SCORM 1.2");';
echo 'LogAPICall("LMSCommit", "result", result, 0);';
echo 'LogAPICall("LMSCommit", "errorCode", errorCode, 0);';
}
@@ -640,8 +648,7 @@ var API = new SCORMapi1_2();
<?php
// pull in the debugging utilities
if (scorm_debugging($scorm)) {
include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
echo 'AppendToLog("Moodle SCORM 1.2 API Loaded, Activity: '.$scorm->name.', SCO: '.$sco->identifier.'", 0);';
include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
echo 'AppendToLog("Moodle SCORM 1.2 API Loaded, Activity: '.$scorm->name.', SCO: '.$sco->identifier.'", 0);';
}
?>
+52 -31
View File
@@ -1,13 +1,28 @@
<?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/>.
/**
* This is really a little language parser for AICC_SCRIPT
* evaluates the expression and returns a boolean answer
* see 2.3.2.5.1. Sequencing/Navigation Today - from the SCORM 1.2 spec (CAM).
*
* @param string $prerequisites the aicc_script prerequisites expression
* @param array $usertracks the tracked user data of each SCO visited
* @return boolean
*/
* This is really a little language parser for AICC_SCRIPT
* evaluates the expression and returns a boolean answer
* see 2.3.2.5.1. Sequencing/Navigation Today - from the SCORM 1.2 spec (CAM).
*
* @param string $prerequisites the aicc_script prerequisites expression
* @param array $usertracks the tracked user data of each SCO visited
* @return boolean
*/
function scorm_eval_prerequisites($prerequisites, $usertracks) {
// this is really a little language parser - AICC_SCRIPT is the reference
@@ -57,10 +72,10 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) {
$set = explode(',', $matches[2]);
$count = 0;
foreach ($set as $setelement) {
if (isset($usertracks[$setelement]) &&
($usertracks[$setelement]->status == 'completed' || $usertracks[$setelement]->status == 'passed')) {
$count++;
}
if (isset($usertracks[$setelement]) &&
($usertracks[$setelement]->status == 'completed' || $usertracks[$setelement]->status == 'passed')) {
$count++;
}
}
if ($count >= $repeat) {
$element = 'true';
@@ -106,7 +121,8 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) {
return eval('return '.implode($stack).';');
}
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 = '';
@@ -129,11 +145,12 @@ 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;
@@ -148,14 +165,14 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
$result->attemptleft = $scorm->maxattempt == 0 ? 1 : $scorm->maxattempt - $attempt;
$conditions['scorm'] = $scorm->id;
if ($scoes = scorm_get_scoes($scorm->id, $currentorg)){
if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
//
// Retrieve user tracking data for each learning object
//
$usertracks = array();
foreach ($scoes as $sco) {
if (!empty($sco->launch)) {
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';
}
@@ -178,7 +195,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$isvisible = true;
}
if ($parents[$level] != $sco->parent) {
if ($newlevel = array_search($sco->parent,$parents)) {
if ($newlevel = array_search($sco->parent, $parents)) {
for ($i=0; $i<($level-$newlevel); $i++) {
$result->toc .= "\t\t</li></ul></li>\n";
}
@@ -226,11 +243,11 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
$strstatus = get_string($usertrack->status,'scorm');
$strstatus = get_string($usertrack->status, 'scorm');
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$OUTPUT->pix_url($usertrack->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" />';
} else {
$statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched', 'scorm').'" title="'.get_string('assetlaunched', 'scorm').'" />';
}
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
@@ -239,12 +256,13 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$scoid = $sco->id;
}
}
if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE,$cmid))) {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE, $cmid))) {
$score = '('.get_string('score', 'scorm').':&nbsp;'.$usertrack->score_raw.')';
}
$strsuspended = get_string('suspended','scorm');
$strsuspended = get_string('suspended', 'scorm');
if ($incomplete && isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) {
$statusicon = '<img src="'.$OUTPUT->pix_url('suspend', 'scorm').'" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('suspend', 'scorm').'" alt="'.
$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
}
} else {
if ($play && empty($scoid)) {
@@ -252,16 +270,20 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
$incomplete = true;
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').
'" alt="'.get_string('notattempted', 'scorm').'" title="'.
get_string('notattempted', 'scorm').'" />';
} else {
$statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').
'" alt="'.get_string('asset', 'scorm').'" title="'.
get_string('asset', 'scorm').'" />';
}
}
if ($sco->id == $scoid) {
$findnext = true;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (($nextid == 0) && (scorm_count_launchable($scorm->id, $currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
}
@@ -283,7 +305,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
}
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
$tocmenus[$sco->id] = scorm_repeater('&minus;', $level) . '&gt;' . format_string($sco->title);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
@@ -308,7 +330,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
}
}
for ($i=0;$i<$level;$i++) {
for ($i=0; $i<$level; $i++) {
$result->toc .= "\t\t</ul></li>\n";
}
@@ -333,7 +355,6 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$result->toc .= '<div id="scorm_navpanel"></div>';
}
if ($scorm->hidetoc == 0) {
$PAGE->requires->data_for_js('scormdata', array(
'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
+27 -13
View File
@@ -1,20 +1,35 @@
<?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/>.
if (isset($userdata->status)) {
if (!isset($userdata->{'cmi.exit'}) || (($userdata->{'cmi.exit'} == 'time-out') || ($userdata->{'cmi.exit'} == 'normal'))) {
$userdata->entry = 'ab-initio';
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
if (isset($userdata->status)) {
if (!isset($userdata->{'cmi.exit'}) || (($userdata->{'cmi.exit'} == 'time-out') || ($userdata->{'cmi.exit'} == 'normal'))) {
$userdata->entry = 'ab-initio';
} else {
if (isset($userdata->{'cmi.exit'}) && (($userdata->{'cmi.exit'} == 'suspend') || ($userdata->{'cmi.exit'} == 'logout'))) {
$userdata->entry = 'resume';
} else {
if (isset($userdata->{'cmi.exit'}) && (($userdata->{'cmi.exit'} == 'suspend') || ($userdata->{'cmi.exit'} == 'logout'))) {
$userdata->entry = 'resume';
} else {
$userdata->entry = '';
}
$userdata->entry = '';
}
}
if (!isset($currentorg)) {
$currentorg = '';
}
}
if (!isset($currentorg)) {
$currentorg = '';
}
?>
// Used need to debug cmi content (if you uncomment this, you must comment the definition inside SCORMapi1_3)
@@ -1283,4 +1298,3 @@ if (scorm_debugging($scorm)) {
include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
echo 'AppendToLog("Moodle SCORM 1.3 API Loaded, Activity: '.$scorm->name.', SCO: '.$sco->identifier.'", 0);';
}
?>
+36 -21
View File
@@ -1,6 +1,22 @@
<?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_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 = '';
@@ -23,11 +39,12 @@ 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 {
$result->toctitle = "$organizationtitle";
} else {
$result->toc .= "\t<li>$organizationtitle</li>\n";
}
$tocmenus[] = $organizationtitle;
@@ -40,7 +57,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
//
@@ -48,7 +65,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$usertracks = array();
foreach ($scoes as $sco) {
if (!empty($sco->launch)) {
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';
}
@@ -70,7 +87,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$isvisible = true;
}
if ($parents[$level]!=$sco->parent) {
if ($newlevel = array_search($sco->parent,$parents)) {
if ($newlevel = array_search($sco->parent, $parents)) {
for ($i=0; $i<($level-$newlevel); $i++) {
$result->toc .= "\t\t</li></ul></li>\n";
}
@@ -119,11 +136,11 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
$strstatus = get_string($usertrack->status,'scorm');
$strstatus = get_string($usertrack->status, 'scorm');
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$OUTPUT->pix_url($usertrack->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" />';
} else {
$statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched', 'scorm').'" title="'.get_string('assetlaunched', 'scorm').'" />';
}
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
@@ -132,10 +149,10 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$scoid = $sco->id;
}
}
if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE,$cmid))) {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE, $cmid))) {
$score = '('.get_string('score', 'scorm').':&nbsp;'.$usertrack->score_raw.')';
}
$strsuspended = get_string('suspended','scorm');
$strsuspended = get_string('suspended', 'scorm');
if ($incomplete && isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} == 'suspend')) {
$statusicon = '<img src="'.$OUTPUT->pix_url('suspend', 'scorm').'" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
}
@@ -144,10 +161,10 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$scoid = $sco->id;
}
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted', 'scorm').'" title="'.get_string('notattempted', 'scorm').'" />';
$incomplete = true;
} else {
$statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
$statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset', 'scorm').'" title="'.get_string('asset', 'scorm').'" />';
}
}
@@ -155,13 +172,13 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$findnext = true;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (($nextid == 0) && (scorm_count_launchable($scorm->id, $currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
}
}
require_once($CFG->dirroot.'/mod/scorm/datamodels/sequencinglib.php');
if (scorm_seq_evaluate($sco->id,$usertracks)) {
if (scorm_seq_evaluate($sco->id, $usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
}
@@ -177,7 +194,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
}
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
$tocmenus[$sco->id] = scorm_repeater('&minus;', $level) . '&gt;' . format_string($sco->title);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
@@ -202,7 +219,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
}
}
for ($i=0;$i<$level;$i++) {
for ($i=0; $i<$level; $i++) {
$result->toc .= "\t\t</ul></li>\n";
}
@@ -221,14 +238,12 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
}
$result->toc .= '</ul>';
// NEW IMS TOC
if ($tocheader) {
$result->toc .= '</div></div></div>';
$result->toc .= '<div id="scorm_navpanel"></div>';
}
if ($scorm->hidetoc == 0) {
$PAGE->requires->data_for_js('scormdata', array(
'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
+126 -116
View File
@@ -1,4 +1,19 @@
<?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_get_resources($blocks) {
$resources = array();
foreach ($blocks as $block) {
@@ -13,7 +28,7 @@ function scorm_get_resources($blocks) {
return $resources;
}
function scorm_get_manifest($blocks,$scoes) {
function scorm_get_manifest($blocks, $scoes) {
static $parents = array();
static $resources;
@@ -28,10 +43,10 @@ function scorm_get_manifest($blocks,$scoes) {
foreach ($block['children'] as $metadata) {
if ($metadata['name'] == 'SCHEMAVERSION') {
if (empty($scoes->version)) {
if (isset($metadata['tagData']) && (preg_match("/^(1\.2)$|^(CAM )?(1\.3)$/",$metadata['tagData'],$matches))) {
if (isset($metadata['tagData']) && (preg_match("/^(1\.2)$|^(CAM )?(1\.3)$/", $metadata['tagData'], $matches))) {
$scoes->version = 'SCORM_'.$matches[count($matches)-1];
} else {
if (isset($metadata['tagData']) && (preg_match("/^2004 (3rd|4th) Edition$/",$metadata['tagData'],$matches))) {
if (isset($metadata['tagData']) && (preg_match("/^2004 (3rd|4th) Edition$/", $metadata['tagData'], $matches))) {
$scoes->version = 'SCORM_1.3';
} else {
$scoes->version = 'SCORM_1.2';
@@ -47,7 +62,7 @@ function scorm_get_manifest($blocks,$scoes) {
$organization = '';
$resources = array();
$resources = scorm_get_resources($block['children']);
$scoes = scorm_get_manifest($block['children'],$scoes);
$scoes = scorm_get_manifest($block['children'], $scoes);
if (empty($scoes->elements) || count($scoes->elements) <= 0) {
foreach ($resources as $item => $resource) {
if (!empty($resource['HREF'])) {
@@ -67,7 +82,7 @@ function scorm_get_manifest($blocks,$scoes) {
$scoes->defaultorg = $block['attrs']['DEFAULT'];
}
if (!empty($block['children'])) {
$scoes = scorm_get_manifest($block['children'],$scoes);
$scoes = scorm_get_manifest($block['children'], $scoes);
}
break;
case 'ORGANIZATION':
@@ -86,7 +101,7 @@ function scorm_get_manifest($blocks,$scoes) {
$organization = $identifier;
if (!empty($block['children'])) {
$scoes = scorm_get_manifest($block['children'],$scoes);
$scoes = scorm_get_manifest($block['children'], $scoes);
}
array_pop($parents);
@@ -128,7 +143,7 @@ function scorm_get_manifest($blocks,$scoes) {
array_push($parents, $parent);
if (!empty($block['children'])) {
$scoes = scorm_get_manifest($block['children'],$scoes);
$scoes = scorm_get_manifest($block['children'], $scoes);
}
array_pop($parents);
@@ -309,7 +324,7 @@ function scorm_get_manifest($blocks,$scoes) {
if (isset($objectiveparam['attrs']['WRITENORMALIZEDMEASURE'])) {
$mapinfo->writenormalizemeasure = $objectiveparam['attrs']['WRITENORMALIZEDMEASURE'] == 'true'?1:0;
}
array_push($mapinfos,$mapinfo);
array_push($mapinfos, $mapinfo);
}
}
if (!empty($mapinfos)) {
@@ -318,8 +333,7 @@ function scorm_get_manifest($blocks,$scoes) {
}
break;
}
//print_object($objectivedata);
array_push($objectives,$objectivedata);
array_push($objectives, $objectivedata);
}
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->objectives = $objectives;
}
@@ -342,7 +356,7 @@ function scorm_get_manifest($blocks,$scoes) {
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->objectivemeasureweight = $sequencing['attrs']['OBJECTIVEMEASUREWEIGHT'];
}
if (!empty($sequencing['children'])){
if (!empty($sequencing['children'])) {
$rolluprules = array();
foreach ($sequencing['children'] as $sequencingrolluprule) {
if ($sequencingrolluprule['name']=='IMSSS:ROLLUPRULE' ) {
@@ -377,7 +391,7 @@ function scorm_get_manifest($blocks,$scoes) {
if (isset($rolluprulecondition['attrs']['OPERATOR'])) {
$condition->operator = $rolluprulecondition['attrs']['OPERATOR'];
}
array_push($conditions,$condition);
array_push($conditions, $condition);
}
}
$rolluprule->conditions = $conditions;
@@ -437,7 +451,7 @@ function scorm_get_manifest($blocks,$scoes) {
if (isset($rulecondition['attrs']['REFERENCEDOBJECTIVE'])) {
$condition->referencedobjective = $rulecondition['attrs']['REFERENCEDOBJECTIVE'];
}
array_push($ruleconditions,$condition);
array_push($ruleconditions, $condition);
}
}
$sequencingrule->ruleconditions = $ruleconditions;
@@ -447,7 +461,7 @@ function scorm_get_manifest($blocks,$scoes) {
}
$sequencingrule->type = $conditiontype;
}
array_push($sequencingrules,$sequencingrule);
array_push($sequencingrules, $sequencingrule);
}
}
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->sequencingrules = $sequencingrules;
@@ -469,7 +483,7 @@ function scorm_parse_scorm($scorm, $manifest) {
if ($manifest instanceof stored_file) {
$xmltext = $manifest->get_content();
} else {
require_once "$CFG->libdir/filelib.php";
require_once("$CFG->libdir/filelib.php");
$xmltext = download_file_content($manifest);
}
@@ -481,11 +495,9 @@ function scorm_parse_scorm($scorm, $manifest) {
$objXML = new xml2Array();
$manifests = $objXML->parse($xmltext);
//print_object($manifests);
$scoes = new stdClass();
$scoes->version = '';
$scoes = scorm_get_manifest($manifests,$scoes);
//print_object($scoes);
$scoes = scorm_get_manifest($manifests, $scoes);
if (count($scoes->elements) > 0) {
$olditems = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id));
foreach ($scoes->elements as $manifest => $organizations) {
@@ -504,47 +516,47 @@ function scorm_parse_scorm($scorm, $manifest) {
}
// Insert the new SCO, and retain the link between the old and new for later adjustment
$id = $DB->insert_record('scorm_scoes',$newitem);
if (!empty($olditems) && ($olditemid = scorm_array_search('identifier',$newitem->identifier,$olditems))) {
$id = $DB->insert_record('scorm_scoes', $newitem);
if (!empty($olditems) && ($olditemid = scorm_array_search('identifier', $newitem->identifier, $olditems))) {
$olditems[$olditemid]->newid = $id;
}
if ($optionaldatas = scorm_optionals_data($item,$standarddatas)) {
if ($optionaldatas = scorm_optionals_data($item, $standarddatas)) {
$data = new stdClass();
$data->scoid = $id;
foreach ($optionaldatas as $optionaldata) {
if (isset($item->$optionaldata)) {
$data->name = $optionaldata;
$data->value = $item->$optionaldata;
$dataid = $DB->insert_record('scorm_scoes_data',$data);
$dataid = $DB->insert_record('scorm_scoes_data', $data);
}
}
}
if (isset($item->sequencingrules)) {
foreach($item->sequencingrules as $sequencingrule) {
foreach ($item->sequencingrules as $sequencingrule) {
$rule = new stdClass();
$rule->scoid = $id;
$rule->ruletype = $sequencingrule->type;
$rule->conditioncombination = $sequencingrule->conditioncombination;
$rule->action = $sequencingrule->action;
$ruleid = $DB->insert_record('scorm_seq_ruleconds',$rule);
$ruleid = $DB->insert_record('scorm_seq_ruleconds', $rule);
if (isset($sequencingrule->ruleconditions)) {
foreach($sequencingrule->ruleconditions as $rulecondition) {
foreach ($sequencingrule->ruleconditions as $rulecondition) {
$rulecond = new stdClass();
$rulecond->scoid = $id;
$rulecond->ruleconditionsid = $ruleid;
$rulecond->referencedobjective = $rulecondition->referencedobjective;
$rulecond->measurethreshold = $rulecondition->measurethreshold;
$rulecond->cond = $rulecondition->cond;
$rulecondid = $DB->insert_record('scorm_seq_rulecond',$rulecond);
$rulecondid = $DB->insert_record('scorm_seq_rulecond', $rulecond);
}
}
}
}
if (isset($item->rolluprules)) {
foreach($item->rolluprules as $rolluprule) {
foreach ($item->rolluprules as $rolluprule) {
$rollup = new stdClass();
$rollup->scoid = $id;
$rollup->childactivityset = $rolluprule->childactivityset;
@@ -553,32 +565,31 @@ function scorm_parse_scorm($scorm, $manifest) {
$rollup->rollupruleaction = $rolluprule->rollupruleaction;
$rollup->conditioncombination = $rolluprule->conditioncombination;
$rollupruleid = $DB->insert_record('scorm_seq_rolluprule',$rollup);
$rollupruleid = $DB->insert_record('scorm_seq_rolluprule', $rollup);
if (isset($rollup->conditions)) {
foreach($rollup->conditions as $condition){
foreach ($rollup->conditions as $condition) {
$cond = new stdClass();
$cond->scoid = $rollup->scoid;
$cond->rollupruleid = $rollupruleid;
$cond->operator = $condition->operator;
$cond->cond = $condition->cond;
$conditionid = $DB->insert_record('scorm_seq_rolluprulecond',$cond);
$conditionid = $DB->insert_record('scorm_seq_rolluprulecond', $cond);
}
}
}
}
if (isset($item->objectives)) {
foreach($item->objectives as $objective) {
foreach ($item->objectives as $objective) {
$obj = new stdClass();
$obj->scoid = $id;
$obj->primaryobj = $objective->primaryobj;
$obj->satisfiedbumeasure = $objective->satisfiedbymeasure;
$obj->objectiveid = $objective->objectiveid;
$obj->minnormalizedmeasure = $objective->minnormalizedmeasure;
$objectiveid = $DB->insert_record('scorm_seq_objective',$obj);
$objectiveid = $DB->insert_record('scorm_seq_objective', $obj);
if (isset($objective->mapinfos)) {
//print_object($objective->mapinfos);
foreach($objective->mapinfos as $objmapinfo) {
foreach ($objective->mapinfos as $objmapinfo) {
$mapinfo = new stdClass();
$mapinfo->scoid = $id;
$mapinfo->objectiveid = $objectiveid;
@@ -587,12 +598,11 @@ function scorm_parse_scorm($scorm, $manifest) {
$mapinfo->writesatisfiedstatus = $objmapinfo->writesatisfiedstatus;
$mapinfo->readnormalizedmeasure = $objmapinfo->readnormalizedmeasure;
$mapinfo->writenormalizedmeasure = $objmapinfo->writenormalizedmeasure;
$mapinfoid = $DB->insert_record('scorm_seq_mapinfo',$mapinfo);
$mapinfoid = $DB->insert_record('scorm_seq_mapinfo', $mapinfo);
}
}
}
}
//print_object($item);
if (($launch == 0) && ((empty($scoes->defaultorg)) || ($scoes->defaultorg == $identifier))) {
$launch = $id;
}
@@ -600,13 +610,13 @@ function scorm_parse_scorm($scorm, $manifest) {
}
}
if (!empty($olditems)) {
foreach($olditems as $olditem) {
foreach ($olditems as $olditem) {
$DB->delete_records('scorm_scoes', array('id'=>$olditem->id));
$DB->delete_records('scorm_scoes_data',array('scoid'=>$olditem->id));
$DB->delete_records('scorm_scoes_data', array('scoid'=>$olditem->id));
if (isset($olditem->newid)) {
$DB->set_field('scorm_scoes_track', 'scoid', $olditem->newid, array('scoid' => $olditem->id));
}
$DB->delete_records('scorm_scoes_track',array('scoid'=>$olditem->id));
$DB->delete_records('scorm_scoes_track', array('scoid'=>$olditem->id));
$DB->delete_records('scorm_seq_objective', array('scoid'=>$olditem->id));
$DB->delete_records('scorm_seq_mapinfo', array('scoid'=>$olditem->id));
$DB->delete_records('scorm_seq_ruleconds', array('scoid'=>$olditem->id));
@@ -618,7 +628,7 @@ function scorm_parse_scorm($scorm, $manifest) {
if (empty($scoes->version)) {
$scoes->version = 'SCORM_1.2';
}
$DB->set_field('scorm','version',$scoes->version, array('id'=>$scorm->id));
$DB->set_field('scorm', 'version', $scoes->version, array('id'=>$scorm->id));
$scorm->version = $scoes->version;
}
@@ -629,7 +639,7 @@ function scorm_parse_scorm($scorm, $manifest) {
function scorm_optionals_data($item, $standarddata) {
$result = array();
$sequencingdata = array('sequencingrules','rolluprules','objectives');
$sequencingdata = array('sequencingrules', 'rolluprules', 'objectives');
foreach ($item as $element => $value) {
if (! in_array($element, $standarddata)) {
if (! in_array($element, $sequencingdata)) {
@@ -653,7 +663,7 @@ function scorm_get_parent($sco) {
global $DB;
if ($sco->parent != '/') {
if ($parent = $DB->get_record('scorm_scoes', array('scorm'=>$sco->scorm,'identifier'=>$sco->parent))) {
if ($parent = $DB->get_record('scorm_scoes', array('scorm'=>$sco->scorm, 'identifier'=>$sco->parent))) {
return scorm_get_sco($parent->id);
}
}
@@ -663,35 +673,35 @@ function scorm_get_parent($sco) {
function scorm_get_children($sco) {
global $DB;
if ($children = $DB->get_records('scorm_scoes', array('scorm'=>$sco->scorm,'parent'=>$sco->identifier))) {//originally this said parent instead of childrean
if ($children = $DB->get_records('scorm_scoes', array('scorm'=>$sco->scorm, 'parent'=>$sco->identifier))) {//originally this said parent instead of childrean
return $children;
}
return null;
}
function scorm_get_available_children($sco){
function scorm_get_available_children($sco) { // TODO: undefined vars!!!
global $DB;
$res = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'element'=>'availablechildren')); // TODO: undefined!!!
if(!$res || $res == null){
$res = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,
'userid'=>$userid,
'element'=>'availablechildren'));
if (!$res || $res == null) {
return false;
}
else{
} else {
return unserialize($res->value);
}
}
function scorm_get_available_descendent($descend = array(),$sco){
if($sco == null){
function scorm_get_available_descendent($descend = array(), $sco) {
if ($sco == null) {
return $descend;
}
else{
} else {
$avchildren = scorm_get_available_children($sco);
foreach($avchildren as $avchild){
array_push($descend,$avchild);
foreach ($avchildren as $avchild) {
array_push($descend, $avchild);
}
foreach($avchildren as $avchild){
scorm_get_available_descendent($descend,$avchild);
foreach ($avchildren as $avchild) {
scorm_get_available_descendent($descend, $avchild);
}
}
}
@@ -699,7 +709,7 @@ function scorm_get_available_descendent($descend = array(),$sco){
function scorm_get_siblings($sco) {
global $DB;
if ($siblings = $DB->get_records('scorm_scoes', array('scorm'=>$sco->scorm,'parent'=>$sco->parent))) {
if ($siblings = $DB->get_records('scorm_scoes', array('scorm'=>$sco->scorm, 'parent'=>$sco->parent))) {
unset($siblings[$sco->id]);
if (!empty($siblings)) {
return $siblings;
@@ -711,7 +721,7 @@ function scorm_get_siblings($sco) {
function scorm_get_ancestors($sco) {
$ancestors = array();
$continue = true;
While ($continue) {
while ($continue) {
$ancestor = scorm_get_parent($sco);
if (!empty($ancestor) && $ancestor->id !== $sco->id) {
$sco = $ancestor;
@@ -726,11 +736,11 @@ function scorm_get_ancestors($sco) {
return $ancestors;
}
function scorm_get_preorder($preorder=array(),$sco) {
function scorm_get_preorder($preorder=array(), $sco) {
if ($sco != null) {
array_push($preorder,$sco);
array_push($preorder, $sco);
$children = scorm_get_children($sco);
foreach ($children as $child){
foreach ($children as $child) {
scorm_get_preorder($sco);
}
} else {
@@ -739,10 +749,10 @@ function scorm_get_preorder($preorder=array(),$sco) {
}
function scorm_find_common_ancestor($ancestors, $sco) {
$pos = scorm_array_search('identifier',$sco->parent,$ancestors);
$pos = scorm_array_search('identifier', $sco->parent, $ancestors);
if ($sco->parent != '/') {
if ($pos === false) {
return scorm_find_common_ancestor($ancestors,scorm_get_parent($sco));
return scorm_find_common_ancestor($ancestors, scorm_get_parent($sco));
}
}
return $pos;
@@ -758,69 +768,69 @@ function scorm_find_common_ancestor($ancestors, $sco) {
*/
class xml2Array {
var $arrOutput = array();
var $resParser;
var $strXmlData;
var $arrOutput = array();
var $resParser;
var $strXmlData;
/**
* Convert a utf-8 string to html entities
*
* @param string $str The UTF-8 string
* @return string
*/
function utf8_to_entities($str) {
global $CFG;
/**
* Convert a utf-8 string to html entities
*
* @param string $str The UTF-8 string
* @return string
*/
function utf8_to_entities($str) {
global $CFG;
$entities = '';
$values = array();
$lookingfor = 1;
$entities = '';
$values = array();
$lookingfor = 1;
return $str;
}
return $str;
}
/**
* Parse an XML text string and create an array tree that rapresent the XML structure
*
* @param string $strInputXML The XML string
* @return array
*/
function parse($strInputXML) {
$this->resParser = xml_parser_create ('UTF-8');
xml_set_object($this->resParser,$this);
xml_set_element_handler($this->resParser, "tagOpen", "tagClosed");
/**
* Parse an XML text string and create an array tree that rapresent the XML structure
*
* @param string $strInputXML The XML string
* @return array
*/
function parse($strInputXML) {
$this->resParser = xml_parser_create ('UTF-8');
xml_set_object($this->resParser, $this);
xml_set_element_handler($this->resParser, "tagOpen", "tagClosed");
xml_set_character_data_handler($this->resParser, "tagData");
xml_set_character_data_handler($this->resParser, "tagData");
$this->strXmlData = xml_parse($this->resParser,$strInputXML );
if(!$this->strXmlData) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->resParser)),
xml_get_current_line_number($this->resParser)));
}
$this->strXmlData = xml_parse($this->resParser, $strInputXML );
if (!$this->strXmlData) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->resParser)),
xml_get_current_line_number($this->resParser)));
}
xml_parser_free($this->resParser);
xml_parser_free($this->resParser);
return $this->arrOutput;
}
return $this->arrOutput;
}
function tagOpen($parser, $name, $attrs) {
$tag=array("name"=>$name,"attrs"=>$attrs);
array_push($this->arrOutput,$tag);
}
function tagOpen($parser, $name, $attrs) {
$tag=array("name"=>$name, "attrs"=>$attrs);
array_push($this->arrOutput, $tag);
}
function tagData($parser, $tagData) {
if(trim($tagData)) {
if(isset($this->arrOutput[count($this->arrOutput)-1]['tagData'])) {
$this->arrOutput[count($this->arrOutput)-1]['tagData'] .= $this->utf8_to_entities($tagData);
} else {
$this->arrOutput[count($this->arrOutput)-1]['tagData'] = $this->utf8_to_entities($tagData);
}
}
}
function tagData($parser, $tagData) {
if (trim($tagData)) {
if (isset($this->arrOutput[count($this->arrOutput)-1]['tagData'])) {
$this->arrOutput[count($this->arrOutput)-1]['tagData'] .= $this->utf8_to_entities($tagData);
} else {
$this->arrOutput[count($this->arrOutput)-1]['tagData'] = $this->utf8_to_entities($tagData);
}
}
}
function tagClosed($parser, $name) {
$this->arrOutput[count($this->arrOutput)-2]['children'][] = $this->arrOutput[count($this->arrOutput)-1];
array_pop($this->arrOutput);
}
function tagClosed($parser, $name) {
$this->arrOutput[count($this->arrOutput)-2]['children'][] = $this->arrOutput[count($this->arrOutput)-1];
array_pop($this->arrOutput);
}
}
+15
View File
@@ -1,4 +1,19 @@
<?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 ($CFG->dirroot.'/mod/scorm/datamodels/scormlib.php');
function scorm_seq_evaluate($scoid,$usertracks) {
+19 -25
View File
@@ -1,33 +1,27 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Capability definitions for the scorm module.
// 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.
//
// The capabilities are loaded into the database table when the module is
// installed or updated. Whenever the capability definitions are updated,
// the module version number should be bumped up.
// 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.
//
// The system has four possible values for a capability:
// CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
//
//
// CAPABILITY NAMING CONVENTION
//
// It is important that capability names are unique. The naming convention
// for capabilities that are specific to modules and blocks is as follows:
// [mod/block]/<plugin_name>:<capabilityname>
//
// component_name should be the same as the directory name of the mod or block.
//
// Core moodle capabilities are defined thus:
// moodle/<capabilityclass>:<capabilityname>
//
// Examples: mod/forum:viewpost
// block/recent_activity:view
// moodle/site:deleteuser
//
// The variable name for the capability definitions array is $capabilities
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capability definitions for the quiz module.
*
* @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
*/
$capabilities = array(
'mod/scorm:viewreport' => array(
-1
View File
@@ -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
+23 -19
View File
@@ -1,24 +1,28 @@
<?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/>.
/**
* Upgrade script for the scorm module.
*
* @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
*/
// This file keeps track of upgrades to
// the scorm module
//
// Sometimes, changes between versions involve
// alterations to database structures and other
// major things that may break installations.
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
// your older installation to the current version.
//
// If there's something it cannot do itself, it
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
/**
* @global moodle_database $DB
-1
View File
@@ -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
+31 -17
View File
@@ -1,25 +1,39 @@
<?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("../../config.php");
$id = required_param('id', PARAM_INT); // Course module ID
$id = required_param('id', PARAM_INT); // Course module ID
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
print_error('invalidcoursemodule');
}
if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record('course', array('id'=> $scorm->course))) {
print_error('coursemisconf');
}
if (! $course = $DB->get_record('course', array('id'=> $scorm->course))) {
print_error('coursemisconf');
}
require_login($course->id, false, $cm);
require_login($course->id, false, $cm);
if (has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE, $cm->id))) {
redirect('report.php?id='.$cm->id);
} else {
redirect('view.php?id='.$cm->id);
}
if (has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE, $cm->id))) {
redirect('report.php?id='.$cm->id);
} else {
redirect('view.php?id='.$cm->id);
}
+102 -91
View File
@@ -1,105 +1,116 @@
<?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($CFG->dirroot.'/mod/scorm/locallib.php');
require_once("../../config.php");
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$id = required_param('id', PARAM_INT); // course id
$id = required_param('id', PARAM_INT); // course id
$PAGE->set_url('/mod/scorm/index.php', array('id'=>$id));
$PAGE->set_url('/mod/scorm/index.php', array('id'=>$id));
if (!empty($id)) {
if (!$course = $DB->get_record('course', array('id'=>$id))) {
print_error('invalidcourseid');
if (!empty($id)) {
if (!$course = $DB->get_record('course', array('id'=>$id))) {
print_error('invalidcourseid');
}
} else {
print_error('missingparameter');
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
$strscorm = get_string("modulename", "scorm");
$strscorms = get_string("modulenameplural", "scorm");
$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
$strsummary = get_string("summary");
$strreport = get_string("report", 'scorm');
$strlastmodified = get_string("lastmodified");
$PAGE->set_title($strscorms);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strscorms);
echo $OUTPUT->header();
$usesections = course_format_uses_sections($course->format);
if ($usesections) {
$sections = get_all_sections($course->id);
}
if ($usesections) {
$sortorder = "cw.section ASC";
} else {
$sortorder = "m.timemodified DESC";
}
if (! $scorms = get_all_instances_in_course("scorm", $course)) {
notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id");
exit;
}
$table = new html_table();
if ($usesections) {
$table->head = array ($strsectionname, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else {
$table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
$table->align = array ("left", "left", "left", "left");
}
foreach ($scorms as $scorm) {
$context = get_context_instance(CONTEXT_MODULE, $scorm->coursemodule);
$tt = "";
if ($usesections) {
if ($scorm->section) {
$tt = get_section_name($course, $sections[$scorm->section]);
}
} else {
print_error('missingparameter');
$tt = userdate($scorm->timemodified);
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
$strscorm = get_string("modulename", "scorm");
$strscorms = get_string("modulenameplural", "scorm");
$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
$strsummary = get_string("summary");
$strreport = get_string("report",'scorm');
$strlastmodified = get_string("lastmodified");
$PAGE->set_title($strscorms);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strscorms);
echo $OUTPUT->header();
$usesections = course_format_uses_sections($course->format);
if ($usesections) {
$sections = get_all_sections($course->id);
}
if ($usesections) {
$sortorder = "cw.section ASC";
} else {
$sortorder = "m.timemodified DESC";
}
if (! $scorms = get_all_instances_in_course("scorm", $course)) {
notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id");
exit;
}
$table = new html_table();
if ($usesections) {
$table->head = array ($strsectionname, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else {
$table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
$table->align = array ("left", "left", "left", "left");
}
foreach ($scorms as $scorm) {
$context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);
$tt = "";
if ($usesections) {
if ($scorm->section) {
$tt = get_section_name($course, $sections[$scorm->section]);
}
$report = '&nbsp;';
$reportshow = '&nbsp;';
if (has_capability('mod/scorm:viewreport', $context)) {
$trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
if ($trackedusers > 0) {
$reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports', 'scorm', $trackedusers).'</a></div>';
} else {
$tt = userdate($scorm->timemodified);
}
$report = '&nbsp;';
$reportshow = '&nbsp;';
if (has_capability('mod/scorm:viewreport', $context)) {
$trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
if ($trackedusers > 0) {
$reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports','scorm',$trackedusers).'</a></div>';
} else {
$reportshow = get_string('noreports','scorm');
}
} else if (has_capability('mod/scorm:viewscores', $context)) {
require_once('locallib.php');
$report = scorm_grade_user($scorm, $USER->id);
$reportshow = get_string('score','scorm').": ".$report;
}
$options = (object)array('noclean'=>true);
if (!$scorm->visible) {
//Show dimmed if the mod is hidden
$table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
} else {
//Show normal if the mod is visible
$table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
$reportshow = get_string('noreports', 'scorm');
}
} else if (has_capability('mod/scorm:viewscores', $context)) {
require_once('locallib.php');
$report = scorm_grade_user($scorm, $USER->id);
$reportshow = get_string('score', 'scorm').": ".$report;
}
$options = (object)array('noclean'=>true);
if (!$scorm->visible) {
//Show dimmed if the mod is hidden
$table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
} else {
//Show normal if the mod is visible
$table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
}
}
echo "<br />";
echo html_writer::table($table);
echo $OUTPUT->footer();
echo "<br />";
echo html_writer::table($table);
echo $OUTPUT->footer();
-1
View File
@@ -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
+34 -36
View File
@@ -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
@@ -75,13 +74,13 @@ function scorm_add_instance($scorm, $mform=null) {
$id = $DB->insert_record('scorm', $scorm);
/// update course module record - from now on this instance properly exists and all function may be used
/// update course module record - from now on this instance properly exists and all function may be used
$DB->set_field('course_modules', 'instance', $id, array('id'=>$cmid));
/// reload scorm instance
/// reload scorm instance
$record = $DB->get_record('scorm', array('id'=>$id));
/// store the package and verify
/// store the package and verify
if ($record->scormtype === SCORM_TYPE_LOCAL) {
if ($mform) {
$filename = $mform->get_new_filename('packagefile');
@@ -109,8 +108,7 @@ function scorm_add_instance($scorm, $mform=null) {
// save reference
$DB->update_record('scorm', $record);
/// extra fields required in grade related functions
/// extra fields required in grade related functions
$record->course = $courseid;
$record->cmidnumber = $cmidnumber;
$record->cmid = $cmid;
@@ -183,8 +181,8 @@ function scorm_update_instance($scorm, $mform=null) {
}
$scorm = scorm_option2text($scorm);
$scorm->width = (int)str_replace('%','',$scorm->width);
$scorm->height = (int)str_replace('%','',$scorm->height);
$scorm->width = (int)str_replace('%', '', $scorm->width);
$scorm->height = (int)str_replace('%', '', $scorm->height);
$scorm->timemodified = time();
if (!isset($scorm->whatgrade)) {
@@ -195,7 +193,7 @@ function scorm_update_instance($scorm, $mform=null) {
$scorm = $DB->get_record('scorm', array('id'=>$scorm->id));
/// extra fields required in grade related functions
/// extra fields required in grade related functions
$scorm->course = $courseid;
$scorm->idnumber = $cmidnumber;
$scorm->cmid = $cmid;
@@ -350,7 +348,7 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
if ($orgs = $DB->get_records_select('scorm_scoes', 'scorm = ? AND '.
$DB->sql_isempty('scorm_scoes', 'launch', false, true).' AND '.
$DB->sql_isempty('scorm_scoes', 'organization', false, false),
array($scorm->id),'id','id,identifier,title')) {
array($scorm->id), 'id', 'id,identifier,title')) {
if (count($orgs) <= 1) {
unset($orgs);
$orgs[]->identifier = '';
@@ -366,13 +364,13 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
}
$report .= "<ul id='0' class='$liststyle'>";
$conditions['scorm'] = $scorm->id;
if ($scoes = $DB->get_records('scorm_scoes', $conditions, "id ASC")){
if ($scoes = $DB->get_records('scorm_scoes', $conditions, "id ASC")) {
// drop keys so that we can access array sequentially
$scoes = array_values($scoes);
$level=0;
$sublist=1;
$parents[$level]='/';
foreach ($scoes as $pos=>$sco) {
foreach ($scoes as $pos => $sco) {
if ($parents[$level]!=$sco->parent) {
if ($level>0 && $parents[$level-1]==$sco->parent) {
$report .= "\t\t</ul></li>\n";
@@ -409,25 +407,25 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
if ($sco->launch) {
$score = '';
$totaltime = '';
if ($usertrack=scorm_get_tracks($sco->id,$user->id)) {
if ($usertrack=scorm_get_tracks($sco->id, $user->id)) {
if ($usertrack->status == '') {
$usertrack->status = 'notattempted';
}
$strstatus = get_string($usertrack->status,'scorm');
$strstatus = get_string($usertrack->status, 'scorm');
$report .= "<img src='".$OUTPUT->pix_url($usertrack->status, 'scorm')."' alt='$strstatus' title='$strstatus' />";
} else {
if ($sco->scormtype == 'sco') {
$report .= '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$report .= '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted', 'scorm').'" title="'.get_string('notattempted', 'scorm').'" />';
} else {
$report .= '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
$report .= '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset', 'scorm').'" title="'.get_string('asset', 'scorm').'" />';
}
}
$report .= "&nbsp;$sco->title $score$totaltime</li>\n";
if ($usertrack !== false) {
$sometoreport = true;
$report .= "\t\t\t<li><ul class='$liststyle'>\n";
foreach($usertrack as $element => $value) {
if (substr($element,0,3) == 'cmi') {
foreach ($usertrack as $element => $value) {
if (substr($element, 0, 3) == 'cmi') {
$report .= '<li>'.$element.' => '.s($value).'</li>';
}
}
@@ -437,7 +435,7 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
$report .= "&nbsp;$sco->title</li>\n";
}
}
for ($i=0;$i<$level;$i++) {
for ($i=0; $i<$level; $i++) {
$report .= "\t\t</ul></li>\n";
}
}
@@ -448,16 +446,16 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
if ($sometoreport) {
if ($firstmodify < $now) {
$timeago = format_time($now - $firstmodify);
echo get_string('firstaccess','scorm').': '.userdate($firstmodify).' ('.$timeago.")<br />\n";
echo get_string('firstaccess', 'scorm').': '.userdate($firstmodify).' ('.$timeago.")<br />\n";
}
if ($lastmodify > 0) {
$timeago = format_time($now - $lastmodify);
echo get_string('lastaccess','scorm').': '.userdate($lastmodify).' ('.$timeago.")<br />\n";
echo get_string('lastaccess', 'scorm').': '.userdate($lastmodify).' ('.$timeago.")<br />\n";
}
echo get_string('report','scorm').":<br />\n";
echo get_string('report', 'scorm').":<br />\n";
echo $report;
} else {
print_string('noactivity','scorm');
print_string('noactivity', 'scorm');
}
return true;
@@ -494,7 +492,7 @@ function scorm_cron () {
mtrace('Updating scorm packages which require daily update');//We are updating
$scormsupdate = $DB->get_records('scorm', array('updatefreq'=>UPDATE_EVERYDAY));
foreach($scormsupdate as $scormupdate) {
foreach ($scormsupdate as $scormupdate) {
scorm_parse($scormupdate, true);
}
}
@@ -560,7 +558,7 @@ function scorm_update_grades($scorm, $userid=0, $nullifnone=true) {
} else if ($userid and $nullifnone) {
$grade = new stdClass();
$grade->userid = $userid;
$grade->rawgrade = NULL;
$grade->rawgrade = null;
scorm_grade_item_update($scorm, $grade);
} else {
@@ -609,7 +607,7 @@ function scorm_upgrade_grades() {
* @param mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return object grade_item
*/
function scorm_grade_item_update($scorm, $grades=NULL) {
function scorm_grade_item_update($scorm, $grades=null) {
global $CFG, $DB;
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
if (!function_exists('grade_update')) { //workaround for buggy PHP versions
@@ -637,7 +635,7 @@ function scorm_grade_item_update($scorm, $grades=NULL) {
if ($grades === 'reset') {
$params['reset'] = true;
$grades = NULL;
$grades = null;
}
return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, $grades, $params);
@@ -654,14 +652,14 @@ function scorm_grade_item_delete($scorm) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');
return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, NULL, array('deleted'=>1));
return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, null, array('deleted'=>1));
}
/**
* @return array
*/
function scorm_get_view_actions() {
return array('pre-view','view','view all','report');
return array('pre-view', 'view', 'view all', 'report');
}
/**
@@ -707,7 +705,7 @@ function scorm_option2text($scorm) {
*/
function scorm_reset_course_form_definition(&$mform) {
$mform->addElement('header', 'scormheader', get_string('modulenameplural', 'scorm'));
$mform->addElement('advcheckbox', 'reset_scorm', get_string('deleteallattempts','scorm'));
$mform->addElement('advcheckbox', 'reset_scorm', get_string('deleteallattempts', 'scorm'));
}
/**
@@ -964,7 +962,7 @@ function scorm_extend_navigation($navigation, $course, $module, $cm) {
* @param string $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
* @param integer $scoid - scoid of object this log entry is for
* @return string The filename as an absolute path
*/
*/
function scorm_debug_log_filename($type, $scoid) {
global $CFG, $USER;
@@ -984,7 +982,7 @@ function scorm_debug_log_write($type, $text, $scoid) {
$debugenablelog = get_config('scorm', 'allowapidebug');
if (!$debugenablelog || empty($text)) {
return ;
return;
}
if (make_upload_directory('temp/scormlogs/')) {
$logfile = scorm_debug_log_filename($type, $scoid);
@@ -992,7 +990,7 @@ function scorm_debug_log_write($type, $text, $scoid) {
}
}
/**
/**
* Remove debug log file
*
* @param string $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
@@ -1024,7 +1022,7 @@ function scorm_print_overview($courses, &$htmlarray) {
return array();
}
if (!$scorms = get_all_instances_in_courses('scorm',$courses)) {
if (!$scorms = get_all_instances_in_courses('scorm', $courses)) {
return;
}
@@ -1038,12 +1036,12 @@ function scorm_print_overview($courses, &$htmlarray) {
}
if (empty($scorm->displayattemptstatus) && (empty($isopen) || empty($scorm->timeclose))) {
unset($scorms[$key]);
}else{
} else {
$scormids[] = $scorm->id;
}
}
if(empty($scormids)){
if (empty($scormids)) {
// no scorms to look at - we're done
return true;
}
+121 -109
View File
@@ -1,131 +1,143 @@
<?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
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$delayseconds = 2; // Delay time before sco launch, used to give time to browser to define API
$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
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');
$delayseconds = 2; // Delay time before sco launch, used to give time to browser to define API
if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
$PAGE->set_url('/mod/scorm/loadSCO.php', array('scoid'=>$scoid, 'id'=>$cm->id));
require_login($course->id, false, $cm);
//check if scorm closed
$timenow = time();
if ($scorm->timeclose !=0) {
if ($scorm->timeopen > $timenow) {
print_error('notopenyet', 'scorm', null, userdate($scorm->timeopen));
} else if ($timenow > $scorm->timeclose) {
print_error('expired', 'scorm', null, userdate($scorm->timeclose));
}
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');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$PAGE->set_url('/mod/scorm/loadSCO.php', array('scoid'=>$scoid, 'id'=>$cm->id));
if (!empty($scoid)) {
require_login($course->id, false, $cm);
//check if scorm closed
$timenow = time();
if ($scorm->timeclose !=0) {
if ($scorm->timeopen > $timenow) {
print_error('notopenyet', 'scorm', null, userdate($scorm->timeopen));
} else if ($timenow > $scorm->timeclose) {
print_error('expired', 'scorm', null, userdate($scorm->timeclose));
}
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!empty($scoid)) {
//
// Direct SCO request
//
if ($sco = scorm_get_sco($scoid)) {
if ($sco->launch == '') {
// Search for the next launchable sco
if ($scoes = $DB->get_records_select('scorm_scoes',"scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true).' AND id > ?",array($scorm->id,$sco->id), 'id ASC')) {
$sco = current($scoes);
}
if ($sco = scorm_get_sco($scoid)) {
if ($sco->launch == '') {
// Search for the next launchable sco
if ($scoes = $DB->get_records_select('scorm_scoes', "scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true).' AND id > ?", array($scorm->id, $sco->id), 'id ASC')) {
$sco = current($scoes);
}
}
}
//
// If no sco was found get the first of SCORM package
//
if (!isset($sco)) {
$scoes = $DB->get_records_select('scorm_scoes',"scorm = ? AND ".$DB->sql_isnotempty('scorm_scoes', 'launch', false, true), array($scorm->id),'id ASC');
$sco = current($scoes);
}
}
//
// If no sco was found get the first of SCORM package
//
if (!isset($sco)) {
$scoes = $DB->get_records_select('scorm_scoes', "scorm = ? AND ".$DB->sql_isnotempty('scorm_scoes', 'launch', false, true), array($scorm->id), 'id ASC');
$sco = current($scoes);
}
if ($sco->scormtype == 'asset') {
$attempt = scorm_get_last_attempt($scorm->id,$USER->id);
$element = ($scorm->version == 'scorm_13' || $scorm->version == 'SCORM_1.3') ? 'cmi.completion_status':'cmi.core.lesson_status';
$value = 'completed';
$result = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
if ($sco->scormtype == 'asset') {
$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
$element = ($scorm->version == 'scorm_13' || $scorm->version == 'SCORM_1.3') ? 'cmi.completion_status':'cmi.core.lesson_status';
$value = 'completed';
$result = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
//
// Forge SCO URL
//
$connector = '';
$version = substr($scorm->version,0,4);
if ((isset($sco->parameters) && (!empty($sco->parameters))) || ($version == 'AICC')) {
if (stripos($sco->launch,'?') !== false) {
$connector = '&';
} else {
$connector = '?';
}
if ((isset($sco->parameters) && (!empty($sco->parameters))) && ($sco->parameters[0] == '?')) {
$sco->parameters = substr($sco->parameters,1);
}
}
if ($version == 'AICC') {
$sco_params = '';
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$sco_params = '&'. $sco->parameters;
}
$launcher = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco_params;
//
// Forge SCO URL
//
$connector = '';
$version = substr($scorm->version, 0, 4);
if ((isset($sco->parameters) && (!empty($sco->parameters))) || ($version == 'AICC')) {
if (stripos($sco->launch, '?') !== false) {
$connector = '&';
} else {
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$launcher = $sco->launch.$connector.$sco->parameters;
} else {
$launcher = $sco->launch;
}
$connector = '?';
}
if (scorm_external_link($sco->launch)) {
//TODO: does this happen?
$result = $launcher;
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
// Remote learning activity
$result = dirname($scorm->reference).'/'.$launcher;
} else if ($scorm->scormtype === SCORM_TYPE_IMSREPOSITORY) {
// Repository
$result = $CFG->repositorywebroot.substr($scorm->reference, 1).'/'.$sco->launch;
} else if ($scorm->scormtype === SCORM_TYPE_LOCAL or $scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
//note: do not convert this to use get_file_url() or moodle_url()
//SCORM does not work without slasharguments and moodle_url() encodes querystring vars
$result = "$CFG->wwwroot/pluginfile.php/$context->id/mod_scorm/content/$scorm->revision/$launcher";
if ((isset($sco->parameters) && (!empty($sco->parameters))) && ($sco->parameters[0] == '?')) {
$sco->parameters = substr($sco->parameters, 1);
}
}
// which API are we looking for
$LMS_api = ($scorm->version == 'scorm_12' || $scorm->version == 'SCORM_1.2' || empty($scorm->version)) ? 'API' : 'API_1484_11';
if ($version == 'AICC') {
$sco_params = '';
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$sco_params = '&'. $sco->parameters;
}
$launcher = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco_params;
} else {
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$launcher = $sco->launch.$connector.$sco->parameters;
} else {
$launcher = $sco->launch;
}
}
if (scorm_external_link($sco->launch)) {
//TODO: does this happen?
$result = $launcher;
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
// Remote learning activity
$result = dirname($scorm->reference).'/'.$launcher;
} else if ($scorm->scormtype === SCORM_TYPE_IMSREPOSITORY) {
// Repository
$result = $CFG->repositorywebroot.substr($scorm->reference, 1).'/'.$sco->launch;
} else if ($scorm->scormtype === SCORM_TYPE_LOCAL or $scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
//note: do not convert this to use get_file_url() or moodle_url()
//SCORM does not work without slasharguments and moodle_url() encodes querystring vars
$result = "$CFG->wwwroot/pluginfile.php/$context->id/mod_scorm/content/$scorm->revision/$launcher";
}
// which API are we looking for
$LMS_api = ($scorm->version == 'scorm_12' || $scorm->version == 'SCORM_1.2' || empty($scorm->version)) ? 'API' : 'API_1484_11';
?>
<html>
<head>
@@ -194,7 +206,7 @@
</head>
<body onload="doredirect();">
<p><?php echo get_string('activitypleasewait', 'scorm');?></p>
<?php if (debugging('',DEBUG_DEVELOPER)) {
<?php if (debugging('', DEBUG_DEVELOPER)) {
add_to_log($course->id, 'scorm', 'launch', 'view.php?id='.$cm->id, $result, $cm->id);
}
?>
+89 -75
View File
@@ -1,93 +1,107 @@
<?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_get('zlib.output_compression') == 'On') {
ini_set('zlib.output_compression', 'Off');
//IE 6 Bug workaround
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && ini_get('zlib.output_compression') == 'On') {
ini_set('zlib.output_compression', 'Off');
}
if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
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 (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
print_error('coursemisconf');
}
$url = new moodle_url('/mod/scorm/loaddatamodel.php', array('scoid'=>$scoid, 'id'=>$cm->id,'attempt'=>$attempt));
if ($mode !== '') {
$url->param('mode', $mode);
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
print_error('invalidcoursemodule');
}
$PAGE->set_url($url);
} 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');
}
require_login($course, false, $cm);
$url = new moodle_url('/mod/scorm/loaddatamodel.php', array('scoid'=>$scoid, 'id'=>$cm->id, 'attempt'=>$attempt));
if ($mode !== '') {
$url->param('mode', $mode);
}
$PAGE->set_url($url);
if ($usertrack = scorm_get_tracks($scoid,$USER->id,$attempt)) {
if ((isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} != 'time-out')) || ($scorm->version != "SCORM_1.3")) {
foreach ($usertrack as $key => $value) {
$userdata->$key = addslashes_js($value);
}
} else {
$userdata->status = '';
$userdata->score_raw = '';
require_login($course, false, $cm);
if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
if ((isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} != 'time-out')) || ($scorm->version != "SCORM_1.3")) {
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;
} 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);
}
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($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php');
} else {
include($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());
} 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($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php');
} else {
include($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());
?>
var errorCode = "0";
+190 -181
View File
@@ -1,4 +1,18 @@
<?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("$CFG->dirroot/mod/scorm/lib.php");
require_once("$CFG->libdir/filelib.php");
@@ -53,7 +67,7 @@ class scorm_package_file_info extends file_info_stored {
*
* @return array an array of popup options as the key and their defaults as the value
*/
function scorm_get_popup_options_array(){
function scorm_get_popup_options_array() {
global $CFG;
$cfg_scorm = get_config('scorm');
@@ -71,7 +85,7 @@ function scorm_get_popup_options_array(){
*
* @return array an array of what grade options
*/
function scorm_get_grade_method_array(){
function scorm_get_grade_method_array() {
return array (GRADESCOES => get_string('gradescoes', 'scorm'),
GRADEHIGHEST => get_string('gradehighest', 'scorm'),
GRADEAVERAGE => get_string('gradeaverage', 'scorm'),
@@ -83,7 +97,7 @@ function scorm_get_grade_method_array(){
*
* @return array an array of what grade options
*/
function scorm_get_what_grade_array(){
function scorm_get_what_grade_array() {
return array (HIGHESTATTEMPT => get_string('highestattempt', 'scorm'),
AVERAGEATTEMPT => get_string('averageattempt', 'scorm'),
FIRSTATTEMPT => get_string('firstattempt', 'scorm'),
@@ -95,9 +109,9 @@ function scorm_get_what_grade_array(){
*
* @return array an array of skip view options
*/
function scorm_get_skip_view_array(){
return array(0 => get_string('never'),
1 => get_string('firstaccess','scorm'),
function scorm_get_skip_view_array() {
return array(0 => get_string('never'),
1 => get_string('firstaccess', 'scorm'),
2 => get_string('always'));
}
@@ -106,10 +120,10 @@ function scorm_get_skip_view_array(){
*
* @return array an array of hide table of contents options
*/
function scorm_get_hidetoc_array(){
return array(0 =>get_string('sided','scorm'),
1 => get_string('hidden','scorm'),
2 => get_string('popupmenu','scorm'));
function scorm_get_hidetoc_array() {
return array(0 =>get_string('sided', 'scorm'),
1 => get_string('hidden', 'scorm'),
2 => get_string('popupmenu', 'scorm'));
}
/**
@@ -117,11 +131,11 @@ function scorm_get_hidetoc_array(){
*
* @return array an array of update frequency options
*/
function scorm_get_updatefreq_array(){
function scorm_get_updatefreq_array() {
return array(0 => get_string('never'),
1 => get_string('onchanges','scorm'),
2 => get_string('everyday','scorm'),
3 => get_string('everytime','scorm'));
1 => get_string('onchanges', 'scorm'),
2 => get_string('everyday', 'scorm'),
3 => get_string('everytime', 'scorm'));
}
/**
@@ -129,7 +143,7 @@ function scorm_get_updatefreq_array(){
*
* @return array an array of popup display options
*/
function scorm_get_popup_display_array(){
function scorm_get_popup_display_array() {
return array(0 => get_string('currentwindow', 'scorm'),
1 => get_string('popup', 'scorm'));
}
@@ -139,12 +153,12 @@ function scorm_get_popup_display_array(){
*
* @return array an array of attempt options
*/
function scorm_get_attempts_array(){
$attempts = array(0 => get_string('nolimit','scorm'),
1 => get_string('attempt1','scorm'));
function scorm_get_attempts_array() {
$attempts = array(0 => get_string('nolimit', 'scorm'),
1 => get_string('attempt1', 'scorm'));
for ($i=2; $i<=6; $i++) {
$attempts[$i] = get_string('attemptsx','scorm', $i);
$attempts[$i] = get_string('attemptsx', 'scorm', $i);
}
return $attempts;
@@ -217,7 +231,6 @@ function scorm_parse($scorm, $full) {
return;
}
if ($manifest = $fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'imsmanifest.xml')) {
require_once("$CFG->dirroot/mod/scorm/datamodels/scormlib.php");
// SCORM
@@ -248,7 +261,7 @@ function scorm_parse($scorm, $full) {
return;
}
require_once("$CFG->dirroot/mod/scorm/datamodels/scormlib.php");
if (!scorm_parse_scorm($scorm, $CFG->repository.substr($scorm->reference,1).'/imsmanifest.xml')) {
if (!scorm_parse_scorm($scorm, $CFG->repository.substr($scorm->reference, 1).'/imsmanifest.xml')) {
$scorm->version = 'ERROR';
}
$newhash = sha1($scorm->reference);
@@ -286,34 +299,33 @@ function scorm_repeater($what, $times) {
return null;
}
$return = '';
for ($i=0; $i<$times;$i++) {
for ($i=0; $i<$times; $i++) {
$return .= $what;
}
return $return;
}
function scorm_external_link($link) {
// check if a link is external
// check if a link is external
$result = false;
$link = strtolower($link);
if (substr($link,0,7) == 'http://') {
if (substr($link, 0, 7) == 'http://') {
$result = true;
} else if (substr($link,0,8) == 'https://') {
} else if (substr($link, 0, 8) == 'https://') {
$result = true;
} else if (substr($link,0,4) == 'www.') {
} else if (substr($link, 0, 4) == 'www.') {
$result = true;
}
return $result;
}
/**
* Returns an object containing all datas relative to the given sco ID
*
* @param integer $id The sco ID
* @return mixed (false if sco id does not exists)
*/
function scorm_get_sco($id,$what=SCO_ALL) {
* Returns an object containing all datas relative to the given sco ID
*
* @param integer $id The sco ID
* @return mixed (false if sco id does not exists)
*/
function scorm_get_sco($id, $what=SCO_ALL) {
global $DB;
if ($sco = $DB->get_record('scorm_scoes', array('id'=>$id))) {
@@ -332,14 +344,13 @@ function scorm_get_sco($id,$what=SCO_ALL) {
}
/**
* Returns an object (array) containing all the scoes data related to the given sco ID
*
* @param integer $id The sco ID
* @param integer $organisation an organisation ID - defaults to false if not required
* @return mixed (false if there are no scoes or an array)
*/
function scorm_get_scoes($id,$organisation=false) {
* Returns an object (array) containing all the scoes data related to the given sco ID
*
* @param integer $id The sco ID
* @param integer $organisation an organisation ID - defaults to false if not required
* @return mixed (false if there are no scoes or an array)
*/
function scorm_get_scoes($id, $organisation=false) {
global $DB;
$organizationsql = '';
@@ -351,7 +362,7 @@ function scorm_get_scoes($id,$organisation=false) {
// drop keys so that it is a simple array as expected
$scoes = array_values($scoes);
foreach ($scoes as $sco) {
if ($scodatas = $DB->get_records('scorm_scoes_data',array('scoid'=>$sco->id))) {
if ($scodatas = $DB->get_records('scorm_scoes_data', array('scoid'=>$sco->id))) {
foreach ($scodatas as $scodata) {
$sco->{$scodata->name} = $scodata->value;
}
@@ -363,7 +374,7 @@ function scorm_get_scoes($id,$organisation=false) {
}
}
function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$forcecompleted=false) {
function scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $value, $forcecompleted=false) {
global $DB, $CFG;
$id = null;
@@ -371,25 +382,25 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$fo
if ($forcecompleted) {
//TODO - this could be broadened to encompass SCORM 2004 in future
if (($element == 'cmi.core.lesson_status') && ($value == 'incomplete')) {
if ($track = $DB->get_record_select('scorm_scoes_track','userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.score.raw\'', array($userid, $scormid, $scoid, $attempt))) {
if ($track = $DB->get_record_select('scorm_scoes_track', 'userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.score.raw\'', array($userid, $scormid, $scoid, $attempt))) {
$value = 'completed';
}
}
if ($element == 'cmi.core.score.raw') {
if ($tracktest = $DB->get_record_select('scorm_scoes_track','userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.lesson_status\'', array($userid, $scormid, $scoid, $attempt))) {
if ($tracktest = $DB->get_record_select('scorm_scoes_track', 'userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.lesson_status\'', array($userid, $scormid, $scoid, $attempt))) {
if ($tracktest->value == "incomplete") {
$tracktest->value = "completed";
$DB->update_record('scorm_scoes_track',$tracktest);
$DB->update_record('scorm_scoes_track', $tracktest);
}
}
}
}
if ($track = $DB->get_record('scorm_scoes_track',array('userid'=>$userid, 'scormid'=>$scormid, 'scoid'=>$scoid, 'attempt'=>$attempt, 'element'=>$element))) {
if ($track = $DB->get_record('scorm_scoes_track', array('userid'=>$userid, 'scormid'=>$scormid, 'scoid'=>$scoid, 'attempt'=>$attempt, 'element'=>$element))) {
if ($element != 'x.start.time' ) { //don't update x.start.time - keep the original value.
$track->value = $value;
$track->timemodified = time();
$DB->update_record('scorm_scoes_track',$track);
$DB->update_record('scorm_scoes_track', $track);
$id = $track->id;
}
} else {
@@ -400,7 +411,7 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$fo
$track->element = $element;
$track->value = $value;
$track->timemodified = time();
$id = $DB->insert_record('scorm_scoes_track',$track);
$id = $DB->insert_record('scorm_scoes_track', $track);
}
if (strstr($element, '.score.raw') ||
@@ -413,18 +424,18 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$fo
return $id;
}
function scorm_get_tracks($scoid,$userid,$attempt='') {
/// Gets all tracks of specified sco and user
function scorm_get_tracks($scoid, $userid, $attempt='') {
/// Gets all tracks of specified sco and user
global $CFG, $DB;
if (empty($attempt)) {
if ($scormid = $DB->get_field('scorm_scoes','scorm', array('id'=>$scoid))) {
$attempt = scorm_get_last_attempt($scormid,$userid);
if ($scormid = $DB->get_field('scorm_scoes', 'scorm', array('id'=>$scoid))) {
$attempt = scorm_get_last_attempt($scormid, $userid);
} else {
$attempt = 1;
}
}
if ($tracks = $DB->get_records('scorm_scoes_track', array('userid'=>$userid, 'scoid'=>$scoid, 'attempt'=>$attempt),'element ASC')) {
if ($tracks = $DB->get_records('scorm_scoes_track', array('userid'=>$userid, 'scoid'=>$scoid, 'attempt'=>$attempt), 'element ASC')) {
$usertrack = new stdClass();
$usertrack->userid = $userid;
$usertrack->scoid = $scoid;
@@ -487,21 +498,19 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) {
$timedata = new stdClass();
$sql = !empty($scoid) ? "userid=$userid AND scormid=$scormid AND scoid=$scoid AND attempt=$attempt" : "userid=$userid AND scormid=$scormid AND attempt=$attempt";
$tracks = $DB->get_records_select('scorm_scoes_track',"$sql ORDER BY timemodified ASC");
$tracks = $DB->get_records_select('scorm_scoes_track', "$sql ORDER BY timemodified ASC");
if ($tracks) {
$tracks = array_values($tracks);
}
if ($tracks) {
$timedata->start = $tracks[0]->timemodified;
}
else {
} else {
$timedata->start = false;
}
if ($tracks && $track = array_pop($tracks)) {
$timedata->finish = $track->timemodified;
}
else {
} else {
$timedata->finish = $timedata->start;
}
return $timedata;
@@ -510,15 +519,15 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) {
function scorm_get_user_data($userid) {
global $DB;
/// Gets user info required to display the table of scorm results
/// for report.php
/// 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 = NULL;
$attemptscore = null;
$attemptscore->scoes = 0;
$attemptscore->values = 0;
$attemptscore->max = 0;
@@ -526,11 +535,11 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
$attemptscore->lastmodify = 0;
if (!$scoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id))) {
return NULL;
return null;
}
foreach ($scoes as $sco) {
if ($userdata=scorm_get_tracks($sco->id, $userid,$attempt)) {
if ($userdata=scorm_get_tracks($sco->id, $userid, $attempt)) {
if (($userdata->status == 'completed') || ($userdata->status == 'passed')) {
$attemptscore->scoes++;
}
@@ -574,7 +583,7 @@ function scorm_grade_user($scorm, $userid) {
// ensure we dont grade user beyond $scorm->maxattempt settings
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
if($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt){
if ($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt) {
$lastattempt = $scorm->maxattempt;
}
@@ -613,7 +622,7 @@ function scorm_grade_user($scorm, $userid) {
}
}
function scorm_count_launchable($scormid,$organization='') {
function scorm_count_launchable($scormid, $organization='') {
global $DB;
$sqlorganization = '';
@@ -622,13 +631,13 @@ function scorm_count_launchable($scormid,$organization='') {
$sqlorganization = " AND organization=?";
$params[] = $organization;
}
return $DB->count_records_select('scorm_scoes',"scorm = ? $sqlorganization AND ".$DB->sql_isnotempty('scorm_scoes', 'launch', false, true), $params);
return $DB->count_records_select('scorm_scoes', "scorm = ? $sqlorganization AND ".$DB->sql_isnotempty('scorm_scoes', 'launch', false, true), $params);
}
function scorm_get_last_attempt($scormid, $userid) {
global $DB;
/// Find the last attempt number for the given user id and scorm id
/// Find the last attempt number for the given user id and scorm id
if ($lastattempt = $DB->get_record('scorm_scoes_track', array('userid'=>$userid, 'scormid'=>$scormid), 'max(attempt) as a')) {
if (empty($lastattempt->a)) {
return '1';
@@ -643,7 +652,7 @@ function scorm_get_last_attempt($scormid, $userid) {
function scorm_get_last_completed_attempt($scormid, $userid) {
global $DB;
/// Find the last attempt number for the given user id and scorm id
/// Find the last attempt number for the given user id and scorm id
if ($lastattempt = $DB->get_record_select('scorm_scoes_track', "userid = ? AND scormid = ? AND (value='completed' OR value='passed')", array($userid, $scormid), 'max(attempt) as a')) {
if (empty($lastattempt->a)) {
return '1';
@@ -655,11 +664,11 @@ function scorm_get_last_completed_attempt($scormid, $userid) {
}
}
function scorm_course_format_display($user,$course) {
function scorm_course_format_display($user, $course) {
global $CFG, $DB, $PAGE, $OUTPUT;
$strupdate = get_string('update');
$context = get_context_instance(CONTEXT_COURSE,$course->id);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
echo '<div class="mod-scorm">';
if ($scorms = get_all_instances_in_course('scorm', $course)) {
@@ -684,14 +693,14 @@ function scorm_course_format_display($user,$course) {
if ($trackedusers->c > 0) {
$headertext .= '<td class="reportlink">'.
'<a href="'.$CFG->wwwroot.'/mod/scorm/report.php?id='.$cm->id.'">'.
get_string('viewallreports','scorm',$trackedusers->c).'</a>';
get_string('viewallreports', 'scorm', $trackedusers->c).'</a>';
} else {
$headertext .= '<td class="reportlink">'.get_string('noreports','scorm');
$headertext .= '<td class="reportlink">'.get_string('noreports', 'scorm');
}
$colspan = ' colspan="2"';
}
$headertext .= '</td></tr><tr><td'.$colspan.'>'.get_string('summary').':<br />'.format_module_intro('scorm', $scorm, $scorm->coursemodule).'</td></tr></table>';
echo $OUTPUT->box($headertext,'generalbox boxwidthwide');
echo $OUTPUT->box($headertext, 'generalbox boxwidthwide');
scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm);
} else {
if (has_capability('moodle/course:update', $context)) {
@@ -714,11 +723,11 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
$organization = optional_param('organization', '', PARAM_INT);
if($scorm->displaycoursestructure == 1) {
if ($scorm->displaycoursestructure == 1) {
echo $OUTPUT->box_start('generalbox boxaligncenter toc');
?>
<div class="structurehead"><?php print_string('contents','scorm') ?></div>
<?php
?>
<div class="structurehead"><?php print_string('contents', 'scorm') ?></div>
<?php
}
if (empty($organization)) {
$organization = $scorm->launch;
@@ -726,10 +735,10 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
if ($orgs = $DB->get_records_select_menu('scorm_scoes', 'scorm = ? AND '.
$DB->sql_isempty('scorm_scoes', 'launch', false, true).' AND '.
$DB->sql_isempty('scorm_scoes', 'organization', false, false),
array($scorm->id),'id','id,title')) {
array($scorm->id), 'id', 'id,title')) {
if (count($orgs) > 1) {
$select = new single_select(new moodle_url($action), 'organization', $orgs, $organization, null);
$select->label = get_string('organizations','scorm');
$select->label = get_string('organizations', 'scorm');
$select->class = 'scorm-center';
echo $OUTPUT->render($select);
}
@@ -749,11 +758,11 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
}
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
$result = scorm_get_toc($user,$scorm,$cm->id,TOCFULLURL,$orgidentifier);
$result = scorm_get_toc($user, $scorm, $cm->id, TOCFULLURL, $orgidentifier);
$incomplete = $result->incomplete;
// do we want the TOC to be displayed?
if($scorm->displaycoursestructure == 1) {
if ($scorm->displaycoursestructure == 1) {
echo $result->toc;
echo $OUTPUT->box_end();
}
@@ -763,41 +772,41 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
// do not give the player launch FORM if the SCORM object is locked after the final attempt
if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) {
?>
?>
<div class="scorm-center">
<form id="theform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
<?php
if ($scorm->hidebrowse == 0) {
print_string('mode','scorm');
echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">'.get_string('browse','scorm').'</label>'."\n";
echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">'.get_string('normal','scorm')."</label>\n";
} else {
echo '<input type="hidden" name="mode" value="normal" />'."\n";
}
if ($scorm->forcenewattempt == 1) {
if ($incomplete === false) {
echo '<input type="hidden" name="newattempt" value="on" />'."\n";
}
} elseif (!empty($attemptcount) && ($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) {
?>
<?php
if ($scorm->hidebrowse == 0) {
print_string('mode', 'scorm');
echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">'.get_string('browse', 'scorm').'</label>'."\n";
echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">'.get_string('normal', 'scorm')."</label>\n";
} else {
echo '<input type="hidden" name="mode" value="normal" />'."\n";
}
if ($scorm->forcenewattempt == 1) {
if ($incomplete === false) {
echo '<input type="hidden" name="newattempt" value="on" />'."\n";
}
} else if (!empty($attemptcount) && ($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) {
?>
<br />
<input type="checkbox" id="a" name="newattempt" />
<label for="a"><?php print_string('newattempt','scorm') ?></label>
<?php
}
?>
<label for="a"><?php print_string('newattempt', 'scorm') ?></label>
<?php
}
?>
<br />
<input type="hidden" name="scoid"/>
<input type="hidden" name="cm" value="<?php echo $cm->id ?>"/>
<input type="hidden" name="currentorg" value="<?php echo $orgidentifier ?>" />
<input type="submit" value="<?php print_string('enter','scorm') ?>" />
<input type="submit" value="<?php print_string('enter', 'scorm') ?>" />
</form>
</div>
<?php
<?php
}
}
function scorm_simple_play($scorm,$user, $context) {
function scorm_simple_play($scorm, $user, $context) {
global $DB;
$result = false;
@@ -814,7 +823,7 @@ function scorm_simple_play($scorm,$user, $context) {
if ($scoes) {
if ($scorm->skipview >= 1) {
$sco = current($scoes);
if (scorm_get_tracks($sco->id,$user->id) === false) {
if (scorm_get_tracks($sco->id, $user->id) === false) {
header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id);
$result = true;
} else if ($scorm->skipview == 2) {
@@ -849,14 +858,14 @@ function scorm_get_count_users($scormid, $groupingid=null) {
}
/**
* Build up the JavaScript representation of an array element
*
* @param string $sversion SCORM API version
* @param array $userdata User track data
* @param string $element_name Name of array element to get values for
* @param array $children list of sub elements of this array element that also need instantiating
* @return None
*/
* Build up the JavaScript representation of an array element
*
* @param string $sversion SCORM API version
* @param array $userdata User track data
* @param string $element_name Name of array element to get values for
* @param array $children list of sub elements of this array element that also need instantiating
* @return None
*/
function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $children) {
// reconstitute comments_from_learner and comments_from_lms
$current = '';
@@ -866,12 +875,12 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
$count_sub = 0;
$scormseperator = '_';
if ($sversion == 'scorm_13') { //scorm 1.3 elements use a . instead of an _
$scormseperator = '.';
$scormseperator = '.';
}
// filter out the ones we want
$element_list = array();
foreach($userdata as $element => $value){
if (substr($element,0,strlen($element_name)) == $element_name) {
foreach ($userdata as $element => $value) {
if (substr($element, 0, strlen($element_name)) == $element_name) {
$element_list[$element] = $value;
}
}
@@ -880,7 +889,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
uksort($element_list, "scorm_element_cmp");
// generate JavaScript
foreach($element_list as $element => $value){
foreach ($element_list as $element => $value) {
if ($sversion == 'scorm_13') {
$element = preg_replace('/\.(\d+)\./', ".N\$1.", $element);
preg_match('/\.(N\d+)\./', $element, $matches);
@@ -897,8 +906,8 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
$current_subelement = '';
$current_sub = '';
$count_sub = 0;
$end = strpos($element,$matches[1])+strlen($matches[1]);
$subelement = substr($element,0,$end);
$end = strpos($element, $matches[1])+strlen($matches[1]);
$subelement = substr($element, 0, $end);
echo ' '.$subelement." = new Object();\n";
// now add the children
foreach ($children as $child) {
@@ -924,8 +933,8 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
$current_subelement = $matches[1];
$current_sub = '';
$count_sub = 0;
$end = strpos($element,$matches[1])+strlen($matches[1]);
$subelement = substr($element,0,$end);
$end = strpos($element, $matches[1])+strlen($matches[1]);
$subelement = substr($element, 0, $end);
echo ' '.$subelement." = new Object();\n";
}
@@ -933,8 +942,8 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
if (count($matches) > 0 && $current_sub != $matches[2]) {
$current_sub = $matches[2];
$count_sub++;
$end = strrpos($element,$matches[2])+strlen($matches[2]);
$subelement = substr($element,0,$end);
$end = strrpos($element, $matches[2])+strlen($matches[2]);
$subelement = substr($element, 0, $end);
echo ' '.$subelement." = new Object();\n";
}
@@ -949,12 +958,12 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
}
/**
* Build up the JavaScript representation of an array element
*
* @param string $a left array element
* @param string $b right array element
* @return comparator - 0,1,-1
*/
* Build up the JavaScript representation of an array element
*
* @param string $a left array element
* @param string $b right array element
* @return comparator - 0,1,-1
*/
function scorm_element_cmp($a, $b) {
preg_match('/.*?(\d+)\./', $a, $matches);
$left = intval($matches[1]);
@@ -962,7 +971,7 @@ function scorm_element_cmp($a, $b) {
$right = intval($matches[1]);
if ($left < $right) {
return -1; // smaller
} elseif ($left > $right) {
} else if ($left > $right) {
return 1; // bigger
} else {
// look for a second level qualifier eg cmi.interactions_0.correct_responses_0.pattern
@@ -974,12 +983,12 @@ function scorm_element_cmp($a, $b) {
$right = intval($matches[3]);
if ($leftterm < $rightterm) {
return -1; // smaller
} elseif ($leftterm > $rightterm) {
} else if ($leftterm > $rightterm) {
return 1; // bigger
} else {
if ($left < $right) {
return -1; // smaller
} elseif ($left > $right) {
} else if ($left > $right) {
return 1; // bigger
}
}
@@ -991,17 +1000,17 @@ function scorm_element_cmp($a, $b) {
}
/**
* Generate the user attempt status string
*
* @param object $user Current context user
* @param object $scorm a moodle scrom object - mdl_scorm
* @return string - Attempt status string
*/
* Generate the user attempt status string
*
* @param object $user Current context user
* @param object $scorm a moodle scrom object - mdl_scorm
* @return string - Attempt status string
*/
function scorm_get_attempt_status($user, $scorm) {
global $DB;
$attempts = scorm_get_attempt_count($user->id, $scorm, true);
if(empty($attempts)) {
if (empty($attempts)) {
$attemptcount = 0;
} else {
$attemptcount = count($attempts);
@@ -1030,8 +1039,8 @@ function scorm_get_attempt_status($user, $scorm) {
$grademethod = get_string('gradescoes', 'scorm');
break;
}
} else {
switch ($scorm->whatgrade) {
} else {
switch ($scorm->whatgrade) {
case HIGHESTATTEMPT:
$grademethod = get_string('highestattempt', 'scorm');
break;
@@ -1045,11 +1054,11 @@ function scorm_get_attempt_status($user, $scorm) {
$grademethod = get_string('lastattempt', 'scorm');
break;
}
}
}
if(!empty($attempts)) {
if (!empty($attempts)) {
$i = 1;
foreach($attempts as $attempt) {
foreach ($attempts as $attempt) {
$gradereported = scorm_grade_user_attempt($scorm, $user->id, $attempt->attemptnumber);
if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) {
$gradereported = $gradereported/$scorm->maxgrade;
@@ -1065,26 +1074,26 @@ function scorm_get_attempt_status($user, $scorm) {
$calculatedgrade = number_format($calculatedgrade*100, 0) .'%';
}
$result .= get_string('grademethod', 'scorm'). ': ' . $grademethod;
if(empty($attempts)) {
$result .= '<br />' . get_string('gradereported','scorm') . ': ' . get_string('none') . '<br />';
if (empty($attempts)) {
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . get_string('none') . '<br />';
} else {
$result .= '<br />' . get_string('gradereported','scorm') . ': ' . $calculatedgrade . '<br />';
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . $calculatedgrade . '<br />';
}
$result .= '</p>';
if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {
$result .= '<p><font color="#cc0000">'.get_string('exceededmaxattempts','scorm').'</font></p>';
$result .= '<p><font color="#cc0000">'.get_string('exceededmaxattempts', 'scorm').'</font></p>';
}
return $result;
}
/**
* Get SCORM attempt count
*
* @param object $user Current context user
* @param object $scorm a moodle scrom object - mdl_scorm
* @param bool $attempts return the list of attempts
* @return int - no. of attempts so far
*/
* Get SCORM attempt count
*
* @param object $user Current context user
* @param object $scorm a moodle scrom object - mdl_scorm
* @param bool $attempts return the list of attempts
* @return int - no. of attempts so far
*/
function scorm_get_attempt_count($userid, $scorm, $attempts_only=false) {
global $DB;
$attemptcount = 0;
@@ -1095,22 +1104,22 @@ function scorm_get_attempt_count($userid, $scorm, $attempts_only=false) {
if ($scorm->version == 'scorm1_3') {
$element = 'cmi.score.raw';
}
$attempts = $DB->get_records_select('scorm_scoes_track',"element=? AND userid=? AND scormid=?", array($element, $userid, $scorm->id),'attempt','DISTINCT attempt AS attemptnumber');
$attempts = $DB->get_records_select('scorm_scoes_track', "element=? AND userid=? AND scormid=?", array($element, $userid, $scorm->id), 'attempt', 'DISTINCT attempt AS attemptnumber');
if ($attempts_only) {
return $attempts;
}
if(!empty($attempts)) {
if (!empty($attempts)) {
$attemptcount = count($attempts);
}
return $attemptcount;
}
/**
* Figure out with this is a debug situation
*
* @param object $scorm a moodle scrom object - mdl_scorm
* @return boolean - debugging true/false
*/
* Figure out with this is a debug situation
*
* @param object $scorm a moodle scrom object - mdl_scorm
* @return boolean - debugging true/false
*/
function scorm_debugging($scorm) {
global $CFG, $USER;
$cfg_scorm = get_config('scorm');
@@ -1130,25 +1139,25 @@ function scorm_debugging($scorm) {
}
/**
* Delete Scorm tracks for selected users
*
* @param array $attemptids list of attempts that need to be deleted
* @param int $scorm instance
*
* return bool true deleted all responses, false failed deleting an attempt - stopped here
*/
* Delete Scorm tracks for selected users
*
* @param array $attemptids list of attempts that need to be deleted
* @param int $scorm instance
*
* return bool true deleted all responses, false failed deleting an attempt - stopped here
*/
function scorm_delete_responses($attemptids, $scorm) {
if(!is_array($attemptids) || empty($attemptids)) {
if (!is_array($attemptids) || empty($attemptids)) {
return false;
}
foreach($attemptids as $num => $attemptid) {
if(empty($attemptid)) {
foreach ($attemptids as $num => $attemptid) {
if (empty($attemptid)) {
unset($attemptids[$num]);
}
}
foreach($attemptids as $attempt) {
foreach ($attemptids as $attempt) {
$keys = explode(':', $attempt);
if (count($keys) == 2) {
$userid = clean_param($keys[0], PARAM_INT);
@@ -1164,14 +1173,14 @@ function scorm_delete_responses($attemptids, $scorm) {
}
/**
* Delete Scorm tracks for selected users
*
* @param int $userid ID of User
* @param int $scormid ID of Scorm
* @param int $attemptid user attempt that need to be deleted
*
* return bool true suceeded
*/
* Delete Scorm tracks for selected users
*
* @param int $userid ID of User
* @param int $scormid ID of Scorm
* @param int $attemptid user attempt that need to be deleted
*
* return bool true suceeded
*/
function scorm_delete_attempt($userid, $scorm, $attemptid) {
global $DB;
+70 -58
View File
@@ -1,9 +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/>.
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
require_once($CFG->dirroot.'/course/moodleform_mod.php');
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
class mod_scorm_mod_form extends moodleform_mod {
@@ -15,16 +30,16 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform = $this->_form;
if (!$CFG->slasharguments) {
$mform->addElement('static', '', '',$OUTPUT->notification(get_string('slashargs', 'scorm'), 'notifyproblem'));
$mform->addElement('static', '', '', $OUTPUT->notification(get_string('slashargs', 'scorm'), 'notifyproblem'));
}
$zlib = ini_get('zlib.output_compression'); //check for zlib compression - if used, throw error because of IE bug. - SEE MDL-16185
if (isset($zlib) && $zlib) {
$mform->addElement('static', '', '',$OUTPUT->notification(get_string('zlibwarning', 'scorm'), 'notifyproblem'));
$mform->addElement('static', '', '', $OUTPUT->notification(get_string('zlibwarning', 'scorm'), 'notifyproblem'));
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
// Name
// Name
$mform->addElement('text', 'name', get_string('name'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
@@ -33,10 +48,10 @@ class mod_scorm_mod_form extends moodleform_mod {
}
$mform->addRule('name', null, 'required', null, 'client');
// Summary
// Summary
$this->add_intro_editor(true);
// Scorm types
// Scorm types
$options = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
if ($cfg_scorm->allowtypeexternal) {
@@ -51,7 +66,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$options[SCORM_TYPE_IMSREPOSITORY] = get_string('typeimsrepository', 'scorm');
}
// Reference
// Reference
if (count($options) > 1) {
$mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $options);
$mform->addHelpButton('scormtype', 'scormtype', 'scorm');
@@ -63,75 +78,75 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->addElement('hidden', 'scormtype', SCORM_TYPE_LOCAL);
}
// New local package upload
// New local package upload
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
$mform->setMaxFileSize($maxbytes);
$mform->addElement('filepicker', 'packagefile', get_string('package','scorm'));
$mform->addElement('filepicker', 'packagefile', get_string('package', 'scorm'));
$mform->addHelpButton('packagefile', 'package', 'scorm');
$mform->disabledIf('packagefile', 'scormtype', 'noteq', SCORM_TYPE_LOCAL);
//-------------------------------------------------------------------------------
// Time restrictions
//-------------------------------------------------------------------------------
// Time restrictions
$mform->addElement('header', 'timerestricthdr', get_string('timerestrict', 'scorm'));
$mform->addElement('date_time_selector', 'timeopen', get_string("scormopen", "scorm"),array('optional' => true));
$mform->addElement('date_time_selector', 'timeclose', get_string("scormclose", "scorm"),array('optional' => true));
//-------------------------------------------------------------------------------
// Other Settings
$mform->addElement('date_time_selector', 'timeopen', get_string("scormopen", "scorm"), array('optional' => true));
$mform->addElement('date_time_selector', 'timeclose', get_string("scormclose", "scorm"), array('optional' => true));
//-------------------------------------------------------------------------------
// Other Settings
$mform->addElement('header', 'advanced', get_string('othersettings', 'form'));
// Grade Method
// Grade Method
$mform->addElement('select', 'grademethod', get_string('grademethod', 'scorm'), scorm_get_grade_method_array());
$mform->addHelpButton('grademethod', 'grademethod', 'scorm');
$mform->setDefault('grademethod', $cfg_scorm->grademethod);
// Maximum Grade
// Maximum Grade
for ($i=0; $i<=100; $i++) {
$grades[$i] = "$i";
$grades[$i] = "$i";
}
$mform->addElement('select', 'maxgrade', get_string('maximumgrade'), $grades);
$mform->setDefault('maxgrade', $cfg_scorm->maxgrade);
$mform->disabledIf('maxgrade', 'grademethod','eq', GRADESCOES);
$mform->disabledIf('maxgrade', 'grademethod', 'eq', GRADESCOES);
// Attempts
$mform->addElement('static', '', '' ,'<hr />');
// Attempts
$mform->addElement('static', '', '' , '<hr />');
// Max Attempts
// Max Attempts
$mform->addElement('select', 'maxattempt', get_string('maximumattempts', 'scorm'), scorm_get_attempts_array());
$mform->addHelpButton('maxattempt', 'maximumattempts', 'scorm');
$mform->setDefault('maxattempt', $cfg_scorm->maxattempts);
// What Grade
// What Grade
$mform->addElement('select', 'whatgrade', get_string('whatgrade', 'scorm'), scorm_get_what_grade_array());
$mform->disabledIf('whatgrade', 'maxattempt','eq',1);
$mform->disabledIf('whatgrade', 'maxattempt', 'eq', 1);
$mform->addHelpButton('whatgrade', 'whatgrade', 'scorm');
$mform->setDefault('whatgrade', $cfg_scorm->whatgrade);
$mform->setAdvanced('whatgrade');
// Display attempt status
// Display attempt status
$mform->addElement('selectyesno', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'));
$mform->addHelpButton('displayattemptstatus', 'displayattemptstatus', 'scorm');
$mform->setDefault('displayattemptstatus', $cfg_scorm->displayattemptstatus);
// Force completed
// Force completed
$mform->addElement('selectyesno', 'forcecompleted', get_string('forcecompleted', 'scorm'));
$mform->addHelpButton('forcecompleted', 'forcecompleted', 'scorm');
$mform->setDefault('forcecompleted', $cfg_scorm->forcecompleted);
$mform->setAdvanced('forcecompleted');
// Force new attempt
// Force new attempt
$mform->addElement('selectyesno', 'forcenewattempt', get_string('forcenewattempt', 'scorm'));
$mform->addHelpButton('forcenewattempt', 'forcenewattempt', 'scorm');
$mform->setDefault('forcenewattempt', $cfg_scorm->forcenewattempt);
$mform->setAdvanced('forcenewattempt');
// Last attempt lock - lock the enter button after the last available attempt has been made
// Last attempt lock - lock the enter button after the last available attempt has been made
$mform->addElement('selectyesno', 'lastattemptlock', get_string('lastattemptlock', 'scorm'));
$mform->addHelpButton('lastattemptlock', 'lastattemptlock', 'scorm');
$mform->setDefault('lastattemptlock', $cfg_scorm->lastattemptlock);
$mform->setAdvanced('lastattemptlock');
// Activation period
// Activation period
/* $mform->addElement('static', '', '' ,'<hr />');
$mform->addElement('static', 'activation', get_string('activation','scorm'));
$datestartgrp = array();
@@ -151,77 +166,77 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->disabledIf('dateendgrp', 'enddisabled', 'checked');
*/
// Framed / Popup Window
// Framed / Popup Window
$mform->addElement('select', 'popup', get_string('display', 'scorm'), scorm_get_popup_display_array());
$mform->setDefault('popup', $cfg_scorm->popup);
$mform->setAdvanced('popup');
// Width
$mform->addElement('text', 'width', get_string('width','scorm'), 'maxlength="5" size="5"');
// Width
$mform->addElement('text', 'width', get_string('width', 'scorm'), 'maxlength="5" size="5"');
$mform->setDefault('width', $cfg_scorm->framewidth);
$mform->setType('width', PARAM_INT);
$mform->setAdvanced('width');
$mform->disabledIf('width', 'popup', 'eq', 0);
// Height
$mform->addElement('text', 'height', get_string('height','scorm'), 'maxlength="5" size="5"');
// Height
$mform->addElement('text', 'height', get_string('height', 'scorm'), 'maxlength="5" size="5"');
$mform->setDefault('height', $cfg_scorm->frameheight);
$mform->setType('height', PARAM_INT);
$mform->setAdvanced('height');
$mform->disabledIf('height', 'popup', 'eq', 0);
// Window Options
// Window Options
$winoptgrp = array();
foreach(scorm_get_popup_options_array() as $key => $value){
foreach (scorm_get_popup_options_array() as $key => $value) {
$winoptgrp[] = &$mform->createElement('checkbox', $key, '', get_string($key, 'scorm'));
$mform->setDefault($key, $value);
}
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options','scorm'), '<br />', false);
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options', 'scorm'), '<br />', false);
$mform->setAdvanced('winoptgrp');
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);
// Skip view page
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'),scorm_get_skip_view_array());
// Skip view page
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), scorm_get_skip_view_array());
$mform->addHelpButton('skipview', 'skipview', 'scorm');
$mform->setDefault('skipview', $cfg_scorm->skipview);
$mform->setAdvanced('skipview');
// Hide Browse
// Hide Browse
$mform->addElement('selectyesno', 'hidebrowse', get_string('hidebrowse', 'scorm'));
$mform->addHelpButton('hidebrowse', 'hidebrowse', 'scorm');
$mform->setDefault('hidebrowse', $cfg_scorm->hidebrowse);
$mform->setAdvanced('hidebrowse');
// Display course structure
// Display course structure
$mform->addElement('selectyesno', 'displaycoursestructure', get_string('displaycoursestructure', 'scorm'));
$mform->addHelpButton('displaycoursestructure', 'displaycoursestructure', 'scorm');
$mform->setDefault('displaycoursestructure', $cfg_scorm->displaycoursestructure);
$mform->setAdvanced('displaycoursestructure');
// Toc display
// Toc display
$mform->addElement('select', 'hidetoc', get_string('hidetoc', 'scorm'), scorm_get_hidetoc_array());
$mform->addHelpButton('hidetoc', 'hidetoc', 'scorm');
$mform->setDefault('hidetoc', $cfg_scorm->hidetoc);
$mform->setAdvanced('hidetoc');
// Hide Navigation panel
// Hide Navigation panel
$mform->addElement('selectyesno', 'hidenav', get_string('hidenav', 'scorm'));
$mform->setDefault('hidenav', $cfg_scorm->hidenav);
$mform->setAdvanced('hidenav');
// Autocontinue
// Autocontinue
$mform->addElement('selectyesno', 'auto', get_string('autocontinue', 'scorm'));
$mform->addHelpButton('auto', 'autocontinue', 'scorm');
$mform->setDefault('auto', $cfg_scorm->auto);
$mform->setAdvanced('auto');
// Update packages timing
// Update packages timing
$mform->addElement('select', 'updatefreq', get_string('updatefreq', 'scorm'), scorm_get_updatefreq_array());
$mform->setDefault('updatefreq', $cfg_scorm->updatefreq);
$mform->setAdvanced('updatefreq');
//-------------------------------------------------------------------------------
// Hidden Settings
//-------------------------------------------------------------------------------
// Hidden Settings
$mform->addElement('hidden', 'datadir', null);
$mform->setType('datadir', PARAM_RAW);
$mform->addElement('hidden', 'pkgtype', null);
@@ -233,13 +248,11 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->addElement('hidden', 'redirecturl', null);
$mform->setType('redirecturl', PARAM_RAW);
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
}
function data_preprocessing(&$default_values) {
@@ -247,9 +260,9 @@ class mod_scorm_mod_form extends moodleform_mod {
if (isset($default_values['popup']) && ($default_values['popup'] == 1) && isset($default_values['options'])) {
if (!empty($default_values['options'])) {
$options = explode(',',$default_values['options']);
$options = explode(',', $default_values['options']);
foreach ($options as $option) {
list($element,$value) = explode('=',$option);
list($element, $value) = explode('=', $option);
$element = trim($element);
$default_values[$element] = trim($value);
}
@@ -258,10 +271,10 @@ class mod_scorm_mod_form extends moodleform_mod {
if (isset($default_values['grademethod'])) {
$default_values['grademethod'] = intval($default_values['grademethod']);
}
if (isset($default_values['width']) && (strpos($default_values['width'],'%') === false) && ($default_values['width'] <= 100)) {
if (isset($default_values['width']) && (strpos($default_values['width'], '%') === false) && ($default_values['width'] <= 100)) {
$default_values['width'] .= '%';
}
if (isset($default_values['width']) && (strpos($default_values['height'],'%') === false) && ($default_values['height'] <= 100)) {
if (isset($default_values['width']) && (strpos($default_values['height'], '%') === false) && ($default_values['height'] <= 100)) {
$default_values['height'] .= '%';
}
$scorms = get_all_instances_in_course('scorm', $COURSE);
@@ -279,7 +292,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$default_values['redirecturl'] = '../mod/scorm/view.php?id='.$default_values['coursemodule'];
}
if (isset($default_values['version'])) {
$default_values['pkgtype'] = (substr($default_values['version'],0,5) == 'SCORM') ? 'scorm':'aicc';
$default_values['pkgtype'] = (substr($default_values['version'], 0, 5) == 'SCORM') ? 'scorm':'aicc';
}
if (isset($default_values['instance'])) {
$default_values['datadir'] = $default_values['instance'];
@@ -391,4 +404,3 @@ class mod_scorm_mod_form extends moodleform_mod {
parent::set_data($default_values);
}
}
+3 -8
View File
@@ -48,10 +48,8 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
var scorm_bloody_labelclick = false;
var scorm_nav_panel;
Y.use('yui2-resize', 'yui2-dragdrop', 'yui2-container', 'yui2-button', 'yui2-layout', 'yui2-treeview', 'yui2-json', 'yui2-event', function(Y) {
var scorm_activate_item = function(node) {
if (!node) {
return;
@@ -122,14 +120,13 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
}
var old = YAHOO.util.Dom.get('scorm_object');
if (old) {
if(window_name) {
if(window_name) {
var cwidth = scormplayerdata.cwidth;
var cheight = scormplayerdata.cheight;
var poptions = scormplayerdata.popupoptions;
scorm_openpopup("loadSCO.php?" + node.title, window_name, poptions, cwidth, cheight);
}
else {
content.replaceChild(obj, old);
} else {
content.replaceChild(obj, old);
}
} else {
content.appendChild(obj);
@@ -230,7 +227,6 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
}
};
var scorm_up = function(node) {
var node = scorm_tree_node.getHighlightedNode();
if (node.depth > 0) {
@@ -285,7 +281,6 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
mod_scorm_next = scorm_next;
mod_scorm_prev = scorm_prev;
// layout
YAHOO.widget.LayoutUnit.prototype.STR_COLLAPSE = M.str.moodle.hide;
YAHOO.widget.LayoutUnit.prototype.STR_EXPAND = M.str.moodle.show;
+15
View File
@@ -1,3 +1,18 @@
// 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_openpopup(url,name,options,width,height) {
fullurl = M.cfg.wwwroot + '/mod/scorm/' + url;
windowobj = window.open(fullurl,name,options);
+183 -174
View File
@@ -1,185 +1,192 @@
<?PHP
<?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/>.
/// This page prints a particular instance of aicc/scorm package
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
require_once($CFG->libdir . '/completionlib.php');
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
require_once($CFG->libdir . '/completionlib.php');
//
// Checkin' script parameters
//
$id = optional_param('cm', '', 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', 'normal', PARAM_ALPHA); // navigation mode
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
$id = optional_param('cm', '', 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', 'normal', PARAM_ALPHA); // navigation mode
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a 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);
//IE 6 Bug workaround
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
@ini_set('zlib.output_compression', 'Off');
@apache_setenv('no-gzip', 1);
}
if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
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 (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
print_error('coursemisconf');
}
$url = new moodle_url('/mod/scorm/player.php', array('scoid'=>$scoid, 'cm'=>$cm->id));
if ($mode !== 'normal') {
$url->param('mode', $mode);
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
print_error('invalidcoursemodule');
}
if ($currentorg !== '') {
$url->param('currentorg', $currentorg);
} else if (!empty($a)) {
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
print_error('invalidcoursemodule');
}
if ($newattempt !== 'off') {
$url->param('newattempt', $newattempt);
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
print_error('coursemisconf');
}
$PAGE->set_url($url);
$forcejs = get_config('scorm','forcejavascript');
if (!empty($forcejs)) {
$PAGE->add_body_class('forcejavascript');
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
print_error('invalidcoursemodule');
}
} else {
print_error('missingparameter');
}
require_login($course->id, false, $cm);
$url = new moodle_url('/mod/scorm/player.php', array('scoid'=>$scoid, 'cm'=>$cm->id));
if ($mode !== 'normal') {
$url->param('mode', $mode);
}
if ($currentorg !== '') {
$url->param('currentorg', $currentorg);
}
if ($newattempt !== 'off') {
$url->param('newattempt', $newattempt);
}
$PAGE->set_url($url);
$forcejs = get_config('scorm', 'forcejavascript');
if (!empty($forcejs)) {
$PAGE->add_body_class('forcejavascript');
}
$strscorms = get_string('modulenameplural', 'scorm');
$strscorm = get_string('modulename', 'scorm');
$strpopup = get_string('popup','scorm');
$strexit = get_string('exitactivity','scorm');
require_login($course->id, false, $cm);
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
$strscorms = get_string('modulenameplural', 'scorm');
$strscorm = get_string('modulename', 'scorm');
$strpopup = get_string('popup', 'scorm');
$strexit = get_string('exitactivity', 'scorm');
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE,$course->id))) {
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
echo $OUTPUT->header();
notice(get_string("activityiscurrentlyhidden"));
echo $OUTPUT->footer();
die;
}
//check if scorm closed
$timenow = time();
if ($scorm->timeclose !=0) {
if ($scorm->timeopen > $timenow) {
echo $OUTPUT->header();
notice(get_string("activityiscurrentlyhidden"));
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
echo $OUTPUT->footer();
die;
}
} else if ($timenow > $scorm->timeclose) {
echo $OUTPUT->header();
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
echo $OUTPUT->footer();
//check if scorm closed
$timenow = time();
if ($scorm->timeclose !=0) {
if ($scorm->timeopen > $timenow) {
echo $OUTPUT->header();
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
echo $OUTPUT->footer();
die;
} elseif ($timenow > $scorm->timeclose) {
echo $OUTPUT->header();
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
echo $OUTPUT->footer();
die;
}
die;
}
}
// TOC processing
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
$scorm->version = 'scorm_12';
}
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) {
$attempt++;
$mode = 'normal';
}
$attemptstr = '&amp;attempt=' . $attempt;
//
// TOC processing
//
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
$scorm->version = 'scorm_12';
}
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) {
$attempt++;
$mode = 'normal';
}
$attemptstr = '&amp;attempt=' . $attempt;
$result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true);
$sco = $result->sco;
$result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true);
$sco = $result->sco;
if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {
$mode = 'normal';
}
if ($mode != 'browse') {
if ($trackdata = scorm_get_tracks($sco->id,$USER->id,$attempt)) {
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
$mode = 'review';
} else {
$mode = 'normal';
}
if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {
$mode = 'normal';
}
if ($mode != 'browse') {
if ($trackdata = scorm_get_tracks($sco->id, $USER->id, $attempt)) {
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
$mode = 'review';
} else {
$mode = 'normal';
}
}
add_to_log($course->id, 'scorm', 'view', "player.php?cm=$cm->id&scoid=$sco->id", "$scorm->id", $cm->id);
$scoidstr = '&amp;scoid='.$sco->id;
$scoidpop = '&scoid='.$sco->id;
$modestr = '&amp;mode='.$mode;
if ($mode == 'browse') {
$modepop = '&mode='.$mode;
} else {
$modepop = '';
$mode = 'normal';
}
$orgstr = '&currentorg='.$currentorg;
}
$SESSION->scorm_scoid = $sco->id;
$SESSION->scorm_status = 'Not Initialized';
$SESSION->scorm_mode = $mode;
$SESSION->scorm_attempt = $attempt;
add_to_log($course->id, 'scorm', 'view', "player.php?cm=$cm->id&scoid=$sco->id", "$scorm->id", $cm->id);
// Mark module viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
//
// Print the page header
//
$bodyscript = '';
if ($scorm->popup == 1) {
$bodyscript = 'onunload="main.close();"';
}
$scoidstr = '&amp;scoid='.$sco->id;
$scoidpop = '&scoid='.$sco->id;
$modestr = '&amp;mode='.$mode;
if ($mode == 'browse') {
$modepop = '&mode='.$mode;
} else {
$modepop = '';
}
$orgstr = '&currentorg='.$currentorg;
$exitlink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'" title="'.$strexit.'">'.$strexit.'</a> ';
$SESSION->scorm_scoid = $sco->id;
$SESSION->scorm_status = 'Not Initialized';
$SESSION->scorm_mode = $mode;
$SESSION->scorm_attempt = $attempt;
$PAGE->set_button($exitlink);
// Mark module viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height,
'popupoptions' => $scorm->options), true);
$PAGE->requires->js('/mod/scorm/request.js', true);
$PAGE->requires->js('/lib/cookies.js', true);
//$PAGE->requires->js('/mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr, true);
$PAGE->requires->css('/mod/scorm/styles.css');
// Print the page header
$bodyscript = '';
if ($scorm->popup == 1) {
$bodyscript = 'onunload="main.close();"';
}
echo $OUTPUT->header();
$exitlink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'" title="'.$strexit.'">'.$strexit.'</a> ';
// NEW IMS TOC
$PAGE->requires->string_for_js('navigation', 'scorm');
$PAGE->requires->string_for_js('toc', 'scorm');
$PAGE->requires->string_for_js('hide', 'moodle');
$PAGE->requires->string_for_js('show', 'moodle');
$PAGE->requires->string_for_js('popupsblocked', 'scorm');
$PAGE->set_button($exitlink);
$name = false;
$PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,
'cheight'=>$scorm->height,
'popupoptions' => $scorm->options), true);
$PAGE->requires->js('/mod/scorm/request.js', true);
$PAGE->requires->js('/lib/cookies.js', true);
$PAGE->requires->css('/mod/scorm/styles.css');
echo $OUTPUT->header();
// NEW IMS TOC
$PAGE->requires->string_for_js('navigation', 'scorm');
$PAGE->requires->string_for_js('toc', 'scorm');
$PAGE->requires->string_for_js('hide', 'moodle');
$PAGE->requires->string_for_js('show', 'moodle');
$PAGE->requires->string_for_js('popupsblocked', 'scorm');
$name = false;
?>
<div id="scormpage">
@@ -190,21 +197,21 @@
</div>
<div id="scormtop">
<?php
if ($result->prerequisites) {
if ($scorm->popup != 0) {
//Added incase javascript popups are blocked we don't provide a direct link to the pop-up as JS communication can fail - the user must disable their pop-up blocker.
$linkcourse = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'">' . get_string('finishscormlinkname','scorm') . '</a>';
echo $OUTPUT->box(get_string('finishscorm','scorm',$linkcourse), 'generalbox', 'altfinishlink');
}
if ($result->prerequisites) {
if ($scorm->popup != 0) {
//Added incase javascript popups are blocked we don't provide a direct link to the pop-up as JS communication can fail - the user must disable their pop-up blocker.
$linkcourse = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'">' . get_string('finishscormlinkname', 'scorm') . '</a>';
echo $OUTPUT->box(get_string('finishscorm', 'scorm', $linkcourse), 'generalbox', 'altfinishlink');
}
}
?>
<?php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?>
<?php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?>
<?php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">'.get_string('browsemode', 'scorm')."</div>\n" : ''; ?>
<?php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">'.get_string('reviewmode', 'scorm')."</div>\n" : ''; ?>
<div id="scormnav" class="scorm-right">
<?php
if ($scorm->hidetoc == 2) {
echo $result->tocmenu;
}
if ($scorm->hidetoc == 2) {
echo $result->tocmenu;
}
?>
</div> <!-- Scormnav -->
</div> <!-- Scormtop -->
@@ -214,23 +221,25 @@
</div> <!-- tocbox -->
<noscript>
<div id="noscript">
<?php print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
<?php print_string('noscriptnoscorm', 'scorm'); // No Martin(i), No Party ;-) ?>
</div>
</noscript>
<?php
if ($result->prerequisites) {
if ($scorm->popup != 0) {
// Clean the name for the window as IE is fussy
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
if (!$name) {
$name = 'DefaultPlayerWindow';
}
$name = 'scorm_'.$name;
echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js');
echo html_writer::script(js_writer::function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop, $name, $scorm->options, $scorm->width, $scorm->height)));
?>
if ($result->prerequisites) {
if ($scorm->popup != 0) {
// Clean the name for the window as IE is fussy
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
if (!$name) {
$name = 'DefaultPlayerWindow';
}
$name = 'scorm_'.$name;
echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js');
echo html_writer::script(
js_writer::function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop,
$name, $scorm->options,
$scorm->width, $scorm->height)));
?>
<noscript>
<!--[if IE]>
<iframe id="main" class="scoframe" name="main" src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></iframe>
@@ -239,11 +248,11 @@
<object id="main" class="scoframe" type="text/html" data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></object>
<![endif]-->
</noscript>
<?php
}
} else {
echo $OUTPUT->box(get_string('noprerequisites','scorm'));
<?php
}
} else {
echo $OUTPUT->box(get_string('noprerequisites', 'scorm'));
}
?>
</div> <!-- SCORM page -->
<?php
+61 -49
View File
@@ -1,59 +1,71 @@
<?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/>.
// this page is called via AJAX to repopulte the TOC when LMSFinish() is called
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
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
$mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
$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
$mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
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');
}
$PAGE->set_url('/mod/scorm/prereqs.php', array('scoid'=>$scoid,'attempt'=>$attempt, 'id'=>$cm->id));
require_login($course->id, false, $cm);
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
$scorm->version = 'scorm_12';
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
print_error('coursemisconf');
}
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
$request = null;
if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) {
$result = scorm_get_toc($USER,$scorm,$cm->id,TOCJSLINK,$currentorg,$scoid,$mode,$attempt,true, false);
echo $result->toc;
}
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/prereqs.php', array('scoid'=>$scoid, 'attempt'=>$attempt, 'id'=>$cm->id));
require_login($course->id, false, $cm);
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
$scorm->version = 'scorm_12';
}
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
$request = null;
if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
$result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, false);
echo $result->toc;
}
}
+20 -8
View File
@@ -1,4 +1,18 @@
<?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/>.
// This script uses installed report plugins to print quiz reports
@@ -141,7 +155,7 @@ if ( !$nostudents ) {
$headers = array();
if (!$download && $candelete) {
$columns[]= 'checkbox';
$headers[]= NULL;
$headers[]= null;
}
if (!$download && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
@@ -170,7 +184,7 @@ if ( !$nostudents ) {
}
}
} else {
$scoes = NULL;
$scoes = null;
}
if (!$download) {
@@ -326,8 +340,7 @@ if ( !$nostudents ) {
if (!$download) {
$sort = $table->get_sql_sort();
}
else {
} else {
$sort = '';
}
// Fix some wired sorting
@@ -349,7 +362,7 @@ if ( !$nostudents ) {
$count = $DB->get_record_sql($countsql);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND '.$twhere;
$countsql .= ' AND '.$twhere;
}
$count = $DB->get_record_sql($countsql, $params);
$total = $count->nbresults;
@@ -377,7 +390,7 @@ $countsql .= ' AND '.$twhere;
// Start form
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo '<form id="attemptsform" method="post" action="' . $reporturlwithdisplayoptions->out(true) .
'" onsubmit="return confirm(\''.$strreallydel.'\');">';
'" onsubmit="return confirm(\''.$strreallydel.'\');">';
echo '<input type="hidden" name="action" value="delete"/>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<div style="display: none;">';
@@ -457,8 +470,7 @@ $countsql .= ' AND '.$twhere;
if (isset($trackdata->$maxkey)) {
$score .= '/'.$trackdata->$maxkey;
}
// else print out status
} else {
} else { // else print out status
$score = $strstatus;
}
if (!$download) {
+19 -5
View File
@@ -1,11 +1,26 @@
<?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/>.
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once "$CFG->libdir/formslib.php";
require_once("$CFG->libdir/formslib.php");
class mod_scorm_report_settings extends moodleform {
function definition() {
global $COURSE;
$mform =& $this->_form;
@@ -14,8 +29,8 @@ class mod_scorm_report_settings extends moodleform {
$options = array();
if ($this->_customdata['currentgroup'] || $COURSE->id != SITEID) {
$options[SCORM_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents','scorm');
$options[SCORM_REPORT_ATTEMPTS_STUDENTS_WITH] = get_string('optattemptsonly','scorm');
$options[SCORM_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents', 'scorm');
$options[SCORM_REPORT_ATTEMPTS_STUDENTS_WITH] = get_string('optattemptsonly', 'scorm');
$options[SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'scorm');
}
$mform->addElement('select', 'attemptsmode', get_string('show', 'scorm'), $options);
@@ -30,5 +45,4 @@ class mod_scorm_report_settings extends moodleform {
$this->add_action_buttons(false, get_string('savepreferences'));
}
}
+25 -11
View File
@@ -1,4 +1,18 @@
<?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/>.
defined('MOODLE_INTERNAL') || die;
@@ -7,24 +21,24 @@ if ($ADMIN->fulltree) {
$yesno = array(0 => get_string('no'),
1 => get_string('yes'));
$settings->add(new admin_setting_configselect('scorm/grademethod', get_string('grademethod', 'scorm'),get_string('grademethoddesc', 'scorm'), GRADEHIGHEST, scorm_get_grade_method_array()));
$settings->add(new admin_setting_configselect('scorm/grademethod', get_string('grademethod', 'scorm'), get_string('grademethoddesc', 'scorm'), GRADEHIGHEST, scorm_get_grade_method_array()));
for ($i=0; $i<=100; $i++) {
$grades[$i] = "$i";
$grades[$i] = "$i";
}
$settings->add(new admin_setting_configselect('scorm/maxgrade', get_string('maximumgrade'),get_string('maximumgradedesc','scorm'), 100, $grades));
$settings->add(new admin_setting_configselect('scorm/maxgrade', get_string('maximumgrade'), get_string('maximumgradedesc', 'scorm'), 100, $grades));
$settings->add(new admin_setting_configtext('scorm/maxattempts', get_string('maximumattempts', 'scorm'), '', 0, PARAM_INT));
$settings->add(new admin_setting_configselect('scorm/displayattemptstatus', get_string('displayattemptstatus', 'scorm'),get_string('displayattemptstatusdesc', 'scorm'),0,$yesno));
$settings->add(new admin_setting_configselect('scorm/displayattemptstatus', get_string('displayattemptstatus', 'scorm'), get_string('displayattemptstatusdesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect('scorm/displaycoursestructure', get_string('displaycoursestructure', 'scorm'),get_string('displaycoursestructuredesc', 'scorm'),0,$yesno));
$settings->add(new admin_setting_configselect('scorm/displaycoursestructure', get_string('displaycoursestructure', 'scorm'), get_string('displaycoursestructuredesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect('scorm/forcecompleted', get_string('forcecompleted', 'scorm'),get_string('forcecompleteddesc', 'scorm'),0,$yesno));
$settings->add(new admin_setting_configselect('scorm/forcecompleted', get_string('forcecompleted', 'scorm'), get_string('forcecompleteddesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect('scorm/forcenewattempt', get_string('forcenewattempt', 'scorm'),get_string('forcenewattemptdesc', 'scorm'),0,$yesno));
$settings->add(new admin_setting_configselect('scorm/forcenewattempt', get_string('forcenewattempt', 'scorm'), get_string('forcenewattemptdesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect('scorm/lastattemptlock', get_string('lastattemptlock', 'scorm'),get_string('lastattemptlockdesc', 'scorm'),0,$yesno));
$settings->add(new admin_setting_configselect('scorm/lastattemptlock', get_string('lastattemptlock', 'scorm'), get_string('lastattemptlockdesc', 'scorm'), 0, $yesno));
$settings->add(new admin_setting_configselect('scorm/whatgrade', get_string('whatgrade', 'scorm'), get_string('whatgradedesc', 'scorm'), HIGHESTATTEMPT, scorm_get_what_grade_array()));
@@ -32,10 +46,10 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtext('scorm/frameheight', get_string('height', 'scorm'), get_string('frameheight', 'scorm'), 500));
$settings->add(new admin_setting_configselect('scorm/popup', get_string('display','scorm'), get_string('displaydesc','scorm'), 0, scorm_get_popup_display_array()));
$settings->add(new admin_setting_configselect('scorm/popup', get_string('display', 'scorm'), get_string('displaydesc', 'scorm'), 0, scorm_get_popup_display_array()));
foreach(scorm_get_popup_options_array() as $key => $value){
$settings->add(new admin_setting_configcheckbox('scorm/'.$key, get_string($key, 'scorm'),'',$value));
foreach (scorm_get_popup_options_array() as $key => $value) {
$settings->add(new admin_setting_configcheckbox('scorm/'.$key, get_string($key, 'scorm'), '', $value));
}
$settings->add(new admin_setting_configselect('scorm/skipview', get_string('skipview', 'scorm'), get_string('skipviewdesc', 'scorm'), 0, scorm_get_skip_view_array()));
+20 -5
View File
@@ -1,4 +1,19 @@
<?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/>.
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
}
@@ -7,7 +22,7 @@ if (!defined('MOODLE_INTERNAL')) {
// Make sure the code being tested is accessible.
require_once($CFG->dirroot . '/mod/scorm/locallib.php'); // Include the code to test
class scorm_formatduration_test extends UnitTestCase {
function test_scorm2004_format() {
$stryears = get_string('years');
@@ -22,12 +37,12 @@ class scorm_formatduration_test extends UnitTestCase {
$validates = array(1=>"1 $strhours 12 $strminutes 43.12 $strseconds", 2=>"15.3 $strseconds", 3=>"1 $stryears 2 $strmonths 5 $strdays 7 $strminutes ",
4=>"1 $strminutes ", 5=>"1 $stryears 15 $strminutes 0.01 $strseconds", 6=>'', 7=>"1 $strmonths 4 $strminutes 0.30 $strseconds",
8=>'', 9=>"1 $strdays 2 $strhours 3 $strseconds", 10=>"4 $strmonths ");
foreach ($SUTs as $key=>$SUT) {
foreach ($SUTs as $key => $SUT) {
$formatted = scorm_format_duration($SUT);
$this->assertEqual($formatted, $validates[$key]);
}
}
function test_scorm12_format() {
$stryears = get_string('years');
$strmonths = trim(get_string('nummonths'));
@@ -41,12 +56,12 @@ class scorm_formatduration_test extends UnitTestCase {
$validates = array(1=>'', 2=>"1 $strhours 2 $strminutes 3 $strseconds", 3=>"12 $strhours 34 $strminutes 56.78 $strseconds",
4=>"12 $strminutes 0.03 $strseconds", 5=>"1 $strhours 23 $strseconds", 6=>"12 $strminutes 34 $strseconds",
7=>"1 $strminutes 2.03 $strseconds", 8=>"0.1 $strseconds", 9=>"1 $strhours 23 $strminutes ", 10=>"2 $strhours ");
foreach ($SUTs as $key=>$SUT) {
foreach ($SUTs as $key => $SUT) {
$formatted = scorm_format_duration($SUT);
$this->assertEqual($formatted, $validates[$key]);
}
}
function test_non_datetime() {
}
}
+16 -1
View File
@@ -1,4 +1,19 @@
<?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/>.
/**
* Sets up the tabs used by the scorm pages based on the users capabilities.
*
@@ -26,7 +41,7 @@ $inactive = array();
$activated = array();
if (has_capability('mod/scorm:savetrack', $contextmodule)) {
$row[] = new tabobject('info', "$CFG->wwwroot/mod/scorm/view.php?id=$cm->id", get_string('info', 'scorm'));
$row[] = new tabobject('info', "$CFG->wwwroot/mod/scorm/view.php?id=$cm->id", get_string('info', 'scorm'));
}
if (has_capability('mod/scorm:viewreport', $contextmodule)) {
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/scorm/report.php?id=$cm->id", get_string('results', 'scorm'));
+2 -3
View File
@@ -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
@@ -246,7 +245,7 @@ if (!empty($b)) {
'cmi.interactions.'.$i.'.learner_response');
$row = array();
foreach ($elements as $element) {
if (isset($trackdata->$element)) {
if (isset($trackdata->$element)) {
$row[] = s($trackdata->$element);
$printedelements[]=$element;
} else {
@@ -315,7 +314,7 @@ if (!empty($b)) {
$existelements = false;
foreach ( $trackdata as $element => $value) {
foreach ($trackdata as $element => $value) {
if (substr($element, 0, 3) == 'cmi') {
if (!(in_array ($element, $printedelements))) {
$existelements = true;
+22 -5
View File
@@ -1,10 +1,27 @@
<?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/>.
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of scorm
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
/**
* scorm version information.
*
* @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
*/
$module->version = 2011021400; // The (date) version of this module
$module->requires = 2010080300; // The version of Moodle that is required
+100 -87
View File
@@ -1,99 +1,112 @@
<?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($CFG->dirroot.'/mod/scorm/locallib.php');
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
$organization = optional_param('organization', '', PARAM_INT); // organization ID
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$organization = optional_param('organization', '', PARAM_INT); // organization ID
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');
}
$url = new moodle_url('/mod/scorm/view.php', array('id'=>$cm->id));
if ($organization !== '') {
$url->param('organization', $organization);
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
print_error('coursemisconf');
}
$PAGE->set_url($url);
$forcejs = get_config('scorm','forcejavascript');
if (!empty($forcejs)) {
$PAGE->add_body_class('forcejavascript');
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
print_error('invalidcoursemodule');
}
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$contextmodule = get_context_instance(CONTEXT_MODULE,$cm->id);
if (isset($SESSION->scorm_scoid)) {
unset($SESSION->scorm_scoid);
} else if (!empty($a)) {
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
print_error('invalidcoursemodule');
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
if ((has_capability('mod/scorm:skipview', $contextmodule)) && scorm_simple_play($scorm,$USER, $contextmodule)) {
exit;
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
print_error('coursemisconf');
}
//
// Print the page header
//
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
$currenttab = 'info';
require($CFG->dirroot . '/mod/scorm/tabs.php');
// Print the main part of the page
echo $OUTPUT->heading(format_string($scorm->name));
$attemptstatus = '';
if ($scorm->displayattemptstatus == 1) {
$attemptstatus = scorm_get_attempt_status($USER,$scorm);
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
print_error('invalidcoursemodule');
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
} else {
print_error('missingparameter');
}
$scormopen = true;
$timenow = time();
if (!empty($scorm->timeopen) && $scorm->timeopen > $timenow) {
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
$scormopen = false;
}
if (!empty($scorm->timeclose) && $timenow > $scorm->timeclose) {
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
$scormopen = false;
}
if ($scormopen) {
scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
}
if (!empty($forcejs)) {
echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
}
echo $OUTPUT->footer();
$url = new moodle_url('/mod/scorm/view.php', array('id'=>$cm->id));
if ($organization !== '') {
$url->param('organization', $organization);
}
$PAGE->set_url($url);
$forcejs = get_config('scorm', 'forcejavascript');
if (!empty($forcejs)) {
$PAGE->add_body_class('forcejavascript');
}
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
if (isset($SESSION->scorm_scoid)) {
unset($SESSION->scorm_scoid);
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
if ((has_capability('mod/scorm:skipview', $contextmodule)) && scorm_simple_play($scorm, $USER, $contextmodule)) {
exit;
}
//
// Print the page header
//
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
$currenttab = 'info';
require($CFG->dirroot . '/mod/scorm/tabs.php');
// Print the main part of the page
echo $OUTPUT->heading(format_string($scorm->name));
$attemptstatus = '';
if ($scorm->displayattemptstatus == 1) {
$attemptstatus = scorm_get_attempt_status($USER, $scorm);
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
$scormopen = true;
$timenow = time();
if (!empty($scorm->timeopen) && $scorm->timeopen > $timenow) {
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
$scormopen = false;
}
if (!empty($scorm->timeclose) && $timenow > $scorm->timeclose) {
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
$scormopen = false;
}
if ($scormopen) {
scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
}
if (!empty($forcejs)) {
echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
}
echo $OUTPUT->footer();