Skip to content
Browse files

Added auxiliar functions for sequencinglib.php

  • Loading branch information...
1 parent b07b4bd commit 60a3aaf932a9ce1e1763e542c977b9005b5a4b59 csantossaenz committed May 3, 2007
Showing with 41 additions and 2 deletions.
  1. +41 −2 mod/scorm/datamodels/scormlib.php
View
43 mod/scorm/datamodels/scormlib.php
@@ -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 != '/') {

0 comments on commit 60a3aaf

Please sign in to comment.
Something went wrong with that request. Please try again.