4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
61 $this->items = array();
62 $this->shuffle =
true;
100 return $shuffler->
shuffle($this->items);
131 return count($this->items);
145 $order = $a_item->getOrder();
146 if (array_key_exists($order, $this->items)) {
148 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++) {
153 array_push($newitems, $this->items[
$i]);
156 foreach ($newitems as $idx => $item) {
157 $newitems[$idx]->setOrder(
$i);
160 $this->items = $newitems;
162 array_push($this->items, $a_item);
178 foreach ($this->items as
$key => $item) {
179 if ($item->getOrder() == $order) {
180 $item->setPoints($points);
196 if (array_key_exists($order, $this->items)) {
197 unset($this->items[$order]);
199 foreach ($this->items as
$key => $item) {
200 $this->items[
$key]->setOrder($order);
218 foreach ($this->items as
$key => $item) {
219 if ($item->getOrder() == $order) {
220 $item->setLowerBound($bound);
237 foreach ($this->items as
$key => $item) {
238 if ($item->getOrder() == $order) {
239 $item->setUpperBound($bound);
256 if (array_key_exists($a_index, $this->items)) {
257 return $this->items[$a_index];
273 $this->items = array();
285 $this->shuffle = (bool) $a_shuffle;
309 foreach ($this->items as $item) {
310 if (strlen($item->getAnswertext()) > $maxwidth) {
311 $maxwidth = strlen($item->getAnswertext());
328 foreach ($this->items as
$key => $item) {
329 if ($item->getPoints() > $maxpoints) {
330 $maxpoints = $item->getPoints();
334 foreach ($this->items as
$key => $item) {
335 if ($item->getPoints() == $maxpoints) {
354 $best_solutions = array();
355 if ($combinations !== null && $combinations[
'best_solution'] == 1) {
356 $best_solutions[$combinations[
'points']] = array();
357 array_push($best_solutions[$combinations[
'points']], $combinations[
'answer']);
359 foreach ($this->
getItems($shuffler) as $answer) {
360 if (isset($best_solutions[$answer->getPoints()]) && is_array($best_solutions[$answer->getPoints()])) {
361 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
363 $best_solutions[$answer->getPoints()] = array();
364 array_push($best_solutions[$answer->getPoints()], $answer->getAnswertext());
369 krsort($best_solutions, SORT_NUMERIC);
370 reset($best_solutions);
371 $found = current($best_solutions);
372 return join(
" " .
$lng->txt(
"or") .
" ", $found);
377 foreach ($this->
getItems($shuffler) as $answer) {
378 if ($answer->getPoints() >= $maxpoints) {
379 $maxpoints = $answer->getPoints();
380 $foundvalue = $answer->getAnswertext();
412 require_once
'Services/Math/classes/class.EvalMath.php';
416 $lowerBound = $math->evaluate($item->getLowerBound());
417 $upperBound = $math->evaluate($item->getUpperBound());
418 $preciseValue = $math->evaluate($item->getAnswertext());
420 if ($lowerBound < $preciseValue || $upperBound > $preciseValue) {
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.
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