Added user activity support

General TAB cleaning
SCO-LMS communication systeme changed to POST method
Several bug fix
This commit is contained in:
bobopinna 2005-05-23 06:56:10 +00:00
parent 362a7d40e1
commit 9633a42350
17 changed files with 1069 additions and 900 deletions

View File

@ -1,17 +1,20 @@
SCORM Module by Roberto "Bobo" Pinna
This module is a SCORM player that import SCORM packages in .zip or .pif format
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.
It plays SCORM1.2 and AICC packages.
It plays SCORM1.2 and launch AICC packages.
Moodle SCORM Module is SCORM Version 1.2 Run-Time Environment Conformant -
Minimum with All Optional Data Model Elements (LMS-RTE3)
THIS MODULE IS JAVA FREE.
================================================================
Still in development (you can see this as a road map):
- LMS store for all datamodels for AICC;
- support for playing SCORM 1.3;
- LMS store for all datamodels;
- navigation/sequencing (prerequisites, objective,etc...);
- SCORM packages validation (I disabled the old one);
@ -27,7 +30,7 @@ mod.html <-- onsubmit --> validate.php (-- include --> validatordomxml.php)
submit load
|| \
|| \
\/ request.js
\/ request.js
view.php
----------------------------------------------------------------
@ -42,7 +45,7 @@ view.php
||
\/
playscorm.php -- load --> request.js
|| api.php -- include --> datamodels/((SCORM1_2.js.php &| SCORM1_3.js.php) || AICC.js.php)
|| api.php -- include --> datamodels/(SCORM1_2.js.php || SCORM1_3.js.php || AICC.js.php)
|| /\
iframe ||
"main"<----- XMLHTTP
@ -53,8 +56,8 @@ playscorm.php -- load --> request.js
loadSCO.php |
| |
| |
---------
reload itself
---------
reload itself
to the right sco

View File

