ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestEvaluationPassData.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once('Modules/Test/exceptions/class.ilTestEvaluationException.php');
5 
20 {
27 
33  private $workingtime;
34 
40  private $questioncount;
41 
47  private $maxpoints;
48 
54  private $reachedpoints;
55 
62 
68  var $pass;
69 
75  private $requestedHintsCount = null;
76 
82  private $deductedHintPoints = null;
83 
89  private $obligationsAnswered = null;
90 
91  public function __sleep()
92  {
93  return array('answeredQuestions', 'pass', 'nrOfAnsweredQuestions', 'reachedpoints',
94  'maxpoints', 'questioncount', 'workingtime');
95  }
96 
103  {
104  $this->answeredQuestions = array();
105  }
106 
107  public function getNrOfAnsweredQuestions()
108  {
110  }
111 
113  {
114  $this->nrOfAnsweredQuestions = $nrOfAnsweredQuestions;
115  }
116 
117  public function getReachedPoints()
118  {
119  return $this->reachedpoints;
120  }
121 
123  {
124  $this->reachedpoints = $reachedpoints;
125  }
126 
127  public function getMaxPoints()
128  {
129  return $this->maxpoints;
130  }
131 
132  public function setMaxPoints($maxpoints)
133  {
134  $this->maxpoints = $maxpoints;
135  }
136 
137  public function getQuestionCount()
138  {
139  return $this->questioncount;
140  }
141 
143  {
144  $this->questioncount = $questioncount;
145  }
146 
147  public function getWorkingTime()
148  {
149  return $this->workingtime;
150  }
151 
152  public function setWorkingTime($workingtime)
153  {
154  $this->workingtime = $workingtime;
155  }
156 
157  public function getPass()
158  {
159  return $this->pass;
160  }
161 
162  public function setPass($a_pass)
163  {
164  $this->pass = $a_pass;
165  }
166 
168  {
170  }
171 
172  function addAnsweredQuestion($question_id, $max_points, $reached_points, $isAnswered, $sequence = NULL, $manual = 0)
173  {
174  $this->answeredQuestions[] = array(
175  "id" => $question_id,
176  "points" => round($max_points, 2),
177  "reached" => round($reached_points, 2),
178  'isAnswered' => $isAnswered,
179  "sequence" => $sequence,
180  'manual' => $manual
181  );
182  }
183 
184  function &getAnsweredQuestion($index)
185  {
186  if (array_key_exists($index, $this->answeredQuestions))
187  {
188  return $this->answeredQuestions[$index];
189  }
190  else
191  {
192  return NULL;
193  }
194  }
195 
196  function &getAnsweredQuestionByQuestionId($question_id)
197  {
198  foreach ($this->answeredQuestions as $question)
199  {
200  if ($question["id"] == $question_id)
201  {
202  return $question;
203  }
204  }
205  return NULL;
206  }
207 
209  {
210  return count($this->answeredQuestions);
211  }
212 
218  public function getRequestedHintsCount()
219  {
221  }
222 
229  {
230  $this->requestedHintsCount = $requestedHintsCount;
231  }
232 
238  public function getDeductedHintPoints()
239  {
241  }
242 
249  {
250  $this->deductedHintPoints = $deductedHintPoints;
251  }
252 
259  {
260  $this->obligationsAnswered = (bool)$obligationsAnswered;
261  }
262 
273  public function areObligationsAnswered()
274  {
275  if( !is_null($this->obligationsAnswered) )
276  {
278  }
279 
280  if( is_array($this->answeredQuestions) && count($this->answeredQuestions) )
281  {
282  foreach($this->answeredQuestions as $question)
283  {
284  if( !$question['isAnswered'] )
285  {
286  return false;
287  }
288  }
289 
290  return true;
291  }
292 
293  throw new ilTestEvaluationException(
294  'Neither the boolean property ilTestEvaluationPassData::obligationsAnswered was set, '.
295  'nor the property array property ilTestEvaluationPassData::answeredQuestions contains elements!'
296  );
297  }
298 
299 } // END ilTestEvaluationPassData