4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
58 $this->items =
array();
59 $this->shuffle =
true;
98 return $shuffler->
shuffle($this->items);
129 return count($this->items);
143 $order = $a_item->getOrder();
144 if (array_key_exists($order, $this->items))
147 for ($i = 0; $i < $order; $i++)
149 array_push($newitems, $this->items[$i]);
151 array_push($newitems, $a_item);
152 for ($i = $order; $i < count($this->items); $i++)
154 array_push($newitems, $this->items[$i]);
157 foreach ($newitems as $idx => $item)
159 $newitems[$idx]->setOrder($i);
162 $this->items = $newitems;
166 array_push($this->items, $a_item);
182 foreach ($this->items as $key => $item)
184 if ($item->getOrder() == $order)
186 $item->setPoints($points);
202 if (array_key_exists($order, $this->items))
204 unset($this->items[$order]);
206 foreach ($this->items as $key => $item)
208 $this->items[$key]->setOrder($order);
226 foreach ($this->items as $key => $item)
228 if ($item->getOrder() == $order)
230 $item->setLowerBound($bound);
247 foreach ($this->items as $key => $item)
249 if ($item->getOrder() == $order)
251 $item->setUpperBound($bound);
267 if (array_key_exists($a_index, $this->items))
269 return $this->items[$a_index];
287 $this->items =
array();
299 $this->shuffle = (bool) $a_shuffle;
323 foreach ($this->items as $item)
325 if (strlen($item->getAnswertext()) > $maxwidth)
327 $maxwidth = strlen($item->getAnswertext());
344 foreach ($this->items as $key => $item)
346 if ($item->getPoints() > $maxpoints)
348 $maxpoints = $item->getPoints();
352 foreach ($this->items as $key => $item)
354 if ($item->getPoints() == $maxpoints)
356 array_push($keys, $key);
374 $best_solutions =
array();
375 if($combinations !== null && $combinations[
'best_solution'] == 1)
377 $best_solutions[$combinations[
'points']] =
array();
378 array_push($best_solutions[$combinations[
'points']], $combinations[
'answer']);
382 foreach ($this->
getItems($shuffler) as $answer)
384 if (isset($best_solutions[$answer->getPoints()]) && is_array($best_solutions[$answer->getPoints()]))
386 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
390 $best_solutions[$answer->getPoints()] =
array();
391 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
396 krsort($best_solutions, SORT_NUMERIC);
397 reset($best_solutions);
398 $found = current($best_solutions);
399 return join(
" " . $lng->txt(
"or") .
" ", $found);
404 foreach ($this->
getItems($shuffler) as $answer)
406 if ($answer->getPoints() >= $maxpoints)
408 $maxpoints = $answer->getPoints();
409 $foundvalue = $answer->getAnswertext();
setItemUpperBound($order, $bound)
Sets the upper bound for a given item.
setType($a_type=0)
Sets the cloze gap type.
const CLOZE_TEXT
Cloze question constants.
deleteItem($order)
Deletes an item at a given index.
setItemLowerBound($order, $bound)
Sets the lower bound for a given item.
clearItems()
Removes all gap items.
Class for cloze question gaps.
setItemPoints($order, $points)
Sets the points for a given item.
getItemsRaw()
Gets the items of a cloze gap.
addItem($a_item)
Adds a gap item.
getBestSolutionIndexes()
Returns the indexes of the best solutions for the gap.
Create styles array
The data for the language used.
getItems(ilArrayElementShuffler $shuffler)
Gets the items of a cloze gap.
getMaxWidth()
Returns the maximum width of the gap.
getItemCount()
Gets the item count.
getType()
Gets the cloze gap type.
getBestSolutionOutput(ilArrayElementShuffler $shuffler, $combinations=null)
getShuffle()
Gets the shuffle state of the items.
getItem($a_index)
Gets the item with a given index.
setShuffle($a_shuffle=true)
Sets the shuffle state of the items.
__construct($a_type)
assClozeGap constructor