@ -5,113 +5,114 @@
require_login($course->id, false, $cm);
if (isset($_POST['command']) && confirm_sesskey($_POST['session_id'])) {
$command = strtolower($_POST['command']);
if (isset($SESSION->scorm_scoid)) {
$scoid = $SESSION->scorm_scoid;
} else {
error('Invalid script call');
}
$mode = 'normal';
if (isset($SESSION->scorm_mode)) {
$mode = $SESSION->scorm_mode;
}
$status = $SESSION->scorm_status;
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if (!$scorm = get_record('scorm','id',$sco->scorm)) {
error('Invalid script call');
}
} else {
error('Invalid script call');
}
if ($scorm = get_record('scorm','id',$sco->scorm)) {
switch $command {
case 'getparam':
if ($status == 'Not Initialized') {
$SESSION->scorm_status = 'Running';
$status = 'Running';
}
if ($status != 'Running') {
echo "error = 101\nerror_text = Terminated\n";
} else {
if ($usertrack=scorm_get_tracks($scoid,$USER->id)) {
$userdata = $usertrack;
} else {
$userdata->status = '';
$userdata->scorre_raw = '';
}
$userdata->student_id = $USER->username;
$userdata->student_name = $USER->lastname .', '. $USER->firstname;
$userdata->mode = $mode;
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
$userdata->datafromlms = $sco->datafromlms;
$userdata->masteryscore = $sco->masteryscore;
$userdata->maxtimeallowed = $sco->maxtimeallowed;
$userdata->timelimitaction = $sco->timelimitaction;
if (!empty($sco->masteryscore)) {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
} else {
error('Sco not found');
}
echo "error = 0\nerror_text = Successful\naicc_data=\n";
echo "[Core]\n";
echo 'Student_ID = '.$userdata->student_id."\n";
echo 'Student_Name = '.$userdata->student_name."\n";
echo 'Lesson_Location = '.isset($userdata->{'cmi.core.lesson_location'})?$userdata->{'cmi.core.lesson_location'}:''."\n";
echo 'Credit = '.$userdata->credit."\n";
echo 'Lesson_Status = '.isset($userdata->{'cmi.core.lesson_status'})?$userdata->{'cmi.core.lesson_status'}:''."\n";
echo 'Score = '.isset($userdata->{'cmi.core.score.raw'})?$userdata->{'cmi.core.score.raw'}:''."\n";
echo 'Time = '.isset($userdata->{'cmi.core.total_time'})?$userdata->{'cmi.core.total_time'}:'00:00:00'."\n";
echo "[Core_Lesson]\n".isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:''."\n";
echo "[Core_Vendor]\n".$userdata->datafromlms."\n";
}
break;
case 'putparam':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putcomments':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putinteractions':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putobjectives':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putpath':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putperformance':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'exitau':
if ($status == 'Running') {
$SESSION->scorm_status = 'Terminated';
echo "error = 0\nerror_text = Successful\n";
}
break;
$command = strtolower($_POST['command']);
if (isset($SESSION->scorm_scoid)) {
$scoid = $SESSION->scorm_scoid;
} else {
error('Invalid script call');
}
$mode = 'normal';
if (isset($SESSION->scorm_mode)) {
$mode = $SESSION->scorm_mode;
}
$status = $SESSION->scorm_status;
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if (!$scorm = get_record('scorm','id',$sco->scorm)) {
error('Invalid script call');
}
} else {
error('Invalid script call');
}
if ($scorm = get_record('scorm','id',$sco->scorm)) {
switch $command {
case 'getparam':
if ($status == 'Not Initialized') {
$SESSION->scorm_status = 'Running';
$status = 'Running';
}
if ($status != 'Running') {
echo "error = 101\nerror_text = Terminated\n";
} else {
if ($usertrack=scorm_get_tracks($scoid,$USER->id)) {
$userdata = $usertrack;
} else {
$userdata->status = '';
$userdata->scorre_raw = '';
}
$userdata->student_id = $USER->username;
$userdata->student_name = $USER->lastname .', '. $USER->firstname;
$userdata->mode = $mode;
if ($sco = get_record('scorm_scoes','id',$scoid)) {
$userdata->datafromlms = $sco->datafromlms;
$userdata->masteryscore = $sco->masteryscore;
$userdata->maxtimeallowed = $sco->maxtimeallowed;
$userdata->timelimitaction = $sco->timelimitaction;
if (!empty($sco->masteryscore)) {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
echo "error = 0\nerror_text = Successful\naicc_data=\n";
echo "[Core]\n";
echo 'Student_ID = '.$userdata->student_id."\n";
echo 'Student_Name = '.$userdata->student_name."\n";
echo 'Lesson_Location = '.isset($userdata->{'cmi.core.lesson_location'})?$userdata->{'cmi.core.lesson_location'}:''."\n";
echo 'Credit = '.$userdata->credit."\n";
echo 'Lesson_Status = '.isset($userdata->{'cmi.core.lesson_status'})?$userdata->{'cmi.core.lesson_status'}:''."\n";
echo 'Score = '.isset($userdata->{'cmi.core.score.raw'})?$userdata->{'cmi.core.score.raw'}:''."\n";
echo 'Time = '.isset($userdata->{'cmi.core.total_time'})?$userdata->{'cmi.core.total_time'}:'00:00:00'."\n";
echo "[Core_Lesson]\n".isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:''."\n";
echo "[Core_Vendor]\n".$userdata->datafromlms."\n";
} else {
error('Sco not found');
}
}
break;
case 'putparam':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putcomments':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putinteractions':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putobjectives':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putpath':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'putperformance':
if ($status == 'Running') {
print_r($_POST['aicc_data']);
echo "error = 0\nerror_text = Successful\n";
}
break;
case 'exitau':
if ($status == 'Running') {
$SESSION->scorm_status = 'Terminated';
echo "error = 0\nerror_text = Successful\n";
}
break;
}
}
?>

View File

@ -48,9 +48,9 @@
$userdata->mode = $mode;
}
if ($userdata->mode == 'normal') {
$userdata->credit = 'credit';
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
$userdata->credit = 'no-credit';
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
$userdata->datafromlms = $sco->datafromlms;
@ -64,16 +64,16 @@
switch ($scorm->version) {
case 'SCORM_1.2':
include_once ('datamodels/scorm1_2.js.php');
break;
break;
case 'SCORM_1.3':
include_once ('datamodels/scorm1_3.js.php');
break;
include_once ('datamodels/scorm1_3.js.php');
break;
case 'AICC':
include_once ('datamodels/aicc.js.php');
break;
include_once ('datamodels/aicc.js.php');
break;
default:
include_once ('datamodels/scorm1_2.js.php');
break;
break;
}
?>

View File

@ -6,16 +6,16 @@
//
// scorm
// (CL,pk->id)---------------------
// | |
// | |
// | |
// scorm_scoes |
// (UL,pk->id, fk->scorm) |
// | |
// | |
// | |
// scorm_scoes_track |
// (UL,k->id, fk->scormid, fk->scoid, k->element)---
// | |
// | |
// | |
// scorm_scoes |
// (UL,pk->id, fk->scorm) |
// | |
// | |
// | |
// scorm_scoes_track |
// (UL,k->id, fk->scormid, fk->scoid, k->element)---
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
@ -50,6 +50,8 @@
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("BROWSEMODE",4,false,$scorm->browsemode));
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
fwrite ($bf,full_tag("WIDTH",4,false,$scorm->width));
fwrite ($bf,full_tag("HEIGHT",4,false,$scorm->height));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);

View File

