51 require_once(
"SeqActivity.php");
53 require_once(
"SeqRule.php");
54 require_once(
"SeqRuleset.php");
56 require_once(
"SeqCondition.php");
57 require_once(
"SeqConditionSet.php");
59 require_once(
"SeqObjective.php");
60 require_once(
"SeqObjectiveMap.php");
62 require_once(
"SeqRollupRule.php");
63 require_once(
"SeqRollupRuleset.php");
65 require_once(
"ADLAuxiliaryResource.php");
71 $doc =
new DomDocument();
73 $organizations = $doc->getElementsByTagName(
"organizations");
76 $default=preg_replace(
'/(%20)+/',
' ', trim($organizations->item(0)->getAttribute(
"default")));
79 $organization = $doc->getElementsByTagName(
"organization");
82 foreach ($organization as $element) {
83 if (preg_replace(
'/(%20)+/',
' ', trim($element->getAttribute(
"identifier")))==$default) {
84 $default_organization = $element;
89 $seqCollection = $doc->getElementsByTagName(
"sequencingCollection")->item(0);
91 $root = $this->
buildNode($default_organization,$seqCollection,$doc);
94 $objectivesGlobalToSystem = $default_organization->getAttributeNS(
"http://www.adlnet.org/xsd/adlseq_v1p3",
"objectivesGlobalToSystem");
96 $org = preg_replace(
'/(%20)+/',
' ', trim($default_organization->getAttribute(
"identifier")));
101 if ($objectivesGlobalToSystem==
"false") {
106 $dataGlobalToSystem = $default_organization->getAttributeNS(
"http://www.adlnet.org/xsd/adlcp_v1p3",
"sharedDataGlobalToSystem");
109 $dataglobaltosystem = 1;
111 if ($dataGlobalToSystem==
"false") {
112 $dataglobaltosystem = 0;
116 $c_root[
'_SeqActivity']=$root;
118 $ret[
'global'] = $globaltosystem;
119 $ret[
'dataglobal'] = $dataglobaltosystem;
120 $ret[
'tree'] = $c_root;
134 $act->setID(preg_replace(
'/(%20)+/',
' ', trim($node->getAttribute(
"identifier"))));
136 $tempVal = preg_replace(
'/(%20)+/',
' ', trim($node->getAttribute(
"identifierref")));
138 $act->setResourceID($tempVal);
141 $tempVal = $node->getAttribute(
"isvisible");
144 $act->setIsVisible(self::convert_to_bool($tempVal));
150 $children = $node->childNodes;
152 for ($i = 0; $i < $children->length; $i++ ) {
154 $curNode=$children->item($i);
157 if ($curNode->nodeType == XML_ELEMENT_NODE) {
159 if ($curNode->localName ==
"item") {
163 $nestedAct = $this->
buildNode($curNode,$seq,$doc);
164 if ($nestedAct != null ) {
165 $act->AddChild($nestedAct);
168 else if ($curNode->localName ==
"title") {
171 else if ($curNode->localName ==
"completionThreshold"){
172 $tempVal = $curNode->getAttribute(
"minProgressMeasure");
175 $act->setCompletionThreshold($tempVal);
177 else if ($curNode->nodeValue != null && $curNode->nodeValue !=
'') {
178 $act->setCompletionThreshold($curNode->nodeValue);
181 $tempVal = $curNode->getAttribute(
"progressWeight");
184 $act->setProgressWeight($tempVal);
186 $tempVal = $curNode->getAttribute(
"completedByMeasure");
189 $act->setCompletedByMeasure(self::convert_to_bool($tempVal));
192 else if ($curNode->localName ==
"sequencing") {
195 $tempVal = preg_replace(
'/(%20)+/',
' ', trim($curNode->getAttribute(
"IDRef")));
202 $sequencing = $seq->getElementsByTagName(
"sequencing");
205 foreach ($sequencing as $element) {
206 if (preg_replace(
'/(%20)+/',
' ', trim($element->getAttribute(
"ID")))==$tempVal) {
207 $seqGlobal = $element;
212 $seqInfo = $seqGlobal->cloneNode(TRUE);
215 $seqChildren = $curNode->childNodes;
216 for ($j = 0; $j < $seqChildren->length; $j++ ) {
218 $curChild = $seqChildren->item($j);
219 if ( $curChild->nodeType == XML_ELEMENT_NODE ) {
222 $seqInfo->appendChild($curChild);
236 $item=$children->item($i)->nodeValue;
247 $children = $iNode->childNodes;
248 for ( $i = 0; $i < $children->length; $i++ ) {
249 $curNode = $children->item($i);
250 if ( $curNode->nodeType == XML_ELEMENT_NODE ) {
251 if ($curNode->localName ==
"controlMode") {
253 $tempVal=$curNode->getAttribute(
"choice");
255 $ioAct->setControlModeChoice(self::convert_to_bool($tempVal));
258 $tempVal=$curNode->getAttribute(
"choiceExit");
260 $ioAct->setControlModeChoiceExit(self::convert_to_bool($tempVal));
264 $tempVal=$curNode->getAttribute(
"flow");
266 $ioAct->setControlModeFlow(self::convert_to_bool($tempVal));
270 $tempVal=$curNode->getAttribute(
"forwardOnly");
272 $ioAct->setControlForwardOnly(self::convert_to_bool($tempVal));
276 $tempVal=$curNode->getAttribute(
"useCurrentAttemptObjectiveInfo");
278 $ioAct->setUseCurObjective(self::convert_to_bool($tempVal));
282 $tempVal=$curNode->getAttribute(
"useCurrentAttemptProgressInfo");
284 $ioAct->setUseCurProgress(self::convert_to_bool($tempVal));
289 else if ($curNode->localName ==
"sequencingRules") {
294 else if ($curNode->localName ==
"limitConditions") {
296 $tempVal=$curNode->getAttribute(
"attemptLimit");
298 $ioAct->setAttemptLimit($tempVal);
302 $tempVal=$curNode->getAttribute(
"attemptAbsoluteDurationLimit");
304 $ioAct->setAttemptAbDur($tempVal);
308 $tempVal=$curNode->getAttribute(
"attemptExperiencedDurationLimit");
310 $ioAct->setAttemptExDur($tempVal);
314 $tempVal=$curNode->getAttribute(
"activityAbsoluteDurationLimit");
316 $ioAct->setActivityAbDur($tempVal);
320 $tempVal=$curNode->getAttribute(
"activityExperiencedDurationLimit");
322 $ioAct->setActivityExDur($tempVal);
326 $tempVal=$curNode->getAttribute(
"beginTimeLimit");
328 $ioAct->setBeginTimeLimit($tempVal);
332 $tempVal=$curNode->getAttribute(
"endTimeLimit");
334 $ioAct->setEndTimeLimit($tempVal);
337 else if ($curNode->localName ==
"auxiliaryResources") {
341 else if ($curNode->localName ==
"rollupRules") {
345 else if ($curNode->localName ==
"objectives" && $curNode->namespaceURI ==
"http://www.imsglobal.org/xsd/imsss") {
349 else if ($curNode->localName ==
"objectives" && $curNode->namespaceURI ==
"http://www.adlnet.org/xsd/adlseq_v1p3") {
352 else if ($curNode->localName ==
"randomizationControls") {
355 $tempVal=$curNode->getAttribute(
"randomizationTiming");
357 $ioAct->setRandomTiming($tempVal);
361 $tempVal=$curNode->getAttribute(
"selectCount");
363 $ioAct->setSelectCount($tempVal);
367 $tempVal=$curNode->getAttribute(
"reorderChildren");
369 $ioAct->setReorderChildren(self::convert_to_bool($tempVal));
373 $tempVal=$curNode->getAttribute(
"selectionTiming");
375 $ioAct->setSelectionTiming($tempVal);
378 else if ($curNode->localName ==
"deliveryControls") {
381 $tempVal=$curNode->getAttribute(
"tracked");
383 $ioAct->setIsTracked(self::convert_to_bool($tempVal));
387 $tempVal=$curNode->getAttribute(
"completionSetByContent");
389 $ioAct->setSetCompletion(self::convert_to_bool($tempVal));
393 $tempVal=$curNode->getAttribute(
"objectiveSetByContent");
395 $ioAct->setSetObjective(self::convert_to_bool($tempVal));
398 else if ($curNode->localName ==
"constrainedChoiceConsiderations") {
401 $tempVal=$curNode->getAttribute(
"preventActivation");
403 $ioAct->setPreventActivation(self::convert_to_bool($tempVal));
407 $tempVal=$curNode->getAttribute(
"constrainChoice");
409 $ioAct->setConstrainChoice(self::convert_to_bool($tempVal));
412 else if ($curNode->localName ==
"rollupConsiderations") {
415 $tempVal=$curNode->getAttribute(
"requiredForSatisfied");
417 $ioAct->setRequiredForSatisfied($tempVal);
421 $tempVal=$curNode->getAttribute(
"requiredForNotSatisfied");
423 $ioAct->setRequiredForNotSatisfied($tempVal);
427 $tempVal=$curNode->getAttribute(
"requiredForCompleted");
429 $ioAct->setRequiredForCompleted($tempVal);
433 $tempVal=$curNode->getAttribute(
"requiredForIncomplete");
435 $ioAct->setRequiredForIncomplete($tempVal);
439 $tempVal=$curNode->getAttribute(
"measureSatisfactionIfActive");
441 $ioAct->setSatisfactionIfActive(self::convert_to_bool($tempVal));
461 $objectives = array();
462 $children = $iNode->childNodes;
463 for ($i = 0; $i < $children->length; $i++ ) {
464 $curNode=$children->item($i);
465 if ($curNode->nodeType == XML_ELEMENT_NODE) {
466 if ($curNode->localName ==
"primaryObjective" || $curNode->localName ==
"objective" ) {
469 if ($curNode->localName ==
"primaryObjective") {
470 $obj->mContributesToRollup =
true;
474 $tempVal = preg_replace(
'/(%20)+/',
' ', trim($curNode->getAttribute(
"objectiveID")));
476 $obj->mObjID = $tempVal;
480 $tempVal = $curNode->getAttribute(
"satisfiedByMeasure");
487 $obj->mMinMeasure = $tempVal;
492 if ( $maps != null ){
497 $c_obj[
'_SeqObjective'] = $obj;
498 array_push($objectives,$c_obj);
502 $ioAct->setObjectives($objectives);
508 $objectives = $ioAct->mObjectives;
509 $children = $iNode->childNodes;
510 for ($i = 0; $i < $children->length; $i++ ) {
511 $curNode=$children->item($i);
512 if ($curNode->nodeType == XML_ELEMENT_NODE) {
513 if ($curNode->localName ==
"objective" ) {
515 $adlseqobjid = preg_replace(
'/(%20)+/',
' ', trim($curNode->getAttribute(
"objectiveID")));
519 for ( $j = 0; $j < count($objectives); $j++ ){
520 $seqobj = $objectives[$j][
'_SeqObjective'];
521 if ( $seqobj->mObjID == $adlseqobjid ){
522 $curseqobj = $seqobj;
523 $curseqobjindex = $j;
529 if ( $curseqobj != null ){
532 $seqobj = $curseqobj;
533 $objectives[$curseqobjindex][
'_SeqObjective'] = $seqobj;
541 $ioAct->setObjectives($objectives);
546 if (count($curseqobj->mMaps)==null) $curseqobj->mMaps = array();
547 $maps = $curseqobj->mMaps;
549 $children = $iNode->childNodes;
550 for ($i = 0; $i < $children->length; $i++ ) {
551 $curNode=$children->item($i);
552 if ($curNode->nodeType == XML_ELEMENT_NODE) {
553 if ($curNode->localName ==
"mapInfo") {
555 $curadltargetobjid = preg_replace(
'/(%20)+/',
' ', trim($curNode->getAttribute(
"targetObjectiveID")));
557 $matchingmapindex = -1;
558 for ( $j = 0; $j < count($maps); $j++ ){
559 if ($maps[$j][
'_SeqObjectiveMap']->mGlobalObjID == $curadltargetobjid){
560 $map = $maps[$j][
'_SeqObjectiveMap'];
561 $matchingmapindex = $j;
567 if ( $matchingmapindex > -1 ){
568 $c_map[
'_SeqObjectiveMap']=$map;
569 $maps[$matchingmapindex] = $c_map;
572 $c_map[
'_SeqObjectiveMap']=$map;
573 array_push($maps, $c_map);
578 $curseqobj->mMaps = $maps;
584 if($map->mGlobalObjID == null) $map->mGlobalObjID = preg_replace(
'/(%20)+/',
' ', trim($iNode->getAttribute(
"targetObjectiveID")));
586 $tempVal = $iNode->getAttribute(
"readRawScore");
591 $tempVal = $iNode->getAttribute(
"readMinScore");
596 $tempVal = $iNode->getAttribute(
"readMaxScore");
601 $tempVal = $iNode->getAttribute(
"readCompletionStatus");
606 $tempVal = $iNode->getAttribute(
"readProgressMeasure");
611 $tempVal = $iNode->getAttribute(
"writeRawScore");
616 $tempVal = $iNode->getAttribute(
"writeMinScore");
621 $tempVal = $iNode->getAttribute(
"writeMaxScore");
626 $tempVal = $iNode->getAttribute(
"writeCompletionStatus");
631 $tempVal = $iNode->getAttribute(
"writeProgressMeasure");
642 $children = $iNode->childNodes;
643 for ($i = 0; $i < $children->length; $i++ ) {
644 $curNode=$children->item($i);
645 if ($curNode->nodeType == XML_ELEMENT_NODE) {
646 if ($curNode->localName ==
"mapInfo") {
650 $tempVal = preg_replace(
'/(%20)+/',
' ', trim($curNode->getAttribute(
"targetObjectiveID")));
652 $map->mGlobalObjID = $tempVal;
656 $tempVal = $curNode->getAttribute(
"readSatisfiedStatus");
662 $tempVal = $curNode->getAttribute(
"readNormalizedMeasure");
668 $tempVal = $curNode->getAttribute(
"writeSatisfiedStatus");
674 $tempVal = $curNode->getAttribute(
"writeNormalizedMeasure");
679 $c_map[
'_SeqObjectiveMap']=$map;
680 array_push($maps,$c_map);
684 if (count($maps)==null) {
693 $rollupRules = array();
696 $tempVal = $iNode->getAttribute(
"rollupObjectiveSatisfied");
698 $ioAct->setIsObjRolledUp(self::convert_to_bool($tempVal));
702 $tempVal = $iNode->getAttribute(
"objectiveMeasureWeight");
704 $ioAct->setObjMeasureWeight($tempVal);
708 $tempVal = $iNode->getAttribute(
"rollupProgressCompletion");
710 $ioAct->setIsProgressRolledUp(self::convert_to_bool($tempVal));
713 $children = $iNode->childNodes;
714 for ($i = 0; $i < $children->length; $i++ ) {
715 $curNode=$children->item($i);
716 if ($curNode->nodeType == XML_ELEMENT_NODE) {
717 if ($curNode->localName ==
"rollupRule") {
721 $tempVal=$curNode->getAttribute(
"childActivitySet");
723 $rule->mChildActivitySet = $tempVal;
726 $tempVal=$curNode->getAttribute(
"minimumCount");
728 $rule->mMinCount = $tempVal;
732 $tempVal=$curNode->getAttribute(
"minimumPercent");
734 $rule->mMinPercent = $tempVal;
737 $conditions = array();
738 $ruleInfo = $curNode->childNodes;
739 for ($j = 0; $j < $ruleInfo->length; $j++ ) {
740 $curRule=$ruleInfo->item($j);
742 if ($curRule->nodeType == XML_ELEMENT_NODE) {
743 if ($curRule->localName ==
"rollupConditions") {
744 $tempVal = $curRule->getAttribute(
"conditionCombination");
746 $rule->mConditions[
'_SeqConditionSet']->mCombination = $tempVal;
748 $rule->mConditions[
'_SeqConditionSet']->mCombination =
COMBINATION_ANY;
750 $conds = $curRule->childNodes;
751 for ($k = 0; $k < $conds->length; $k++ ) {
752 $con=$conds->item($k);
753 if ($con->nodeType == XML_ELEMENT_NODE) {
754 if ($con->localName ==
"rollupCondition") {
757 $tempVal = $con->getAttribute(
"condition");
759 $cond->mCondition=$tempVal;
762 $tempVal = $con->getAttribute(
"operator");
764 if($tempVal==
'not') {$cond->mNot =
true;}
else {$cond->mNot =
false;}
767 $c_cond[
'_SeqCondition'] = $cond;
768 array_push($conditions,$c_cond);
774 else if ($curRule->localName ==
"rollupAction") {
775 $tempVal = $curRule->getAttribute(
"action");
777 $rule->setRollupAction($tempVal);
785 $rule->mConditions[
'_SeqConditionSet']->mConditions = $conditions;
789 $c_rule[
'_SeqRollupRule']=$rule;
790 array_push($rollupRules,$c_rule);
795 if ( $rollupRules != null ) {
799 $c_rules[
'_SeqRollupRuleset']=$rules;
800 $ioAct->setRollupRules($c_rules);
813 $exitRules = array();
814 $postRules = array();
817 $children = $iNode->childNodes;
820 for ($i = 0; $i < $children->length; $i++ ) {
821 $curNode=$children->item($i);
822 if ($curNode->nodeType == XML_ELEMENT_NODE) {
823 if ($curNode->localName ==
"preConditionRule" || $curNode->localName ==
"exitConditionRule" || $curNode->localName ==
"postConditionRule" ) {
825 $ruleInfo = $curNode->childNodes;
826 for ($j = 0; $j < $ruleInfo->length; $j++ ){
827 $curRule=$ruleInfo->item($j);
829 if ($curRule->nodeType == XML_ELEMENT_NODE) {
830 if ($curRule->localName ==
"ruleConditions") {
833 else if($curRule->localName ==
"ruleAction"){
834 $tempVal=$curRule->getAttribute(
"action");
836 $rule->mAction = $tempVal;
842 if ( $rule->mConditions != null && $rule->mAction != null ) {
844 if ($curNode->localName ==
"preConditionRule") {
847 $c_rule[
'_SeqRule'] = $rule;
848 array_push($preRules,$c_rule);
850 if ($curNode->localName ==
"exitConditionRule") {
853 $c_rule[
'_SeqRule'] = $rule;
854 array_push($exitRules,$c_rule);
856 if ($curNode->localName ==
"postConditionRule") {
859 $c_rule[
'_SeqRule'] = $rule;
860 array_push($postRules,$c_rule);
868 if ( count($preRules) > 0 ) {
871 $c_rules[
'_SeqRuleset']=$rules;
872 $ioAct->setPreSeqRules($c_rules);
876 if ( count($exitRules) > 0 ){
879 $c_rules[
'_SeqRuleset']=$rules;
880 $ioAct->setExitSeqRules($c_rules);
882 if ( count($postRules) > 0 ){
885 $c_rules[
'_SeqRuleset']=$rules;
886 $ioAct->setPostSeqRules($c_rules);
899 $conditions = array();
900 $tempVal=$iNode->getAttribute(
"conditionCombination");
902 $condSet->mCombination=$tempVal;
906 $condInfo = $iNode->childNodes;
907 for ($i = 0; $i < $condInfo->length; $i++ ) {
908 $curCond=$condInfo->item($i);
909 if ($curCond->nodeType == XML_ELEMENT_NODE) {
910 if ($curCond->localName ==
"ruleCondition") {
914 $tempVal=$curCond->getAttribute(
"condition");
916 $cond->mCondition = $tempVal;
920 $tempVal=preg_replace(
'/(%20)+/',
' ', trim($curCond->getAttribute(
"referencedObjective")));
922 $cond->mObjID = $tempVal;
927 $tempVal=$curCond->getAttribute(
"measureThreshold");
929 $cond->mThreshold = $tempVal;
933 $tempVal = $curCond->getAttribute(
"operator");
935 if ($tempVal ==
'not') {
943 $c_cond[
'_SeqCondition']=$cond;
944 array_push($conditions,$c_cond);
950 if (count($conditions)>0) {
951 $condSet->mConditions = $conditions;
953 $condSet->mConditions = null;
956 $c_condSet[
'_SeqConditionSet']=$condSet;
965 $children = $iNode->childNodes;
968 for ($i = 0; $i < $children->length; $i++ ) {
969 $curNode=$children->item($i);
970 if ($curNode->nodeType == XML_ELEMENT_NODE) {
971 if ($curNode->localName ==
"auxiliaryResource") {
976 $tempVal=$curNode->getAttribute(
"purpose");
978 $res->mType = $tempVal;
981 $tempVal=preg_replace(
'/(%20)+/',
' ', trim($curNode->getAttribute(
"auxiliaryResourceID")));
983 $res->mResourceID = $tempVal;
985 array_push($auxRes,
$res);
990 $c_auxRes[
'_ADLAuxiliaryResource']=$auxRes;
991 $ioAct->setAuxResources($c_auxRes);
998 if (strtoupper($string)==
"FALSE") {
1011 if ( $iNode != null && $iElement != null ){
1012 $children = $iNode->childNodes;
1013 for ($i = 0; $i < $children->length; $i++ ) {
1014 $curNode = $children->item($i);
1015 if ( ($curNode->nodeType == XML_ELEMENT_NODE)) {
1016 if ($curNode->localName == $iElement) {
1022 if ($curNode != null ) {
1023 $comp = $curNode->localName;
1024 if ($comp != null) {
1025 if ($comp != $iElement) {
1040 if ( $curNode != null )
1042 $children = $curNode->childNodes;
1043 if ( $children != null ) {
1044 for ($i = 0; $i < $children->length; $i++ ) {
1045 $curNode = $children->item($i);
1047 if ( ($curNode->nodeType == XML_TEXT_NODE) ||($curNode->nodeType == XML_CDATA_SECTION_NODE) )
1049 $value = $value.$curNode->nodeValue;