Added auxiliar functions for sequencinglib.php

This commit is contained in:
csantossaenz 2007-05-03 12:52:11 +00:00
parent b07b4bd246
commit 60a3aaf932

View File

@ -638,13 +638,38 @@ function scorm_get_parent($sco) {
}
function scorm_get_children($sco) {
if ($parent = get_records('scorm_scoes','scorm',$sco->scorm,'parent',$sco->identifier)) {
if ($children = get_records('scorm_scoes','scorm',$sco->scorm,'parent',$sco->identifier)) {//originally this said parent instead of childrean
return $children;
}
return null;
}
function scorm_get_sibling($sco) {
function scorm_get_available_children($sco){
$res = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'element','availablechildren');
if(!$res || $res == null){
return false;
}
else{
return unserialize($res->value);
}
}
function scorm_get_available_descendent($descend = array(),$sco){
if($sco == null){
return $descend;
}
else{
$avchildren = scorm_get_available_children($sco);
foreach($avchildren as $avchild){
array_push($descend,$avchild);
}
foreach($avchildren as $avchild){
scorm_get_available_descendent($descend,$avchild);
}
}
}
function scorm_get_siblings($sco) {
if ($siblings = get_records('scorm_scoes','scorm',$sco->scorm,'parent',$sco->parent)) {
unset($siblings[$sco->id]);
if (!empty($siblings)) {
@ -662,6 +687,20 @@ function scorm_get_ancestors($sco) {
}
}
function scorm_get_preorder($preorder=array(),$sco) {
if ($sco != null) {
array_push($preorder,$sco);
$children = scorm_get_children($sco);
foreach ($children as $child){
scorm_get_preorder($sco);
}
} else {
return $preorder;
}
}
function scorm_find_common_ancestor($ancestors, $sco) {
$pos = scorm_array_search('identifier',$sco->parent,$ancestors);
if ($sco->parent != '/') {