Changeset 186 for Dev/trunk/classes/Session.php
- Timestamp:
- 12/16/11 11:19:54 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/Session.php
r174 r186 37 37 } 38 38 39 /* 40 * function evaluate(() 41 * Evaluates all the references of this object. 42 */ 43 public function evaluate() 44 { 45 $dbi = new DatabaseInterface(); 46 if(is_string($this->creator)) 47 { 48 $result = $dbi->get("user", array("uid" => $this->creator)); 49 if(!isset($result[0])) 50 return false; 51 $this->creator = $result[0]; 52 } 53 if(!empty($this->pipeline) && is_string($this->pipeline[0])) 54 { 55 $newPipeline = array(); 56 foreach($this->pipeline as $element) 57 { 58 //Check if the element's UID can be found in surveys, if not: 59 //Check applications. If it isn't in either: invalid reference. 60 $result = $dbi->get("survey", array("uid" => $element)); 61 if(!isset($result[0])) 62 $result = $dbi->get("application", array("uid" => $element)); 63 if(!isset($result[0])) 64 return false; 65 $newPipeline[] = $result[0]; 66 } 67 $this->pipeline = $newPipeline; 68 } 69 if(!empty($this->answersets) && is_string($this->answersets[0])) 70 { 71 $newAnswerSets = array(); 72 foreach($this->answersets as $element) 73 { 74 $result = $dbi->get("answerset", array("uid" => $element)); 75 if(!isset($result[0])) 76 return false; 77 $newAnswerSets[] = $result[0]; 78 } 79 $this->answersets = $newAnswerSets; 80 } 81 return true; 82 } 83 39 84 /** 40 85 * function toSPSS 41 86 * @param type $location 42 87 * Writes an SPSS parseable file at the given location, named '$datetime_$title.txt' 88 * One big note about toSPSS: If this session contains multiple instances of THE SAME Survey, 89 * the world burns, people die, etcetera. (or, in a more fortunate case, the latest values 90 * are written to the file whilst the others get lost. 43 91 */ 44 92 public function toSPSS($location) 45 93 { 94 $this->evaluate(); 46 95 if(!is_dir($location)) 47 96 { … … 58 107 if(get_class($element) == "Survey") 59 108 { 109 $element->evaluate(); 60 110 foreach($element->questions as $question) 61 111 { 112 //TODO: This might need fixing after lazy initialization refactoring. 62 113 $headers[] = $element->title . '_' . $question->uid; 63 114 }
Note: See TracChangeset
for help on using the changeset viewer.