mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Added auxiliar functions for sequencinglib.php
This commit is contained in:
parent
b07b4bd246
commit
60a3aaf932
1 changed files with 41 additions and 2 deletions
|
@ -638,13 +638,38 @@ function scorm_get_parent($sco) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function scorm_get_children($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 $children;
|
||||||
}
|
}
|
||||||
return null;
|
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)) {
|
if ($siblings = get_records('scorm_scoes','scorm',$sco->scorm,'parent',$sco->parent)) {
|
||||||
unset($siblings[$sco->id]);
|
unset($siblings[$sco->id]);
|
||||||
if (!empty($siblings)) {
|
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) {
|
function scorm_find_common_ancestor($ancestors, $sco) {
|
||||||
$pos = scorm_array_search('identifier',$sco->parent,$ancestors);
|
$pos = scorm_array_search('identifier',$sco->parent,$ancestors);
|
||||||
if ($sco->parent != '/') {
|
if ($sco->parent != '/') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue