ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SeqTreeBuilder.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 /*
24  PHP port of several ADL-sources
25  @author Hendrik Holtmann <holtmann@mac.com>
26 
27  This .php file is GPL licensed (see above) but based on
28  Sourcecode by ADL Co-Lab, which is licensed as:
29 
30  Advanced Distributed Learning Co-Laboratory (ADL Co-Lab) Hub grants you
31  ("Licensee") a non-exclusive, royalty free, license to use, modify and
32  redistribute this software in source and binary code form, provided that
33  i) this copyright notice and license appear on all copies of the software;
34  and ii) Licensee does not utilize the software in a manner which is
35  disparaging to ADL Co-Lab Hub.
36 
37  This software is provided "AS IS," without a warranty of any kind. ALL
38  EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
39  ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
40  OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ADL Co-Lab Hub AND ITS LICENSORS
41  SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
42  USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO
43  EVENT WILL ADL Co-Lab Hub OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
44  PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
45  INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
46  THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
47  SOFTWARE, EVEN IF ADL Co-Lab Hub HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
48  DAMAGES.
49 */
50 
51  require_once("SeqActivity.php");
52 
53  require_once("SeqRule.php");
54  require_once("SeqRuleset.php");
55 
56  require_once("SeqCondition.php");
57  require_once("SeqConditionSet.php");
58 
59  require_once("SeqObjective.php");
60  require_once("SeqObjectiveMap.php");
61 
62  require_once("SeqRollupRule.php");
63  require_once("SeqRollupRuleset.php");
64 
65  require_once("ADLAuxiliaryResource.php");
66 
68  {
69  public function buildNodeSeqTree($file)
70  {
71  $doc = new DomDocument();
72  $doc->load($file);
73  $organizations = $doc->getElementsByTagName("organizations");
74 
75  //lookup default organization id
76  $default=preg_replace('/(%20)+/', ' ', trim($organizations->item(0)->getAttribute("default")));
77 
78  //get all organization nodes
79  $organization = $doc->getElementsByTagName("organization");
80 
81  //lookup the default organization
82  foreach ($organization as $element) {
83  if (preg_replace('/(%20)+/', ' ', trim($element->getAttribute("identifier")))==$default) {
84  $default_organization = $element;
85  }
86  }
87 
88  //read seqCollection
89  $seqCollection = $doc->getElementsByTagName("sequencingCollection")->item(0);
90 
91  $root = $this->buildNode($default_organization, $seqCollection, $doc);
92 
93  //return no data please check
94  $objectivesGlobalToSystem = $default_organization->getAttributeNS("http://www.adlnet.org/xsd/adlseq_v1p3", "objectivesGlobalToSystem");
95 
96  $org = preg_replace('/(%20)+/', ' ', trim($default_organization->getAttribute("identifier")));
97 
98  //default true
99  $globaltosystem = 1;
100 
101  if ($objectivesGlobalToSystem=="false") {
102  $globaltosystem = 0;
103  }
104 
105  //return no data please check
106  $dataGlobalToSystem = $default_organization->getAttributeNS("http://www.adlnet.org/xsd/adlcp_v1p3", "sharedDataGlobalToSystem");
107 
108  //default true
109  $dataglobaltosystem = 1;
110 
111  if ($dataGlobalToSystem=="false") {
112  $dataglobaltosystem = 0;
113  }
114 
115  //assign SeqActivity to top node
116  $c_root['_SeqActivity']=$root;
117 
118  $ret['global'] = $globaltosystem;
119  $ret['dataglobal'] = $dataglobaltosystem;
120  $ret['tree'] = $c_root;
121 
122  return $ret;
123  }
124 
125 
126 
127  private function buildNode($node, $seq, $doc)
128  {
129 
130  //create a new activity object
131  $act = new SeqActivity();
132 
133  //set various attributes, if existent
134  $act->setID(preg_replace('/(%20)+/', ' ', trim($node->getAttribute("identifier"))));
135 
136  $tempVal = preg_replace('/(%20)+/', ' ', trim($node->getAttribute("identifierref")));
137  if ($tempVal) {
138  $act->setResourceID($tempVal);
139  }
140 
141  $tempVal = $node->getAttribute("isvisible");
142 
143  if ($tempVal) {
144  $act->setIsVisible(self::convert_to_bool($tempVal));
145  }
146 
147 
148 
149  //Proceed nested items
150  $children = $node->childNodes;
151 
152  for ($i = 0; $i < $children->length; $i++) {
153  $curNode=$children->item($i);
154  //elements only
155 
156  if ($curNode->nodeType == XML_ELEMENT_NODE) {
157  //only items are nested
158  if ($curNode->localName == "item") {
159  //init;
160  $c_nestedAct=null;
161  $nestedAct = new SeqActivity();
162  $nestedAct = $this->buildNode($curNode, $seq, $doc);
163  if ($nestedAct != null) {
164  $act->AddChild($nestedAct);
165  }
166  } elseif ($curNode->localName == "title") {
167  $act->setTitle($this->lookupElement($curNode, null));
168  } elseif ($curNode->localName == "completionThreshold") {
169  $tempVal = $curNode->getAttribute("minProgressMeasure");
170 
171  if ($tempVal) {
172  $act->setCompletionThreshold($tempVal);
173  } elseif ($curNode->nodeValue != null && $curNode->nodeValue != '') {
174  $act->setCompletionThreshold($curNode->nodeValue);
175  }
176 
177  $tempVal = $curNode->getAttribute("progressWeight");
178 
179  if ($tempVal) {
180  $act->setProgressWeight($tempVal);
181  }
182  $tempVal = $curNode->getAttribute("completedByMeasure");
183 
184  if ($tempVal) {
185  $act->setCompletedByMeasure(self::convert_to_bool($tempVal));
186  }
187  } elseif ($curNode->localName == "sequencing") {
188  $seqInfo = $curNode;
189  //get IDRef
190  $tempVal = preg_replace('/(%20)+/', ' ', trim($curNode->getAttribute("IDRef")));
191  //only execute for referenced sequencing parts
192  if ($tempVal) {
193  //init seqGlobal
194  $seqGlobal = null;
195 
196  //get all sequencing nodes in collections
197  $sequencing = $seq->getElementsByTagName("sequencing");
198 
199  //lookup the matching sequencing element
200  foreach ($sequencing as $element) {
201  if (preg_replace('/(%20)+/', ' ', trim($element->getAttribute("ID")))==$tempVal) {
202  $seqGlobal = $element;
203  }
204  }
205 
206  //clone the global node
207  $seqInfo = $seqGlobal->cloneNode(true);
208 
209  //back to the local node
210  $seqChildren = $curNode->childNodes;
211  for ($j = 0; $j < $seqChildren->length; $j++) {
212  //process local nodes
213  $curChild = $seqChildren->item($j);
214  if ($curChild->nodeType == XML_ELEMENT_NODE) {
215  //echo "\nFound Sequencing Element Node".$curChild->localName;
216  //add local to global sequencing info
217  $seqInfo->appendChild($curChild);
218  }
219  }
220  }
221  //extract the sequencing info, if we have one
222  //avoid working with
223  $act=$this->extractSeqInfo($seqInfo, $act);
224  }
225  }
226 
227 
228 
229  $item=$children->item($i)->nodeValue;
230  }
231  //add class
232  //$c_act['_SeqActivity']=$act;
233  return $act;
234  }
235 
236 
237  private function extractSeqInfo($iNode, $ioAct)
238  {
239  //set sequencing information
240  $children = $iNode->childNodes;
241  for ($i = 0; $i < $children->length; $i++) {
242  $curNode = $children->item($i);
243  if ($curNode->nodeType == XML_ELEMENT_NODE) {
244  if ($curNode->localName == "controlMode") {
245  //look for choice
246  $tempVal=$curNode->getAttribute("choice");
247  if ($tempVal) {
248  $ioAct->setControlModeChoice(self::convert_to_bool($tempVal));
249  }
250  //look for choiceExit
251  $tempVal=$curNode->getAttribute("choiceExit");
252  if ($tempVal) {
253  $ioAct->setControlModeChoiceExit(self::convert_to_bool($tempVal));
254  }
255 
256  //look for flow
257  $tempVal=$curNode->getAttribute("flow");
258  if ($tempVal) {
259  $ioAct->setControlModeFlow(self::convert_to_bool($tempVal));
260  }
261 
262  // Look for 'forwardOnly'
263  $tempVal=$curNode->getAttribute("forwardOnly");
264  if ($tempVal) {
265  $ioAct->setControlForwardOnly(self::convert_to_bool($tempVal));
266  }
267 
268  // Look for 'useCurrentAttemptObjectiveInfo'
269  $tempVal=$curNode->getAttribute("useCurrentAttemptObjectiveInfo");
270  if ($tempVal) {
271  $ioAct->setUseCurObjective(self::convert_to_bool($tempVal));
272  }
273 
274  // Look for 'useCurrentAttemptProgressInfo'
275  $tempVal=$curNode->getAttribute("useCurrentAttemptProgressInfo");
276  if ($tempVal) {
277  $ioAct->setUseCurProgress(self::convert_to_bool($tempVal));
278  }
279  } elseif ($curNode->localName == "sequencingRules") {
280  $ioAct = $this->getSequencingRules($curNode, $ioAct);
281  } elseif ($curNode->localName == "limitConditions") {
282  // Look for 'useCurrentAttemptObjectiveInfo'
283  $tempVal=$curNode->getAttribute("attemptLimit");
284  if ($tempVal) {
285  $ioAct->setAttemptLimit($tempVal);
286  }
287 
288  // Look for 'attemptAbsoluteDurationLimit'
289  $tempVal=$curNode->getAttribute("attemptAbsoluteDurationLimit");
290  if ($tempVal) {
291  $ioAct->setAttemptAbDur($tempVal);
292  }
293 
294  // Look for 'attemptExperiencedDurationLimit'
295  $tempVal=$curNode->getAttribute("attemptExperiencedDurationLimit");
296  if ($tempVal) {
297  $ioAct->setAttemptExDur($tempVal);
298  }
299 
300  // Look for 'activityAbsoluteDurationLimit'
301  $tempVal=$curNode->getAttribute("activityAbsoluteDurationLimit");
302  if ($tempVal) {
303  $ioAct->setActivityAbDur($tempVal);
304  }
305 
306  // Look for 'activityExperiencedDurationLimit'
307  $tempVal=$curNode->getAttribute("activityExperiencedDurationLimit");
308  if ($tempVal) {
309  $ioAct->setActivityExDur($tempVal);
310  }
311 
312  // Look for 'beginTimeLimit'
313  $tempVal=$curNode->getAttribute("beginTimeLimit");
314  if ($tempVal) {
315  $ioAct->setBeginTimeLimit($tempVal);
316  }
317 
318  // Look for 'endTimeLimit'
319  $tempVal=$curNode->getAttribute("endTimeLimit");
320  if ($tempVal) {
321  $ioAct->setEndTimeLimit($tempVal);
322  }
323  } elseif ($curNode->localName == "auxiliaryResources") {
324  $ioAct = self::getAuxResources($curNode, $ioAct);
325  } elseif ($curNode->localName == "rollupRules") {
326  $ioAct = self::getRollupRules($curNode, $ioAct);
327  } elseif ($curNode->localName == "objectives" && $curNode->namespaceURI == "http://www.imsglobal.org/xsd/imsss") {
328  $ioAct = self::getObjectives($curNode, $ioAct);
329  } elseif ($curNode->localName == "objectives" && $curNode->namespaceURI == "http://www.adlnet.org/xsd/adlseq_v1p3") {
330  $ioAct = self::getADLSEQObjectives($curNode, $ioAct);
331  } elseif ($curNode->localName == "randomizationControls") {
332 
333  // Look for 'randomizationTiming'
334  $tempVal=$curNode->getAttribute("randomizationTiming");
335  if ($tempVal) {
336  $ioAct->setRandomTiming($tempVal);
337  }
338 
339  // Look for 'selectCount'
340  $tempVal=$curNode->getAttribute("selectCount");
341  if ($tempVal) {
342  $ioAct->setSelectCount($tempVal);
343  }
344 
345  // Look for 'reorderChildren'
346  $tempVal=$curNode->getAttribute("reorderChildren");
347  if ($tempVal) {
348  $ioAct->setReorderChildren(self::convert_to_bool($tempVal));
349  }
350 
351  // Look for 'selectionTiming'
352  $tempVal=$curNode->getAttribute("selectionTiming");
353  if ($tempVal) {
354  $ioAct->setSelectionTiming($tempVal);
355  }
356  } elseif ($curNode->localName == "deliveryControls") {
357 
358  // Look for 'tracked'
359  $tempVal=$curNode->getAttribute("tracked");
360  if ($tempVal) {
361  $ioAct->setIsTracked(self::convert_to_bool($tempVal));
362  }
363 
364  // Look for 'completionSetByContent'
365  $tempVal=$curNode->getAttribute("completionSetByContent");
366  if ($tempVal) {
367  $ioAct->setSetCompletion(self::convert_to_bool($tempVal));
368  }
369 
370  // Look for 'objectiveSetByContent'
371  $tempVal=$curNode->getAttribute("objectiveSetByContent");
372  if ($tempVal) {
373  $ioAct->setSetObjective(self::convert_to_bool($tempVal));
374  }
375  } elseif ($curNode->localName == "constrainedChoiceConsiderations") {
376 
377  // Look for 'preventActivation'
378  $tempVal=$curNode->getAttribute("preventActivation");
379  if ($tempVal) {
380  $ioAct->setPreventActivation(self::convert_to_bool($tempVal));
381  }
382 
383  // Look for 'constrainChoice'
384  $tempVal=$curNode->getAttribute("constrainChoice");
385  if ($tempVal) {
386  $ioAct->setConstrainChoice(self::convert_to_bool($tempVal));
387  }
388  } elseif ($curNode->localName == "rollupConsiderations") {
389 
390  // Look for 'requiredForSatisfied'
391  $tempVal=$curNode->getAttribute("requiredForSatisfied");
392  if ($tempVal) {
393  $ioAct->setRequiredForSatisfied($tempVal);
394  }
395 
396  // Look for 'requiredForNotSatisfied'
397  $tempVal=$curNode->getAttribute("requiredForNotSatisfied");
398  if ($tempVal) {
399  $ioAct->setRequiredForNotSatisfied($tempVal);
400  }
401 
402  // Look for 'requiredForCompleted'
403  $tempVal=$curNode->getAttribute("requiredForCompleted");
404  if ($tempVal) {
405  $ioAct->setRequiredForCompleted($tempVal);
406  }
407 
408  // Look for 'requiredForIncomplete'
409  $tempVal=$curNode->getAttribute("requiredForIncomplete");
410  if ($tempVal) {
411  $ioAct->setRequiredForIncomplete($tempVal);
412  }
413 
414  // Look for 'measureSatisfactionIfActive'
415  $tempVal=$curNode->getAttribute("measureSatisfactionIfActive");
416  if ($tempVal) {
417  $ioAct->setSatisfactionIfActive(self::convert_to_bool($tempVal));
418  }
419  }
420  } //end note-type check
421  } //end for-loop
422 
423  return $ioAct;
424  }
425 
426 
427  public static function getObjectives($iNode, $ioAct)
428  {
429  global $ilLog;
430 
431 
432  $ok = true;
433  $tempVal = null;
434  $objectives = array();
435  $children = $iNode->childNodes;
436  for ($i = 0; $i < $children->length; $i++) {
437  $curNode=$children->item($i);
438  if ($curNode->nodeType == XML_ELEMENT_NODE) {
439  if ($curNode->localName == "primaryObjective" || $curNode->localName == "objective") {
440  $obj = new SeqObjective();
441  if ($curNode->localName == "primaryObjective") {
442  $obj->mContributesToRollup = true;
443  }
444 
445  // Look for 'objectiveID'
446  $tempVal = preg_replace('/(%20)+/', ' ', trim($curNode->getAttribute("objectiveID")));
447  if ($tempVal) {
448  $obj->mObjID = $tempVal;
449  }
450 
451  // Look for 'satisfiedByMeasure'
452  $tempVal = $curNode->getAttribute("satisfiedByMeasure");
453  if ($tempVal) {
454  $obj->mSatisfiedByMeasure = self::convert_to_bool($tempVal);
455  }
456  // Look for 'minNormalizedMeasure'
457  $tempVal=self::lookupElement($curNode, "minNormalizedMeasure");
458  if ($tempVal) {
459  $obj->mMinMeasure = $tempVal;
460  }
461 
462  //get ObjectiveMaps
463  $maps = self::getObjectiveMaps($curNode);
464  if ($maps != null) {
465  $obj->mMaps = $maps;
466  }
467  //$obj->mContributesToRollup = true;
468  //add class
469  $c_obj['_SeqObjective'] = $obj;
470  array_push($objectives, $c_obj);
471  }
472  }
473  }
474  $ioAct->setObjectives($objectives);
475  return $ioAct;
476  }
477 
478  public static function getADLSEQObjectives($iNode, $ioAct)
479  {
480  global $ilLog;
481  $objectives = $ioAct->mObjectives;
482  $children = $iNode->childNodes;
483  for ($i = 0; $i < $children->length; $i++) {
484  $curNode=$children->item($i);
485  if ($curNode->nodeType == XML_ELEMENT_NODE) {
486  if ($curNode->localName == "objective") {
487  // get the objectiveID
488  $adlseqobjid = preg_replace('/(%20)+/', ' ', trim($curNode->getAttribute("objectiveID")));
489 
490  // find the imsss objective with the same objectiveID
491  $curseqobj = null;
492  for ($j = 0; $j < count($objectives); $j++) {
493  $seqobj = $objectives[$j]['_SeqObjective'];
494  if ($seqobj->mObjID == $adlseqobjid) {
495  $curseqobj = $seqobj;
496  $curseqobjindex = $j;
497  break;
498  }
499  }
500 
501  // if there's a current seq then let's add the maps
502  if ($curseqobj != null) {
503  // for each adlseq map info populate that mMaps with map info in the adlseq objective
504  $curseqobj = self::getADLSeqMaps($curNode, $curseqobj);
505  $seqobj = $curseqobj;
506  $objectives[$curseqobjindex]['_SeqObjective'] = $seqobj;
507  }
508  }
509  }
510  }
511  // before i leave what do i have to duplicate in SeqActivity or some other class?
512  // prolly just
513  $ioAct->setObjectives($objectives);
514  return $ioAct;
515  }
516 
517  public static function getADLSeqMaps($iNode, $curseqobj)
518  {
519  if (count($curseqobj->mMaps)==null) {
520  $curseqobj->mMaps = array();
521  }
522  $maps = $curseqobj->mMaps;
523 
524  $children = $iNode->childNodes;
525  for ($i = 0; $i < $children->length; $i++) {
526  $curNode=$children->item($i);
527  if ($curNode->nodeType == XML_ELEMENT_NODE) {
528  if ($curNode->localName == "mapInfo") {
529  $map = new SeqObjectiveMap();
530  $curadltargetobjid = preg_replace('/(%20)+/', ' ', trim($curNode->getAttribute("targetObjectiveID")));
531  // if the adl map target id matches an imsssssss one, then add to the imsssss one
532  $matchingmapindex = -1;
533  for ($j = 0; $j < count($maps); $j++) {
534  if ($maps[$j]['_SeqObjectiveMap']->mGlobalObjID == $curadltargetobjid) {
535  $map = $maps[$j]['_SeqObjectiveMap'];
536  $matchingmapindex = $j;
537  }
538  }
539  // tom: if default access is dependent on map existence then this will need to know if an imsss:mapInfo existed
540  $map = self::fillinADLSeqMaps($curNode, $map);
541 
542  if ($matchingmapindex > -1) {
543  $c_map['_SeqObjectiveMap']=$map;
544  $maps[$matchingmapindex] = $c_map;
545  } else {
546  $c_map['_SeqObjectiveMap']=$map;
547  array_push($maps, $c_map);
548  }
549  }
550  }
551  }
552  $curseqobj->mMaps = $maps;
553  return $curseqobj;
554  }
555 
556  public static function fillinADLSeqMaps($iNode, $map)
557  {
558  if ($map->mGlobalObjID == null) {
559  $map->mGlobalObjID = preg_replace('/(%20)+/', ' ', trim($iNode->getAttribute("targetObjectiveID")));
560  }
561 
562  $tempVal = $iNode->getAttribute("readRawScore");
563  if ($tempVal) {
564  $map->mReadRawScore = self::convert_to_bool($tempVal);
565  }
566 
567  $tempVal = $iNode->getAttribute("readMinScore");
568  if ($tempVal) {
569  $map->mReadMinScore = self::convert_to_bool($tempVal);
570  }
571 
572  $tempVal = $iNode->getAttribute("readMaxScore");
573  if ($tempVal) {
574  $map->mReadMaxScore = self::convert_to_bool($tempVal);
575  }
576 
577  $tempVal = $iNode->getAttribute("readCompletionStatus");
578  if ($tempVal) {
579  $map->mReadCompletionStatus = self::convert_to_bool($tempVal);
580  }
581 
582  $tempVal = $iNode->getAttribute("readProgressMeasure");
583  if ($tempVal) {
584  $map->mReadProgressMeasure = self::convert_to_bool($tempVal);
585  }
586 
587  $tempVal = $iNode->getAttribute("writeRawScore");
588  if ($tempVal) {
589  $map->mWriteRawScore = self::convert_to_bool($tempVal);
590  }
591 
592  $tempVal = $iNode->getAttribute("writeMinScore");
593  if ($tempVal) {
594  $map->mWriteMinScore = self::convert_to_bool($tempVal);
595  }
596 
597  $tempVal = $iNode->getAttribute("writeMaxScore");
598  if ($tempVal) {
599  $map->mWriteMaxScore = self::convert_to_bool($tempVal);
600  }
601 
602  $tempVal = $iNode->getAttribute("writeCompletionStatus");
603  if ($tempVal) {
604  $map->mWriteCompletionStatus = self::convert_to_bool($tempVal);
605  }
606 
607  $tempVal = $iNode->getAttribute("writeProgressMeasure");
608  if ($tempVal) {
609  $map->mWriteProgressMeasure = self::convert_to_bool($tempVal);
610  }
611 
612  return $map;
613  }
614 
615  public static function getObjectiveMaps($iNode)
616  {
617  $tempVal = null;
618  $maps = array();
619  $children = $iNode->childNodes;
620  for ($i = 0; $i < $children->length; $i++) {
621  $curNode=$children->item($i);
622  if ($curNode->nodeType == XML_ELEMENT_NODE) {
623  if ($curNode->localName == "mapInfo") {
624  $map = new SeqObjectiveMap();
625 
626  // Look for 'targetObjectiveID'
627  $tempVal = preg_replace('/(%20)+/', ' ', trim($curNode->getAttribute("targetObjectiveID")));
628  if ($tempVal) {
629  $map->mGlobalObjID = $tempVal;
630  }
631 
632  // Look for 'readSatisfiedStatus'
633  $tempVal = $curNode->getAttribute("readSatisfiedStatus");
634  if ($tempVal) {
635  $map->mReadStatus = self::convert_to_bool($tempVal);
636  }
637 
638  // Look for 'readNormalizedMeasure'
639  $tempVal = $curNode->getAttribute("readNormalizedMeasure");
640  if ($tempVal) {
641  $map->mReadMeasure = self::convert_to_bool($tempVal);
642  }
643 
644  // Look for 'writeSatisfiedStatus'
645  $tempVal = $curNode->getAttribute("writeSatisfiedStatus");
646  if ($tempVal) {
647  $map->mWriteStatus = self::convert_to_bool($tempVal);
648  }
649 
650  // Look for 'writeNormalizedMeasure'
651  $tempVal = $curNode->getAttribute("writeNormalizedMeasure");
652  if ($tempVal) {
653  $map->mWriteMeasure = self::convert_to_bool($tempVal);
654  }
655  //add class
656  $c_map['_SeqObjectiveMap']=$map;
657  array_push($maps, $c_map);
658  }
659  }
660  }
661  if (count($maps)==null) {
662  $maps = null;
663  }
664  return $maps;
665  }
666 
667  public static function getRollupRules($iNode, $ioAct)
668  {
669  $ok = true;
670  $tempVal = null;
671  $rollupRules = array();
672 
673  // Look for 'rollupObjectiveSatisfied'
674  $tempVal = $iNode->getAttribute("rollupObjectiveSatisfied");
675  if ($tempVal) {
676  $ioAct->setIsObjRolledUp(self::convert_to_bool($tempVal));
677  }
678 
679  // Look for 'objectiveMeasureWeight'
680  $tempVal = $iNode->getAttribute("objectiveMeasureWeight");
681  if ($tempVal) {
682  $ioAct->setObjMeasureWeight($tempVal);
683  }
684  // Look for 'rollupProgressCompletion'
685  $tempVal = $iNode->getAttribute("rollupProgressCompletion");
686  if ($tempVal) {
687  $ioAct->setIsProgressRolledUp(self::convert_to_bool($tempVal));
688  }
689  $children = $iNode->childNodes;
690  for ($i = 0; $i < $children->length; $i++) {
691  $curNode=$children->item($i);
692  if ($curNode->nodeType == XML_ELEMENT_NODE) {
693  if ($curNode->localName == "rollupRule") {
694  $rule = new SeqRollupRule();
695 
696  // Look for 'childActivitySet'
697  $tempVal=$curNode->getAttribute("childActivitySet");
698  if ($tempVal) {
699  $rule->mChildActivitySet = $tempVal;
700  }
701  // Look for 'minimumCount'
702  $tempVal=$curNode->getAttribute("minimumCount");
703  if ($tempVal) {
704  $rule->mMinCount = $tempVal;
705  }
706 
707  // Look for 'minimumPercent'
708  $tempVal=$curNode->getAttribute("minimumPercent");
709  if ($tempVal) {
710  $rule->mMinPercent = $tempVal;
711  }
712  $rule->mConditions['_SeqConditionSet'] = new SeqConditionSet(true);
713  $conditions = array();
714  $ruleInfo = $curNode->childNodes;
715  for ($j = 0; $j < $ruleInfo->length; $j++) {
716  $curRule=$ruleInfo->item($j);
717  //check for element
718  if ($curRule->nodeType == XML_ELEMENT_NODE) {
719  if ($curRule->localName == "rollupConditions") {
720  $tempVal = $curRule->getAttribute("conditionCombination");
721  if ($tempVal) {
722  $rule->mConditions['_SeqConditionSet']->mCombination = $tempVal;
723  } else {
724  $rule->mConditions['_SeqConditionSet']->mCombination = COMBINATION_ANY;
725  }
726  $conds = $curRule->childNodes;
727  for ($k = 0; $k < $conds->length; $k++) {
728  $con=$conds->item($k);
729  if ($con->nodeType == XML_ELEMENT_NODE) {
730  if ($con->localName == "rollupCondition") {
731  $cond = new SeqCondition();
732  // Look for 'condition'
733  $tempVal = $con->getAttribute("condition");
734  if ($tempVal) {
735  $cond->mCondition=$tempVal;
736  }
737  // Look for 'operator'
738  $tempVal = $con->getAttribute("operator");
739  if ($tempVal) {
740  if ($tempVal=='not') {
741  $cond->mNot = true;
742  } else {
743  $cond->mNot = false;
744  }
745  }
746  //add class
747  $c_cond['_SeqCondition'] = $cond;
748  array_push($conditions, $c_cond);
749  }
750  }
751  }
752  } elseif ($curRule->localName == "rollupAction") {
753  $tempVal = $curRule->getAttribute("action");
754  if ($tempVal) {
755  $rule->setRollupAction($tempVal);
756  }
757  }
758  }
759  }
760  // Add the conditions to the condition set for the rule
761  $rule->mConditions['_SeqConditionSet']->mConditions = $conditions;
762 
763  // Add the rule to the ruleset
764  //add class
765  $c_rule['_SeqRollupRule']=$rule;
766  array_push($rollupRules, $c_rule);
767  }
768  }
769  }
770 
771  if ($rollupRules != null) {
772  $rules = new SeqRollupRuleset($rollupRules);
773  // Set the Activity's rollup rules
774  //add class
775  $c_rules['_SeqRollupRuleset']=$rules;
776  $ioAct->setRollupRules($c_rules);
777  }
778 
779  return $ioAct;
780  }
781 
782 
783  public static function getSequencingRules($iNode, $ioAct)
784  {
785  //local variables
786  $ok = true;
787  $tempVal = null;
788 
789  $preRules = array();
790  $exitRules = array();
791  $postRules = array();
792 
793  //get children
794  $children = $iNode->childNodes;
795 
796  //find sequencing rules
797  for ($i = 0; $i < $children->length; $i++) {
798  $curNode=$children->item($i);
799  if ($curNode->nodeType == XML_ELEMENT_NODE) {
800  if ($curNode->localName == "preConditionRule" || $curNode->localName == "exitConditionRule" || $curNode->localName == "postConditionRule") {
801  $rule = new SeqRule();
802  $ruleInfo = $curNode->childNodes;
803  for ($j = 0; $j < $ruleInfo->length; $j++) {
804  $curRule=$ruleInfo->item($j);
805  //echo "$curRule->localName\n";
806  if ($curRule->nodeType == XML_ELEMENT_NODE) {
807  if ($curRule->localName == "ruleConditions") {
808  $rule->mConditions = self::extractSeqRuleConditions($curRule);
809  } elseif ($curRule->localName == "ruleAction") {
810  $tempVal=$curRule->getAttribute("action");
811  if ($tempVal) {
812  $rule->mAction = $tempVal;
813  }
814  }
815  }
816  }//end for inner
817  if ($rule->mConditions != null && $rule->mAction != null) {
818  //changed from ADL Code..
819  if ($curNode->localName == "preConditionRule") {
820  //echo "ADD PRE";
821  //add class
822  $c_rule['_SeqRule'] = $rule;
823  array_push($preRules, $c_rule);
824  }
825  if ($curNode->localName == "exitConditionRule") {
826  //echo "ADD EXIT";
827  //add class
828  $c_rule['_SeqRule'] = $rule;
829  array_push($exitRules, $c_rule);
830  }
831  if ($curNode->localName == "postConditionRule") {
832  //echo "ADD POST";
833  //add class
834  $c_rule['_SeqRule'] = $rule;
835  array_push($postRules, $c_rule);
836  }
837  }
838  } //end if preCondition
839  } //end if ELEMENT
840  }
841 
842  if (count($preRules) > 0) {
843  $rules = new SeqRuleset($preRules);
844  //add class
845  $c_rules['_SeqRuleset']=$rules;
846  $ioAct->setPreSeqRules($c_rules);
847  }
848 
849  if (count($exitRules) > 0) {
850  $rules = new SeqRuleset($exitRules);
851  //add class
852  $c_rules['_SeqRuleset']=$rules;
853  $ioAct->setExitSeqRules($c_rules);
854  }
855  if (count($postRules) > 0) {
856  $rules = new SeqRuleset($postRules);
857  //add class
858  $c_rules['_SeqRuleset']=$rules;
859  $ioAct->setPostSeqRules($c_rules);
860  }
861  //echo json_encode($ioAct);
862 
863  return $ioAct;
864  }
865 
866  public static function extractSeqRuleConditions($iNode)
867  {
868  $tempVal = null;
869  $condSet = new SeqConditionSet(false);
870 
871  $conditions = array();
872  $tempVal=$iNode->getAttribute("conditionCombination");
873  if ($tempVal) {
874  $condSet->mCombination=$tempVal;
875  } else {
876  $condSet->mCombination=COMBINATION_ALL;
877  }
878  $condInfo = $iNode->childNodes;
879  for ($i = 0; $i < $condInfo->length; $i++) {
880  $curCond=$condInfo->item($i);
881  if ($curCond->nodeType == XML_ELEMENT_NODE) {
882  if ($curCond->localName == "ruleCondition") {
883  $cond = new SeqCondition();
884 
885  //look for condition
886  $tempVal=$curCond->getAttribute("condition");
887  if ($tempVal) {
888  $cond->mCondition = $tempVal;
889  }
890 
891  // Look for 'referencedObjective'
892  $tempVal=preg_replace('/(%20)+/', ' ', trim($curCond->getAttribute("referencedObjective")));
893  if ($tempVal) {
894  $cond->mObjID = $tempVal;
895  }
896 
897  // Look for 'measureThreshold'
898  $tempVal=$curCond->getAttribute("measureThreshold");
899  if ($tempVal) {
900  $cond->mThreshold = $tempVal;
901  }
902 
903  // Look for 'operator'
904  $tempVal = $curCond->getAttribute("operator");
905  if ($tempVal) {
906  if ($tempVal == 'not') {
907  $cond->mNot = true;
908  } else {
909  $cond->mNot = false;
910  }
911  }
912 
913  //add class
914  $c_cond['_SeqCondition']=$cond;
915  array_push($conditions, $c_cond);
916  }
917  }
918  }
919 
920  if (count($conditions)>0) {
921  $condSet->mConditions = $conditions;
922  } else {
923  $condSet->mConditions = null;
924  }
925  //add class
926  $c_condSet['_SeqConditionSet']=$condSet;
927  return $c_condSet;
928  }
929 
930  public static function getAuxResources($iNode, $ioAct)
931  {
932  $ok = true;
933  $tempVal = null;
934  $auxRes = array();
935  //get children
936  $children = $iNode->childNodes;
937 
938  //find ressources
939  for ($i = 0; $i < $children->length; $i++) {
940  $curNode=$children->item($i);
941  if ($curNode->nodeType == XML_ELEMENT_NODE) {
942  if ($curNode->localName == "auxiliaryResource") {
943  //found it
944  $res = new ADLAuxiliaryResource();
945 
946  // Get the resource's purpose
947  $tempVal=$curNode->getAttribute("purpose");
948  if ($tempVal) {
949  $res->mType = $tempVal;
950  }
951  // Get the resource's ID
952  $tempVal=preg_replace('/(%20)+/', ' ', trim($curNode->getAttribute("auxiliaryResourceID")));
953  if ($tempVal) {
954  $res->mResourceID = $tempVal;
955  }
956  array_push($auxRes, $res);
957  }
958  }
959  }
960  //add class
961  $c_auxRes['_ADLAuxiliaryResource']=$auxRes;
962  $ioAct->setAuxResources($c_auxRes);
963  return $ioAct;
964  }
965 
966  //helper functions
967 
968  private static function convert_to_bool($string)
969  {
970  if (strtoupper($string)=="FALSE") {
971  return false;
972  } else {
973  return true;
974  }
975  }
976 
977 
978  private static function lookupElement($iNode, $iElement)
979  {
980  $value = null;
981  $curNode = null;
982  $children = null;
983 
984  if ($iNode != null && $iElement != null) {
985  $children = $iNode->childNodes;
986  for ($i = 0; $i < $children->length; $i++) {
987  $curNode = $children->item($i);
988  if (($curNode->nodeType == XML_ELEMENT_NODE)) {
989  if ($curNode->localName == $iElement) {
990  break;
991  }
992  }
993  }
994  if ($curNode != null) {
995  $comp = $curNode->localName;
996  if ($comp != null) {
997  if ($comp != $iElement) {
998  $curNode = null;
999  }
1000  } else {
1001  $curNode = null;
1002  }
1003  }
1004  } else {
1005  //$iElement is null
1006  $curNode = $iNode;
1007  }
1008 
1009  if ($curNode != null) {
1010  $children = $curNode->childNodes;
1011  if ($children != null) {
1012  for ($i = 0; $i < $children->length; $i++) {
1013  $curNode = $children->item($i);
1014  // make sure we have a 'text' element
1015  if (($curNode->nodeType == XML_TEXT_NODE) ||($curNode->nodeType == XML_CDATA_SECTION_NODE)) {
1016  $value = $value . $curNode->nodeValue;
1017  }
1018  }
1019  }
1020  }
1021  return $value;
1022  }
1023  } //end class
static getObjectives($iNode, $ioAct)
const COMBINATION_ALL
static lookupElement($iNode, $iElement)
static getADLSeqMaps($iNode, $curseqobj)
static getObjectiveMaps($iNode)
if($source===NULL) $organizations
const COMBINATION_ANY
buildNode($node, $seq, $doc)
foreach($_POST as $key=> $value) $res
$rule
Definition: showstats.php:43
static extractSeqRuleConditions($iNode)
static getSequencingRules($iNode, $ioAct)
static getAuxResources($iNode, $ioAct)
Create styles array
The data for the language used.
static getADLSEQObjectives($iNode, $ioAct)
extractSeqInfo($iNode, $ioAct)
$ret
Definition: parser.php:6
$i
Definition: disco.tpl.php:19
buildNodeSeqTree($file)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static fillinADLSeqMaps($iNode, $map)
static convert_to_bool($string)
static getRollupRules($iNode, $ioAct)