@ -2,7 +2,7 @@
if (empty($CFG->scorm_frameheight)) {
$CFG->scorm_frameheight = 600;
}
if (empty($CFG->scorm_framewidth)) {
if (empty($CFG->scorm_framewidth)) {
$CFG->scorm_structurewidth = 800;
}
?>
@ -36,7 +36,7 @@
<input type="text" name="scorm_framewidth" value="<?php echo $CFG->scorm_framewidth ?>" size="3" />
</td>
<td>
<?php print_string("framewidth", "scorm") ?>
<?php print_string("framewidth", "scorm") ?>
</td>
</tr>
<tr valign="top">
@ -45,7 +45,7 @@
<input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="4" />
</td>
<td>
<?php print_string("frameheight", "scorm") ?>
<?php print_string("frameheight", "scorm") ?>
</td>
</tr>
<tr>

View File

@ -9,15 +9,12 @@
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
if (! $course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
error('Course module is incorrect');
}
} else {
if (! $scorm = get_record('scorm', 'id', $a)) {
error('Course module is incorrect');
@ -35,12 +32,13 @@
if (confirm_sesskey() && (isset($SESSION->scorm_scoid))) {
$scoid = $SESSION->scorm_scoid;
$result = true;
foreach ($_GET as $element => $value) {
foreach ($_POST as $element => $value) {
if (substr($element,0,3) == 'cmi') {
$element = str_replace('__','.',$element);
$element = preg_replace('/_(\d+)/',".\$1",$element);
if ($track = get_record_select('scorm_scoes_track',"userid='$USER->id' AND scormid='$scorm->id' AND scoid='$scoid' AND element='$element'")) {
$track->value = $value;
$track->timemodified = time();
$result = update_record('scorm_scoes_track',$track) && $result;
} else {
$track->userid = $USER->id;
@ -48,9 +46,9 @@
$track->scoid = $scoid;
$track->element = $element;
$track->value = $value;
$track->timemodified = time();
$result = insert_record('scorm_scoes_track',$track) && $result;
}
//print_r($track);
}
}
if ($result) {

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
optional_variable($id); // Course Module ID, or
optional_variable($a); // scorm ID
optional_variable($scoid); // sco ID
optional_variable($mode); // lesson mode
optional_variable($mode); // lesson mode
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
@ -33,35 +33,31 @@
}
require_login($course->id, false, $cm);
if (!empty($scoid)) {
if (!empty($scoid)) {
//
// Direct sco request
//
if ($sco = get_record("scorm_scoes","id",$scoid)) {
if ($sco->launch == '') {
// Search for the next launchable sco
if ($scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' AND id>".$sco->id,"id ASC")) {
$sco = current($scoes);
}
// Search for the next launchable sco
if ($scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' AND id>".$sco->id,"id ASC")) {
$sco = current($scoes);
}
}
}
} else {
//
// Search for first incomplete sco
//
if ( $scoes_track = get_records_select("scorm_scoes_track","userid=".$USER->id." AND element='cmi.core.lesson_status' AND scormid=".$scorm->id,"scoid ASC") ) {
$sco_track = current($scoes_track);
if ( $scoes_track = get_records_select("scorm_scoes_track","userid=".$USER->id." AND element='cmi.core.lesson_status' AND scormid=".$scorm->id,"scoid ASC") ) {
$sco_track = current($scoes_track);
while ((($sco_track->value == "completed") || ($sco_track->value == "passed") || ($sco_track->value == "failed")) && ($mode == "normal")) {
$sco_track = next($scoes_track);
$sco_track = next($scoes_track);
}
$sco = get_record("scorm_scoes","id",$sco_track->scoid);
}
}
//
}
//
// If no sco was found get the first of SCORM package
//
if (!isset($sco)) {
@ -78,13 +74,13 @@
if (stripos($sco->launch,'?') !== false) {
$connector = '&';
} else {
$connector = '?';
}
$connector = '?';
}
}
if (scorm_external_link($sco->launch)) {
if ($version == 'AICC') {
if (!empty($sco->parameters)) {
$sco->parameters = '&'. $sco->parameters;
$sco->parameters = '&'. $sco->parameters;
}
$result = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters;
} else {
@ -101,11 +97,11 @@
<html>
<head>
<title>LoadSCO</title>
<script language="javascript" type="text/javascript">
<!--
setTimeout('document.location = "<?php echo $result ?>";',1000);
-->
</script>
<script language="javascript" type="text/javascript">
<!--
setTimeout('document.location = "<?php echo $result ?>";',1000);
-->
</script>
</head>
<body>
&nbsp;

View File

@ -51,10 +51,10 @@
<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" ></script>
<script type="text/javascript">
function validate_scorm(theform,filename) {
//alert(filename);
//alert(filename);
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>");
//alert(result);
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>");
//alert(result);
results = result.split('\n');
result = '';
errorlogs = '';
@ -63,26 +63,26 @@
element = results[i].split('=');
//alert(element);
switch(element[0]) {
case 'result':
result = element[1];
break;
case 'launch':
launch = element[1];
break;
case 'datadir':
datadir = element[1];
break;
case 'pkgtype':
pkgtype = element[1];
break;
case 'errorlogs':
i++;
do {
errorlogs.concat(results[i]+'\n');
i++;
} while (i<results.lenght());
break;
case 'result':
result = element[1];
break;
case 'launch':
launch = element[1];
break;
case 'datadir':
datadir = element[1];
break;
case 'pkgtype':
pkgtype = element[1];
break;
case 'errorlogs':
i++;
do {
errorlogs.concat(results[i]+'\n');
i++;
} while (i<results.lenght());
break;
}
}
if ((result == "found") || (result == "regular")) {
@ -98,7 +98,7 @@
} else {
result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
if (errorlogs != '') {
result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
}
alert(result);
return false;
@ -122,15 +122,15 @@
<input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
</td>
</tr>
<?php
<?php
$strfilename = get_string("coursepacket", "scorm");
$strchooseafile = get_string("chooseapacket", "scorm");
?>
<tr valign="top">
<td align="right"><b><?php print_string("summary") ?>:</b><br />
<font size="1">
<?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
</font>
<font size="1">
<?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
</font>
</td>
<td>
<?php print_textarea($usehtmleditor, 10, 50, 680, 400, "summary", $form->summary); ?>
@ -138,15 +138,15 @@
</tr>
<tr valign="top">
<td align="right" nowrap="nowrap">
<b><?php echo $strfilename?>:</b>
<b><?php echo $strfilename?>:</b>
</td>
<td>
<?php
echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference",
"coursefiles", $strchooseafile, 500, 750, $strchooseafile);
helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true);
?>
<?php
echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference",
"coursefiles", $strchooseafile, 500, 750, $strchooseafile);
helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true);
?>
</td>
</tr>
<tr valign="top">
@ -165,12 +165,12 @@
for ($i=100; $i>=1; $i--) {
$grades[$i] = $i;
}
$disabled = $form->grademethod=='0';
$disabled = $form->grademethod=='0';
choose_from_menu($grades, 'maxgrade', "$form->maxgrade", '','','0',false,$disabled);
helpbutton('maxgrade', get_string('maximumgrade'), 'scorm');
?>
</td>
</tr>
</tr>
<tr>
<td align="right"><b><?php print_string("autocontinue","scorm") ?>:</b></td>
<td>
@ -198,30 +198,30 @@
<tr valign="top">
<td align="right"><b><?php print_string("width","scorm") ?>:</b></td>
<td>
<input type="text" name="width" value="<?php echo $form->width ?>" size="4" />
<input type="text" name="width" value="<?php echo $form->width ?>" size="4" />
<?php helpbutton("width", get_string("width", "scorm"), "scorm", true); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("height","scorm") ?>:</b></td>
<td>
<input type="text" name="height" value="<?php echo $form->height ?>" size="4" />
<input type="text" name="height" value="<?php echo $form->height ?>" size="4" />
<?php helpbutton("height", get_string("height", "scorm"), "scorm", true); ?>
</td>
</tr>
</table>
<input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
<input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
<input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
<input type="hidden" name="section" value="<?php p($form->section) ?>" />
<input type="hidden" name="module" value="<?php p($form->module) ?>" />
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
<input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
<input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
<input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
<input type="hidden" name="section" value="<?php p($form->section) ?>" />
<input type="hidden" name="module" value="<?php p($form->module) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<center>
<input type="submit" value="<?php print_string('savechanges') ?>" />
<input type="button" name="cancel" value="<?php print_string('cancel') ?>" onclick="document.location='view.php?id=<?php echo $form->course ?>'" />

View File

@ -12,11 +12,11 @@
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
if (! $course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
error('Course module is incorrect');
}
@ -34,10 +34,10 @@
}
require_login($course->id, false, $cm);
$strscorms = get_string('modulenameplural', 'scorm');
$strscorm = get_string('modulename', 'scorm');
if ($course->category) {
$navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
@ -48,11 +48,11 @@
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
if (!$cm->visible and !isteacher($course->id)) {
print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
notice(get_string("activityiscurrentlyhidden"));
}
//
// Checkin script parameters
//
@ -74,42 +74,39 @@
$currentorg = $_POST['currentorg'];
$currentorgstring = '&currentorg='.$currentorg;
}
$strexpand = get_string('expcoll','scorm');
$strpopup = get_string('popup','scorm');
//
// Print the page header
//
//$bodyscripts = "onunload='SCOFinish();'";
$bodyscripts = '';
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm),'',false,$bodyscripts);
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm));
?>
<table width="100%">
<tr><td valign="top">
<p><?php echo format_text($scorm->summary) ?></p>
<p><?php echo $mode == 'browse' ? get_string('browsemode','scorm') : '&nbsp;'; ?></p>
<table class='generalbox' cellpadding='5' cellspacing='0'>
<tr>
<th>
<div style='float: left;'><?php print_string('coursestruct','scorm') ?></div>
<!--<div style='float:right;'>
<a href='#' onClick='popup(main,popupimg);'><img id='popupimg' src="pix/popup.gif" alt="<?php echo $strpopup ?>" title="<?php echo $strpopup ?>"/></a>
</div> -->
</th>
</tr>
<!-- <tr><td width="<?php echo $CFG->scorm_structurewidth ?>%"> -->
<tr><td width="<?php echo $CFG->scorm_structurewidth ?>%">
<table class="fullscreen">
<tr><td class="top">
<p><?php echo format_text($scorm->summary) ?></p>
<p><?php echo $mode == 'browse' ? get_string('browsemode','scorm') : '&nbsp;'; ?></p>
<table class='generalbox' cellpadding='5' cellspacing='0'>
<tr>
<th>
<div class="structurehead"><?php print_string('coursestruct','scorm') ?></div>
<!--<div class="popupbutton">
<a href='#' onClick='popup(main,popupimg);'><img id='popupimg' src="pix/popup.gif" alt="<?php echo $strpopup ?>" title="<?php echo $strpopup ?>"/></a>
</div> -->
</th>
</tr>
<tr><td class="top">
<?php
$sco = scorm_display_structure($scorm,'scormlist',$currentorg,$scoid,$mode,true);
$sco = scorm_display_structure($scorm,'structurelist',$currentorg,$scoid,$mode,true);
if ($mode == 'normal') {
if ($trackdata = scorm_get_tracks($USER->id,$sco->id)) {
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
$mode = 'review';
$mode = 'review';
}
}
}
@ -119,68 +116,62 @@
$SESSION->scorm_scoid = $sco->id;
?>
</td></tr>
<tr><td align="center">
<form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top">
<input name="scoid" type="hidden" />
<input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
<input name="mode" type="hidden" value="<?php echo $mode ?>" />
<input name="prev" type="<?php if (($sco->prev == 0) || ($sco->showprev == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="prevSCO();" />
<input name="next" type="<?php if (($sco->next == 0) || ($sco->shownext == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('next','scorm') ?>" onClick="nextSCO();" /><br />
<input name="exit" type="button" value="<?php print_string('exit','scorm') ?>" onClick="playSCO(0)" />
</form>
</td></tr>
</table>
</td></tr>
<tr><td class="center">
<form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top">
<input name="scoid" type="hidden" />
<input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
<input name="mode" type="hidden" value="<?php echo $mode ?>" />
<input name="prev" type="<?php if (($sco->prev == 0) || ($sco->showprev == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="prevSCO();" />
<input name="next" type="<?php if (($sco->next == 0) || ($sco->shownext == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('next','scorm') ?>" onClick="nextSCO();" /><br />
<input name="exit" type="button" value="<?php print_string('exit','scorm') ?>" onClick="playSCO(0)" />
</form>
</td></tr>
</table>
</td>
<td valign="top" width="<?php print $scorm->width ?>">
<iframe name="main" width="100%" height="<?php echo $scorm->height ?>" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></iframe>
<td class="top" width="<?php print $scorm->width ?>">
<iframe name="main" width="<?php print $scorm->width ?>" height="<?php echo $scorm->height ?>" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></iframe>
</td></tr>
</table>
<style type="text/css">
.scormlist {
list-style-type:none;
text-indent:-4ex;
}
</style>
<script language="javascript" type="text/javascript">
<!--
function playSCO(scoid) {
if (scoid == 0) {
document.location = 'view.php?id=<?php echo $cm->id ?>';
document.location = '<?php echo $CFG->wwwroot ?>/course/view.php?id=<?php echo $cm->course ?>';
} else {
document.navform.scoid.value=scoid;
document.navform.submit();
document.navform.scoid.value=scoid;
document.navform.submit();
}
}
function popup(win,image) {
win = window.open("loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>","","width=<?php echo $scorm->width ?>,height=<?php echo $scorm->height ?>,scrollbars=1");
image.src = "pix/popdown.gif";
return win;
}
function popup(win,image) {
win = window.open("loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>","","width=<?php echo $scorm->width ?>,height=<?php echo $scorm->height ?>,scrollbars=1");
image.src = "pix/popdown.gif";
return win;
}
function prevSCO() {
playSCO(<?php echo $sco->prev ?>);
}
function prevSCO() {
playSCO(<?php echo $sco->prev ?>);
}
function nextSCO() {
playSCO(<?php echo $sco->next ?>);
}
function nextSCO() {
playSCO(<?php echo $sco->next ?>);
}
function expandCollide(which,list) {
var nn=document.ids?true:false
var w3c=document.getElementById?true:false
var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all.";
var mid=w3c?").style":".style";
if (eval(beg+list+mid+".display") != "none") {
which.src = "pix/plus.gif";
eval(beg+list+mid+".display='none';");
} else {
which.src = "pix/minus.gif";
eval(beg+list+mid+".display='block';");
}
}
var nn=document.ids?true:false
var w3c=document.getElementById?true:false
var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all.";
var mid=w3c?").style":".style";
if (eval(beg+list+mid+".display") != "none") {
which.src = "pix/plus.gif";
eval(beg+list+mid+".display='none';");
} else {
which.src = "pix/minus.gif";
eval(beg+list+mid+".display='block';");
}
}
-->
</script>
<script language="JavaScript" type="text/javascript" src="request.js"></script>

