ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestEvaluationPassData.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
25 require_once('Modules/Test/exceptions/class.ilTestEvaluationException.php');
26 
27 
42 {
49 
55  private $workingtime;
56 
62  private $questioncount;
63 
69  private $maxpoints;
70 
76  private $reachedpoints;
77 
84 
90  var $pass;
91 
97  private $requestedHintsCount = null;
98 
104  private $deductedHintPoints = null;
105 
111  private $obligationsAnswered = null;
112 
113  public function __sleep()
114  {
115  return array('answeredQuestions', 'pass', 'nrOfAnsweredQuestions', 'reachedpoints',
116  'maxpoints', 'questioncount', 'workingtime');
117  }
118 
125  {
126  $this->answeredQuestions = array();
127  }
128 
129  public function getNrOfAnsweredQuestions()
130  {
132  }
133 
135  {
136  $this->nrOfAnsweredQuestions = $nrOfAnsweredQuestions;
137  }
138 
139  public function getReachedPoints()
140  {
141  return $this->reachedpoints;
142  }
143 
145  {
146  $this->reachedpoints = $reachedpoints;
147  }
148 
149  public function getMaxPoints()
150  {
151  return $this->maxpoints;
152  }
153 
154  public function setMaxPoints($maxpoints)
155  {
156  $this->maxpoints = $maxpoints;
157  }
158 
159  public function getQuestionCount()
160  {
161  return $this->questioncount;
162  }
163 
165  {
166  $this->questioncount = $questioncount;
167  }
168 
169  public function getWorkingTime()
170  {
171  return $this->workingtime;
172  }
173 
174  public function setWorkingTime($workingtime)
175  {
176  $this->workingtime = $workingtime;
177  }
178 
179  public function getPass()
180  {
181  return $this->pass;
182  }
183 
184  public function setPass($a_pass)
185  {
186  $this->pass = $a_pass;
187  }
188 
190  {
192  }
193 
194  function addAnsweredQuestion($question_id, $max_points, $reached_points, $isAnswered, $sequence = NULL)
195  {
196  $this->answeredQuestions[] = array(
197  "id" => $question_id,
198  "points" => round($max_points, 2),
199  "reached" => round($reached_points, 2),
200  'isAnswered' => $isAnswered,
201  "sequence" => $sequence
202  );
203  }
204 
205  function &getAnsweredQuestion($index)
206  {
207  if (array_key_exists($index, $this->answeredQuestions))
208  {
209  return $this->answeredQuestions[$index];
210  }
211  else
212  {
213  return NULL;
214  }
215  }
216 
217  function &getAnsweredQuestionByQuestionId($question_id)
218  {
219  foreach ($this->answeredQuestions as $question)
220  {
221  if ($question["id"] == $question_id)
222  {
223  return $question;
224  }
225  }
226  return NULL;
227  }
228 
230  {
231  return count($this->answeredQuestions);
232  }
233 
239  public function getRequestedHintsCount()
240  {
242  }
243 
250  {
251  $this->requestedHintsCount = $requestedHintsCount;
252  }
253 
259  public function getDeductedHintPoints()
260  {
262  }
263 
270  {
271  $this->deductedHintPoints = $deductedHintPoints;
272  }
273 
280  {
281  $this->obligationsAnswered = (bool)$obligationsAnswered;
282  }
283 
294  public function areObligationsAnswered()
295  {
296  if( !is_null($this->obligationsAnswered) )
297  {
299  }
300 
301  if( is_array($this->answeredQuestions) && count($this->answeredQuestions) )
302  {
303  foreach($this->answeredQuestions as $question)
304  {
305  if( !$question['isAnswered'] )
306  {
307  return false;
308  }
309  }
310 
311  return true;
312  }
313 
314  throw new ilTestEvaluationException(
315  'Neither the boolean property ilTestEvaluationPassData::obligationsAnswered was set, '.
316  'nor the property array property ilTestEvaluationPassData::answeredQuestions contains elements!'
317  );
318  }
319 
320 } // END ilTestEvaluationPassData