Skip to content

Commit

Permalink
Added a function to control the rollup process and changed some store…
Browse files Browse the repository at this point in the history
…d data
  • Loading branch information
csantossaenz committed May 7, 2007
1 parent 5c6f918 commit 1536b92
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions mod/scorm/datamodels/sequencinglib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function scorm_seq_navigation ($scoid,$userid,$request,$attempt=0) {
$seq->exception = null; $seq->exception = null;
$seq->reachable = true; $seq->reachable = true;
$seq->prevact = true; $seq->prevact = true;
$seq->constrainedchoice = true;


switch ($request) { switch ($request) {
case 'start_': case 'start_':
Expand Down Expand Up @@ -81,15 +80,15 @@ function scorm_seq_navigation ($scoid,$userid,$request,$attempt=0) {
if ($sco->parent != '/') { if ($sco->parent != '/') {
if ($parentsco = scorm_get_parent($sco)) { if ($parentsco = scorm_get_parent($sco)) {


if (!isset($parentsco->flow) || ($parentsco->flow == true)) {//I think it's parentsco if (isset($parentsco->flow) && ($parentsco->flow == true)) {//I think it's parentsco
// Current activity is active ! // Current activity is active !
if (scorm_seq_is('active',$sco->id,$userid)) { if (scorm_seq_is('active',$sco->id,$userid)) {
if ($request == 'continue_') { if ($request == 'continue_') {
$seq->navigation = true; $seq->navigation = true;
$seq->termination = 'exit'; $seq->termination = 'exit';
$seq->sequencing = 'continue'; $seq->sequencing = 'continue';
} else { } else {
if (isset($parentsco->forwardonly) && ($parentsco->forwardonly == false)) { if (!isset($parentsco->forwardonly) || ($parentsco->forwardonly == false)) {
$seq->navigation = true; $seq->navigation = true;
$seq->termination = 'exit'; $seq->termination = 'exit';
$seq->sequencing = 'previous'; $seq->sequencing = 'previous';
Expand Down Expand Up @@ -538,7 +537,7 @@ function scorm_seq_measure_rollup($sco,$userid){
if($countedmeasures>0){ if($countedmeasures>0){
scorm_seq_set('objectivemeasurestatus',$sco->id,$userid); scorm_seq_set('objectivemeasurestatus',$sco->id,$userid);
$val=$totalmeasure/$countedmeasure; $val=$totalmeasure/$countedmeasure;
scorm_seq_set('normalizedmeasure',$sco->id,$userid,$val); scorm_seq_set('objectivenormalizedmeasure',$sco->id,$userid,$val);


} }
else{ else{
Expand All @@ -551,6 +550,35 @@ function scorm_seq_measure_rollup($sco,$userid){


} }


function scorm_seq_objective_rollup($sco,$userid){

if($targetobjective->satisfiedbymeasure){
scorm_seq_objective_rollup_measure($sco,$userid);
}
else{
if ((scorm_seq_rollup_rule_check($sco,$userid,'incomplete'))|| (scorm_seq_rollup_rule_check($sco,$userid,'completed'))){
scorm_seq_objective_rollup_rules($sco,$userid);
}
else{

$rolluprules = get_record('scorm_seq_rolluprule','scoid',$sco->id,'userid',$userid);
foreach($rolluprules as $rolluprule){
$rollupruleconds = get_records('scorm_seq_rolluprulecond','rollupruleid',$rolluprule->id);
foreach($rollupruleconds as $rolluprulecond){

switch ($rolluprulecond->cond!='satisfied' && $rolluprulecond->cond!='completed' && $rolluprulecond->cond!='attempted'){

scorm_seq_set('objectivesatisfiedstatus',$sco->id,$userid, false);

break;
}
}


}
}
}

function scorm_seq_objective_rollup_measure($sco,$userid){ function scorm_seq_objective_rollup_measure($sco,$userid){
$targetobjective = null; $targetobjective = null;


Expand Down Expand Up @@ -596,6 +624,7 @@ function scorm_seq_objective_rollup_measure($sco,$userid){
} }
} }
else{ else{

scorm_seq_set('objectiveprogressstatus',$sco->id,$userid,false); scorm_seq_set('objectiveprogressstatus',$sco->id,$userid,false);


} }
Expand Down Expand Up @@ -660,8 +689,6 @@ function scorm_seq_rollup_rule_check ($sco,$userid,$action){


foreach($rolluprules as $rolluprule){ foreach($rolluprules as $rolluprule){




foreach ($children as $child){ foreach ($children as $child){


/*$tracked = get_records('scorm_scoes_track','scoid',$child->id,'userid',$userid); /*$tracked = get_records('scorm_scoes_track','scoid',$child->id,'userid',$userid);
Expand Down Expand Up @@ -1106,7 +1133,7 @@ function scorm_seq_continue_sequencing($scoid,$userid,$seq){
if ($currentact->parent != '/') {//if the activity is the root and is leaf if ($currentact->parent != '/') {//if the activity is the root and is leaf
$parent = scorm_get_parent ($currentact); $parent = scorm_get_parent ($currentact);


if (isset($parent->flow) && ($parent->flow == false)) { if (!isset($parent->flow) || ($parent->flow == false)) {
$seq->delivery = null; $seq->delivery = null;
$seq->exception = 'SB.2.7-2'; $seq->exception = 'SB.2.7-2';
return $seq; return $seq;
Expand All @@ -1133,7 +1160,7 @@ function scorm_seq_previous_sequencing($scoid,$userid,$seq){
$currentact= $seq->currentactivity; $currentact= $seq->currentactivity;
if ($currentact->parent != '/') {//if the activity is the root and is leaf if ($currentact->parent != '/') {//if the activity is the root and is leaf
$parent = scorm_get_parent ($activity); $parent = scorm_get_parent ($activity);
if (isset($parent->flow) && ($parent->flow == false)) { if (!isset($parent->flow) || ($parent->flow == false)) {
$seq->delivery = null; $seq->delivery = null;
$seq->exception = 'SB.2.8-2'; $seq->exception = 'SB.2.8-2';
return $seq; return $seq;
Expand Down Expand Up @@ -1228,7 +1255,7 @@ function scorm_seq_flow ($candidate,$direction,$seq,$childrenflag,$userid){
function scorm_seq_flow_activity_traversal ($activity, $userid, $direction, $childrenflag, $prevdirection, $seq,$userid){//returns the next activity on the tree, traversal direction, control returned to the LTS, (may) exception function scorm_seq_flow_activity_traversal ($activity, $userid, $direction, $childrenflag, $prevdirection, $seq,$userid){//returns the next activity on the tree, traversal direction, control returned to the LTS, (may) exception
$activity = scorm_get_sco ($activity); $activity = scorm_get_sco ($activity);
$parent = scorm_get_parent ($activity); $parent = scorm_get_parent ($activity);
if (isset($parent->flow) && ($parent->flow == false)) { if (!isset($parent->flow) || ($parent->flow == false)) {
$seq->deliverable = false; $seq->deliverable = false;
$seq->exception = 'SB.2.2-1'; $seq->exception = 'SB.2.2-1';
$seq->nextactivity = $activity; $seq->nextactivity = $activity;
Expand Down Expand Up @@ -1396,7 +1423,7 @@ function scorm_seq_flow_tree_traversal ($activity,$direction,$childrenflag,$prev
else{ else{
if (!empty($children){ if (!empty($children){
$activity = scorm_get_sco($activity->id); $activity = scorm_get_sco($activity->id);
if (!isset($parent->flow) || ($parent->flow == true)) { if (isset($parent->flow) && ($parent->flow == true)) {
$children = scorm_get_children ($activity); $children = scorm_get_children ($activity);
$seq->traversaldir = 'forward'; $seq->traversaldir = 'forward';
$seq->nextactivity = $children[0]; $seq->nextactivity = $children[0];
Expand Down Expand Up @@ -1674,8 +1701,8 @@ function scorm_seq_choice_sequencing($sco,$userid,$seq){
return $seq; return $seq;
} }
if ($constrained == null){ if ($constrained == null){
if($acti->constrainedchoice){ if($acti->constrainchoice == true){
$constrained = $acti;//adlseq:can i write it like another property for the $seq object? $constrained = $acti;
} }
} }
} }
Expand Down Expand Up @@ -1722,7 +1749,7 @@ function scorm_seq_choice_sequencing($sco,$userid,$seq){
return $seq; return $seq;
} }
$act = scorm_get_sco($act->id); $act = scorm_get_sco($act->id);
if(scorm_seq_is('active',$act->id,$userid) && ($act->id != $comancestor->id && $act->preventactivation)){//adlseq:can i write it like another property for the $seq object? if(scorm_seq_is('active',$act->id,$userid) && ($act->id != $comancestor->id && ($act->preventactivation == true))){
$seq->delivery = null; $seq->delivery = null;
$seq->exception = 'SB.2.9-6'; $seq->exception = 'SB.2.9-6';
return $seq; return $seq;
Expand All @@ -1733,7 +1760,7 @@ function scorm_seq_choice_sequencing($sco,$userid,$seq){
else{ else{
foreach ($comtarget as $act){ foreach ($comtarget as $act){
$act = scorm_get_sco($act->id); $act = scorm_get_sco($act->id);
if(scorm_seq_is('active',$act->id,$userid) && ($act->id != $comancestor->id && $act->preventactivation)){ if(scorm_seq_is('active',$act->id,$userid) && ($act->id != $comancestor->id && ($act->preventactivation==true))){
$seq->delivery = null; $seq->delivery = null;
$seq->exception = 'SB.2.9-6'; $seq->exception = 'SB.2.9-6';
return $seq; return $seq;
Expand Down Expand Up @@ -1851,7 +1878,7 @@ function scorm_seq_choice_activity_traversal($activity,$userid,$seq,$direction){
if($direction == 'backward'){ if($direction == 'backward'){
$parentsco = scorm_get_parent($activity); $parentsco = scorm_get_parent($activity);
if($parentsco!= null){ if($parentsco!= null){
if (!isset($parentsco->forwardonly) || ($parentsco->forwardonly == true)){ if (isset($parentsco->forwardonly) && ($parentsco->forwardonly == true)){
$seq->reachable = false; $seq->reachable = false;
$seq->exception = 'SB.2.4-2'; $seq->exception = 'SB.2.4-2';
return $seq; return $seq;
Expand Down

0 comments on commit 1536b92

Please sign in to comment.