View File

@ -6,18 +6,16 @@
require_once("lib.php");
optional_variable($id); // Course Module ID, or
optional_variable($b); // SCO ID
optional_variable($user);
optional_variable($b); // SCO ID
optional_variable($user); // User ID
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
@ -34,7 +32,6 @@
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
}
require_login($course->id, false, $cm);
@ -47,7 +44,6 @@
/// Print the page header
if (empty($noheader)) {
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
} else {
@ -58,115 +54,113 @@
$strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm");
$strname = get_string('name');
if (!empty($id)) {
if (!empty($id)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",
"", "", true);
} else {
} else {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
-> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
-> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
"", "", true);
}
}
print_heading(format_string($scorm->name));
}
if (!empty($id)) {
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {
$table->head = array('&nbsp;', $strname);
$table->align = array('center', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array(10, '*');
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$table->head[]=scorm_string_round($sco->title);
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
$table->size[] = '*';
}
$table->head = array('&nbsp;', $strname);
$table->align = array('center', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array(10, '*');
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$table->head[]=scorm_string_round($sco->title);
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
$table->size[] = '*';
}
}
foreach ($scousers as $scouser) {
if ($userdata = scorm_get_user_data($scouser->userid)) {
$row = '';
$row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a>";
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$anchorstart = '';
$anchorend = '';
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
if ($trackdata->score_raw != '') {
$scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
} else {
$anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.get_string('details','scorm').'">';
$anchorend = '</a>';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
$row[] = $anchorstart.'<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.$scoreview.$anchorend;
}
}
$table->data[] = $row;
}
}
print_table($table);
foreach ($scousers as $scouser) {
if ($userdata = scorm_get_user_data($scouser->userid)) {
$row = '';
$row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a>";
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$anchorstart = '';
$anchorend = '';
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
if ($trackdata->score_raw != '') {
$scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
} else {
$anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.
get_string('details','scorm').'">';
$anchorend = '</a>';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
$row[] = $anchorstart.'<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.$scoreview.$anchorend;
}
}
$table->data[] = $row;
}
}
print_table($table);
} else {
notice('No users to report');
}
}
} else {
if (!empty($user)) {
if ($userdata = scorm_get_user_data($user)) {
print_simple_box_start('center');
print_heading(format_string($sco->title));
echo '<div align="center">'."\n";
print_user_picture($user, $course->id, $userdata->picture, false, false);
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a><br />";
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$user)) {
if ($trackdata->score_raw != '') {
$scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
echo '<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
echo '</div>'."\n";
//print_r($trackdata);
foreach($trackdata as $element => $value) {
if (substr($element,0,3) == 'cmi') {
echo $element.' => '.$value.'<br />';
}
}
print_simple_box_end();
notice('No users to report');
}
}
} else {
error('Missing script parameter');
}
if (!empty($user)) {
if ($userdata = scorm_get_user_data($user)) {
print_simple_box_start('center');
print_heading(format_string($sco->title));
echo '<div align="center">'."\n";
print_user_picture($user, $course->id, $userdata->picture, false, false);
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a><br />";
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$user)) {
if ($trackdata->score_raw != '') {
$scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
echo '<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
echo '</div>'."\n";
foreach($trackdata as $element => $value) {
if (substr($element,0,3) == 'cmi') {
echo $element.' => '.$value.'<br />';
}
}
print_simple_box_end();
}
} else {
error('Missing script parameter');
}
}
if (empty($noheader)) {
print_footer($course);
}
?>

