Splitted scoes optional data in a new table

This commit is contained in:
bobopinna 2006-11-21 16:12:19 +00:00
parent 9c03bbaa04
commit b3659259fd
19 changed files with 633 additions and 378 deletions

View File

@ -30,7 +30,7 @@
$attempt = 1;
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if ($sco = scorm_get_sco($scoid, SCO_ONLY)) {
if (!$scorm = get_record('scorm','id',$sco->scorm)) {
error('Invalid script call');
}
@ -63,12 +63,12 @@
$userdata->credit = 'no-credit';
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if ($sco = scorm_get_sco($scoid)) {
$userdata->course_id = $sco->identifier;
$userdata->datafromlms = $sco->datafromlms;
$userdata->masteryscore = $sco->masteryscore;
$userdata->maxtimeallowed = $sco->maxtimeallowed;
$userdata->timelimitaction = $sco->timelimitaction;
$userdata->datafromlms = isset($sco->datafromlms)?$sco->datafromlms:'';
$userdata->masteryscore = isset($sco->masteryscore)?$sco->masteryscore:'';
$userdata->maxtimeallowed = isset($sco->maxtimeallowed)?$sco->maxtimeallowed:'';
$userdata->timelimitaction = isset($sco->timelimitaction)?$sco->timelimitaction:'';
echo "error = 0\nerror_text = Successful\naicc_data=\n";
echo "[Core]\n";

View File

@ -57,18 +57,9 @@
} else {
$userdata->credit = 'no-credit';
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if (!empty($sco->datafromlms)) {
$userdata->datafromlms = $sco->datafromlms;
}
if (!empty($sco->masteryscore)) {
$userdata->masteryscore = $sco->masteryscore;
}
if (!empty($sco->maxtimeallowed)) {
$userdata->maxtimeallowed = $sco->maxtimeallowed;
}
if (!empty($sco->timelimitaction)) {
$userdata->timelimitaction = $sco->timelimitaction;
if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
foreach ($scodatas as $key => $value) {
$userdata->$key = $value;
}
} else {
error('Sco not found');

View File

@ -5,17 +5,17 @@
//This is the "graphical" structure of the scorm mod:
//
// scorm
// (CL,pk->id)---------------------
// | |
// | |
// | |
// scorm_scoes |
// (UL,pk->id, fk->scorm) |
// | |
// | |
// | |
// scorm_scoes_track |
// (UL,k->id, fk->scormid, fk->scoid, k->element)---
// (CL,pk->id)-------------------------------------
// | |
// | |
// | |
// scorm_scoes scorm_scoes_data |
// (UL,pk->id, fk->scorm)-------(UL,pk->id, 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
@ -33,7 +33,7 @@
$status = true;
//Iterate over scorm table
$scorms = get_records ("scorm","course",$preferences->backup_course,"id");
$scorms = get_records ('scorm','course',$preferences->backup_course,'id');
if ($scorms) {
foreach ($scorms as $scorm) {
if (backup_mod_selected($preferences,'scorm',$scorm->id)) {
@ -52,27 +52,27 @@
}
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
fwrite ($bf,start_tag('MOD',3,true));
//Print scorm data
fwrite ($bf,full_tag("ID",4,false,$scorm->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"scorm"));
fwrite ($bf,full_tag("NAME",4,false,$scorm->name));
fwrite ($bf,full_tag("REFERENCE",4,false,$scorm->reference));
fwrite ($bf,full_tag("VERSION",4,false,$scorm->version));
fwrite ($bf,full_tag("MAXGRADE",4,false,$scorm->maxgrade));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$scorm->grademethod));
fwrite ($bf,full_tag("LAUNCH",4,false,$scorm->launch));
fwrite ($bf,full_tag("SKIPVIEW",4,false,$scorm->skipview));
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("HIDEBROWSE",4,false,$scorm->hidebrowse));
fwrite ($bf,full_tag("HIDETOC",4,false,$scorm->hidetoc));
fwrite ($bf,full_tag("HIDENAV",4,false,$scorm->hidenav));
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
fwrite ($bf,full_tag("POPUP",4,false,$scorm->popup));
fwrite ($bf,full_tag("OPTIONS",4,false,$scorm->options));
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));
fwrite ($bf,full_tag('ID',4,false,$scorm->id));
fwrite ($bf,full_tag('MODTYPE',4,false,'scorm'));
fwrite ($bf,full_tag('NAME',4,false,$scorm->name));
fwrite ($bf,full_tag('REFERENCE',4,false,$scorm->reference));
fwrite ($bf,full_tag('VERSION',4,false,$scorm->version));
fwrite ($bf,full_tag('MAXGRADE',4,false,$scorm->maxgrade));
fwrite ($bf,full_tag('GRADEMETHOD',4,false,$scorm->grademethod));
fwrite ($bf,full_tag('LAUNCH',4,false,$scorm->launch));
fwrite ($bf,full_tag('SKIPVIEW',4,false,$scorm->skipview));
fwrite ($bf,full_tag('SUMMARY',4,false,$scorm->summary));
fwrite ($bf,full_tag('HIDEBROWSE',4,false,$scorm->hidebrowse));
fwrite ($bf,full_tag('HIDETOC',4,false,$scorm->hidetoc));
fwrite ($bf,full_tag('HIDENAV',4,false,$scorm->hidenav));
fwrite ($bf,full_tag('AUTO',4,false,$scorm->auto));
fwrite ($bf,full_tag('POPUP',4,false,$scorm->popup));
fwrite ($bf,full_tag('OPTIONS',4,false,$scorm->options));
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);
//if we've selected to backup users info, then execute backup_scorm_scoes_track
@ -84,7 +84,7 @@
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
$status =fwrite ($bf,end_tag('MOD',3,true));
return $status;
}
@ -95,41 +95,63 @@
$status = true;
$scorm_scoes = get_records("scorm_scoes","scorm",$scorm,"id");
$scorm_scoes = get_records('scorm_scoes','scorm',$scorm,'id');
//If there is scoes
if ($scorm_scoes) {
//Write start tag
$status =fwrite ($bf,start_tag("SCOES",4,true));
$status =fwrite ($bf,start_tag('SCOES',4,true));
//Iterate over each sco
foreach ($scorm_scoes as $sco) {
//Start sco
$status =fwrite ($bf,start_tag("SCO",5,true));
$status =fwrite ($bf,start_tag('SCO',5,true));
//Print submission contents
fwrite ($bf,full_tag("ID",6,false,$sco->id));
fwrite ($bf,full_tag("MANIFEST",6,false,$sco->manifest));
fwrite ($bf,full_tag("ORGANIZATION",6,false,$sco->organization));
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("PARAMETERS",6,false,$sco->parameters));
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));
fwrite ($bf,full_tag('ID',6,false,$sco->id));
fwrite ($bf,full_tag('MANIFEST',6,false,$sco->manifest));
fwrite ($bf,full_tag('ORGANIZATION',6,false,$sco->organization));
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('SCORMTYPE',6,false,$sco->scormtype));
fwrite ($bf,full_tag('TITLE',6,false,$sco->title));
$status = backup_scorm_scoes_data($bf,$preferences,$sco->id);
//End sco
$status =fwrite ($bf,end_tag("SCO",5,true));
$status =fwrite ($bf,end_tag('SCO',5,true));
}
//Write end tag
$status =fwrite ($bf,end_tag("SCOES",4,true));
$status =fwrite ($bf,end_tag('SCOES',4,true));
}
return $status;
}
//Backup scorm_scoes_data contents (executed from scorm_backup_scorm_scoes)
function backup_scorm_scoes_data ($bf,$preferences,$sco) {
global $CFG;
$status = true;
$scorm_sco_datas = get_records('scorm_scoes_data','scoid',$sco,'id');
//If there is data
if ($scorm_sco_datas) {
//Write start tag
$status =fwrite ($bf,start_tag('SCO_DATAS',4,true));
//Iterate over each sco
foreach ($scorm_sco_datas as $sco_data) {
//Start sco track
$status =fwrite ($bf,start_tag('SCO_DATA',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$sco_data->id));
fwrite ($bf,full_tag('NAME',6,false,$sco_data->name));
fwrite ($bf,full_tag('VALUE',6,false,$sco_data->value));
//End sco track
$status =fwrite ($bf,end_tag('SCO_DATA',5,true));
}
//Write end tag
$status =fwrite ($bf,end_tag('SCO_DATAS',4,true));
}
return $status;
}
//Backup scorm_scoes_track contents (executed from scorm_backup_mods)
function backup_scorm_scoes_track ($bf,$preferences,$scorm) {
@ -137,26 +159,26 @@
$status = true;
$scorm_scoes_track = get_records("scorm_scoes_track","scormid",$scorm,"id");
$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_TRACKS",4,true));
$status =fwrite ($bf,start_tag('SCO_TRACKS',4,true));
//Iterate over each sco
foreach ($scorm_scoes_track as $sco_track) {
//Start sco track
$status =fwrite ($bf,start_tag("SCO_TRACK",5,true));
$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));
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));
$status =fwrite ($bf,end_tag('SCO_TRACK',5,true));
}
//Write end tag
$status =fwrite ($bf,end_tag("SCO_TRACKS",4,true));
$status =fwrite ($bf,end_tag('SCO_TRACKS',4,true));
}
return $status;
}
@ -171,7 +193,7 @@
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","scorm");
$info[0][0] = get_string('modulenameplural','scorm');
if ($ids = scorm_ids ($course)) {
$info[0][1] = count($ids);
} else {
@ -180,7 +202,7 @@
//Now, if requested, the user_data
if ($user_data) {
$info[1][0] = get_string("scoes","scorm");
$info[1][0] = get_string('scoes','scorm');
if ($ids = scorm_scoes_track_ids_by_course ($course)) {
$info[1][1] = count($ids);
} else {
@ -194,7 +216,7 @@
$info[$instance->id.'0'][0] = $instance->name;
$info[$instance->id.'0'][1] = '';
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("scoes","scorm");
$info[$instance->id.'1'][0] = get_string('scoes','scorm');
if ($ids = scorm_scoes_track_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
@ -214,12 +236,12 @@
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/scorm/",true);
$status = check_dir_exists($CFG->dataroot.'/temp/backup/'.$preferences->backup_unique_code.'/moddata/scorm/',true);
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm/".$instanceid,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/scorm/".$instanceid);
if (is_dir($CFG->dataroot.'/'.$preferences->backup_course.'/'.$CFG->moddata.'/scorm/'.$instanceid)) {
$status = backup_copy_file($CFG->dataroot.'/'.$preferences->backup_course.'/'.$CFG->moddata.'/scorm/'.$instanceid,
$CFG->dataroot.'/temp/backup/'.$preferences->backup_unique_code.'/moddata/scorm/'.$instanceid);
}
}
@ -239,14 +261,14 @@
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
//Now copy the scorm dir
if ($status) {
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm")) {
$handle = opendir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm");
if (is_dir($CFG->dataroot.'/'.$preferences->backup_course.'/'.$CFG->moddata.'/scorm')) {
$handle = opendir($CFG->dataroot.'/'.$preferences->backup_course.'/'.$CFG->moddata.'/scorm');
while (false!==($item = readdir($handle))) {
if ($item != '.' && $item != '..' && is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/sorm/".$item)
if ($item != '.' && $item != '..' && is_dir($CFG->dataroot.'/'.$preferences->backup_course.'/'.$CFG->moddata.'/scorm/'.$item)
&& array_key_exists($item,$preferences->mods['scorm']->instances)
&& !empty($preferences->mods['scorm']->instances[$item]->backup)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm/".$item,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/scorm/",$item);
$status = backup_copy_file($CFG->dataroot.'/'.$preferences->backup_course.'/'.$CFG->moddata.'/scorm/'.$item,
$CFG->dataroot.'/temp/backup/'.$preferences->backup_unique_code.'/moddata/scorm/',$item);
}
}
}

View File

@ -11,25 +11,6 @@
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<table cellpadding="9" cellspacing="0" >
<!--<tr valign="top">
<td align="right">scorm_validate:</td>
<td>
<?php
unset($choices);
$choices[""] = get_string("none");
if (extension_loaded('domxml')) {
$choices["domxml"] = get_string("domxml","scorm");
}
if (version_compare(phpversion(),"5.0.0",">=")) {
$choices["php5"] = get_string("php5","scorm");
}
choose_from_menu ($choices, "scorm_validate", $CFG->scorm_validate, "");
?>
</td>
<td>
<?php print_string("validationtype", "scorm") ?>
</td>
</tr> -->
<tr valign="top">
<td align="right">scorm_framewidth:</td>
<td>

View File

@ -68,7 +68,7 @@ function SCORMapi1_2() {
'cmi.core.exit':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.exit'})?$userdata->{'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':{'defaultvalue':'<?php echo isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
'cmi.launch_data':{'defaultvalue':'<?php echo $userdata->datafromlms ?>', 'mod':'r', 'writeerror':'403'},
'cmi.launch_data':{'defaultvalue':'<?php echo isset($userdata->datafromlms)?$userdata->datafromlms:'' ?>', 'mod':'r', 'writeerror':'403'},
'cmi.comments':{'defaultvalue':'<?php echo isset($userdata->{'cmi.comments'})?$userdata->{'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':'402'},
@ -80,9 +80,9 @@ function SCORMapi1_2() {
'cmi.objectives.n.score.max':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
'cmi.objectives.n.status':{'pattern':CMIIndex, 'format':CMIStatus2, 'mod':'rw', 'writeerror':'405'},
'cmi.student_data._children':{'defaultvalue':student_data_children, 'mod':'r', 'writeerror':'402'},
'cmi.student_data.mastery_score':{'defaultvalue':'<?php echo $userdata->masteryscore ?>', 'mod':'r', 'writeerror':'403'},
'cmi.student_data.max_time_allowed':{'defaultvalue':'<?php echo $userdata->maxtimeallowed ?>', 'mod':'r', 'writeerror':'403'},
'cmi.student_data.time_limit_action':{'defaultvalue':'<?php echo $userdata->timelimitaction ?>', 'mod':'r', 'writeerror':'403'},
'cmi.student_data.mastery_score':{'defaultvalue':'<?php echo isset($userdata->masteryscore)?$userdata->masteryscore:'' ?>', 'mod':'r', 'writeerror':'403'},
'cmi.student_data.max_time_allowed':{'defaultvalue':'<?php echo isset($userdata->maxtimeallowed)?$userdata->maxtimeallowed:'' ?>', 'mod':'r', 'writeerror':'403'},
'cmi.student_data.time_limit_action':{'defaultvalue':'<?php echo isset($userdata->timelimitaction)?$userdata->timelimitaction:'' ?>', 'mod':'r', 'writeerror':'403'},
'cmi.student_preference._children':{'defaultvalue':student_preference_children, 'mod':'r', 'writeerror':'402'},
'cmi.student_preference.audio':{'defaultvalue':'0', 'format':CMISInteger, 'range':audio_range, 'mod':'rw', 'writeerror':'405'},
'cmi.student_preference.language':{'defaultvalue':'', 'format':CMIString256, 'mod':'rw', 'writeerror':'405'},
@ -167,7 +167,7 @@ function SCORMapi1_2() {
if (param == "") {
if (!Initialized) {
<?php
if (($CFG->debug > 7) && (isadmin())) {
if (debugging('',DEBUG_DEVELOPER)) {
echo 'alert("Initialized SCORM 1.2");';
}
?>
@ -188,7 +188,7 @@ function SCORMapi1_2() {
if (param == "") {
if (Initialized) {
<?php
if (($CFG->debug > 7) && (isadmin())) {
if (debugging('',DEBUG_DEVELOPER)) {
echo 'alert("Finished SCORM 1.2");';
}
?>
@ -233,7 +233,7 @@ function SCORMapi1_2() {
if (subelement == element) {
errorCode = "0";
<?php
if (($CFG->debug > 7) && (isadmin())) {
if (debugging('',DEBUG_DEVELOPER)) {
echo 'alert(element+": "+eval(element));';
}
?>
@ -337,7 +337,7 @@ function SCORMapi1_2() {
eval(element+'="'+value+'";');
errorCode = "0";
<?php
if (($CFG->debug > 7) && (isadmin())) {
if (debugging('',DEBUG_DEVELOPER)) {
echo 'alert(element+":= "+value);';
}
?>
@ -353,7 +353,7 @@ function SCORMapi1_2() {
}
errorCode = "0";
<?php
if (($CFG->debug > 7) && (isadmin())) {
if (debugging('',DEBUG_DEVELOPER)) {
echo 'alert(element+":= "+value);';
}
?>
@ -384,7 +384,7 @@ function SCORMapi1_2() {
if (Initialized) {
result = StoreData(cmi,false);
<?php
if (($CFG->debug > 7) && (isadmin())) {
if (debugging('',DEBUG_DEVELOPER)) {
echo 'alert("Data Commited");';
}
?>
@ -539,7 +539,7 @@ function SCORMapi1_2() {
datastring = CollectData(data,'cmi');
}
datastring += '&attempt=<?php echo $attempt ?>';
datastring += '&scoid=<?php echo $sco->id ?>';
datastring += '&scoid=<?php echo $scoid ?>';
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);

View File

@ -81,7 +81,7 @@ function scorm_eval_prerequisites($prerequisites,$usertracks) {
$setelements = explode(',', substr($prerequisites, $open+1, $close-($open+1)-1));
$settrue = 0;
foreach ($setelements as $setelement) {
if (eval_prerequisites($setelement,$usertracks)) {
if (scorm_eval_prerequisites($setelement,$usertracks)) {
$settrue++;
}
}
@ -212,6 +212,12 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$parents[$level]='/';
foreach ($scoes as $sco) {
$isvisible = false;
if ($optionaldatas = scorm_get_sco($sco->id, SCO_DATA)) {
if (!isset($optionaldatas->isvisible) || (isset($optionaldatas->isvisible) && ($optionaldatas->isvisible == 'true'))) {
$isvisible = true;
}
}
if ($parents[$level]!=$sco->parent) {
if ($newlevel = array_search($sco->parent,$parents)) {
for ($i=0; $i<($level-$newlevel); $i++) {
@ -239,86 +245,97 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$parents[$level]=$sco->parent;
}
}
$result->toc .= "\t\t<li>";
if ($isvisible) {
$result->toc .= "\t\t<li>";
}
$nextsco = next($scoes);
if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$nextisvisible = false;
if (($nextsco !== false) && ($optionaldatas = scorm_get_sco($nextsco->id, SCO_DATA))) {
if (!isset($optionaldatas->isvisible) || (isset($optionaldatas->isvisible) && ($optionaldatas->isvisible == 'true'))) {
$nextisvisible = true;
}
}
if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++;
$icon = 'minus';
if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
$icon = 'plus';
}
$result->toc .= '<a href="javascript:expandCollide(img'.$sublist.','.$sublist.','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$scormpixdir.'/'.$icon.'.gif" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
} else {
} else if ($isvisible) {
$result->toc .= '<img src="'.$scormpixdir.'/spacer.gif" />';
}
if (empty($sco->title)) {
$sco->title = $sco->identifier;
}
if (!empty($sco->launch)) {
$startbold = '';
$endbold = '';
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
}
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
$strstatus = get_string($usertrack->status,'scorm');
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$scormpixdir.'/'.$usertrack->status.'.gif" alt="'.$strstatus.'" title="'.$strstatus.'" />';
} else {
$statusicon = '<img src="'.$scormpixdir.'/assetc.gif" alt="'.get_string('assetlauched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
if ($isvisible) {
$startbold = '';
$endbold = '';
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
}
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
$strstatus = get_string($usertrack->status,'scorm');
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$scormpixdir.'/'.$usertrack->status.'.gif" alt="'.$strstatus.'" title="'.$strstatus.'" />';
} else {
$statusicon = '<img src="'.$scormpixdir.'/assetc.gif" alt="'.get_string('assetlauched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
}
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
$incomplete = true;
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
$incomplete = true;
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
}
if ($usertrack->score_raw != '') {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
}
$strsuspended = get_string('suspended','scorm');
if (isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) {
$statusicon = '<img src="'.$scormpixdir.'/suspend.gif" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
}
} else {
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$scormpixdir.'/notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$incomplete = true;
} else {
$statusicon = '<img src="'.$scormpixdir.'/asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
}
}
if ($usertrack->score_raw != '') {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
if ($sco->id == $scoid) {
$scodata = scorm_get_sco($sco->id, SCO_DATA);
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = isset($scodata->next) ? $scodata->next : 0;
$showprev = isset($scodata->previous) ? $scodata->previous : 0;
}
$strsuspended = get_string('suspended','scorm');
if (isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) {
$statusicon = '<img src="'.$scormpixdir.'/suspend.gif" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
}
} else {
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
if ($sco->scormtype == 'sco') {
$statusicon= '<img src="'.$scormpixdir.'/notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$incomplete = true;
} else {
$statusicon .= '<img src="'.$scormpixdir.'/asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
}
}
if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = $sco->next;
$showprev = $sco->previous;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
}
}
}
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
}
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
$result->toc .= $statusicon.'&nbsp;'.$sco->title."</li>\n";
}
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
$result->toc .= '&nbsp;'.$sco->title."</li>\n";
}
} else {
$result->toc .= '&nbsp;'.$sco->title."</li>\n";
@ -334,7 +351,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
}
if ($play) {
$sco = get_record('scorm_scoes','id',$scoid);
$sco = scorm_get_sco($scoid);
$sco->previd = $previd;
$sco->nextid = $nextid;
$result->sco = $sco;

View File

@ -1,24 +1,5 @@
<?php
/* // Added by Pham Minh Duc
case 'ADLNAV:PRESENTATION':
$parent = array_pop($parents);
array_push($parents, $parent);
foreach ($block['children'] as $adlnav) {
if ($adlnav['name'] == 'ADLNAV:NAVIGATIONINTERFACE') {
foreach ($adlnav['children'] as $adlnavInterface) {
if ($adlnavInterface['name'] == 'ADLNAV:HIDELMSUI') {
if ($adlnavInterface['tagData'] == 'continue') {
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->next = 1;
}
if ($adlnavInterface['tagData'] == 'previous') {
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->previous = 1;
}
}
}
}
}
break;
case 'IMSSS:SEQUENCING':
$parent = array_pop($parents);
array_push($parents, $parent);
@ -373,7 +354,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
//
// Added by Pham Minh Duc
$suspendedscoid = scorm_get_suspendedscoid($scorm->id,$user->id,$attempt);
// $suspendedscoid = scorm_get_suspendedscoid($scorm->id,$user->id,$attempt);
// End add
$usertracks = array();
@ -394,8 +375,13 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$nextid = 0;
$findnext = false;
$parents[$level]='/';
foreach ($scoes as $sco) {
$isvisible = false;
if ($optionaldatas = scorm_get_sco($sco->id, SCO_DATA)) {
if (!isset($optionaldatas->isvisible) || (isset($optionaldatas->isvisible) && ($optionaldatas->isvisible == 'true'))) {
$isvisible = true;
}
}
if ($parents[$level]!=$sco->parent) {
if ($newlevel = array_search($sco->parent,$parents)) {
for ($i=0; $i<($level-$newlevel); $i++) {
@ -423,97 +409,107 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$parents[$level]=$sco->parent;
}
}
$result->toc .= "\t\t<li>";
if ($isvisible) {
$result->toc .= "\t\t<li>";
}
$nextsco = next($scoes);
if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$nextisvisible = false;
if (($nextsco !== false) && ($optionaldatas = scorm_get_sco($nextsco->id, SCO_DATA))) {
if (!isset($optionaldatas->isvisible) || (isset($optionaldatas->isvisible) && ($optionaldatas->isvisible == 'true'))) {
$nextisvisible = true;
}
}
if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++;
$icon = 'minus';
if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
$icon = 'plus';
}
$result->toc .= '<a href="javascript:expandCollide(img'.$sublist.','.$sublist.','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$scormpixdir.'/'.$icon.'.gif" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
} else {
} else if ($isvisible) {
$result->toc .= '<img src="'.$scormpixdir.'/spacer.gif" />';
}
if (empty($sco->title)) {
$sco->title = $sco->identifier;
}
if (!empty($sco->launch)) {
$startbold = '';
$endbold = '';
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
}
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
$strstatus = get_string($usertrack->status,'scorm');
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$scormpixdir.'/'.$usertrack->status.'.gif" alt="'.$strstatus.'" title="'.$strstatus.'" />';
} else {
$statusicon = '<img src="'.$scormpixdir.'/assetc.gif" alt="'.get_string('assetlaunched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
if ($isvisible) {
$startbold = '';
$endbold = '';
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
}
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
$incomplete = true;
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
$strstatus = get_string($usertrack->status,'scorm');
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$scormpixdir.'/'.$usertrack->status.'.gif" alt="'.$strstatus.'" title="'.$strstatus.'" />';
} else {
$statusicon = '<img src="'.$scormpixdir.'/assetc.gif" alt="'.get_string('assetlaunched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
}
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
$incomplete = true;
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
}
if ($usertrack->score_raw != '') {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
}
$strsuspended = get_string('suspended','scorm');
if (isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) {
$statusicon = '<img src="'.$scormpixdir.'/suspend.gif" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
}
} else {
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$scormpixdir.'/notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$incomplete = true;
} else {
$statusicon = '<img src="'.$scormpixdir.'/asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
}
}
if ($usertrack->score_raw != '') {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
}
$strsuspended = get_string('suspended','scorm');
if (isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) {
$statusicon = '<img src="'.$scormpixdir.'/suspend.gif" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
}
} else {
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$scormpixdir.'/notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$incomplete = true;
} else {
$statusicon = '<img src="'.$scormpixdir.'/asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
}
}
if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = $sco->next;
$showprev = $sco->previous;
}
if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = $sco->next;
$showprev = $sco->previous;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
}
}
}
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
}
// Modified by Pham Minh Duc
// if (scorm_isChoice($scorm->id,$sco->id) == 1) {
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
// } else {
// $result->toc .= '&nbsp;'.$startbold.format_string($sco->title).$score.$endbold."</li>\n";
// $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
// }
// End modify
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
$result->toc .= '&nbsp;'.format_string($sco->title)."</li>\n";
}
// Modified by Pham Minh Duc
// if (scorm_isChoice($scorm->id,$sco->id) == 1) {
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
// } else {
// $result->toc .= '&nbsp;'.$startbold.format_string($sco->title).$score.$endbold."</li>\n";
// $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
// }
// End modify
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
$result->toc .= '&nbsp;'.$sco->title."</li>\n";
}
} else {
$result->toc .= '&nbsp;'.$sco->title."</li>\n";
$result->toc .= '&nbsp;'.format_string($sco->title)."</li>\n";
}
if (($nextsco !== false) && ($nextid == 0) && ($findnext)) {
if (!empty($nextsco->launch)) {

View File

@ -177,6 +177,33 @@ function scorm_get_manifest($blocks,$scoes) {
}
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->masteryscore = addslashes($block['tagData']);
break;
case 'ADLCP:COMPLETIONTHRESHOLD':
$parent = array_pop($parents);
array_push($parents, $parent);
if (!isset($block['tagData'])) {
$block['tagData'] = '';
}
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->threshold = addslashes($block['tagData']);
break;
case 'ADLNAV:PRESENTATION':
$parent = array_pop($parents);
array_push($parents, $parent);
foreach ($block['children'] as $adlnav) {
if ($adlnav['name'] == 'ADLNAV:NAVIGATIONINTERFACE') {
foreach ($adlnav['children'] as $adlnavInterface) {
if ($adlnavInterface['name'] == 'ADLNAV:HIDELMSUI') {
if ($adlnavInterface['tagData'] == 'continue') {
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->next = 1;
}
if ($adlnavInterface['tagData'] == 'previous') {
$scoes->elements[$manifest][$parent->organization][$parent->identifier]->previous = 1;
}
}
}
}
}
break;
}
}
}
@ -191,9 +218,14 @@ function scorm_parse_scorm($pkgdir,$scormid) {
if (is_file($manifestfile)) {
$xmlstring = file_get_contents($manifestfile);
$xmltext = file_get_contents($manifestfile);
$pattern = '/&(?!\w{2,6};)/';
$replacement = '&amp;';
$xmltext = preg_replace($pattern, $replacement, $xmltext);
$objXML = new xml2Array();
$manifests = $objXML->parse($xmlstring);
$manifests = $objXML->parse($xmltext);
//print_r($manifests);
$scoes = new stdClass();
$scoes->version = '';
@ -205,13 +237,13 @@ function scorm_parse_scorm($pkgdir,$scormid) {
foreach ($organizations as $organization => $items) {
foreach ($items as $identifier => $item) {
// This new db mngt will support all SCORM future extensions
/*$newitem = new stdClass();
$newitem = new stdClass();
$newitem->scorm = $scormid;
$newitem->manifest = $manifest;
$newitem->organization = $organization;
$standarddatas = array('parent', 'identifier', 'launch', 'scormtype', 'title');
foreach ($standarddatas as $standarddata) {
$newitem->$standarddata = $item->$standarddata;
$newitem->$standarddata = addslashes($item->$standarddata);
}
if ($olditemid = scorm_array_search('identifier',$newitem->identifier,$olditems)) {
@ -224,18 +256,18 @@ function scorm_parse_scorm($pkgdir,$scormid) {
}
$data = new stdClass();
$data->scormid = $scormid;
$data->scoid = $id;
$optionaldatas = scorm_optionals_data();
foreach ($optionalsdatas as $optionaldata) {
if (isset($item->$optionaldata)) {
$data->name = $optionaldata;
$data->value = $item->$optionaldata;
$dataid = insert_record('scorm_scoes_data');
if ($optionaldatas = scorm_optionals_data($item,$standarddatas)) {
foreach ($optionaldatas as $optionaldata) {
if (isset($item->$optionaldata)) {
$data->name = $optionaldata;
$data->value = addslashes($item->$optionaldata);
$dataid = insert_record('scorm_scoes_data',$data);
}
}
} */
}
$item->scorm = $scormid;
/*$item->scorm = $scormid;
$item->manifest = $manifest;
$item->organization = $organization;
if ($olditemid = scorm_array_search('identifier',$item->identifier,$olditems)) {
@ -244,7 +276,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
unset($olditems[$olditemid]);
} else {
$id = insert_record('scorm_scoes',$item);
}
} */
if (($launch == 0) && ((empty($scoes->defaultorg)) || ($scoes->defaultorg == $identifier))) {
$launch = $id;
@ -266,6 +298,16 @@ function scorm_parse_scorm($pkgdir,$scormid) {
return $launch;
}
function scorm_optionals_data($item, $standarddata) {
$result = array();
foreach ($item as $element => $value) {
if (! in_array($element, $standarddata)) {
$result[] = $element;
}
}
return $result;
}
/* Usage
Grab some XML data, either from a file, URL, etc. however you want. Assume storage in $strYourXML;

View File

@ -63,7 +63,6 @@ $mod_scorm_capabilities = array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/scorm/db" VERSION="20060926" COMMENT="XMLDB file for Moodle mod/scorm"
<XMLDB PATH="mod/scorm/db" VERSION="20061121" COMMENT="XMLDB file for Moodle mod/scorm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@ -34,7 +34,7 @@
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
</INDEXES>
</TABLE>
<TABLE NAME="scorm_scoes" COMMENT="each SCO part of the SCORM module" PREVIOUS="scorm" NEXT="scorm_scoes_track">
<TABLE NAME="scorm_scoes" COMMENT="each SCO part of the SCORM module" PREVIOUS="scorm" NEXT="scorm_scoes_data">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="scorm"/>
<FIELD NAME="scorm" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="manifest"/>
@ -42,24 +42,30 @@
<FIELD NAME="organization" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="manifest" NEXT="parent"/>
<FIELD NAME="parent" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="organization" NEXT="identifier"/>
<FIELD NAME="identifier" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="parent" NEXT="launch"/>
<FIELD NAME="launch" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="identifier" NEXT="parameters"/>
<FIELD NAME="parameters" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="launch" NEXT="scormtype"/>
<FIELD NAME="scormtype" TYPE="char" LENGTH="5" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="parameters" NEXT="title"/>
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="scormtype" NEXT="prerequisites"/>
<FIELD NAME="prerequisites" TYPE="char" LENGTH="200" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="maxtimeallowed"/>
<FIELD NAME="maxtimeallowed" TYPE="char" LENGTH="19" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="prerequisites" NEXT="timelimitaction"/>
<FIELD NAME="timelimitaction" TYPE="char" LENGTH="19" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="maxtimeallowed" NEXT="datafromlms"/>
<FIELD NAME="datafromlms" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="timelimitaction" NEXT="masteryscore"/>
<FIELD NAME="masteryscore" TYPE="char" LENGTH="200" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="datafromlms" NEXT="next"/>
<FIELD NAME="next" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="masteryscore" NEXT="previous"/>
<FIELD NAME="previous" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="next"/>
<FIELD NAME="launch" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="identifier" NEXT="scormtype"/>
<FIELD NAME="scormtype" TYPE="char" LENGTH="5" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="launch" NEXT="title"/>
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="scormtype"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for scorm_scoes" NEXT="scorm"/>
<KEY NAME="scorm" TYPE="foreign" FIELDS="scorm" REFTABLE="scorm" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
</TABLE>
<TABLE NAME="scorm_scoes_track" COMMENT="to track SCOes" PREVIOUS="scorm_scoes">
<TABLE NAME="scorm_scoes_data" COMMENT="Contains variable data get from packages" PREVIOUS="scorm_scoes" NEXT="scorm_scoes_track">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="scoid"/>
<FIELD NAME="scoid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="scoid" NEXT="value"/>
<FIELD NAME="value" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for scorm_scoes_data"/>
</KEYS>
<INDEXES>
<INDEX NAME="dev_scorscoedata_sco_ix" UNIQUE="false" FIELDS="scoid"/>
</INDEXES>
</TABLE>
<TABLE NAME="scorm_scoes_track" COMMENT="to track SCOes" PREVIOUS="scorm_scoes_data">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="scormid"/>

View File

@ -6,6 +6,7 @@ CREATE TABLE prefix_scorm (
id int(10) unsigned NOT NULL auto_increment,
course int(10) unsigned NOT NULL default '0',
name varchar(255) NOT NULL default '',
summary text NOT NULL default '',
reference varchar(255) NOT NULL default '',
version varchar(9) NOT NULL default '',
maxgrade float(3) NOT NULL default '0',
@ -13,8 +14,9 @@ CREATE TABLE prefix_scorm (
maxattempt int(10) NOT NULL default '1',
launch int(10) unsigned NOT NULL default '0',
skipview tinyint(1) unsigned NOT NULL default '1',
summary text NOT NULL default '',
hidebrowse tinyint(1) NOT NULL default '0',
hideexit tinyint(1) NOT NULL default '0',
hideabandon tinyint(1) NOT NULL default '0',
hidetoc tinyint(1) NOT NULL default '0',
hidenav tinyint(1) NOT NULL default '0',
auto tinyint(1) unsigned NOT NULL default '0',
@ -24,7 +26,6 @@ CREATE TABLE prefix_scorm (
height int(10) unsigned NOT NULL default '600',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY course (course)
) TYPE=MyISAM;
@ -35,22 +36,31 @@ CREATE TABLE prefix_scorm_scoes (
organization varchar(255) NOT NULL default '',
parent varchar(255) NOT NULL default '',
identifier varchar(255) NOT NULL default '',
launch varchar(255) NOT NULL default '',
parameters varchar(255) NOT NULL default '',
/* launch varchar(255) NOT NULL default '', */
launch int(10) NOT NULL default '0',
scormtype varchar(5) NOT NULL default '',
title varchar(255) NOT NULL default '',
/* parameters varchar(255) NOT NULL default '',
prerequisites varchar(200) NOT NULL default '',
maxtimeallowed varchar(19) NOT NULL default '',
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',
previous tinyint(1) unsigned NOT NULL default '0', */
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY scorm (scorm)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_scoes_data (
id int(10) unsigned NOT NULL auto_increment,
scoid int(10) unsigned NOT NULL default '0',
name varchar(255) NOT NULL default '',
value text NOT NULL default '',
PRIMARY KEY (id),
KEY scoid (scoid)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_scoes_track (
id int(10) unsigned NOT NULL auto_increment,
userid int(10) unsigned NOT NULL default '0',
@ -60,7 +70,7 @@ CREATE TABLE prefix_scorm_scoes_track (
element varchar(255) NOT NULL default '',
value longtext NOT NULL default '',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
PRIMARY KEY (id),
KEY userid (userid),
KEY scormid (scormid),
KEY scoid (scoid),
@ -68,6 +78,106 @@ CREATE TABLE prefix_scorm_scoes_track (
UNIQUE track (userid, scormid, scoid, attempt, element)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_sequencing_ruleconditions (
id int(10) unsigned NOT NULL auto_increment,
scormid int(10) unsigned NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
conditioncombination varchar(3) NOT NULL default 'all',
ruletype tinyint(2) unsigned NOT NULL default '0',
action varchar(25) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE (scormid, scoid,id),
KEY scormid (scormid),
KEY scoid (scoid)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_sequencing_rulecondition (
id int(10) unsigned NOT NULL auto_increment,
scormid int(10) unsigned NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
ruleconditionsid int(10) unsigned NOT NULL default '0',
refrencedobjective varchar(255) NOT NULL default '',
measurethreshold float(11,4) NOT NULL default '0.0000',
operator varchar(5) NOT NULL default 'noOp',
condition varchar(30) NOT NULL default 'always',
PRIMARY KEY (id),
UNIQUE (scormid, scoid,id,ruleconditionsid),
KEY ruleconditionsid (ruleconditionsid),
KEY scormid (scormid),
KEY scoid (scoid)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_sequencing_rolluprules (
id int(10) unsigned NOT NULL auto_increment,
scormid int(10) unsigned NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
rollupobjectivesatisfied TINYINT(1) unsigned NOT NULL default '1',
rollupprogresscompletion TINYINT(1) unsigned NOT NULL default '1',
objectivemeasureweight float(11,4) NOT NULL default '1.0000',
PRIMARY KEY (id),
KEY scormid (scormid),
KEY scoid (scoid)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_sequencing_rolluprule (
id int(10) unsigned NOT NULL auto_increment,
scormid int(10) unsigned NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
rolluprulesid int(10) unsigned NOT NULL default '0',
childactivityset varchar(15) NOT NULL default '',
minimumcount int(10) unsigned NOT NULL default '0',
minimumpercent float(11,4) unsigned NOT NULL default '0.0000',
conditioncombination varchar(3) NOT NULL default 'all',
action varchar(15) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE (scormid, scoid, rolluprulesid, id),
KEY scormid (scormid),
KEY scoid (scoid)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_sequencing_rolluprulecondition (
id int(10) unsigned NOT NULL auto_increment,
scormid int(10) unsigned NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
rollupruleid int(10) unsigned NOT NULL default '0',
operator varchar(5) NOT NULL default 'noOp',
condition varchar(25) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE (scormid, scoid, rollupruleid, id),
KEY scormid (scormid),
KEY scoid (scoid)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_sequencing_objectives (
id int(10) unsigned NOT NULL auto_increment,
scormid int(10) unsigned NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
primary tinyint(1) NOT NULL default '0',
objectiveid int(10) unsigned NOT NULL default '0',
satisfiedbymeasure tinyint(1) NOT NULL default '1',
minnormalizedmeasure float(11,4) unsigned NOT NULL default '1.0',
PRIMARY KEY (id),
UNIQUE (scormid, scoid, id),
KEY scormid (scormid),
KEY scoid (scoid)
) TYPE=MyISAM;
CREATE TABLE prefix_scorm_sequencing_objective (
id int(10) unsigned NOT NULL auto_increment,
scormid int(10) unsigned NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
objectiveid int(10) unsigned NOT NULL default '0',
targetobjectiveid int(10) unsigned NOT NULL default '0',
readsatisfiedstatus tinyint(1) NOT NULL default '1',
readnormalizedmeasure tinyint(1) NOT NULL default '1',
writesatisfiedstatus tinyint(1) NOT NULL default '0',
writenormalizedmeasure tinyint(1) NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE (scormid, scoid, id, objectiveid),
KEY scormid (scormid),
KEY scoid (scoid)
) TYPE=MyISAM;
#
# Dumping data for table log_display
#

View File

@ -23,14 +23,61 @@ function xmldb_scorm_upgrade($oldversion=0) {
$result = true;
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
if ($result && $oldversion < 2006103100) {
/// Create the new sco optionals data table
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of "/lib/ddllib.php" function calls
/// }
/// Define table scorm_scoes_data to be created
$table = new XMLDBTable('scorm_scoes_data');
/// Adding fields to table scorm_scoes_data
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table scorm_scoes_data
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table scorm_scoes_data
$table->addIndexInfo('scoid', XMLDB_INDEX_NOTUNIQUE, array('scoid'));
/// Launch create table for scorm_scoes_data
$result = $result && create_table($table);
/// The old fields used in scorm_scoes
$fields = array('parameters' => '',
'prerequisites' => '',
'maxtimeallowed' => '',
'timelimitaction' => '',
'datafromlms' => '',
'masteryscore' => '',
'next' => '0',
'previous' => '0');
/// Retrieve old datas
if ($olddatas = get_records('scorm_scoes')) {
foreach ($olddatas as $olddata) {
$newdata = new stdClass();
$newdata->scoid = $olddata->id;
foreach ($fields as $field => $value) {
if ($olddata->$field != $value) {
$newdata->name = addslashes($field);
$newdata->value = addslashes($olddata->$field);
$id = insert_record('scorm_scoes_data', $newdata);
$result = $result && ($id != 0);
}
}
}
}
/// Remove no more used fields
$table = new XMLDBTable('scorm_scoes');
foreach ($fields as $field => $value) {
$field = new XMLDBField($field);
$result = $result && drop_field($table, $field);
}
}
return $result;
}

View File

@ -23,6 +23,10 @@ function scorm_add_instance($scorm) {
//sanitize submitted values a bit
$scorm->width = clean_param($scorm->width, PARAM_INT);
$scorm->height = clean_param($scorm->height, PARAM_INT);
if (!isset($scorm->whatgrade)) {
$scorm->whatgrade = 0;
}
$scorm->grademethod = ($scorm->whatgrade * 10) + $scorm->grademethod;
$id = insert_record('scorm', $scorm);
@ -64,6 +68,9 @@ function scorm_update_instance($scorm) {
$scorm->width = str_replace('%','',$scorm->width);
$scorm->height = str_replace('%','',$scorm->height);
if (!isset($scorm->whatgrade)) {
$scorm->whatgrade = 0;
}
$scorm->grademethod = ($scorm->whatgrade * 10) + $scorm->grademethod;
// Check if scorm manifest needs to be reparsed
@ -124,7 +131,14 @@ function scorm_delete_instance($id) {
if (! delete_records('scorm_scoes_track', 'scormid', $scorm->id)) {
$result = false;
}
if (! delete_records('scorm_scoes', 'scorm', $scorm->id)) {
if ($scoes = get_records('scorm_scoes','scorm',$scorm->id)) {
foreach ($scoes as $sco) {
if (! delete_records('scorm_scoes_data', 'scoid', $sco->id)) {
$result = false;
}
}
delete_records('scorm_scoes', 'scorm', $scorm->id);
} else {
$result = false;
}
if (! delete_records('scorm', 'id', $scorm->id)) {

View File

@ -1,5 +1,5 @@
<?php
require_once("../../config.php");
require_once('../../config.php');
require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
@ -8,23 +8,23 @@
if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
error("Course Module ID was incorrect");
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 (!empty($a)) {
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');
}
} else {
error('A required parameter is missing');
@ -35,10 +35,10 @@
//
// Direct SCO request
//
if ($sco = get_record("scorm_scoes","id",$scoid)) {
if ($sco = scorm_get_sco($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")) {
if ($scoes = get_records_select('scorm_scoes','scorm='.$scorm->id." AND launch<>'' AND id>".$sco->id,'id ASC')) {
$sco = current($scoes);
}
}
@ -48,7 +48,7 @@
// 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");
$scoes = get_records_select('scorm_scoes','scorm='.$scorm->id." AND launch<>''",'id ASC');
$sco = current($scoes);
}
@ -64,24 +64,28 @@
//
$connector = '';
$version = substr($scorm->version,0,4);
if (!empty($sco->parameters) || ($version == 'AICC')) {
if ((isset($sco->parameters) && (!empty($sco->parameters))) || ($version == 'AICC')) {
if (stripos($sco->launch,'?') !== false) {
$connector = '&';
} else {
$connector = '?';
}
if (!empty($sco->parameters) && ($sco->parameters[0] == '?')) {
if ((isset($sco->parameters) && (!empty($sco->parameters))) && ($sco->parameters[0] == '?')) {
$sco->parameters = substr($sco->parameters,1);
}
}
if ($version == 'AICC') {
if (!empty($sco->parameters)) {
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$sco->parameters = '&'. $sco->parameters;
}
$launcher = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters;
} else {
$launcher = $sco->launch.$connector.$sco->parameters;
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$launcher = $sco->launch.$connector.$sco->parameters;
} else {
$launcher = $sco->launch;
}
}
if (scorm_external_link($sco->launch)) {

View File

@ -1,6 +1,9 @@
<?php // $Id$
/// Constants and settings for module scorm
define('SCO_ALL', 0);
define('SCO_DATA', 1);
define('SCO_ONLY', 2);
define('GRADESCOES', '0');
define('GRADEHIGHEST', '1');
@ -218,6 +221,26 @@ function scorm_validate($packagedir) {
return $validation;
}
/**
* Returns an object containing all datas relative to the given sco ID
*
* @param integer $id The sco ID
* @return mixed (false if sco id does not exists)
*/
function scorm_get_sco($id,$what=SCO_ALL) {
if ($sco = get_record('scorm_scoes','id',$id)) {
$sco = ($what == SCO_DATA) ? new stdClass() : $sco;
if (($what != SCO_ONLY) && ($scodatas = get_records('scorm_scoes_data','scoid',$id))) {
foreach ($scodatas as $scodata) {
$sco->{$scodata->name} = $scodata->value;
}
}
return $sco;
} else {
return false;
}
}
function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value) {
$id = null;
if ($track = get_record_select('scorm_scoes_track',"userid='$userid' AND scormid='$scormid' AND scoid='$scoid' AND attempt='$attempt' AND element='$element'")) {
@ -519,11 +542,11 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
}
}
$orgidentifier = '';
if ($org = get_record('scorm_scoes','id',$organization)) {
if (($org->organization == '') && ($org->launch == '')) {
$orgidentifier = $org->identifier;
if ($sco = scorm_get_sco($organization, SCO_ONLY)) {
if (($sco->organization == '') && ($sco->launch == '')) {
$orgidentifier = $sco->identifier;
} else {
$orgidentifier = $org->organization;
$orgidentifier = $sco->organization;
}
}
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe

View File

@ -131,13 +131,13 @@
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstr.$modestr.$attemptstr ?>"></script>
<?php
}
if (($sco->previd != 0) && ($sco->previous == 0)) {
if (($sco->previd != 0) && ((!isset($sco->previous)) || ($sco->previous == 0))) {
$scostr = '&scoid='.$sco->previd;
echo ' <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
} else {
echo ' <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";
}
if (($sco->nextid != 0) && ($sco->next == 0)) {
if (($sco->nextid != 0) && ((!isset($sco->next)) || ($sco->next == 0))) {
$scostr = '&scoid='.$sco->nextid;
echo ' <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
} else {
@ -170,11 +170,11 @@
(
(
($sco->previd != 0) && // This is not the first learning object of the package
($sco->previous == 0) // Moodle must manage the previous link
((!isset($sco->previous)) || ($sco->previous == 0)) // Moodle must manage the previous link
) ||
(
($sco->nextid != 0) && // This is not the last learning object of the package
($sco->next == 0) // Moodle must manage the next link
((!isset($sco->next)) || ($sco->next == 0)) // Moodle must manage the next link
)
)
) || ($scorm->hidetoc == 2) // Teacher want to display toc in a small dropdown menu
@ -189,7 +189,7 @@
<div id="scormnav" class="right">
<?php
$orgstr = '&amp;currentorg='.$currentorg;
if (($scorm->hidenav == 0) && ($sco->previd != 0) && ($sco->previous == 0)) {
if (($scorm->hidenav == 0) && ($sco->previd != 0) && ((!isset($sco->previous)) || ($sco->previous == 0))) {
/// Print the prev LO link
$scostr = '&amp;scoid='.$sco->previd;
$url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
@ -198,7 +198,7 @@
if ($scorm->hidetoc == 2) {
echo $result->tocmenu;
}
if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ($sco->next == 0)) {
if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ((!isset($sco->next)) || ($sco->next == 0))) {
/// Print the next LO link
$scostr = '&amp;scoid='.$sco->nextid;
$url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;

View File

@ -13,30 +13,30 @@
if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
error("Course Module ID was incorrect");
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 (!empty($b)) {
if (! $sco = get_record("scorm_scoes", "id", $b)) {
error("Scorm activity is incorrect");
if (! $sco = get_record('scorm_scoes', 'id', $b)) {
error('Scorm activity is incorrect');
}
$a = $sco->scorm;
}
if (!empty($a)) {
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');
}
}
}
@ -44,10 +44,10 @@
require_login($course->id, false, $cm);
if (!has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE,$cm->id))) {
error("You are not allowed to use this script");
error('You are not allowed to use this script');
}
add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id");
add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id);
if (!empty($user)) {
$userdata = scorm_get_user_data($user);
@ -63,23 +63,23 @@
$navigation = '';
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm");
$strattempt = get_string("attempt", "scorm");
$strscorms = get_string('modulenameplural', 'scorm');
$strscorm = get_string('modulename', 'scorm');
$strreport = get_string('report', 'scorm');
$strattempt = get_string('attempt', 'scorm');
$strname = get_string('name');
if (empty($b)) {
if (empty($a)) {
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);
'', '', true);
} 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> -> $strattempt $attempt - ".fullname($userdata),
"", "", true);
'', '', true);
}
} else {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
@ -87,7 +87,7 @@
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
-> <a href=\"report.php?id=$cm->id\">$strreport</a>
-> <a href=\"report.php?a=$a&user=$user&attempt=$attempt\">$strattempt $attempt - ".fullname($userdata)."</a> -> $sco->title",
"", "", true);
'', '', true);
}
print_heading(format_string($scorm->name));
}
@ -97,7 +97,7 @@
if (empty($b)) {
if (empty($a)) {
// No options, show the global scorm report
if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {
if ($scousers=get_records_select('scorm_scoes_track', "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {
$table = new stdClass();
$table->head = array('&nbsp;', get_string('name'));
$table->align = array('center', 'left');
@ -135,7 +135,7 @@
fullname($userdata).'</a>';
$row[] = '<a href="report.php?a='.$scorm->id.'&user='.$scouser->userid.'&attempt='.$a.'">'.$a.'</a>';
$select = 'scormid = '.$scorm->id.' and userid = '.$scouser->userid.' and attempt = '.$a;
$timetracks = get_record_select("scorm_scoes_track", $select,'min(timemodified) as started, max(timemodified) as last');
$timetracks = get_record_select('scorm_scoes_track', $select,'min(timemodified) as started, max(timemodified) as last');
$row[] = userdate($timetracks->started, get_string('strftimedaydatetime'));
$row[] = userdate($timetracks->last, get_string('strftimedaydatetime'));
@ -148,7 +148,7 @@
} else {
if (!empty($user)) {
// User SCORM report
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 (!empty($userdata)) {
print_simple_box_start('center');
echo '<div align="center">'."\n";
@ -258,6 +258,7 @@
'status' => 'cmi.core.lesson_status',
'time' => 'cmi.core.total_time');
}
$printedelements = array();
foreach ($elements as $key => $element) {
if (isset($trackdata->$element)) {
$existelements = true;

View File

@ -174,19 +174,12 @@
$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->title = backup_todb($sub_info['#']['TITLE']['0']['#']);
if ($restore->backup_version < 2005031300) {
$sco->scormtype = backup_todb($sub_info['#']['TYPE']['0']['#']);
} else {
$sco->scormtype = backup_todb($sub_info['#']['SCORMTYPE']['0']['#']);
}
$sco->title = backup_todb($sub_info['#']['TITLE']['0']['#']);
$sco->prerequisites = backup_todb($sub_info['#']['PREREQUISITES']['0']['#']);
$sco->maxtimeallowed = backup_todb($sub_info['#']['MAXTIMEALLOWED']['0']['#']);
$sco->timelimitaction = backup_todb($sub_info['#']['TIMELIMITACTION']['0']['#']);
$sco->datafromlms = backup_todb($sub_info['#']['DATAFROMLMS']['0']['#']);
$sco->masteryscore = 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);
@ -214,6 +207,15 @@
return $status;
}
$sco->prerequisites = backup_todb($sub_info['#']['PREREQUISITES']['0']['#']);
$sco->maxtimeallowed = backup_todb($sub_info['#']['MAXTIMEALLOWED']['0']['#']);
$sco->timelimitaction = backup_todb($sub_info['#']['TIMELIMITACTION']['0']['#']);
$sco->datafromlms = backup_todb($sub_info['#']['DATAFROMLMS']['0']['#']);
$sco->masteryscore = backup_todb($sub_info['#']['MASTERYSCORE']['0']['#']);
$sco->next = backup_todb($sub_info['#']['NEXT']['0']['#']);
$sco->previous = backup_todb($sub_info['#']['PREVIOUS']['0']['#']);
//This function restores the scorm_scoes_track
function scorm_scoes_tracks_restore_mods($scorm_id,$info,$restore) {

View File

@ -10,7 +10,7 @@
// catch up now, so until 27th October please only increment in very tiny steps
// in HEAD, until we get past that date..
$module->version = 2006102702; // The (date) version of this module
$module->version = 2006112100; // The (date) version of this module
$module->requires = 2006080900; // The version of Moodle that is required
$module->cron = 0; // How often should cron check this module (seconds)?