Exemplo n.º 1
0
function scorm_find_common_ancestor($ancestors, $sco)
{
    $pos = scorm_array_search('identifier', $sco->parent, $ancestors);
    if ($sco->parent != '/') {
        if ($pos === false) {
            return scorm_find_common_ancestor($ancestors, scorm_get_parent($sco));
        }
    }
    return $pos;
}
Exemplo n.º 2
0
function scorm_seq_choice_activity_traversal($activity, $userid, $seq, $direction)
{
    if ($direction == 'forward') {
        $act = scorm_seq_rules_check($activity, 'stopforwardtraversal');
        if ($act != null) {
            $seq->reachable = false;
            $seq->exception = 'SB.2.4-1';
            return $seq;
        }
        $seq->reachable = false;
        return $seq;
    }
    if ($direction == 'backward') {
        $parentsco = scorm_get_parent($activity);
        if ($parentsco != null) {
            if (isset($parentsco->forwardonly) && $parentsco->forwardonly == true) {
                $seq->reachable = false;
                $seq->exception = 'SB.2.4-2';
                return $seq;
            } else {
                $seq->reachable = false;
                $seq->exception = 'SB.2.4-3';
                return $seq;
            }
        }
    }
    $seq->reachable = true;
    return $seq;
}
Exemplo n.º 3
0
function scorm_seq_flow_activity_traversal($activity, $userid, $direction, $childrenflag, $prevdirection, $seq, $userid)
{
    $parent = scorm_get_parent($activity);
    if (!isset($parent->flow) || $parent->flow == false) {
        $seq->deliverable = false;
        $seq->exception = 'SB.2.2-1';
        $seq->nextactivity = $activity;
        return $seq;
    }
    $rulecheck = scorm_seq_rules_check($activity, 'skip');
    if ($rulecheck != null) {
        $skip = scorm_evaluate_condition($rulecheck, $activity, $userid);
        if ($skip) {
            $seq = scorm_seq_flow_tree_traversal($activity, $direction, false, $prevdirection, $seq, $userid, $skip);
            $seq = scorm_seq_flow_activity_traversal($seq->nextactivity, $userid, $direction, $childrenflag, $prevdirection, $seq, $userid);
        } else {
            if (!empty($seq->identifiedactivity)) {
                $seq->nextactivity = $activity;
            }
        }
        return $seq;
    }
    $ch = scorm_check_activity($activity, $userid);
    if ($ch) {
        $seq->deliverable = false;
        $seq->exception = 'SB.2.2-2';
        $seq->nextactivity = $activity;
        return $seq;
    }
    if (!scorm_is_leaf($activity)) {
        $seq = scorm_seq_flow_tree_traversal($activity, $direction, true, null, $seq, $userid);
        if ($seq->identifiedactivity == null) {
            $seq->deliverable = false;
            $seq->nextactivity = $activity;
            return $seq;
        } else {
            if ($direction == 'backward' && $seq->traversaldir == 'forward') {
                $seq = scorm_seq_flow_activity_traversal($seq->identifiedactivity, $userid, 'forward', $childrenflag, 'backward', $seq, $userid);
            } else {
                $seq = scorm_seq_flow_activity_traversal($seq->identifiedactivity, $userid, $direction, $childrenflag, null, $seq, $userid);
            }
            return $seq;
        }
    }
    $seq->deliverable = true;
    $seq->nextactivity = $activity;
    $seq->exception = null;
    return $seq;
}
Exemplo n.º 4
0
function scorm_seq_temination($seq, $userid)
{
    if (empty($seq->currentactivity)) {
        $seq->termination = false;
        $seq->exception = 'TB.2.3-1';
        return $seq;
    }
    $sco = $seq->currentactivity;
    if (($seq->termination == 'exit' || $seq->termination == 'abandon') && !$seq->active) {
        $seq->termination = false;
        $seq->exception = 'TB.2.3-2';
        return $seq;
    }
    switch ($seq->termination) {
        case 'exit':
            scorm_seq_end_attempt($sco, $userid);
            $seq = scorm_seq_exit_action_rules($seq, $userid);
            do {
                $exit = true;
                $seq = scorm_seq_post_cond_rules($seq, $userid);
                if ($seq->termination == 'exitparent') {
                    if ($sco->parent != '/') {
                        $sco = scorm_get_parent($sco);
                        $seq->currentactivity = $sco;
                        $seq->active = scorm_seq_is('active', $sco->id, $userid);
                        scorm_seq_end_attempt($sco, $userid);
                        $exit = false;
                    } else {
                        $seq->termination = false;
                        $seq->exception = 'TB.2.3-4';
                        return $seq;
                    }
                }
            } while ($exit == false && $seq->termination == 'exit');
            if ($seq->termination == 'exit') {
                $seq->termination = true;
                return $seq;
            }
        case 'exitall':
            if ($seq->active) {
                scorm_seq_end_attempt($sco, $userid);
            }
            /// Terminate Descendent Attempts Process
            if ($ancestors = scorm_get_ancestors($sco)) {
                foreach ($ancestors as $ancestor) {
                    scorm_seq_end_attempt($ancestor, $userid);
                    $seq->currentactivity = $ancestor;
                }
            }
            $seq->active = scorm_seq_is('active', $seq->currentactivity->id, $userid);
            $seq->termination = true;
            break;
        case 'suspendall':
            if ($seq->active || $seq->suspended) {
                scorm_seq_set('suspended', $sco->id, $userid);
            } else {
                if ($sco->parent != '/') {
                    $parentsco = scorm_get_parent($sco);
                    scorm_seq_set('suspended', $parentsco->id, $userid);
                } else {
                    $seq->termination = false;
                    $seq->exception = 'TB.2.3-3';
                    // return $seq;
                }
            }
            if ($ancestors = scorm_get_ancestors($sco)) {
                foreach ($ancestors as $ancestor) {
                    scorm_seq_set('active', $ancestor->id, $userid, 0, false);
                    scorm_seq_set('suspended', $ancestor->id, $userid);
                    $seq->currentactivity = $ancestor;
                }
                $seq->termination = true;
                $seq->sequencing = 'exit';
            } else {
                $seq->termination = false;
                $seq->exception = 'TB.2.3-5';
            }
            break;
        case 'abandon':
            scorm_seq_set('active', $sco->id, $userid, 0, false);
            $seq->active = null;
            $seq->termination = true;
            break;
        case 'abandonall':
            if ($ancestors = scorm_get_ancestors($sco)) {
                foreach ($ancestors as $ancestor) {
                    scorm_seq_set('active', $ancestor->id, $userid, 0, false);
                    $seq->currentactivity = $ancestor;
                }
                $seq->termination = true;
                $seq->sequencing = 'exit';
            } else {
                $seq->termination = false;
                $seq->exception = 'TB.2.3-6';
            }
            break;
        default:
            $seq->termination = false;
            $seq->exception = 'TB.2.3-7';
            break;
    }
    return $seq;
}