View File

@ -21,16 +21,16 @@ function NewHttpReq() {
}
function DoRequest(httpReq,url,param) {
//
// httpReq.open (Method("get","post"), URL(string), Asyncronous(true,false))
//
httpReq.open("get", url+'?'+param,false);
//httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
httpReq.send(null);
httpReq.open("POST", url,false);
httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
httpReq.send(param);
if (httpReq.status == 200) {
return httpReq.responseText;
return httpReq.responseText;
} else {
return httpReq.status;
return httpReq.status;
}
}

View File

@ -4,18 +4,18 @@
//This is the "graphical" structure of the scorm mod:
//
// scorm
// scorm
// (CL,pk->id)---------------------
// | |
// | |
// | |
// scorm_scoes |
// (UL,pk->id, fk->scorm) |
// | |
// | |
// | |
// scorm_scoes_track |
// (UL,pk->id, fk->scormid, fk->scoid, fk->userid)--
// | |
// | |
// | |
// scorm_scoes |
// (UL,pk->id, fk->scorm) |
// | |
// | |
// | |
// scorm_scoes_track |
// (UL,pk->id, fk->scormid, fk->scoid, fk->userid)--
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
@ -52,11 +52,13 @@
$scorm->launch = backup_todb($info['MOD']['#']['LAUNCH']['0']['#']);
$scorm->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
$scorm->auto = backup_todb($info['MOD']['#']['AUTO']['0']['#']);
$scorm->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']);
$scorm->height = backup_todb($info['MOD']['#']['HEIGHT']['0']['#']);
$scorm->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the scorm
$newid = insert_record ("scorm",$scorm);
//Do some output
//Do some output
echo "<li>".get_string("modulename","scorm")." \"".format_string(stripslashes($scorm->name),true)."\"</li>";
backup_flush(300);
@ -64,13 +66,13 @@
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now copy moddata associated files
$status = scorm_restore_files ($scorm, $restore);
if ($status)
$status = scorm_scoes_restore_mods ($newid,$info,$restore);
} else {
$status = false;
}
@ -97,7 +99,7 @@
//We'll need this later!!
$oldid = backup_todb($sub_info['#']['ID']['0']['#']);
//Now, build the scorm_scoes record structure
$sco->scorm = $scorm_id;
$sco->manifest = backup_todb($sub_info['#']['MANIFEST']['0']['#']);
@ -117,7 +119,7 @@
//The structure is equal to the db, so insert the scorm_scoes
$newid = insert_record ("scorm_scoes",$sco);
//Now check if want to restore user data and do it.
if ($restore->mods['scorm']->userinfo) {
//Restore scorm_scoes
@ -134,7 +136,7 @@
}
backup_flush(300);
}
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"scorm_scoes", $oldid, $newid);
@ -145,7 +147,7 @@
return $status;
}
//This function restores the scorm_scoes_track
function scorm_scoes_tracks_restore_mods($scorm_id,$info,$restore) {
@ -179,7 +181,7 @@
if ($user) {
$sco_track->userid = $user->new_id;
}
//We have to recode the scoid field
$sco = backup_getid($restore->backup_unique_code,"scorm_scoes",$sco_track->scoid);
if ($sco) {
@ -202,7 +204,7 @@
return $status;
}
//This function copies the scorm related info from backup temp dir to course moddata folder,
//creating it if needed
function scorm_restore_files ($package, $restore) {
@ -222,7 +224,7 @@
//First, locate course's moddata directory
$moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
//Check it exists and create it
$status = check_dir_exists($moddata_path,true);
@ -247,19 +249,19 @@
if ($status and $todo) {
//Make scorm package directory path
$this_scorm_path = $scorm_path."/".$package->id;
$status = backup_copy_file($temp_path, $this_scorm_path);
}
return $status;
}
//This function returns a log record with all the necessay transformations
//done. It's used by restore_log_module() to restore modules log.
function scorm_restore_logs($restore,$log) {
$status = true;
return $status;
}
?>

35
mod/scorm/styles.php Normal file
View File

@ -0,0 +1,35 @@
.top {
vertical-align: top;
}
.center {
text-align: center;
}
.fullscreen {
width: 100%;
}
.structlist {
list-style-type: none;
white-space: nowrap;
font-size: small;
}
#mod-scorm-playscorm .structurehead {
float: left;
}
#mod-scorm-playscorm .structurelist {
list-style-type: none;
text-indent:-4ex;
font-size: small;
}
#mod-scorm-playscorm .popupbutton {
float: right;
}
#mod-scorm-view .structurehead {
font-weight: bold;
text-align: center;
}
#mod-scorm-view .structurelist {
list-style-type: none;
white-space: nowrap;
}

