added a comment - - edited
Good news,
I solve a part of this bug, ordering the structure list. To do that i use two functions added in mod/scorm/datamodels/scormlib.php called in the function scorm_get_toc in the mod/scorm/datamodels/scormlib_12.php. This hack solve the bug for scorm 1.2 package only :
mod/scorm/datamodels/scormlib_12.php :
line1:
++ require_once('scormlib.php');
== function scorm_eval_prerequisites($prerequisites,$usertracks) {
in function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false) near the line 215:
++ $ordered_table = list_item_manifest($scorm);
++ if(count($ordered_table)!=0)$scoes = reorder_scoes($scoes,$ordered_table);
== foreach ($scoes as $sco) {
== $isvisible = false;
== if ($optionaldatas = scorm_get_sco($sco->id, SCO_DATA)) {
mod/scorm/datamodels/scormlib.php :
//insert these 2 functions at the end of the file
function list_item_manifest($scorm){
global $CFG;
$orderedItems = array();
$manifestfile = $CFG->dataroot.'\\'.$scorm->course.'\\moddata\\scorm
'.$scorm->id.'/imsmanifest.xml';
$manifestfile = str_ireplace('
','/',$manifestfile);
if (is_file($manifestfile)) {
$xmltext = file_get_contents($manifestfile);
$pattern = '/&(?!\w{2,6}
/';
$replacement = '&';
$xmltext = preg_replace($pattern, $replacement, $xmltext);
$objXML = new xml2Array();
$manifests = $objXML->parse($xmltext);
$scoes = new stdClass();
$scoes->version = '';
$scoes = scorm_get_manifest($manifests,$scoes);
foreach ($scoes->elements as $manifest => $organizations) {
foreach ($organizations as $organization => $items) {
foreach ($items as $identifier => $item) {
$newitem = new stdClass();
$newitem->manifest = $manifest;
$newitem->organization = $organization;
$standarddatas = array('parent', 'identifier', 'launch', 'scormtype', 'title');
foreach ($standarddatas as $standarddata) {
$newitem->$standarddata = addslashes($item->$standarddata);
}
array_push($orderedItems, $newitem->identifier);
}
}
}
}
return $orderedItems;
}
function reorder_scoes($scoes, $orderedItems){
$i=0;
$scoes_res=array();
while($i<count($orderedItems)){
foreach($scoes as $sco){
if($sco->identifier == $orderedItems[$i]){
$scoes_res[]=$sco;
}
}
$i++;
}
return $scoes_res;
}
This hack doesn't solve all problems due to the bug, for example in the report page, the order is not respected....
I'm working on this point.
Cordially
Antoine
I tracked down the origin of the bug. Indeed, during the update of Scorm, the new scos see each other attributed one ID in the data base following ID of the last one Sco composing the ancient package. "Structure List" being built according to ID of scoes in the data base thus adds irreparably the scoes new at the end of the arborescence.
Ideally, the arborescence should be built according to the imsmanifest.xml file of scorm or during an update package, ID should be updated to respect the order of items such as defined in the imsmanifest what involves an update of ID in at least three tables (mdl_scorm_scoes, mdl_scorm_scoes_data and mdl_scorm_scoes_track).
I'm looking for code modification to assure this functionality. Any suggestion / help will be welcome
Cordially yours.