4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
55 $this->type = $a_type;
56 $this->items = array();
57 $this->shuffle =
true;
83 $this->type = $a_type;
132 return count($this->items);
146 $order = $a_item->getOrder();
147 if (array_key_exists($order, $this->items))
150 for ($i = 0; $i < $order; $i++)
152 array_push($newitems, $this->items[$i]);
154 array_push($newitems, $a_item);
155 for ($i = $order; $i < count($this->items); $i++)
157 array_push($newitems, $this->items[$i]);
160 foreach ($newitems as $idx => $item)
162 $newitems[$idx]->setOrder($i);
165 $this->items = $newitems;
169 array_push($this->items, $a_item);
185 foreach ($this->items as $key => $item)
187 if ($item->getOrder() == $order)
189 $item->setPoints($points);
205 if (array_key_exists($order, $this->items))
207 unset($this->items[$order]);
209 foreach ($this->items as $key => $item)
211 $this->items[$key]->setOrder($order);
229 foreach ($this->items as $key => $item)
231 if ($item->getOrder() == $order)
233 $item->setLowerBound($bound);
250 foreach ($this->items as $key => $item)
252 if ($item->getOrder() == $order)
254 $item->setUpperBound($bound);
270 if (array_key_exists($a_index, $this->items))
272 return $this->items[$a_index];
290 $this->items = array();
302 $this->shuffle = (bool) $a_shuffle;
331 mt_srand((
double)microtime()*1000000);
342 $array[$j] = $array[$i];
361 foreach ($this->items as $item)
363 if (strlen($item->getAnswertext()) > $maxwidth)
365 $maxwidth = strlen($item->getAnswertext());
382 foreach ($this->items as $key => $item)
384 if ($item->getPoints() > $maxpoints)
386 $maxpoints = $item->getPoints();
390 foreach ($this->items as $key => $item)
392 if ($item->getPoints() == $maxpoints)
394 array_push($keys, $key);
407 $best_solutions = array();
408 foreach ($this->
getItems() as $answer)
410 if (is_array($best_solutions[$answer->getPoints()]))
412 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
416 $best_solutions[$answer->getPoints()] = array();
417 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
420 krsort($best_solutions, SORT_NUMERIC);
421 reset($best_solutions);
422 $found = current($best_solutions);
423 return join(
" " . $lng->txt(
"or") .
" ", $found);
428 foreach ($this->
getItems() as $answer)
430 if ($answer->getPoints() >= $maxpoints)
432 $maxpoints = $answer->getPoints();
433 $foundvalue = $answer->getAnswertext();