Several change to db fields, a complete redesign of user data track
This commit is contained in:
+11
-264
@@ -4,6 +4,7 @@
|
||||
|
||||
optional_variable($id); // Course Module ID, or
|
||||
optional_variable($a); // scorm ID
|
||||
optional_variable($userid); // user ID
|
||||
|
||||
if ($id) {
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
@@ -31,6 +32,12 @@
|
||||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
if (empty($userid) || !isteacher($course->id)) {
|
||||
$user = $USER;
|
||||
} else {
|
||||
$user = get_user_info_from_db('id', $userid);
|
||||
}
|
||||
?>
|
||||
|
||||
function SCOFinish(){
|
||||
@@ -39,17 +46,8 @@ function SCOFinish(){
|
||||
} */
|
||||
}
|
||||
|
||||
function closeMain() {
|
||||
if (document.all) {
|
||||
document.cookie = "SCORMpopup=" + escape(",top="+top.main.screenTop+",left="+top.main.screenLeft);
|
||||
} else {
|
||||
document.cookie = "SCORMpopup=" + escape(",top="+top.main.screenY+",left="+top.main.screenX);
|
||||
}
|
||||
top.main.close();
|
||||
}
|
||||
|
||||
//
|
||||
// SCORM API Implementation Call
|
||||
// SCORM Call Implementation
|
||||
//
|
||||
var errorCode = "0";
|
||||
|
||||
@@ -58,7 +56,7 @@ function SCORM_Call (call,param) {
|
||||
alert ("Invalid SCORM_Call function call: too few arguments.\nYou need pass at least 2 parameters");
|
||||
}
|
||||
var myRequest = NewHttpReq();
|
||||
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php?id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>&call="+call+param);
|
||||
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>&call="+call+param);
|
||||
//alert('Call: '+call+'\nParam: '+param+'\nResult: '+result);
|
||||
results = result.split('\n');
|
||||
|
||||
@@ -70,195 +68,9 @@ function SCORM_Call (call,param) {
|
||||
// SCORM 1.2 API Implementation
|
||||
//
|
||||
function SCORMapi1_2() {
|
||||
var Initialized = false;
|
||||
<?php include_once ('datamodels/scorm1_2.js'); ?>
|
||||
|
||||
function LMSInitialize (param) {
|
||||
if (param == "") {
|
||||
if (!Initialized) {
|
||||
Initialized = true;
|
||||
errorCode = "0";
|
||||
return "true";
|
||||
} else {
|
||||
errorCode = "101";
|
||||
}
|
||||
} else {
|
||||
errorCode = "201";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
|
||||
function LMSFinish (param) {
|
||||
if (param == "") {
|
||||
if (Initialized) {
|
||||
LMSCommit("");
|
||||
Initialized = false;
|
||||
errorCode = "0";
|
||||
return "true";
|
||||
} else {
|
||||
errorCode = "301";
|
||||
}
|
||||
} else {
|
||||
errorCode = "201";
|
||||
}
|
||||
}
|
||||
<?php include_once ('datamodels/scorm1_2.js.php'); ?>
|
||||
|
||||
function LMSGetValue (element) {
|
||||
if (Initialized) {
|
||||
if (element !="") {
|
||||
expression = new RegExp(CMIIndex,'g');
|
||||
element = element.replace(expression,'.n.');
|
||||
if ((typeof eval('datamodel["'+element+'"]')) != "undefined") {
|
||||
if (eval('datamodel["'+element+'"].mod') != 'w') {
|
||||
errorCode = "0";
|
||||
return eval(element);
|
||||
} else {
|
||||
errorCode = eval('datamodel["'+element+'"].readerror');
|
||||
}
|
||||
} else {
|
||||
errorCode = "401"
|
||||
}
|
||||
} else {
|
||||
errorCode = "201";
|
||||
}
|
||||
} else {
|
||||
errorCode = "301";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function LMSSetValue (element,value) {
|
||||
if (Initialized) {
|
||||
if (element != "") {
|
||||
expression = new RegExp(CMIIndex,'g');
|
||||
elementmodel = element.replace(expression,'.n.');
|
||||
if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
|
||||
if (eval('datamodel["'+elementmodel+'"].mod') != 'r') {
|
||||
expression.compile(eval('datamodel["'+elementmodel+'"].format'));
|
||||
value = value+'';
|
||||
matches = value.match(expression);
|
||||
if (matches != null) {
|
||||
//Create dynamic data model element
|
||||
if (element != elementmodel) {
|
||||
elementIndexes = element.split('.');
|
||||
subelement = 'cmi';
|
||||
for (i=1;i<elementIndexes.length-1;i++) {
|
||||
elementIndex = elementIndexes[i];
|
||||
if (elementIndexes[i+1].match(/^\d+$/)) {
|
||||
//alert(eval(subelement+'.'+elementIndex+'._count')+1.0);
|
||||
//if (elementIndexes[i+1] > eval(subelement+'.'+elementIndex+'._count')) {
|
||||
// if (elementIndexes[i+1] == eval(subelement+'.'+elementIndex+'._count')) {
|
||||
// eval(subelement+'.'+elementIndex+'._count')+1.0;
|
||||
// }
|
||||
subelement = subelement.concat('.'+elementIndex+'_'+elementIndexes[i+1]);
|
||||
i++;
|
||||
//}
|
||||
} else {
|
||||
subelement = subelement.concat('.'+elementIndex);
|
||||
}
|
||||
|
||||
if ((typeof eval(subelement)) == "undefined") {
|
||||
eval(subelement+' = new Object();');
|
||||
/*if (elementIndexes[i].match(/^\d+$/)) {
|
||||
alert(subelement.substring(0,subelement.length-elementIndexes[i]-1));
|
||||
if ((typeof eval(subelement.substring(0,subelement.length-elementIndexes[i]-1))) == "undefined") {
|
||||
// create new count
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
||||
element = subelement.concat('.'+elementIndexes[elementIndexes.length-1]);
|
||||
//alert('LMSSetValue: '+element+'\nModel: '+elementmodel+'\nValue: '+value+'\nMatches: '+matches);
|
||||
}
|
||||
//Store data
|
||||
if ((typeof eval('datamodel["'+elementmodel+'"].range')) != "undefined") {
|
||||
range = eval('datamodel["'+elementmodel+'"].range');
|
||||
ranges = range.split('#');
|
||||
value = value+0.0;
|
||||
if ((value >= ranges[0]) && (value <= ranges[1])) {
|
||||
eval(element+'="'+value+'";');
|
||||
errorCode = "0";
|
||||
return "true";
|
||||
} else {
|
||||
errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
|
||||
}
|
||||
} else {
|
||||
eval(element+'="'+value+'";');
|
||||
errorCode = "0";
|
||||
return "true";
|
||||
}
|
||||
} else {
|
||||
errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
|
||||
}
|
||||
} else {
|
||||
errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
|
||||
}
|
||||
} else {
|
||||
errorCode = "401"
|
||||
}
|
||||
} else {
|
||||
errorCode = "201";
|
||||
}
|
||||
} else {
|
||||
errorCode = "301";
|
||||
}
|
||||
alert('LMSSetValue: '+element+'\nValue: '+value+'\nPattern: '+expression+'\nMatches: '+matches+'\nError Code: '+errorCode);
|
||||
return "false";
|
||||
}
|
||||
|
||||
function LMSCommit (param) {
|
||||
if (param == "") {
|
||||
if (Initialized) {
|
||||
errorCode = "0";
|
||||
return "true";
|
||||
} else {
|
||||
errorCode = "301";
|
||||
}
|
||||
} else {
|
||||
errorCode = "201";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
|
||||
function LMSGetLastError () {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
function LMSGetErrorString (param) {
|
||||
if (param != "") {
|
||||
var errorString = new Array();
|
||||
errorString["0"] = "No error";
|
||||
errorString["101"] = "General exception";
|
||||
errorString["201"] = "Invalid argument error";
|
||||
errorString["202"] = "Element cannot have children";
|
||||
errorString["203"] = "Element not an array - cannot have count";
|
||||
errorString["301"] = "Not initialized";
|
||||
errorString["401"] = "Not implemented error";
|
||||
errorString["402"] = "Invalid set value, element is a keyword";
|
||||
errorString["403"] = "Element is read only";
|
||||
errorString["404"] = "Element is write only";
|
||||
errorString["405"] = "Incorrect data type";
|
||||
return errorString[param];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function LMSGetDiagnostic (param) {
|
||||
if (param == "") {
|
||||
param = errorCode;
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
this.LMSInitialize = LMSInitialize;
|
||||
this.LMSFinish = LMSFinish;
|
||||
this.LMSGetValue = LMSGetValue;
|
||||
this.LMSSetValue = LMSSetValue;
|
||||
this.LMSCommit = LMSCommit;
|
||||
this.LMSGetLastError = LMSGetLastError;
|
||||
this.LMSGetErrorString = LMSGetErrorString;
|
||||
this.LMSGetDiagnostic = LMSGetDiagnostic;
|
||||
}
|
||||
|
||||
var API = new SCORMapi1_2();
|
||||
@@ -268,73 +80,8 @@ var API = new SCORMapi1_2();
|
||||
//
|
||||
function SCORMapi2004() {
|
||||
|
||||
function Initialize (param) {
|
||||
return SCORM_Call('Initialize',param);
|
||||
}
|
||||
<?php include_once ('datamodels/scorm1_3.js.php'); ?>
|
||||
|
||||
function Terminate (param) {
|
||||
return SCORM_Call('Terminate',param);
|
||||
}
|
||||
|
||||
function GetValue (element) {
|
||||
return SCORM_Call('GetValue',element);
|
||||
}
|
||||
|
||||
function SetValue (element, value) {
|
||||
return SCORM_Call('SetValue',element,value);
|
||||
}
|
||||
|
||||
function Commit (param) {
|
||||
return SCORM_Call('Commit',param);
|
||||
}
|
||||
|
||||
function GetLastError () {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
function GetErrorString (param) {
|
||||
var errorString = new Array();
|
||||
errorString["0"] = "No error";
|
||||
errorString["101"] = "General exception";
|
||||
errorString["102"] = "General Inizialization Failure";
|
||||
errorString["103"] = "Already Initialized";
|
||||
errorString["104"] = "Content Instance Terminated";
|
||||
errorString["111"] = "General Termination Failure";
|
||||
errorString["112"] = "Termination Before Inizialization";
|
||||
errorString["113"] = "Termination After Termination";
|
||||
errorString["122"] = "Retrieve Data Before Initialization";
|
||||
errorString["123"] = "Retrieve Data After Termination";
|
||||
errorString["132"] = "Store Data Before Inizialization";
|
||||
errorString["133"] = "Store Data After Termination";
|
||||
errorString["142"] = "Commit Before Inizialization";
|
||||
errorString["143"] = "Commit After Termination";
|
||||
errorString["201"] = "General Argument Error";
|
||||
errorString["301"] = "General Get Failure";
|
||||
errorString["351"] = "General Set Failure";
|
||||
errorString["391"] = "General Commit Failure";
|
||||
errorString["401"] = "Undefinited Data Model";
|
||||
errorString["402"] = "Unimplemented Data Model Element";
|
||||
errorString["403"] = "Data Model Element Value Not Initialized";
|
||||
errorString["404"] = "Data Model Element Is Read Only";
|
||||
errorString["405"] = "Data Model Element Is Write Only";
|
||||
errorString["406"] = "Data Model Element Type Mismatch";
|
||||
errorString["407"] = "Data Model Element Value Out Of Range";
|
||||
errorString["408"] = "Data Model Dependency Not Established";
|
||||
return errorString[param];
|
||||
}
|
||||
|
||||
function GetDiagnostic (param) {
|
||||
return SCORM_Call('GetDiagnostic',param);
|
||||
}
|
||||
|
||||
this.Initialize = Initialize;
|
||||
this.Terminate = Terminate;
|
||||
this.GetValue = GetValue;
|
||||
this.SetValue = SetValue;
|
||||
this.Commit = Commit;
|
||||
this.GetLastError = GetLastError;
|
||||
this.GetErrorString = GetErrorString;
|
||||
this.GetDiagnostic = GetDiagnostic;
|
||||
}
|
||||
|
||||
var API_1484_11 = new SCORMapi2004();
|
||||
|
||||
+35
-37
@@ -4,18 +4,18 @@
|
||||
|
||||
//This is the "graphical" structure of the scorm mod:
|
||||
//
|
||||
// scorm
|
||||
// (CL,pk->id)--------------------
|
||||
// scorm
|
||||
// (CL,pk->id)---------------------
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// scorm_scoes |
|
||||
// (UL,pk->id, fk->scorm) |
|
||||
// scorm_scoes |
|
||||
// (UL,pk->id, fk->scorm) |
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// scorm_sco_users |
|
||||
// (UL,pk->id, fk->scormid, fk->scoid)----
|
||||
// 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
|
||||
@@ -49,14 +49,13 @@
|
||||
fwrite ($bf,full_tag("LAUNCH",4,false,$scorm->launch));
|
||||
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
|
||||
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
|
||||
fwrite ($bf,full_tag("POPUP",4,false,$scorm->popup));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
|
||||
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);
|
||||
|
||||
//if we've selected to backup users info, then execute backup_scorm_sco_users
|
||||
//if we've selected to backup users info, then execute backup_scorm_scoes_track
|
||||
if ($status) {
|
||||
if ($preferences->mods["scorm"]->userinfo) {
|
||||
$status = backup_scorm_sco_users($bf,$preferences,$scorm->id);
|
||||
$status = backup_scorm_scoes_track($bf,$preferences,$scorm->id);
|
||||
}
|
||||
}
|
||||
//End mod
|
||||
@@ -79,7 +78,7 @@
|
||||
$status = true;
|
||||
|
||||
$scorm_scoes = get_records("scorm_scoes","scorm",$scorm,"id");
|
||||
//If there is submissions
|
||||
//If there is scoes
|
||||
if ($scorm_scoes) {
|
||||
//Write start tag
|
||||
$status =fwrite ($bf,start_tag("SCOES",4,true));
|
||||
@@ -94,9 +93,13 @@
|
||||
fwrite ($bf,full_tag("PARENT",6,false,$sco->parent));
|
||||
fwrite ($bf,full_tag("IDENTIFIER",6,false,$sco->identifier));
|
||||
fwrite ($bf,full_tag("LAUNCH",6,false,$sco->launch));
|
||||
fwrite ($bf,full_tag("TYPE",6,false,$sco->type));
|
||||
fwrite ($bf,full_tag("SCORMTYPE",6,false,$sco->scormtype));
|
||||
fwrite ($bf,full_tag("TITLE",6,false,$sco->title));
|
||||
fwrite ($bf,full_tag("PREREQUISITES",6,false,$sco->prerequisites));
|
||||
fwrite ($bf,full_tag("MAXTIMEALLOWED",6,false,$sco->maxtimeallowed));
|
||||
fwrite ($bf,full_tag("TIMELIMITACTION",6,false,$sco->timelimitaction));
|
||||
fwrite ($bf,full_tag("DATAFROMLMS",6,false,$sco->datafromlms));
|
||||
fwrite ($bf,full_tag("MASTERYSCORE",6,false,$sco->masteryscore));
|
||||
fwrite ($bf,full_tag("NEXT",6,false,$sco->next));
|
||||
fwrite ($bf,full_tag("PREVIOUS",6,false,$sco->previous));
|
||||
//End sco
|
||||
@@ -108,38 +111,33 @@
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup scorm_sco_users contents (executed from scorm_backup_mods)
|
||||
function backup_scorm_sco_users ($bf,$preferences,$scorm) {
|
||||
//Backup scorm_scoes_track contents (executed from scorm_backup_mods)
|
||||
function backup_scorm_scoes_track ($bf,$preferences,$scorm) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_sco_users = get_records("scorm_sco_users","scormid",$scorm,"id");
|
||||
//If there is submissions
|
||||
if ($scorm_sco_users) {
|
||||
$scorm_scoes_track = get_records("scorm_scoes_track","scormid",$scorm,"id");
|
||||
//If there is track
|
||||
if ($scorm_scoes_track) {
|
||||
//Write start tag
|
||||
$status =fwrite ($bf,start_tag("SCO_USERS",4,true));
|
||||
$status =fwrite ($bf,start_tag("SCO_TRACKS",4,true));
|
||||
//Iterate over each sco
|
||||
foreach ($scorm_sco_users as $sco_user) {
|
||||
//Start sco
|
||||
$status =fwrite ($bf,start_tag("SCO_USER",5,true));
|
||||
//Print submission contents
|
||||
fwrite ($bf,full_tag("ID",6,false,$sco_user->id));
|
||||
fwrite ($bf,full_tag("USERID",6,false,$sco_user->userid));
|
||||
fwrite ($bf,full_tag("SCOID",6,false,$sco_user->scoid));
|
||||
fwrite ($bf,full_tag("CMI_CORE_LESSON_LOCATION",6,false,$sco_user->cmi_core_lesson_location));
|
||||
fwrite ($bf,full_tag("CMI_CORE_LESSON_STATUS",6,false,$sco_user->cmi_core_lesson_status));
|
||||
fwrite ($bf,full_tag("CMI_CORE_EXIT",6,false,$sco_user->cmi_core_exit));
|
||||
fwrite ($bf,full_tag("CMI_CORE_TOTAL_TIME",6,false,$sco_user->cmi_core_total_time));
|
||||
fwrite ($bf,full_tag("CMI_CORE_SESSION_TIME",6,false,$sco_user->cmi_core_session_time));
|
||||
fwrite ($bf,full_tag("CMI_CORE_SCORE_RAW",6,false,$sco_user->cmi_core_score_raw));
|
||||
fwrite ($bf,full_tag("CMI_SUSPEND_DATA",6,false,$sco_user->cmi_suspend_data));
|
||||
//End sco
|
||||
$status =fwrite ($bf,end_tag("SCO_USER",5,true));
|
||||
foreach ($scorm_scoes_track as $sco_track) {
|
||||
//Start sco track
|
||||
$status =fwrite ($bf,start_tag("SCO_TRACK",5,true));
|
||||
//Print track contents
|
||||
fwrite ($bf,full_tag("ID",6,false,$sco_track->id));
|
||||
fwrite ($bf,full_tag("USERID",6,false,$sco_track->userid));
|
||||
fwrite ($bf,full_tag("SCOID",6,false,$sco_track->scoid));
|
||||
fwrite ($bf,full_tag("ELEMENT",6,false,$sco_track->element));
|
||||
fwrite ($bf,full_tag("VALUE",6,false,$sco_track->value));
|
||||
//End sco track
|
||||
$status =fwrite ($bf,end_tag("SCO_TRACK",5,true));
|
||||
}
|
||||
//Write end tag
|
||||
$status =fwrite ($bf,end_tag("SCO_USERS",4,true));
|
||||
$status =fwrite ($bf,end_tag("SCO_TRACKS",4,true));
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
@@ -157,7 +155,7 @@
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
$info[1][0] = get_string("scoes","scorm");
|
||||
if ($ids = scorm_sco_users_ids_by_course ($course)) {
|
||||
if ($ids = scorm_scoes_track_ids_by_course ($course)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
@@ -202,12 +200,12 @@
|
||||
}
|
||||
|
||||
//Returns an array of scorm_scoes id
|
||||
function scorm_sco_users_ids_by_course ($course) {
|
||||
function scorm_scoes_track_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.scormid
|
||||
FROM {$CFG->prefix}scorm_sco_users s,
|
||||
FROM {$CFG->prefix}scorm_scoes_track s,
|
||||
{$CFG->prefix}scorm a
|
||||
WHERE a.course = '$course' AND
|
||||
s.scormid = a.id");
|
||||
|
||||
@@ -21,60 +21,6 @@
|
||||
<?php print_string("validationtype", "scorm") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">scorm_framesize:</td>
|
||||
<td>
|
||||
<input name="scorm_framesize" type="text" size="5" value="<?php p($CFG->scorm_framesize) ?>" />
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configframesize", "scorm") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">scorm_popup:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($choices);
|
||||
$choices[""] = get_string("no");
|
||||
$choices["checked"] = get_string("yes");
|
||||
choose_from_menu ($choices, "scorm_popup", $CFG->scorm_popup, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configpopup", "scorm") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
|
||||
$defaultvalue = "scorm_popup$optionname";
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\">$defaultvalue:</td>";
|
||||
echo "<td>";
|
||||
if ($optionname == "height" or $optionname == "width") {
|
||||
echo "<input name=$defaultvalue type=\"text\" size=\"5\" value=\"".$CFG->$defaultvalue."\" />";
|
||||
} else {
|
||||
choose_from_menu ($choices, $defaultvalue, $CFG->$defaultvalue, "");
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("configpopup$optionname", "scorm");
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="right"><p>scorm_windowsettings:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($choices);
|
||||
$choices[""] = get_string("no");
|
||||
$choices["checked"] = get_string("yes");
|
||||
choose_from_menu ($choices, "scorm_windowsettings", $CFG->scorm_windowsettings, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("windowsettings", "scorm") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center">
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>" />
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
// Standard Data Type Definition
|
||||
CMIString255 = '^.{0,255}$';
|
||||
CMIString4096 = '^[.|\\n|\\r]{0,4096}$';
|
||||
CMITime = '^([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,2})?$';
|
||||
CMITimespan = '^([0-9]{2,4}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,2})?$';
|
||||
CMIInteger = '^\\d+$';
|
||||
CMISInteger = '^-?([0-9]+)$';
|
||||
CMIDecimal = '^[0-9]?(\.[0-9]{1,2})?$';
|
||||
CMIIdentifier = '^\\w{0,255}$';
|
||||
CMIFeedback = CMIString255; // This must be redefined
|
||||
CMIIndex = '.\\d+.';
|
||||
// Vocabulary Data Type Definition
|
||||
CMIStatus = '^passed|completed|failed|incomplete|browsed|not attempted$';
|
||||
CMIExit = '^time-out|suspend|logout|$';
|
||||
CMIType = '^true-false|choice|fill-in|matching|performance|sequencing|likert|numeric$';
|
||||
CMIResult = '^correct|wrong|unanticipated|neutral|[0-9]?(\.[0-9]{1,2})?$';
|
||||
// Children lists
|
||||
cmi_children = 'core, suspend_data, launch_data, comments, objectives, student_data, student_preference, interactions';
|
||||
core_children = 'student_id, student_name, lesson_location, credit, lesson_status, entry, score, total_time, lesson_mode, exit, session_time';
|
||||
score_children = 'raw, min, max';
|
||||
objectives_children = 'id, score, status';
|
||||
student_data_children = 'mastery_score, max_time_allowed, time_limit_action';
|
||||
student_preference_children = 'audio, language, speed, text';
|
||||
interactions_children = 'id, objectives, time, type, correct_responses, weighting, student_response, result, latency';
|
||||
// Data ranges
|
||||
score_range = '0#100';
|
||||
audio_range = '-1#100';
|
||||
speed_range = '-100#100';
|
||||
text_range = '-1#1';
|
||||
// The SCORM 1.2 data model
|
||||
var datamodel = {
|
||||
'cmi._children':{'defaultvalue':cmi_children, 'mod':'r', 'writeerror':'402'},
|
||||
'cmi._version':{'defaultvalue':'3.4', 'mod':'r', 'writeerror':'402'},
|
||||
'cmi.core._children':{'defaultvalue':core_children, 'mod':'r', 'writeerror':'402'},
|
||||
'cmi.core.student_id':{'defaultvalue':'<?php echo $USER->username ?>', 'mod':'r', 'writeerror':'403'},
|
||||
'cmi.core.student_name':{'defaultvalue':'<?php echo $USER->lastname.', '.$USER->firstname ?>', 'mod':'r', 'writeerror':'403'},
|
||||
'cmi.core.lesson_location':{'format':CMIString255, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.core.credit':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.core.lesson_status':{'format':CMIStatus, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.core.entry':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.core.score._children':{'defaultvalue':score_children, 'mod':'r', 'writeerror':'402'},
|
||||
'cmi.core.score.raw':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.core.score.max':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.core.score.min':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.core.total_time':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.core.lesson_mode':{'mod':'r', 'writeerror':'405'},
|
||||
'cmi.core.exit':{'format':CMIExit, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.core.session_time':{'format':CMITimespan, 'mod':'w', 'defaultvalue':'00:00:00', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.suspend_data':{'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.launch_data':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.comments':{'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.comments_from_lms':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r', 'writeerror':'403'},
|
||||
'cmi.objectives._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
|
||||
'cmi.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.objectives.n.score._children':{'pattern':CMIIndex, 'defaultvalue':score_children, 'mod':'r', 'writeerror':'402'},
|
||||
'cmi.objectives.n.score.raw':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.objectives.n.score.min':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.objectives.n.score.max':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.objectives.n.status':{'pattern':CMIIndex, 'format':CMIStatus, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.student_data._children':{'defaultvalue':student_data_children, 'mod':'r', 'writeerror':'403'},
|
||||
'cmi.student_data.mastery_score':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.student_data.max_time_allowed':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.student_data.time_limit_action':{'mod':'r', 'writeerror':'403'},
|
||||
'cmi.student_preference._children':{'defaultvalue':student_preference_children, 'mod':'r', 'writeerror':'403'},
|
||||
'cmi.student_preference.audio':{'format':CMISInteger, 'range':audio_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.student_preference.language':{'format':CMIString255, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.student_preference.speed':{'format':CMISInteger, 'range':speed_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.student_preference.text':{'format':CMISInteger, 'range':text_range, 'mod':'rw', 'writeerror':'405'},
|
||||
'cmi.interactions._children':{'defaultvalue':interactions_children, 'mod':'r', 'writeerror':'403'},
|
||||
'cmi.interactions._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
|
||||
'cmi.interactions.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.objectives._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
|
||||
'cmi.interactions.n.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.time':{'pattern':CMIIndex, 'format':CMITime, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.type':{'pattern':CMIIndex, 'format':CMIType, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.correct_responses._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
|
||||
'cmi.interactions.n.correct_responses.n.pattern':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.weighting':{'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.student_response':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.result':{'pattern':CMIIndex, 'format':CMIResult, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
|
||||
'cmi.interactions.n.latency':{'pattern':CMIIndex, 'format':CMITimespan, 'mod':'w', 'readerror':'404', 'writeerror':'405'}
|
||||
};
|
||||
// Datamodel inizialization
|
||||
var cmi = new Object();
|
||||
cmi.core = new Object();
|
||||
cmi.core.score = new Object();
|
||||
cmi.objectives = new Object();
|
||||
cmi.student_data = new Object();
|
||||
cmi.student_preference = new Object();
|
||||
cmi.interactions = new Object();
|
||||
var nav = new Object();
|
||||
for (element in datamodel) {
|
||||
if (element.match(/\.n\./) == null) {
|
||||
//alert (element+' = '+eval('datamodel["'+element+'"].defaultvalue'));
|
||||
if ((typeof eval('datamodel["'+element+'"].defaultvalue')) != 'undefined') {
|
||||
eval(element+' = datamodel["'+element+'"].defaultvalue;');
|
||||
} else {
|
||||
eval(element+' = "";');
|
||||
}
|
||||
//alert (element+' = '+eval(element));
|
||||
}
|
||||
}
|
||||
+54
-2
@@ -23,8 +23,8 @@ function scorm_upgrade($oldversion) {
|
||||
table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
|
||||
}
|
||||
if ($oldversion < 2004071900) {
|
||||
table_column("scorm", "", "maxgrade", "FLOAT", "3", "", "0", "NOT NULL", "reference");
|
||||
table_column("scorm", "", "grademethod", "TINYINT", "2", "", "0", "NOT NULL", "maxgrade");
|
||||
table_column("scorm", "", "maxgrade", "FLOAT", "3", "", "0", "NOT NULL", "reference");
|
||||
table_column("scorm", "", "grademethod", "TINYINT", "2", "", "0", "NOT NULL", "maxgrade");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004111200) {
|
||||
@@ -40,6 +40,58 @@ function scorm_upgrade($oldversion) {
|
||||
modify_database('','ALTER TABLE prefix_scorm_sco_users ADD INDEX userid (userid);');
|
||||
modify_database('','ALTER TABLE prefix_scorm_sco_users ADD INDEX scoid (scoid);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005031300) {
|
||||
table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title");
|
||||
table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites");
|
||||
modify_database('',"ALTER TABLE prefix_scorm_scoes ADD timelimitaction SET('exit,message','exit,no message','continue,message','continue,no message') DEFAULT '' AFTER `maxtimeallowed`");
|
||||
table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms");
|
||||
|
||||
$oldScoesData = get_records_select("scorm_scoes","1","id ASC");
|
||||
modify_database('',"ALTER TABLE prefix_scorm_scoes CHANGE type scormtype SET('sco','asset') DEFAULT '' NOT NULL");
|
||||
foreach ($oldScoesData as $sco) {
|
||||
$sco->scormtype = $sco->type;
|
||||
unset($sco->type);
|
||||
update_record("scorm_scoes",$sco);
|
||||
}
|
||||
|
||||
execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
userid int(10) unsigned NOT NULL default '0',
|
||||
scormid int(10) NOT NULL default '0',
|
||||
scoid int(10) unsigned NOT NULL default '0',
|
||||
element varchar(255) NOT NULL default '',
|
||||
value longtext NOT NULL default '',
|
||||
PRIMARY KEY (userid, scormid, scoid, element),
|
||||
UNIQUE (userid, scormid, scoid, element),
|
||||
KEY userdata (userid, scormid, scoid),
|
||||
KEY id (id)
|
||||
) TYPE=MyISAM;",false);
|
||||
|
||||
$oldTrackingData = get_records_select("scorm_sco_users","1","id ASC");
|
||||
$oldElementArray = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
|
||||
foreach ($oldTrackingData as $oldTrack) {
|
||||
$newTrack = '';
|
||||
$newTrack->userid = $oldTrack->userid;
|
||||
$newTrack->scormid = $oldTrack->scormid;
|
||||
$newTrack->scoid = $oldTrack->scoid;
|
||||
|
||||
foreach ( $oldElementArray as $element) {
|
||||
$newTrack->element = $element;
|
||||
$newTrack->value = $oldTrack->$element;
|
||||
if ($newTrack->value == NULL) {
|
||||
$newTrack->value = '';
|
||||
}
|
||||
insert_record("scorm_scoes_track",$newTrack,false);
|
||||
}
|
||||
}
|
||||
modify_database('',"DROP TABLE prefix_scorm_sco_users");
|
||||
modify_database('',"INSERT INTO prefix_log_display VALUES ('resource', 'review', 'resource', 'name')");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005031400) {
|
||||
table_column("scorm", "popup", "");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+13
-15
@@ -13,7 +13,6 @@ CREATE TABLE prefix_scorm (
|
||||
launch int(10) unsigned NOT NULL default 0,
|
||||
summary text NOT NULL,
|
||||
auto tinyint(1) unsigned NOT NULL default '0',
|
||||
popup varchar(255) NOT NULL default '',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
@@ -28,9 +27,13 @@ CREATE TABLE prefix_scorm_scoes (
|
||||
parent varchar(255) NOT NULL default '',
|
||||
identifier varchar(255) NOT NULL default '',
|
||||
launch varchar(255) NOT NULL default '',
|
||||
type varchar(5) NOT NULL default '',
|
||||
scormtype set('sco','asset') NOT NULL default '',
|
||||
title varchar(255) NOT NULL default '',
|
||||
datafromlms longtext,
|
||||
prerequisites varchar(200) NOT NULL default '',
|
||||
maxtimeallowed set('exit,message','exit,no message','continue,message','continue,no message'),
|
||||
timelimitaction varchar(19) NOT NULL default '',
|
||||
datafromlms varchar(255) NOT NULL default '',
|
||||
masteryscore varchar(200) NOT NULL default '',
|
||||
next tinyint(1) unsigned NOT NULL default '0',
|
||||
previous tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
@@ -38,22 +41,16 @@ CREATE TABLE prefix_scorm_scoes (
|
||||
KEY scorm (scorm)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
CREATE TABLE prefix_scorm_sco_users (
|
||||
CREATE TABLE prefix_scorm_scoes_track (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
userid int(10) unsigned NOT NULL default '0',
|
||||
scormid int(10) NOT NULL default '0',
|
||||
scoid int(10) unsigned NOT NULL default '0',
|
||||
cmi_core_lesson_location varchar(255) NOT NULL default '',
|
||||
cmi_core_lesson_status varchar(30) NOT NULL default '',
|
||||
cmi_core_exit varchar(30) NOT NULL default '',
|
||||
cmi_core_total_time varchar(13) NOT NULL default '00:00:00',
|
||||
cmi_core_session_time varchar(13) NOT NULL default '00:00:00',
|
||||
cmi_core_score_raw float(3) NOT NULL default '0',
|
||||
cmi_suspend_data longtext,
|
||||
PRIMARY KEY (id),
|
||||
KEY userid (userid),
|
||||
KEY scormid (scormid),
|
||||
KEY scoid (scoid)
|
||||
element varchar(255) NOT NULL default '',
|
||||
value longtext NOT NULL default '',
|
||||
PRIMARY KEY (userid, scormid, scoid, element),
|
||||
UNIQUE (userid, scormid, scoid, element),
|
||||
KEY userdata (userid, scormid, scoid)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
#
|
||||
@@ -61,5 +58,6 @@ CREATE TABLE prefix_scorm_sco_users (
|
||||
#
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('scorm', 'view', 'scorm', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('scorm', 'review', 'scorm', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('scorm', 'update', 'scorm', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('scorm', 'add', 'scorm', 'name');
|
||||
@@ -40,6 +40,58 @@ function scorm_upgrade($oldversion) {
|
||||
modify_database('','CREATE INDEX prefix_scorm_sco_users_scormid_idx ON prefix_scorm_sco_users (scormid);');
|
||||
modify_database('','CREATE INDEX prefix_scorm_sco_users_scoid_idx ON prefix_scorm_sco_users (scoid);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005031300) {
|
||||
table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title");
|
||||
table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites");
|
||||
table_column("scorm_scoes", "", "timelimitaction", "VARCHAR", "19", "", "", "NOT NULL", "maxtimeallowed");
|
||||
table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms");
|
||||
|
||||
$oldScoesData = get_records_select("scorm_scoes","1","id ASC");
|
||||
table_column("scorm_scoes", "type", "scormtype", "VARCHAR", "5", "", "", "NOT NULL");
|
||||
foreach ($oldScoesData as $sco) {
|
||||
$sco->scormtype = $sco->type;
|
||||
unset($sco->type);
|
||||
update_record("scorm_scoes",$sco);
|
||||
}
|
||||
|
||||
execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
userid int(10) unsigned NOT NULL default '0',
|
||||
scormid int(10) NOT NULL default '0',
|
||||
scoid int(10) unsigned NOT NULL default '0',
|
||||
element varchar(255) NOT NULL default '',
|
||||
value longtext NOT NULL default '',
|
||||
PRIMARY KEY (userid, scormid, scoid, element),
|
||||
UNIQUE (userid, scormid, scoid, element),
|
||||
KEY userdata (userid, scormid, scoid),
|
||||
KEY id (id)
|
||||
) TYPE=MyISAM;",false);
|
||||
|
||||
$oldTrackingData = get_records_select("scorm_sco_users","1","id ASC");
|
||||
$oldElementArray = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
|
||||
foreach ($oldTrackingData as $oldTrack) {
|
||||
$newTrack = '';
|
||||
$newTrack->userid = $oldTrack->userid;
|
||||
$newTrack->scormid = $oldTrack->scormid;
|
||||
$newTrack->scoid = $oldTrack->scoid;
|
||||
|
||||
foreach ( $oldElementArray as $element) {
|
||||
$newTrack->element = $element;
|
||||
$newTrack->value = $oldTrack->$element;
|
||||
if ($newTrack->value == NULL) {
|
||||
$newTrack->value = '';
|
||||
}
|
||||
insert_record("scorm_scoes_track",$newTrack,false);
|
||||
}
|
||||
}
|
||||
modify_database('',"DROP TABLE prefix_scorm_sco_users");
|
||||
modify_database('',"INSERT INTO prefix_log_display VALUES ('resource', 'review', 'resource', 'name')");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005031400) {
|
||||
table_column("scorm", "popup", "");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ CREATE TABLE prefix_scorm (
|
||||
launch integer NOT NULL default '0',
|
||||
summary text NOT NULL default '',
|
||||
auto integer NOT NULL default '0',
|
||||
popup varchar(255) NOT NULL default '',
|
||||
timemodified integer NOT NULL default '0'
|
||||
);
|
||||
|
||||
@@ -27,7 +26,7 @@ CREATE TABLE prefix_scorm_scoes (
|
||||
parent varchar(255) NOT NULL default '',
|
||||
identifier varchar(255) NOT NULL default '',
|
||||
launch varchar(255) NOT NULL default '',
|
||||
type varchar(5) NOT NULL default '',
|
||||
scormtype varchar(5) NOT NULL default '',
|
||||
title varchar(255) NOT NULL default '',
|
||||
datafromlms text NOT NULL default '',
|
||||
next integer NOT NULL default '0',
|
||||
@@ -37,27 +36,23 @@ CREATE TABLE prefix_scorm_scoes (
|
||||
CREATE INDEX prefix_scorm_scoes_scorm_idx ON prefix_scorm_scoes (scorm);
|
||||
|
||||
CREATE TABLE prefix_scorm_sco_users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
id SERIAL KEY,
|
||||
userid integer NOT NULL default '0',
|
||||
scormid integer NOT NULL default '0',
|
||||
scoid integer NOT NULL default '0',
|
||||
cmi_core_lesson_location varchar(255) NOT NULL default '',
|
||||
cmi_core_lesson_status varchar(30) NOT NULL default '',
|
||||
cmi_core_exit varchar(30) NOT NULL default '',
|
||||
cmi_core_total_time varchar(13) NOT NULL default '00:00:00',
|
||||
cmi_core_session_time varchar(13) NOT NULL default '00:00:00',
|
||||
cmi_core_score_raw real NOT NULL default '0',
|
||||
cmi_suspend_data text NOT NULL default ''
|
||||
element varchar(255) NOT NULL deafult '',
|
||||
value text NOT NULL default '',
|
||||
PRIMARY KEY (userid, scormid, scoid, element),
|
||||
UNIQUE (userid, scormid, scoid, element),
|
||||
INDEX userdata (userid, scormid, scoid)
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_scorm_sco_users_userid_idx ON prefix_scorm_sco_users (userid);
|
||||
CREATE INDEX prefix_scorm_sco_users_scormid_idx ON prefix_scorm_sco_users (scormid);
|
||||
CREATE INDEX prefix_scorm_sco_users_scoid_idx ON prefix_scorm_sco_users (scoid);
|
||||
|
||||
#
|
||||
# Dumping data for table `log_display`
|
||||
#
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('resource', 'view', 'resource', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('resource', 'review', 'resource', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('resource', 'update', 'resource', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('resource', 'add', 'resource', 'name');
|
||||
|
||||
+77
-77
@@ -11,12 +11,7 @@ $SCORM_GRADE_METHOD = array (VALUESCOES => get_string("gradescoes", "scorm"),
|
||||
VALUEHIGHEST => get_string("gradehighest", "scorm"),
|
||||
VALUEAVERAGE => get_string("gradeaverage", "scorm"),
|
||||
VALUESUM => get_string("gradesum", "scorm"));
|
||||
|
||||
$SCORM_WINDOW_OPTIONS = array('resizable', 'scrollbars', 'status', 'height', 'width');
|
||||
|
||||
if (!isset($CFG->scorm_popup)) {
|
||||
set_config('scorm_popup', '');
|
||||
}
|
||||
if (!isset($CFG->scorm_validate)) {
|
||||
$scorm_validate = 'none';
|
||||
//I've commented this out for Moodle 1.4, as I've seen errors in
|
||||
@@ -30,23 +25,6 @@ if (!isset($CFG->scorm_validate)) {
|
||||
set_config('scorm_validate', $scorm_validate);
|
||||
}
|
||||
|
||||
foreach ($SCORM_WINDOW_OPTIONS as $popupoption) {
|
||||
$popupoption = "scorm_popup$popupoption";
|
||||
if (!isset($CFG->$popupoption)) {
|
||||
if ($popupoption == 'scorm_popupheight') {
|
||||
set_config($popupoption, 450);
|
||||
} else if ($popupoption == 'scorm_popupwidth') {
|
||||
set_config($popupoption, 620);
|
||||
} else {
|
||||
set_config($popupoption, 'checked');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($CFG->scorm_framesize)) {
|
||||
set_config('scorm_framesize', 140);
|
||||
}
|
||||
|
||||
function scorm_add_instance($scorm) {
|
||||
/// Given an object containing all the necessary data,
|
||||
/// (defined by the form in mod.html) this function
|
||||
@@ -56,23 +34,8 @@ function scorm_add_instance($scorm) {
|
||||
$scorm->timemodified = time();
|
||||
|
||||
# May have to add extra stuff in here #
|
||||
global $CFG,$SCORM_WINDOW_OPTIONS;
|
||||
global $CFG;
|
||||
|
||||
$scorm->popup = '';
|
||||
|
||||
$optionlist = array();
|
||||
foreach ($SCORM_WINDOW_OPTIONS as $option) {
|
||||
if (isset($scorm->$option)) {
|
||||
$optionlist[] = $option.'='.$scorm->$option;
|
||||
}
|
||||
}
|
||||
$scorm->popup = implode(',', $optionlist);
|
||||
|
||||
|
||||
if ($scorm->popup != '') {
|
||||
$scorm->popup .= ',location=0,menubar=0,toolbar=0';
|
||||
$scorm->auto = '0';
|
||||
}
|
||||
$id = insert_record('scorm', $scorm);
|
||||
|
||||
//
|
||||
@@ -98,22 +61,8 @@ function scorm_update_instance($scorm) {
|
||||
$scorm->id = $scorm->instance;
|
||||
|
||||
# May have to add extra stuff in here #
|
||||
global $CFG,$SCORM_WINDOW_OPTIONS;
|
||||
global $CFG;
|
||||
|
||||
$scorm->popup = '';
|
||||
|
||||
$optionlist = array();
|
||||
foreach ($SCORM_WINDOW_OPTIONS as $option) {
|
||||
if (isset($scorm->$option)) {
|
||||
$optionlist[] = $option.'='.$scorm->$option;
|
||||
}
|
||||
}
|
||||
$scorm->popup = implode(',', $optionlist);
|
||||
|
||||
if ($scorm->popup != '') {
|
||||
$scorm->popup .= ',location=0,menubar=0,toolbar=0';
|
||||
$scorm->auto = '0';
|
||||
}
|
||||
|
||||
//
|
||||
// Check if scorm manifest needs to be reparsed
|
||||
@@ -145,7 +94,7 @@ function scorm_delete_instance($id) {
|
||||
scorm_delete_files($CFG->dataroot.'/'.$scorm->course.'/moddata/scorm'.$scorm->datadir);
|
||||
|
||||
# Delete any dependent records here #
|
||||
if (! delete_records('scorm_sco_users', 'scormid', $scorm->id)) {
|
||||
if (! delete_records('scorm_scoes_track', 'scormid', $scorm->id)) {
|
||||
$result = false;
|
||||
}
|
||||
if (! delete_records('scorm_scoes', 'scorm', $scorm->id)) {
|
||||
@@ -211,9 +160,9 @@ function scorm_grades($scormid) {
|
||||
}
|
||||
|
||||
$return->grades = NULL;
|
||||
if ($sco_users=get_records_select('scorm_sco_users', "scormid='$scormid' GROUP BY userid")) {
|
||||
if ($sco_users=get_records_select('scorm_scoes_track', "scormid='$scormid' GROUP BY userid")) {
|
||||
foreach ($sco_users as $sco_user) {
|
||||
$user_data=get_records_select('scorm_sco_users',"scormid='$scormid' AND userid='$sco_user->userid'");
|
||||
$user_data=get_records_select('scorm_scoes_track',"scormid='$scormid' AND userid='$sco_user->userid' AND element='cmi_core_lesson_status'");
|
||||
$scores->completed=0;
|
||||
$scores->browsed=0;
|
||||
$scores->incomplete=0;
|
||||
@@ -222,10 +171,10 @@ function scorm_grades($scormid) {
|
||||
$result='';
|
||||
$data = current($user_data);
|
||||
foreach ($user_data as $data) {
|
||||
if ($data->cmi_core_lesson_status=='passed')
|
||||
if ($data->value=='passed')
|
||||
$scores->completed++;
|
||||
else
|
||||
$scores->{scorm_remove_spaces($data->cmi_core_lesson_status)}++;
|
||||
$scores->{scorm_remove_spaces($data->value)}++;
|
||||
}
|
||||
if ($scores->completed)
|
||||
$result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/completed.gif\" alt=\"".get_string('completed','scorm')."\" title=\"".get_string('completed','scorm')."\" /> $scores->completed ";
|
||||
@@ -243,8 +192,8 @@ function scorm_grades($scormid) {
|
||||
|
||||
}
|
||||
} else {
|
||||
$grades = get_records_select("scorm_sco_users", "scormid=$scormid AND cmi_core_score_raw>0","","id,userid,cmi_core_score_raw");
|
||||
//$grades = get_records_menu("scorm_sco_users", "scormid",$scormid,"","userid,cmi_core_score_raw");
|
||||
$grades = get_records_select("scorm_scoes_track", "scormid=$scormid AND element='cmi_core_score_raw' AND value<>''","","id,userid,value");
|
||||
//$grades = get_records_menu("scorm_scoes_track", "scormid",$scormid,"","userid,cmi_core_score_raw");
|
||||
$valutations = array();
|
||||
foreach ($grades as $grade) {
|
||||
if (!isset($valutations[$grade->userid])) {
|
||||
@@ -257,16 +206,16 @@ function scorm_grades($scormid) {
|
||||
}
|
||||
switch ($scorm->grademethod) {
|
||||
case VALUEHIGHEST:
|
||||
if ($grade->cmi_core_score_raw > $valutations[$grade->userid]) {
|
||||
$valutations[$grade->userid] = $grade->cmi_core_score_raw;
|
||||
if ($grade->value > $valutations[$grade->userid]) {
|
||||
$valutations[$grade->userid] = $grade->value;
|
||||
}
|
||||
break;
|
||||
case VALUEAVERAGE:
|
||||
$values[$grade->userid]->grade += $grade->cmi_core_score_raw;
|
||||
$values[$grade->userid]->grade += $grade->value;
|
||||
$values[$grade->userid]->values++;
|
||||
break;
|
||||
case VALUESUM:
|
||||
$valutations[$grade->userid] += $grade->cmi_core_score_raw;
|
||||
$valutations[$grade->userid] += $grade->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -445,7 +394,7 @@ function scorm_startElement($parser, $name, $attrs) {
|
||||
if (!isset($attrs['ADLCP:SCORMTYPE'])) {
|
||||
$attrs['ADLCP:SCORMTYPE'] = '';
|
||||
}
|
||||
$resources[$attrs['IDENTIFIER']]['type']=$attrs['ADLCP:SCORMTYPE'];
|
||||
$resources[$attrs['IDENTIFIER']]['scormtype']=$attrs['ADLCP:SCORMTYPE'];
|
||||
}
|
||||
if ($name == 'ORGANIZATION') {
|
||||
$i++;
|
||||
@@ -485,6 +434,18 @@ function scorm_endElement($parser, $name) {
|
||||
if ($name == 'ADLCP:DATAFROMLMS') {
|
||||
$scoes[$i]['datafromlms'] = $datacontent;
|
||||
}
|
||||
if ($name == 'ADLCP:PREREQUISITES') {
|
||||
$scoes[$i]['prerequisites'] = $datacontent;
|
||||
}
|
||||
if ($name == 'ADLCP:MAXTIMEALLOWED') {
|
||||
$scoes[$i]['maxtimeallowed'] = $datacontent;
|
||||
}
|
||||
if ($name == 'ADLCP:TIMELIMITACTION') {
|
||||
$scoes[$i]['timelimitaction'] = $datacontent;
|
||||
}
|
||||
if ($name == 'ADLCP:MASTERYSCORE') {
|
||||
$scoes[$i]['masteryscore'] = $datacontent;
|
||||
}
|
||||
if ($name == 'ORGANIZATION') {
|
||||
$organization = '';
|
||||
$level--;
|
||||
@@ -531,7 +492,7 @@ function scorm_parse($basedir,$file,$scorm_id) {
|
||||
|
||||
$sco->scorm = $scorm_id;
|
||||
delete_records('scorm_scoes','scorm',$scorm_id);
|
||||
delete_records('scorm_sco_users','scormid',$scorm_id);
|
||||
delete_records('scorm_scoes_track','scormid',$scorm_id);
|
||||
|
||||
if (isset($scoes[1])) {
|
||||
for ($j=1; $j<=$i; $j++) {
|
||||
@@ -543,6 +504,22 @@ function scorm_parse($basedir,$file,$scorm_id) {
|
||||
$scoes[$j]['datafromlms'] = '';
|
||||
}
|
||||
$sco->datafromlms = $scoes[$j]['datafromlms'];
|
||||
if (!isset($scoes[$j]['prerequisites'])) {
|
||||
$scoes[$j]['prerequisites'] = '';
|
||||
}
|
||||
$sco->datafromlms = $scoes[$j]['prerequisites'];
|
||||
if (!isset($scoes[$j]['maxtimeallowed'])) {
|
||||
$scoes[$j]['maxtimeallowed'] = '';
|
||||
}
|
||||
$sco->datafromlms = $scoes[$j]['maxtimeallowed'];
|
||||
if (!isset($scoes[$j]['timelimitaction'])) {
|
||||
$scoes[$j]['timelimitaction'] = '';
|
||||
}
|
||||
$sco->datafromlms = $scoes[$j]['timelimitaction'];
|
||||
if (!isset($scoes[$j]['masteryscore'])) {
|
||||
$scoes[$j]['masteryscore'] = '';
|
||||
}
|
||||
$sco->datafromlms = $scoes[$j]['masteryscore'];
|
||||
|
||||
if (!isset($resources[($scoes[$j]['identifierref'])]['href'])) {
|
||||
$resources[($scoes[$j]['identifierref'])]['href'] = '';
|
||||
@@ -591,13 +568,45 @@ function scorm_parse($basedir,$file,$scorm_id) {
|
||||
return $launch;
|
||||
}
|
||||
|
||||
function scorm_get_tracks($scoid,$userid) {
|
||||
/// Gets all tracks of specified sco and user
|
||||
global $CFG;
|
||||
|
||||
if ($tracks = get_records_select("scorm_scoes_track","userid=$userid AND scoid=$scoid")) {
|
||||
$user_tracks->userid = $userid;
|
||||
$user_tracks->scoid = $scoid;
|
||||
foreach ($tracks as $track) {
|
||||
$element = str_replace('.','_',$track->element);
|
||||
switch ($element) {
|
||||
case "cmi_core_lesson_status":
|
||||
case "cmi_completition_status":
|
||||
if ($track->value == 'not attempted') {
|
||||
$track->value = 'notattempted';
|
||||
}
|
||||
$user_tracks->status = $track->value;
|
||||
break;
|
||||
case "cmi_core_score_raw":
|
||||
case "cmi_score_raw":
|
||||
$user_tracks->score_raw = $track->value;
|
||||
break;
|
||||
default:
|
||||
$user_tracks->{$element} = $track->value;
|
||||
}
|
||||
}
|
||||
//print_r($user_tracks);
|
||||
return $user_tracks;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function scorm_get_scoes_records($sco_user) {
|
||||
/// Gets all info required to display the table of scorm results
|
||||
/// for report.php
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql("SELECT su.*, u.firstname, u.lastname, u.picture
|
||||
FROM {$CFG->prefix}scorm_sco_users su,
|
||||
FROM {$CFG->prefix}scorm_scoes_track su,
|
||||
{$CFG->prefix}user u
|
||||
WHERE su.scormid = '$sco_user->scormid'
|
||||
AND su.userid = u.id
|
||||
@@ -615,9 +624,8 @@ function scorm_remove_spaces($sourcestr) {
|
||||
return $newstr;
|
||||
}
|
||||
|
||||
function scorm_string_round($stringa) {
|
||||
function scorm_string_round($stringa, $len=11) {
|
||||
// Crop a string to $len character and set an anchor title to the full string
|
||||
$len=11;
|
||||
if ( strlen($stringa)>$len ) {
|
||||
return "<a name=\"none\" title=\"$stringa\">".substr($stringa,0,$len-4).'...'.substr($stringa,strlen($stringa)-1,1).'</a>';
|
||||
} else
|
||||
@@ -634,14 +642,6 @@ function scorm_external_link($link) {
|
||||
$result = true;
|
||||
else if (substr($link,0,4) == 'www.')
|
||||
$result = true;
|
||||
/*else if (substr($link,0,7) == 'rstp://')
|
||||
$result = true;
|
||||
else if (substr($link,0,6) == 'rtp://')
|
||||
$result = true;
|
||||
else if (substr($link,0,6) == 'ftp://')
|
||||
$result = true;
|
||||
else if (substr($link,0,9) == 'gopher://')
|
||||
$result = true; */
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
|
||||
+28
-81
@@ -33,83 +33,40 @@
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
if ( $scoes_user = get_records_select("scorm_sco_users","userid = ".$USER->id." AND scormid = ".$scorm->id,"scoid ASC") ) {
|
||||
//
|
||||
// Already user
|
||||
//
|
||||
if (!empty($scoid)) {
|
||||
//
|
||||
// Direct sco request
|
||||
//
|
||||
if ($sco = get_record("scorm_scoes","id",$scoid)) {
|
||||
if ($sco->launch == '') {
|
||||
// Search for th first launchable sco
|
||||
if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) {
|
||||
$sco = current($scoes);
|
||||
while ($sco->id < $scoid) {
|
||||
$sco = next($scoes);
|
||||
}
|
||||
while ($sco->launch == '') {
|
||||
$sco = next($scoes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Search for first incomplete sco
|
||||
//
|
||||
foreach ( $scoes_user as $sco_user ) {
|
||||
if (($sco_user->cmi_core_lesson_status != "completed") && ($sco_user->cmi_core_lesson_status != "passed") && ($sco_user->cmi_core_lesson_status != "failed")) {
|
||||
$sco = get_record("scorm_scoes","id",$sco_user->scoid);
|
||||
break;
|
||||
} else {
|
||||
// If review mode get the first
|
||||
if ($mode == "review") {
|
||||
$sco = get_record("scorm_scoes","id",$sco_user->scoid);
|
||||
break;
|
||||
}
|
||||
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>".$scoid,"id ASC")) {
|
||||
$sco = current($scoes);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// If no sco was found get the first of SCORM package
|
||||
//
|
||||
if (!isset($sco)) {
|
||||
$scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' order by id ASC");
|
||||
$sco = each($scoes);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// A new user
|
||||
//
|
||||
if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) {
|
||||
//
|
||||
// Create user scoes records
|
||||
//
|
||||
foreach ($scoes as $sco) {
|
||||
if (($sco->launch != "") && ($sco->type != "sca") && ($sco->type != "asset")){
|
||||
if (!isset($first)) {
|
||||
$first = $sco;
|
||||
}
|
||||
$sco_user->userid = $USER->id;
|
||||
$sco_user->scoid = $sco->id;
|
||||
$sco_user->scormid = $scorm->id;
|
||||
$element = "cmi_core_lesson_status";
|
||||
$sco_user->$element = "not attempted";
|
||||
$ident = insert_record("scorm_sco_users",$sco_user);
|
||||
}
|
||||
}
|
||||
if (isset($first)) {
|
||||
$sco = $first;
|
||||
}
|
||||
if (!empty($scoid)) {
|
||||
if ($sco = get_record("scorm_scoes","id",$scoid)) {
|
||||
unset($first);
|
||||
}
|
||||
//
|
||||
// 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);
|
||||
while ((($sco_track->value == "completed") || ($sco_track->value == "passed") || ($sco_track->value == "failed")) && ($mode == "normal")) {
|
||||
$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)) {
|
||||
$scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>''","id ASC");
|
||||
$sco = current($scoes);
|
||||
}
|
||||
|
||||
//
|
||||
// Forge SCO URL
|
||||
//
|
||||
@@ -129,17 +86,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<script language="javascript">
|
||||
<?php
|
||||
if ($scorm->popup == "") {
|
||||
echo "\t document.location=\"$result\";\n";
|
||||
} else {
|
||||
$popuplocation = '';
|
||||
if (isset($_COOKIE["SCORMpopup"])) {
|
||||
$popuplocation = $_COOKIE["SCORMpopup"];
|
||||
}
|
||||
echo "\t top.main = window.open('$result','main','$scorm->popup$popuplocation');\n";
|
||||
}
|
||||
?>
|
||||
document.location='<?php echo $result ?>';
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+8
-158
@@ -18,9 +18,6 @@
|
||||
if (empty($form->datadir)) {
|
||||
$form->datadir = "";
|
||||
}
|
||||
if (empty($form->popup)) {
|
||||
$form->popup = "";
|
||||
}
|
||||
if (empty($form->maxgrade)) {
|
||||
$form->maxgrade = "";
|
||||
}
|
||||
@@ -43,7 +40,7 @@
|
||||
function validate_scorm(theform,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 $scormid.$datadir ?>");
|
||||
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $scormid.$datadir ?>");
|
||||
//alert(result);
|
||||
results = result.split('\n');
|
||||
if ((results[0] == "found") || (results[0] == "regular")) {
|
||||
@@ -99,48 +96,6 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$strnewwindow = get_string("newwindow", "scorm");
|
||||
$strnewwindowopen = get_string("newwindowopen", "scorm");
|
||||
foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
|
||||
$stringname = "str$optionname";
|
||||
$$stringname = get_string("new$optionname", "scorm");
|
||||
$window->$optionname = "";
|
||||
$jsoption[] = "\"$optionname\"";
|
||||
}
|
||||
$alljsoptions = implode(",", $jsoption);
|
||||
|
||||
if ($form->instance) { // Re-editing
|
||||
if ($form->popup == "") {
|
||||
$newwindow = ""; // Disable the new window
|
||||
foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
|
||||
$defaultvalue = "scorm_popup$optionname";
|
||||
$window->$optionname = $CFG->$defaultvalue;
|
||||
}
|
||||
} else {
|
||||
$newwindow = "checked";
|
||||
$rawoptions = explode(',', $form->popup);
|
||||
foreach ($rawoptions as $rawoption) {
|
||||
$option = explode('=', trim($rawoption));
|
||||
if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) {
|
||||
$optionname = $option[0];
|
||||
$optionvalue = $option[1];
|
||||
if ($optionname == "height" or $optionname == "width") {
|
||||
$window->$optionname = $optionvalue;
|
||||
} else if ($optionvalue == 1) {
|
||||
$window->$optionname = "checked";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
|
||||
$defaultvalue = "scorm_popup$optionname";
|
||||
$window->$optionname = $CFG->$defaultvalue;
|
||||
}
|
||||
$newwindow = $CFG->scorm_popup;
|
||||
}
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("grademethod", "scorm") ?>:</b></td>
|
||||
<td>
|
||||
@@ -163,126 +118,21 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string("display", "scorm") ?>:</b></td>
|
||||
<td>
|
||||
<input type="button" value="hide settings" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />
|
||||
<input type="hidden" name="windowsettingspref" id="windowsettingspref"
|
||||
value="<?php echo get_user_preferences('windowsettingspref', $CFG->scorm_windowsettings); ?>" />
|
||||
<?php helpbutton("window", get_string("display", "scorm"), "scorm", true) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
var subitems = [<?php echo $alljsoptions; ?>];
|
||||
|
||||
function autowindow(set) {
|
||||
divobj = document.getElementById('autocontinue');
|
||||
if (document.form.newwindow.checked) {
|
||||
divobj.style.display = 'none';
|
||||
} else {
|
||||
divobj.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
function showhide (id, set) {
|
||||
divobj = document.getElementById(id);
|
||||
butobj = document.getElementById(id+'button');
|
||||
prefobj = document.getElementById(id+'pref');
|
||||
if (set == true) {
|
||||
if (prefobj.value == '1') {
|
||||
divobj.style.display = 'block';
|
||||
butobj.value = '<?php print_string("hidesettings") ?>';
|
||||
} else {
|
||||
divobj.style.display = 'none';
|
||||
butobj.value = '<?php print_string("showsettings") ?>...';
|
||||
}
|
||||
} else {
|
||||
if (prefobj.value == '1') {
|
||||
divobj.style.display = 'none';
|
||||
butobj.value = '<?php print_string("showsettings") ?>...';
|
||||
prefobj.value = '0';
|
||||
} else {
|
||||
divobj.style.display = 'block';
|
||||
butobj.value = '<?php print_string("hidesettings") ?>';
|
||||
prefobj.value = '1';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="windowsettings" align="center">
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap="nowrap">
|
||||
<b><?php p($strnewwindow) ?>:</b>
|
||||
</td>
|
||||
<td>
|
||||
<input name="setnewwindow" type="hidden" value="1" />
|
||||
<input name="newwindow" type="checkbox" value="1" onclick="autowindow();return lockoptions('form','newwindow', subitems);" <?php echo $newwindow ?> />
|
||||
<?php echo $strnewwindowopen."\n"; ?>
|
||||
<ul style='list-style-type:none;'><li>
|
||||
<?php
|
||||
foreach ($window as $name => $value) {
|
||||
if ($name == "height" or $name == "width") {
|
||||
continue;
|
||||
}
|
||||
echo "\t\t<input name=\"h$name\" type=\"hidden\" value=\"0\" />\n";
|
||||
if ($window->$name == 'checked') {
|
||||
$window->$name = 'checked="checked"';
|
||||
}
|
||||
echo "\t\t<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." /> ";
|
||||
$stringname = "str$name";
|
||||
echo $$stringname."<br />\n";
|
||||
}
|
||||
?>
|
||||
|
||||
<input name="hwidth" type="hidden" value="0" />
|
||||
<input name="width" type="text" size="4" value="<?php p($window->width) ?>" alt="width" /> <?php p($strwidth) ?><br />
|
||||
<input name="hheight" type="hidden" value="0" />
|
||||
<input name="height" type="text" size="4" value="<?php p($window->height) ?>" alt="height" /> <?php p($strheight) ?><br />
|
||||
<?php
|
||||
if (!$newwindow) {
|
||||
echo "<script type=\"text/javascript\">\n<!--\n";
|
||||
echo "\tlockoptions('form','newwindow', subitems);";
|
||||
echo "\n-->\n</script>";
|
||||
}
|
||||
?>
|
||||
</li></ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="autocontinue">
|
||||
<table>
|
||||
<tr>
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string("autocontinue","scorm") ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
<td>
|
||||
<?php
|
||||
$options = array();
|
||||
$options[0]=get_string("no");
|
||||
$options[1]=get_string("yes");
|
||||
choose_from_menu ($options, "auto", $form->auto);
|
||||
helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
if ($newwindow == "checked") {
|
||||
echo "autowindow();\n";
|
||||
echo "showhide('windowsettings',false);\n";
|
||||
$newwindow = "checked='checked'";
|
||||
} else {
|
||||
echo "showhide('windowsettings',true);\n";
|
||||
}
|
||||
?>
|
||||
</script>
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
|
||||
<input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
|
||||
<input type="hidden" name="popup" value="<?php p($form->popup) ?>" />
|
||||
<input type="hidden" name="auto" value="<?php p($form->auto) ?>" />
|
||||
<input type="hidden" name="maxgrade" value="<?php p($form->maxgrade) ?>" />
|
||||
<input type="hidden" name="grademethod" value="<?php p($form->grademethod) ?>" />
|
||||
|
||||
+97
-68
@@ -1,45 +1,43 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
/// This page prints a particular instance of scorm
|
||||
/// (Replace scorm with the name of your module)
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once('../../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
optional_variable($id); // Course Module ID, or
|
||||
optional_variable($a); // scorm ID
|
||||
optional_variable($frameset, "");
|
||||
|
||||
if ($id) {
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
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 (! $course = get_record('course', 'id', $cm->course)) {
|
||||
error('Course is misconfigured');
|
||||
}
|
||||
|
||||
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
|
||||
error("Course module is incorrect");
|
||||
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");
|
||||
if (! $scorm = get_record('scorm', 'id', $a)) {
|
||||
error('Course module is incorrect');
|
||||
}
|
||||
if (! $course = get_record("course", "id", $scorm->course)) {
|
||||
error("Course is misconfigured");
|
||||
if (! $course = get_record('course', 'id', $scorm->course)) {
|
||||
error('Course is misconfigured');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
|
||||
$strscorms = get_string("modulenameplural", "scorm");
|
||||
$strscorm = get_string("modulename", "scorm");
|
||||
$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> ->
|
||||
@@ -51,7 +49,7 @@
|
||||
$pagetitle = strip_tags("$course->shortname: $scorm->name");
|
||||
|
||||
if (!$cm->visible and !isteacher($course->id)) {
|
||||
print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", "", "", true,
|
||||
print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", '', '', true,
|
||||
update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
@@ -65,12 +63,12 @@
|
||||
$modestring = '';
|
||||
$scoidstring = '';
|
||||
$currentorgstring = '';
|
||||
if (!empty($_POST["mode"])) {
|
||||
$mode = $_POST["mode"];
|
||||
if (!empty($_POST['mode'])) {
|
||||
$mode = $_POST['mode'];
|
||||
$modestring = '&mode='.$mode;
|
||||
}
|
||||
if (!empty($_POST["scoid"])) {
|
||||
$scoid = $_POST["scoid"];
|
||||
if (!empty($_POST['scoid'])) {
|
||||
$scoid = $_POST['scoid'];
|
||||
$scoidstring = '&scoid='.$scoid;
|
||||
}
|
||||
if (!empty($_POST['currentorg'])) {
|
||||
@@ -78,26 +76,36 @@
|
||||
$currentorgstring = '¤torg='.$currentorg;
|
||||
}
|
||||
|
||||
add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
|
||||
$strexpand = get_string('expcoll','scorm');
|
||||
|
||||
//
|
||||
// Print the page header
|
||||
//
|
||||
$bodyscripts = "onUnload='SCOFinish(); closeMain();'";
|
||||
$bodyscripts = "onUnload='SCOFinish();'";
|
||||
print_header($pagetitle, "$course->fullname",
|
||||
"$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">$scorm->name</a>",
|
||||
"", "", true, update_module_button($cm->id, $course->id, $strscorm), "", "", $bodyscripts);
|
||||
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>$scorm->name</a>",
|
||||
'', '', true, update_module_button($cm->id, $course->id, $strscorm), "", "", $bodyscripts);
|
||||
?>
|
||||
<style type="text/css">
|
||||
.scormlist {
|
||||
list-style-type:none;
|
||||
text-indent:-4ex;
|
||||
}
|
||||
|
||||
.fullscreen {
|
||||
width: 100%;
|
||||
vertical-align: top;
|
||||
}
|
||||
</style>
|
||||
<script language="Javascript">
|
||||
<!--
|
||||
function playSCO(scoid) {
|
||||
document.navform.scoid.value=scoid;
|
||||
document.navform.submit();
|
||||
if (scoid == 0) {
|
||||
document.location = 'view.php?id=<?php echo $cm->id ?>';
|
||||
} else {
|
||||
document.navform.scoid.value=scoid;
|
||||
document.navform.submit();
|
||||
}
|
||||
}
|
||||
|
||||
function expandCollide(which,list) {
|
||||
@@ -120,20 +128,30 @@
|
||||
|
||||
<script language="JavaScript" type="text/javascript" src="request.js"></script>
|
||||
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id ?>"></script>
|
||||
<table width="100%">
|
||||
<table border=1 class="fullscreen" height="90%">
|
||||
<tr><td valign="top">
|
||||
<p><?php echo text_to_html($scorm->summary, false, false) ?></p>
|
||||
<p><?php echo $mode == "browse" ? get_string("browsemode","scorm") : ' '; ?></p>
|
||||
<?php print_simple_box_start(); ?>
|
||||
<table>
|
||||
<tr><th><?php print_string("coursestruct","scorm") ?></th></tr>
|
||||
<p><?php echo $mode == 'browse' ? get_string('browsemode','scorm') : ' '; ?></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='expandCollide(imgmain,0);'>
|
||||
<img id='imgmain' src="pix/minus.gif" alt="<?php echo $strexpand ?>" title="<?php echo $strexpand ?>"/>
|
||||
</a>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
<tr><td nowrap>
|
||||
<ul class="scormlist">
|
||||
<ul id='0' class='scormlist'>
|
||||
<?php
|
||||
$incomplete = false;
|
||||
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
|
||||
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
|
||||
$level=0;
|
||||
$sublist=0;
|
||||
$sublist=1;
|
||||
$previd = 0;
|
||||
$nextid = 0;
|
||||
$parents[$level]="/";
|
||||
foreach ($scoes as $sco) {
|
||||
if ($parents[$level]!=$sco->parent) {
|
||||
@@ -142,13 +160,13 @@
|
||||
$level--;
|
||||
} else {
|
||||
$i = $level;
|
||||
$closelist = "";
|
||||
$closelist = '';
|
||||
while (($i > 0) && ($parents[$level] != $sco->parent)) {
|
||||
$closelist .= "\t\t</ul></li>\n";
|
||||
$i--;
|
||||
}
|
||||
if (($i == 0) && ($sco->parent != $currentorg)) {
|
||||
echo "\t\t<li><ul id='".$sublist."' class=\"scormlist\"'>\n";
|
||||
echo "\t\t<li><ul id='".$sublist."' class='scormlist'>\n";
|
||||
$level++;
|
||||
} else {
|
||||
echo $closelist;
|
||||
@@ -159,11 +177,13 @@
|
||||
}
|
||||
echo "\t\t<li>";
|
||||
$nextsco = next($scoes);
|
||||
if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
|
||||
if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) ||
|
||||
(($level>0) && ($nextsco->parent == $sco->identifier)))) {
|
||||
$sublist++;
|
||||
echo "<img id='img".$sublist."' src=\"pix/minus.gif\" onClick='expandCollide(this,".$sublist.");'/>";
|
||||
|
||||
echo "<a href='#' onClick='expandCollide(img".$sublist.",".$sublist.");'><img id='img".$sublist."' src='pix/minus.gif' alt='$strexpand' title='$strexpand'/></a>";
|
||||
} else {
|
||||
echo "<img src=\"pix/spacer.gif\" />";
|
||||
echo "<img src='pix/spacer.gif' />";
|
||||
}
|
||||
|
||||
if ($sco->launch) {
|
||||
@@ -172,6 +192,13 @@
|
||||
if ($sco->id == $scoid) {
|
||||
$startbold = '-> <b>';
|
||||
$endbold = '</b> <-';
|
||||
if ($nextsco !== false) {
|
||||
$nextid = $nextsco->id;
|
||||
} else {
|
||||
$nextid = 0;
|
||||
}
|
||||
} else if ($nextid == 0) {
|
||||
$previd = $sco->id;
|
||||
}
|
||||
if (($scoid == "") && ($mode != "normal")) {
|
||||
$scoid = $sco->id;
|
||||
@@ -179,31 +206,32 @@
|
||||
$endbold = '</b> <-';
|
||||
}
|
||||
$score = "";
|
||||
if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
|
||||
if ( $sco_user->cmi_core_lesson_status == "") {
|
||||
$sco_user->cmi_core_lesson_status = "not attempted";
|
||||
if ($user_tracks=scorm_get_tracks($sco->id,$USER->id)) {
|
||||
if ( $user_tracks->status == '') {
|
||||
$user_tracks->status = 'notattempted';
|
||||
}
|
||||
echo "<img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
|
||||
if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
|
||||
if ($scoid == "") {
|
||||
$strstatus = get_string($user_tracks->status,'scorm');
|
||||
echo "<img src='pix/".$user_tracks->status.".gif' alt='$strstatus' title='$strstatus' />";
|
||||
if (($user_tracks->status == 'notattempted') || ($user_tracks->status == 'incomplete')) {
|
||||
if ($scoid == '') {
|
||||
$incomplete = true;
|
||||
$scoid = $sco->id;
|
||||
$startbold = '-> <b>';
|
||||
$endbold = '</b> <-';
|
||||
}
|
||||
}
|
||||
if ($sco_user->cmi_core_score_raw > 0) {
|
||||
$score = "(".get_string("score","scorm").": ".$sco_user->cmi_core_score_raw.")";
|
||||
if ($user_tracks->score_raw != "") {
|
||||
$score = '('.get_string('score','scorm').': '.$user_tracks->score_raw.')';
|
||||
}
|
||||
} else {
|
||||
if ($sco->type == 'sco') {
|
||||
echo "<img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
|
||||
if ($sco->scormtype == 'sco') {
|
||||
echo "<img src='pix/notattempted.gif' alt='".get_string('notattempted','scorm')."' />";
|
||||
$incomplete = true;
|
||||
} else {
|
||||
echo "<img src=\"pix/asset.gif\" alt=\"".get_string("asset","scorm")."\" />";
|
||||
echo "<img src='pix/asset.gif' alt='".get_string('asset','scorm')."' />";
|
||||
}
|
||||
}
|
||||
echo " $startbold<a href=\"javascript:playSCO(".$sco->id.");\">$sco->title</a> $score$endbold</li>\n";
|
||||
echo " $startbold<a href='javascript:playSCO(".$sco->id.");'>$sco->title</a> $score$endbold</li>\n";
|
||||
} else {
|
||||
echo " $sco->title</li>\n";
|
||||
}
|
||||
@@ -212,6 +240,7 @@
|
||||
echo "\t\t</ul></li>\n";
|
||||
}
|
||||
}
|
||||
add_to_log($course->id, 'scorm', 'view', "reviewscorm.php?id=$cm->id&uid=$USER->id&scoid=$scoid", "$scorm->id");
|
||||
?>
|
||||
</ul>
|
||||
</td></tr>
|
||||
@@ -220,25 +249,25 @@
|
||||
<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="button" value="<?php print_string('prev','scorm') ?>" onClick="top.changeSco('previous');" />
|
||||
<input name="next" type="button" value="<?php print_string('next','scorm') ?>" onClick="top.changeSco('continue')" />
|
||||
<input name="prev" type="<?php if ($previd == 0) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="playSCO(<?php echo $previd ?>);" />
|
||||
<input name="next" type="button" value="<?php if ($nextid == 0) { print_string('exit','scorm'); } else { print_string('next','scorm'); } ?>" onClick="playSCO(<?php echo $nextid ?>)" />
|
||||
</form>
|
||||
</td></tr>
|
||||
</table>
|
||||
<?php print_simple_box_end(); ?>
|
||||
</td>
|
||||
<td width="100%">
|
||||
<iframe name="main" height="500" width="100%" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring ?>"></iframe>
|
||||
<td class="fullscreen">
|
||||
<iframe name="main" class="fullscreen" height="100%" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring ?>"></iframe>
|
||||
<script language="javascript">
|
||||
if (parseInt(navigator.appVersion)>3) {
|
||||
if (navigator.appName.indexOf("Microsoft")!=-1) {
|
||||
winH = document.body.offsetHeight-20;
|
||||
} else {
|
||||
winH = window.innerHeight-16;
|
||||
}
|
||||
}
|
||||
main.height = winH;
|
||||
</script>
|
||||
</td></tr>
|
||||
</table>
|
||||
<?php
|
||||
/*$popuplocation = '';
|
||||
if (isset($_COOKIE["SCORMpopup"])) {
|
||||
$popuplocation = $_COOKIE["SCORMpopup"];
|
||||
}
|
||||
echo "<script language=\"javascript\">\n";
|
||||
echo "\t top.main = window.open('loadSCO.php?id=$cm->id".$scoidstring."','main','$scorm->popup$popuplocation');\n";
|
||||
echo "</script>\n"; */
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
print_heading($scorm->name);
|
||||
}
|
||||
if ($scoes =get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
|
||||
if ($sco_users=get_records_select("scorm_sco_users", "scormid='$scorm->id' GROUP BY userid")) {
|
||||
if ($sco_users=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid")) {
|
||||
|
||||
$strname = get_string("name");
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
}
|
||||
|
||||
foreach ($sco_users as $sco_user) {
|
||||
$user_data = scorm_get_scoes_records($sco_user);
|
||||
$user_data = scorm_get_user_track($scorm->id,$sco_user->userid);
|
||||
|
||||
$row = array();
|
||||
$data = current($user_data);
|
||||
|
||||
@@ -20,11 +20,11 @@ function NewHttpReq() {
|
||||
return httpReq;
|
||||
}
|
||||
|
||||
function DoRequest(httpReq,url) {
|
||||
function DoRequest(httpReq,url,param) {
|
||||
//
|
||||
// httpReq.open (Method("get","post"), URL(string), Asyncronous(true,false))
|
||||
//
|
||||
httpReq.open("get", url,false);
|
||||
httpReq.send(null);
|
||||
httpReq.open("post", url,false);
|
||||
httpReq.send(param);
|
||||
return httpReq.responseText;
|
||||
}
|
||||
+35
-35
@@ -4,18 +4,18 @@
|
||||
|
||||
//This is the "graphical" structure of the scorm mod:
|
||||
//
|
||||
// scorm
|
||||
// (CL,pk->id)--------------------
|
||||
// scorm
|
||||
// (CL,pk->id)---------------------
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// scorm_scoes |
|
||||
// (UL,pk->id, fk->scorm) |
|
||||
// scorm_scoes |
|
||||
// (UL,pk->id, fk->scorm) |
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// scorm_sco_users |
|
||||
// (UL,pk->id, fk->scormid, fk->scoid)----
|
||||
// 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
|
||||
@@ -53,7 +53,6 @@
|
||||
$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->popup = backup_todb($info['MOD']['#']['POPUP']['0']['#']);
|
||||
$scorm->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
|
||||
|
||||
//The structure is equal to the db, so insert the scorm
|
||||
@@ -73,12 +72,6 @@
|
||||
if ($status)
|
||||
$status = scorm_scoes_restore_mods ($newid,$info,$restore);
|
||||
|
||||
//Now check if want to restore user data and do it.
|
||||
if ($restore->mods['scorm']->userinfo) {
|
||||
//Restore scorm_scoes
|
||||
if ($status)
|
||||
$status = scorm_sco_users_restore_mods ($newid,$info,$restore);
|
||||
}
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
@@ -113,14 +106,26 @@
|
||||
$sco->parent = backup_todb($sub_info['#']['PARENT']['0']['#']);
|
||||
$sco->identifier = backup_todb($sub_info['#']['IDENTIFIER']['0']['#']);
|
||||
$sco->launch = backup_todb($sub_info['#']['LAUNCH']['0']['#']);
|
||||
$sco->type = backup_todb($sub_info['#']['TYPE']['0']['#']);
|
||||
$sco->scormtype = backup_todb($sub_info['#']['SCORMTYPE']['0']['#']);
|
||||
$sco->title = backup_todb($sub_info['#']['TITLE']['0']['#']);
|
||||
$sco->title = backup_todb($sub_info['#']['PREREQUISITES']['0']['#']);
|
||||
$sco->title = backup_todb($sub_info['#']['MAXTIMEALLOWED']['0']['#']);
|
||||
$sco->title = backup_todb($sub_info['#']['TIMELIMITACTION']['0']['#']);
|
||||
$sco->datafromlms = backup_todb($sub_info['#']['DATAFROMLMS']['0']['#']);
|
||||
$sco->title = backup_todb($sub_info['#']['MASTERYSCORE']['0']['#']);
|
||||
$sco->next = backup_todb($sub_info['#']['NEXT']['0']['#']);
|
||||
$sco->previous = backup_todb($sub_info['#']['PREVIOUS']['0']['#']);
|
||||
|
||||
//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
|
||||
if ($status) {
|
||||
$status = scorm_scoes_tracks_restore_mods ($scorm_id,$info,$restore);
|
||||
}
|
||||
}
|
||||
|
||||
//Do some output
|
||||
if (($i+1) % 50 == 0) {
|
||||
@@ -142,53 +147,48 @@
|
||||
return $status;
|
||||
}
|
||||
|
||||
//This function restores the scorm_sco_users
|
||||
function scorm_sco_users_restore_mods($scorm_id,$info,$restore) {
|
||||
//This function restores the scorm_scoes_track
|
||||
function scorm_scoes_tracks_restore_mods($scorm_id,$info,$restore) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
$sco_users = NULL;
|
||||
$sco_tracks = NULL;
|
||||
|
||||
//Get the sco array
|
||||
if (!empty($info['MOD']['#']['SCO_USERS']['0']['#']['SCO_USER']))
|
||||
$sco_users = $info['MOD']['#']['SCO_USERS']['0']['#']['SCO_USER'];
|
||||
if (!empty($info['MOD']['#']['SCO_TRACKS']['0']['#']['SCO_TRACK']))
|
||||
$sco_tracks = $info['MOD']['#']['SCO_TRACKS']['0']['#']['SCO_TRACK'];
|
||||
|
||||
//Iterate over sco_users
|
||||
for($i = 0; $i < sizeof($sco_users); $i++) {
|
||||
$sub_info = $sco_users[$i];
|
||||
for($i = 0; $i < sizeof($sco_tracks); $i++) {
|
||||
$sco_track = $sco_tracks[$i];
|
||||
|
||||
//We'll need this later!!
|
||||
$oldid = backup_todb($sub_info['#']['ID']['0']['#']);
|
||||
$oldscoid = backup_todb($sub_info['#']['SCOID']['0']['#']);
|
||||
$olduserid = backup_todb($sub_info['#']['USERID']['0']['#']);
|
||||
|
||||
//Now, build the scorm_sco_users record structure
|
||||
//Now, build the scorm_scoes_track record structure
|
||||
$sco_user->scormid = $scorm_id;
|
||||
$sco_user->userid = backup_todb($sub_info['#']['USERID']['0']['#']);
|
||||
$sco_user->scoid = backup_todb($sub_info['#']['SCOID']['0']['#']);
|
||||
$sco_user->cmi_core_lesson_location = backup_todb($sub_info['#']['CMI_CORE_LESSON_LOCATION']['0']['#']);
|
||||
$sco_user->cmi_core_lesson_status = backup_todb($sub_info['#']['CMI_CORE_LESSON_STATUS']['0']['#']);
|
||||
$sco_user->cmi_core_exit = backup_todb($sub_info['#']['CMI_CORE_EXIT']['0']['#']);
|
||||
$sco_user->cmi_core_total_time = backup_todb($sub_info['#']['CMI_CORE_TOTAL_TIME']['0']['#']);
|
||||
$sco_user->cmi_core_session_time = backup_todb($sub_info['#']['CMI_CORE_SESSION_TIME']['0']['#']);
|
||||
$sco_user->cmi_core_score_raw = backup_todb($sub_info['#']['CMI_CORE_SCORE_RAW']['0']['#']);
|
||||
$sco_user->cmi_suspend_data = backup_todb($sub_info['#']['CMI_SUSPEND_DATA']['0']['#']);
|
||||
$sco_user->element = backup_todb($sub_info['#']['ELEMENT']['0']['#']);
|
||||
$sco_user->value = backup_todb($sub_info['#']['VALUE']['0']['#']);
|
||||
|
||||
//We have to recode the userid field
|
||||
$user = backup_getid($restore->backup_unique_code,"user",$sco_user->userid);
|
||||
$user = backup_getid($restore->backup_unique_code,"user",$sco_track->userid);
|
||||
if ($user) {
|
||||
$sco_user->userid = $user->new_id;
|
||||
$sco_track->userid = $user->new_id;
|
||||
}
|
||||
|
||||
//We have to recode the scoid field
|
||||
$sco = backup_getid($restore->backup_unique_code,"scorm_scoes",$sco_user->scoid);
|
||||
$sco = backup_getid($restore->backup_unique_code,"scorm_scoes",$sco_track->scoid);
|
||||
if ($sco) {
|
||||
$sco_user->scoid = $sco->new_id;
|
||||
$sco_track->scoid = $sco->new_id;
|
||||
}
|
||||
|
||||
//The structure is equal to the db, so insert the scorm_sco_users
|
||||
$newid = insert_record ("scorm_sco_users",$sco_user);
|
||||
//The structure is equal to the db, so insert the scorm_scoes_track
|
||||
$newid = insert_record ("scorm_scoes_track",$sco_track);
|
||||
|
||||
//Do some output
|
||||
if (($i+1) % 50 == 0) {
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
require_login();
|
||||
|
||||
|
||||
$reference = clean_param($_GET["reference"], PARAM_PATH);
|
||||
$courseid = $_GET["id"];
|
||||
$reference = clean_param($_POST["reference"], PARAM_PATH);
|
||||
$courseid = $_POST["id"];
|
||||
$datadir = '';
|
||||
if (isset($_GET["datadir"])) {
|
||||
$datadir = $_GET["datadir"];
|
||||
if (isset($_POST["datadir"])) {
|
||||
$datadir = $_POST["datadir"];
|
||||
}
|
||||
|
||||
$scormid = 0;
|
||||
$launch = 0;
|
||||
$result = '';
|
||||
$errorlogs = '';
|
||||
if (isset($_GET["instance"])) {
|
||||
$scormid = $_GET["instance"];
|
||||
if (isset($_POST["instance"])) {
|
||||
$scormid = $_POST["instance"];
|
||||
$launch = 1;
|
||||
$fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r");
|
||||
$fstat = fstat($fp);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2005022100; // The (date) version of this module
|
||||
$module->version = 2005031300; // 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)?
|
||||
|
||||
|
||||
+11
-10
@@ -63,7 +63,7 @@
|
||||
"", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
|
||||
|
||||
if (isteacher($course->id)) {
|
||||
if ($sco_users = get_records_select("scorm_sco_users", "scormid='$scorm->id' GROUP BY userid")) {
|
||||
if ($sco_users = get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid")) {
|
||||
echo "<p align=\"right\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string("viewallreports","scorm",count($sco_users))."</a></p>";
|
||||
} else {
|
||||
echo "<p align=\"right\">".get_string("noreports","scorm")."</p>";
|
||||
@@ -148,19 +148,20 @@
|
||||
}
|
||||
if ($sco->launch) {
|
||||
$score = "";
|
||||
if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
|
||||
if ( $sco_user->cmi_core_lesson_status == "") {
|
||||
$sco_user->cmi_core_lesson_status = "not attempted";
|
||||
if ($user_tracks=scorm_get_tracks($sco->id,$USER->id)) {
|
||||
if ( $user_tracks->status == "") {
|
||||
$user_tracks->status = "notattempted";
|
||||
}
|
||||
echo " <img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
|
||||
if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
|
||||
$strstatus = get_string($user_tracks->status,'scorm');
|
||||
echo "<img src='pix/".$user_tracks->status.".gif' alt='$strstatus' title='$strstatus' />";
|
||||
if (($user_tracks->status == "notattempted") || ($user_tracks->status == "incomplete")) {
|
||||
$incomplete = true;
|
||||
}
|
||||
if ($sco_user->cmi_core_score_raw > 0) {
|
||||
$score = "(".get_string("score","scorm").": ".$sco_user->cmi_core_score_raw.")";
|
||||
if ($user_tracks->score_raw != "") {
|
||||
$score = "(".get_string("score","scorm").": ".$user_tracks->score_raw.")";
|
||||
}
|
||||
} else {
|
||||
if ($sco->type == 'sco') {
|
||||
if ($sco->scormtype == 'sco') {
|
||||
echo " <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\" />";
|
||||
$incomplete = true;
|
||||
} else {
|
||||
@@ -196,7 +197,7 @@
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
function playSCO(scoid,status) {
|
||||
function playSCO(scoid) {
|
||||
document.theform.scoid.value = scoid;
|
||||
document.theform.submit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user