4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
57 $this->type = $a_type;
58 $this->items = array();
59 $this->shuffle =
true;
85 $this->type = $a_type;
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);
369 $best_solutions = array();
370 foreach ($this->
getItems($shuffler) as $answer)
372 if (isset($best_solutions[$answer->getPoints()]) && is_array($best_solutions[$answer->getPoints()]))
374 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
378 $best_solutions[$answer->getPoints()] = array();
379 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
382 krsort($best_solutions, SORT_NUMERIC);
383 reset($best_solutions);
384 $found = current($best_solutions);
385 return join(
" " . $lng->txt(
"or") .
" ", $found);
390 foreach ($this->
getItems($shuffler) as $answer)
392 if ($answer->getPoints() >= $maxpoints)
394 $maxpoints = $answer->getPoints();
395 $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.
getItems(ilArrayElementShuffler $shuffler)
Gets the items of a cloze gap.
getMaxWidth()
Returns the maximum width of the gap.
assClozeGap($a_type)
assClozeGap constructor
getItemCount()
Gets the item count.
getType()
Gets the cloze gap type.
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.
getBestSolutionOutput(ilArrayElementShuffler $shuffler)