24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
77 $this->type = $a_type;
78 $this->items = array();
79 $this->shuffle =
true;
107 $this->type = $a_type;
156 return count($this->items);
170 $order = $a_item->getOrder();
171 if (array_key_exists($order, $this->items))
174 for ($i = 0; $i < $order; $i++)
176 array_push($newitems, $this->items[$i]);
178 array_push($newitems, $a_item);
179 for ($i = $order; $i < count($this->items); $i++)
181 array_push($newitems, $this->items[$i]);
184 foreach ($newitems as $idx => $item)
186 $newitems[$idx]->setOrder($i);
189 $this->items = $newitems;
193 array_push($this->items, $a_item);
209 foreach ($this->items as
$key => $item)
211 if ($item->getOrder() == $order)
229 if (array_key_exists($order, $this->items))
231 unset($this->items[$order]);
233 foreach ($this->items as
$key => $item)
235 $this->items[
$key]->setOrder($order);
253 foreach ($this->items as
$key => $item)
255 if ($item->getOrder() == $order)
257 $item->setLowerBound($bound);
274 foreach ($this->items as
$key => $item)
276 if ($item->getOrder() == $order)
278 $item->setUpperBound($bound);
294 if (array_key_exists($a_index, $this->items))
296 return $this->items[$a_index];
314 $this->items = array();
328 $this->shuffle = $a_shuffle ? TRUE : FALSE;
355 mt_srand((
double)microtime()*1000000);
366 $array[$j] = $array[$i];
385 foreach ($this->items as $item)
387 if (strlen($item->getAnswertext()) > $maxwidth)
389 $maxwidth = strlen($item->getAnswertext());
406 foreach ($this->items as
$key => $item)
408 if ($item->getPoints() > $maxpoints)
410 $maxpoints = $item->getPoints();
414 foreach ($this->items as
$key => $item)
416 if ($item->getPoints() == $maxpoints)
418 array_push($keys,
$key);
431 $best_solutions = array();
432 foreach ($this->
getItems() as $answer)
434 if (is_array($best_solutions[$answer->getPoints()]))
436 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
440 $best_solutions[$answer->getPoints()] = array();
441 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
444 krsort($best_solutions, SORT_NUMERIC);
445 reset($best_solutions);
446 $found = current($best_solutions);
447 return join(
" " . $lng->txt(
"or") .
" ", $found);
452 foreach ($this->
getItems() as $answer)
454 if ($answer->getPoints() >= $maxpoints)
456 $maxpoints = $answer->getPoints();
457 $foundvalue = $answer->getAnswertext();