View File

@ -6,71 +6,69 @@ require_once("lib.php");
require_login();
if (confirm_sesskey()) {
$reference = clean_param($_GET["reference"], PARAM_PATH);
$courseid = $_GET["id"];
$reference = clean_param($_POST["reference"], PARAM_PATH);
$courseid = $_POST["id"];
$launch = 0;
if (isset($_GET["instance"])) {
$scormid = $_GET["instance"];
if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) {
$fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r");
$fstat = fstat($fp);
fclose($fp);
if ($scorm = get_record("scorm","id",$scormid)) {
$launch = $scorm->launch;
if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
// This is a new package
$launch = 0;
} else {
// Old package already validated
$validation->result = 'found';
if (strpos($scorm->version,'AICC') !== false) {
$validation->pkgtype = 'AICC';
} else {
$validation->pkgtype = 'SCORM';
}
}
} else {
$validation->result = 'badinstance';
$launch = -1;
if (isset($_POST["instance"])) {
$scormid = $_POST["instance"];
if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) {
$fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r");
$fstat = fstat($fp);
fclose($fp);
if ($scorm = get_record("scorm","id",$scormid)) {
$launch = $scorm->launch;
if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
// This is a new package
$launch = 0;
} else {
// Old package already validated
$validation->result = 'found';
if (strpos($scorm->version,'AICC') !== false) {
$validation->pkgtype = 'AICC';
} else {
$validation->pkgtype = 'SCORM';
}
}
} else {
$validation->result = 'badinstance';
$launch = -1;
}
} else {
$validation->result = 'badreference';
$launch = -1;
}
} else {
$validation->result = 'badreference';
$launch = -1;
}
}
//$launch = 0;
if ($launch == 0) {
//
// Package must be validated
//
//
// Package must be validated
//
// Create a temporary directory to unzip package and validate package
$tempdir = '';
$scormdir = '';
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
if ($tempdir = scorm_datadir($scormdir)) {
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
$ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.')));
if (($ext == '.zip') || ($ext == '.pif')) {
unzip_file($tempdir."/".basename($reference), $tempdir, false);
$validation = scorm_validate($tempdir);
} else {
$validation->result = "packagefile";
}
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
if ($tempdir = scorm_datadir($scormdir)) {
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
$ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.')));
if (($ext == '.zip') || ($ext == '.pif')) {
unzip_file($tempdir."/".basename($reference), $tempdir, false);
unlink ($tempdir."/".basename($reference));
$validation = scorm_validate($tempdir);
} else {
$validation->result = "packagefile";
}
} else {
$validation->result = "packagedir";
}
} else {
$validation->result = "packagedir";
$validation->result = "datadir";
}
} else {
$validation->result = "datadir";
}
if (($validation->result != "regular") && ($validation->result != "found")) {
$validation->result = get_string($validation->result,'scorm');
if (($validation->result != "regular") && ($validation->result != "found")) {
$validation->result = get_string($validation->result,'scorm');
if (is_dir($tempdir)) {
// Delete files and temporary directory
scorm_delete_files($tempdir);
} else {
// Delete package file
unlink ($tempdir."/".basename($reference));
}
} else {
$datadir = substr($tempdir,strlen($scormdir));
@ -79,25 +77,21 @@ if (confirm_sesskey()) {
//
// Print validation result
//
echo 'result=' . $validation->result . "\n";
echo 'result=' . $validation->result . "\n";
echo 'launch=' . $launch . "\n";
if (isset($validation->pkgtype)) {
echo 'pkgtype=' . $validation->pkgtype . "\n";
echo 'pkgtype=' . $validation->pkgtype . "\n";
}
if (isset($datadir)) {
echo 'datadir=' . $datadir . "\n";
echo 'datadir=' . $datadir . "\n";
}
if (isset($validation->errors[1])) {
echo 'errorlogs='."\n";
foreach($validation->errors as $error) {
echo get_string($error->type,"scorm",$error->data) . "\n";
echo 'errorlogs='."\n";
foreach($validation->errors as $error) {
echo get_string($error->type,"scorm",$error->data) . "\n";
}
}
}
/*if ($validation->pkgtype == 'AICC') {
scorm_parse_aicc("$CFG->dataroot/$courseid/$CFG->moddata/scorm$datadir",$scormid);
}*/
} else {
echo 'result=' . get_string('badrequest','scorm') . "\n";
echo 'result=' . get_string('badrequest','scorm') . "\n";
}
?>

View File

@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2005050800; // The (date) version of this module
$module->version = 2005052200; // The (date) version of this module
$module->requires = 2005021600; // The version of Moodle that is required
$module->cron = 0; // How often should cron check this module (seconds)?

View File

@ -13,15 +13,12 @@
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
@ -35,11 +32,11 @@
}
require_login($course->id, false, $cm);
if (isset($SESSION->scorm_scoid)) {
unset($SESSION->scorm_scoid);
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
@ -50,26 +47,27 @@
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
add_to_log($course->id, "scorm", "pre-view", "view.php?id=$cm->id", "$scorm->id");
$pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
//
// Print the page header
//
if (!$cm->visible and !isteacher($course->id)) {
print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), "", "", true,
update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
notice(get_string("activityiscurrentlyhidden"));
print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
notice(get_string('activityiscurrentlyhidden'));
} else {
print_header($pagetitle, "$course->fullname","$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",
"", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
print_header($pagetitle, "$course->fullname",
"$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
if (isteacher($course->id)) {
if ($trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c')) {
echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string("viewallreports","scorm",$trackedusers->c)."</a></div>";
echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
} else {
echo "<div class=\"reportlink\">".get_string("noreports","scorm")."</div>";
echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
}
}
// Print the main part of the page
@ -83,44 +81,47 @@
print_footer($course);
exit;
}
echo "<br />";
$liststyle = "style=\"list-style-type:none;\"";
print_simple_box_start("center");
echo "<table>\n";
echo " <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
print_simple_box_start('center');
?>
<div class="structurehead"><?php print_string('coursestruct','scorm') ?></div>
<?php
$organization = $scorm->launch;
if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) {
if (count($orgs) > 1) {
if (isset($_POST['organization'])) {
$organization = $_POST['organization'];
if (isset($_POST['organization'])) {
$organization = $_POST['organization'];
}
?>
<div class='center'>
<?php print_string('organizations','scorm') ?>
<form name='changeorg' method='post' action='view.php?id=<?php echo $cm->id ?>'>
<?php choose_from_menu($orgs, 'organization', "$organization", '','submit()') ?>
</form>
</div>
<?php
}
echo "<tr><td align='center'><form name='changeorg' method='post' action='view.php?id=$cm->id'>".get_string('organizations','scorm').": \n";
choose_from_menu($orgs, 'organization', "$organization", '','submit()');
echo "</form></td></tr>\n";
}
}
$orgidentifier = '';
if ($org = get_record('scorm_scoes','id',$organization)) {
if (($org->organization == '') && ($org->launch == '')) {
$orgidentifier = $org->identifier;
} else {
$orgidentifier = $org->organization;
$orgidentifier = '';
if ($org = get_record('scorm_scoes','id',$organization)) {
if (($org->organization == '') && ($org->launch == '')) {
$orgidentifier = $org->identifier;
} else {
$orgidentifier = $org->organization;
}
}
}
echo " <tr><td nowrap=\"nowrap\">\n";
$incomplete = scorm_display_structure($scorm,'scormlist',$orgidentifier);
echo "</td></tr>\n";
echo "</table>\n";
print_simple_box_end();
echo "<form name=\"theform\" method=\"post\" action=\"playscorm.php?id=$cm->id\">\n";
echo "<table align=\"center\">\n<tr>\n<td align=\"center\">";
?>
<?php $incomplete = scorm_display_structure($scorm,'structurelist',$orgidentifier); ?>
<?php print_simple_box_end(); ?>
<div class="center">
<form name="theform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>">
<?php
if ($scorm->browsemode == 1) {
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="b" name="mode" value="browse" /><label for="b">'.get_string('browse','scorm').'</label>'."\n";
if ($incomplete === true) {
echo "<input type=\"radio\" id=\"n\" name=\"mode\" value=\"normal\" checked=\"checked\" /><label for=\"n\">".get_string("normal","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=\"radio\" id=\"r\" name=\"mode\" value=\"review\" checked=\"checked\" /><label for=\"r\">".get_string("review","scorm")."</label>\n";
echo '<input type="radio" id="r" name="mode" value="review" checked="checked" /><label for="r">'.get_string('review','scorm')."</label>\n";
}
} else {
if ($incomplete === true) {
@ -128,38 +129,34 @@
} else {
echo '<input type="hidden" name="mode" value="review" />'."\n";
}
}
echo "</td>\n</tr>\n<tr><td align=\"center\">";
echo '<input type="hidden" name="scoid" />
<input type="hidden" name="currentorg" value="'.$orgidentifier.'" />
<input type="submit" value="'.get_string("entercourse","scorm").'" />';
echo "\n</td>\n</tr>\n</table>\n</form><br />";
}
?>
<style type="text/css">
.scormlist {
list-style-type:none;
}
</style>
<br />
<input type="hidden" name="scoid" />
<input type="hidden" name="currentorg" value="<?php echo $orgidentifier ?>" />
<input type="submit" value="<? print_string('entercourse','scorm') ?>" />
</form>
</div>
<script language="javascript" type="text/javascript">
<!--
function playSCO(scoid) {
document.theform.scoid.value = scoid;
document.theform.submit();
}
function expandCollide(which,list) {
var nn=document.ids?true:false
var w3c=document.getElementById?true:false
var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all.";
var mid=w3c?").style":".style";
if (eval(beg+list+mid+".display") != "none") {
which.src = "pix/plus.gif";
eval(beg+list+mid+".display='none';");
} else {
which.src = "pix/minus.gif";
eval(beg+list+mid+".display='block';");
}
}
}
-->
</script>