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())
136 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, textgap_rating, correctanswers, answerscount) VALUES (%s, %s, %s, %s)",
137 array(
"integer",
"text",
"integer",
"integer"),
146 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
148 array($this->
getId())
151 foreach ($this->answers as $key => $value)
153 $answer_obj = $this->answers[$key];
154 $next_id = $ilDB->nextId(
'qpl_a_textsubset');
155 $query = $ilDB->manipulateF(
"INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
156 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer'),
160 $answer_obj->getAnswertext(),
161 $answer_obj->getPoints(),
162 $answer_obj->getOrder(),
186 if ($result->numRows() == 1)
188 $data = $ilDB->fetchAssoc($result);
189 $this->
setId($question_id);
198 include_once(
"./Services/RTE/classes/class.ilRTE.php");
202 $this->answerscount =
$data[
"answerscount"];
208 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
212 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
213 if ($result->numRows() > 0)
215 while (
$data = $ilDB->fetchAssoc($result))
231 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
232 if (array_key_exists($order, $this->answers))
236 $newchoices = array();
237 for ($i = 0; $i < $order; $i++)
239 array_push($newchoices, $this->answers[$i]);
241 array_push($newchoices, $answer);
242 for ($i = $order; $i < count($this->answers); $i++)
248 $this->answers = $newchoices;
270 $this_id = $this->
getId();
272 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
299 $clone->copyPageOfQuestion($this_id);
301 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
303 $clone->duplicateFeedbackGeneric($this_id);
304 $clone->onDuplicate($this_id);
323 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
326 $source_questionpool = $this->
getObjId();
327 $clone->setObjId($target_questionpool);
354 return count($this->answers);
368 if ($index < 0)
return NULL;
369 if (count($this->answers) < 1)
return NULL;
370 if ($index >= count($this->answers))
return NULL;
372 return $this->answers[$index];
385 if ($index < 0)
return;
386 if (count($this->answers) < 1)
return;
387 if ($index >= count($this->answers))
return;
388 unset($this->answers[$index]);
389 $this->answers = array_values($this->answers);
390 for ($i = 0; $i < count($this->answers); $i++)
392 if ($this->answers[$i]->getOrder() > $index)
394 $this->answers[$i]->setOrder($i);
407 $this->answers = array();
419 foreach ($this->answers as $answer)
421 if ($answer->getPoints() > 0)
423 array_push(
$points, $answer->getPoints());
430 $maxpoints +=
$points[$counter];
443 $available_answers = array();
444 foreach ($this->answers as $answer)
446 array_push($available_answers, $answer->getAnswertext());
448 return $available_answers;
463 include_once
"./Services/Utilities/classes/class.ilStr.php";
466 foreach (
$answers as $key => $value)
474 if (strcmp($value, $answer) == 0)
return $key;
477 if (levenshtein($value, $answer) <= 1)
return $key;
480 if (levenshtein($value, $answer) <= 2)
return $key;
483 if (levenshtein($value, $answer) <= 3)
return $key;
486 if (levenshtein($value, $answer) <= 4)
return $key;
489 if (levenshtein($value, $answer) <= 5)
return $key;
517 switch ($a_text_rating)
526 $this->text_rating = $a_text_rating;
554 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
555 array(
'integer',
'integer',
'integer'),
558 while (
$data = $ilDB->fetchAssoc($result))
560 $enteredtext =
$data[
"value1"];
562 if ($index !== FALSE)
564 unset($available_answers[$index]);
565 $points += $this->answers[$index]->getPoints();
581 $this->correctanswers = $a_correct_answers;
621 include_once
"./Modules/Test/classes/class.ilObjTest.php";
626 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
627 array(
'integer',
'integer',
'integer'),
630 foreach (
$_POST as $key => $value)
632 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
636 $next_id = $ilDB->nextId(
'tst_solutions');
637 $affectedRows = $ilDB->insert(
"tst_solutions", array(
638 "solution_id" => array(
"integer", $next_id),
639 "active_fi" => array(
"integer", $active_id),
640 "question_fi" => array(
"integer", $this->
getId()),
641 "value1" => array(
"clob", trim($value)),
642 "value2" => array(
"clob", null),
643 "pass" => array(
"integer",
$pass),
644 "tstamp" => array(
"integer", time())
652 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
660 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
678 return "assTextSubset";
690 foreach ($this->answers as $answer)
692 if (!is_array($join[$answer->getPoints() .
""]))
694 $join[$answer->getPoints() .
""] = array();
696 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
710 foreach ($this->answers as $answer)
712 $len = strlen($answer->getAnswertext());
713 if ($len > $maxwidth) $maxwidth = $len;
715 return $maxwidth + 3;
726 return "qpl_qst_textsubset";
737 return "qpl_a_textsubset";
763 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
768 foreach ($solutions as $solution)
773 return $startrow + $i + 1;