]> git.mjollnir.org Git - moodle.git/commitdiff
Added auxiliar functions for sequencinglib.php
authorcsantossaenz <csantossaenz>
Thu, 3 May 2007 12:52:11 +0000 (12:52 +0000)
committercsantossaenz <csantossaenz>
Thu, 3 May 2007 12:52:11 +0000 (12:52 +0000)
mod/scorm/datamodels/scormlib.php

index 13adc61242e020a861e8e8d4b4368b9e0dafdac7..417f45d1483560c26b0ea0bd397bd373e0574274 100644 (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 != '/') {