23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
95 $this->answers = array();
96 $this->correctanswers = 0;
107 if (($this->title) and ($this->author) and ($this->question) and (count($this->answers) >= $this->correctanswers) and ($this->
getMaximumPoints() > 0))
130 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
132 array($this->
getId())
135 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, textgap_rating, correctanswers, answerscount) VALUES (%s, %s, %s, %s)",
136 array(
"integer",
"text",
"integer",
"integer"),
145 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
147 array($this->
getId())
150 foreach ($this->answers as $key => $value)
152 $answer_obj = $this->answers[$key];
153 $next_id = $ilDB->nextId(
'qpl_a_textsubset');
154 $query = $ilDB->manipulateF(
"INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
155 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer'),
159 $answer_obj->getAnswertext(),
160 $answer_obj->getPoints(),
161 $answer_obj->getOrder(),
185 if ($result->numRows() == 1)
187 $data = $ilDB->fetchAssoc($result);
188 $this->
setId($question_id);
197 include_once(
"./Services/RTE/classes/class.ilRTE.php");
206 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
210 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
211 if ($result->numRows() > 0)
213 while (
$data = $ilDB->fetchAssoc($result))
229 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
230 if (array_key_exists($order, $this->answers))
234 $newchoices = array();
235 for ($i = 0; $i < $order; $i++)
237 array_push($newchoices, $this->answers[$i]);
239 array_push($newchoices, $answer);
240 for ($i = $order; $i < count($this->answers); $i++)
246 $this->answers = $newchoices;
268 $this_id = $this->
getId();
270 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
297 $clone->copyPageOfQuestion($this_id);
299 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
301 $clone->duplicateFeedbackGeneric($this_id);
302 $clone->onDuplicate($this_id);
321 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
324 $source_questionpool = $this->
getObjId();
325 $clone->setObjId($target_questionpool);
352 return count($this->answers);
366 if ($index < 0)
return NULL;
367 if (count($this->answers) < 1)
return NULL;
368 if ($index >= count($this->answers))
return NULL;
370 return $this->answers[$index];
383 if ($index < 0)
return;
384 if (count($this->answers) < 1)
return;
385 if ($index >= count($this->answers))
return;
386 unset($this->answers[$index]);
387 $this->answers = array_values($this->answers);
388 for ($i = 0; $i < count($this->answers); $i++)
390 if ($this->answers[$i]->getOrder() > $index)
392 $this->answers[$i]->setOrder($i);
405 $this->answers = array();
417 foreach ($this->answers as $answer)
419 if ($answer->getPoints() > 0)
421 array_push(
$points, $answer->getPoints());
428 $maxpoints +=
$points[$counter];
441 $available_answers = array();
442 foreach ($this->answers as $answer)
444 array_push($available_answers, $answer->getAnswertext());
446 return $available_answers;
461 include_once
"./Services/Utilities/classes/class.ilStr.php";
464 foreach (
$answers as $key => $value)
472 if (strcmp($value, $answer) == 0)
return $key;
475 if (levenshtein($value, $answer) <= 1)
return $key;
478 if (levenshtein($value, $answer) <= 2)
return $key;
481 if (levenshtein($value, $answer) <= 3)
return $key;
484 if (levenshtein($value, $answer) <= 4)
return $key;
487 if (levenshtein($value, $answer) <= 5)
return $key;
515 switch ($a_text_rating)
524 $this->text_rating = $a_text_rating;
552 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
553 array(
'integer',
'integer',
'integer'),
556 while (
$data = $ilDB->fetchAssoc($result))
558 $enteredtext =
$data[
"value1"];
560 if ($index !== FALSE)
562 unset($available_answers[$index]);
563 $points += $this->answers[$index]->getPoints();
579 $this->correctanswers = $a_correct_answers;
590 $this->allanswers = $a_all_answers;
630 include_once
"./Modules/Test/classes/class.ilObjTest.php";
635 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
636 array(
'integer',
'integer',
'integer'),
639 foreach (
$_POST as $key => $value)
641 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
645 $next_id = $ilDB->nextId(
'tst_solutions');
646 $affectedRows = $ilDB->insert(
"tst_solutions", array(
647 "solution_id" => array(
"integer", $next_id),
648 "active_fi" => array(
"integer", $active_id),
649 "question_fi" => array(
"integer", $this->
getId()),
650 "value1" => array(
"clob", trim($value)),
651 "value2" => array(
"clob", null),
652 "pass" => array(
"integer",
$pass),
653 "tstamp" => array(
"integer", time())
661 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
669 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
687 return "assTextSubset";
699 foreach ($this->answers as $answer)
701 if (!is_array($join[$answer->getPoints() .
""]))
703 $join[$answer->getPoints() .
""] = array();
705 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
719 foreach ($this->answers as $answer)
721 $len = strlen($answer->getAnswertext());
722 if ($len > $maxwidth) $maxwidth = $len;
724 return $maxwidth + 3;
735 return "qpl_qst_textsubset";
746 return "qpl_a_textsubset";
770 $adapter->setCellValue($startrow, 0, $this->lng->txt($this->getQuestionType()),
CELL_FORMAT_TITLE);
773 foreach ($solutions as $solution)
775 $adapter->setCellValue($startrow + $i, 0, $solution[
"value1"]);
778 return $startrow + $i + 1;