23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
88 $this->answers = array();
89 $this->correctanswers = 0;
100 if (($this->title) and ($this->author) and ($this->question) and (count($this->answers) >= $this->correctanswers) and ($this->
getMaximumPoints() > 0))
123 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
125 array($this->
getId())
128 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
129 array(
"integer",
"text",
"integer"),
137 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
139 array($this->
getId())
142 foreach ($this->answers as
$key => $value)
144 $answer_obj = $this->answers[
$key];
145 $next_id = $ilDB->nextId(
'qpl_a_textsubset');
146 $query = $ilDB->manipulateF(
"INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
147 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer'),
151 $answer_obj->getAnswertext(),
152 $answer_obj->getPoints(),
153 $answer_obj->getOrder(),
180 $this->
setId($question_id);
189 include_once(
"./Services/RTE/classes/class.ilRTE.php");
197 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
201 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
220 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
221 if (array_key_exists($order, $this->answers))
225 $newchoices = array();
226 for ($i = 0; $i < $order; $i++)
228 array_push($newchoices, $this->answers[$i]);
230 array_push($newchoices, $answer);
231 for ($i = $order; $i < count($this->answers); $i++)
237 $this->answers = $newchoices;
259 $this_id = $this->
getId();
261 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
288 $clone->copyPageOfQuestion($this_id);
290 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
292 $clone->duplicateFeedbackGeneric($this_id);
293 $clone->onDuplicate($this_id);
312 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
315 $source_questionpool = $this->
getObjId();
316 $clone->setObjId($target_questionpool);
343 return count($this->answers);
357 if ($index < 0)
return NULL;
358 if (count($this->answers) < 1)
return NULL;
359 if ($index >= count($this->answers))
return NULL;
361 return $this->answers[$index];
374 if ($index < 0)
return;
375 if (count($this->answers) < 1)
return;
376 if ($index >= count($this->answers))
return;
377 unset($this->answers[$index]);
378 $this->answers = array_values($this->answers);
379 for ($i = 0; $i < count($this->answers); $i++)
381 if ($this->answers[$i]->getOrder() > $index)
383 $this->answers[$i]->setOrder($i);
396 $this->answers = array();
408 foreach ($this->answers as $answer)
410 if ($answer->getPoints() > 0)
412 array_push(
$points, $answer->getPoints());
419 $maxpoints +=
$points[$counter];
432 $available_answers = array();
433 foreach ($this->answers as $answer)
435 array_push($available_answers, $answer->getAnswertext());
437 return $available_answers;
452 include_once
"./Services/Utilities/classes/class.ilStr.php";
463 if (strcmp($value, $answer) == 0)
return $key;
466 if (levenshtein($value, $answer) <= 1)
return $key;
469 if (levenshtein($value, $answer) <= 2)
return $key;
472 if (levenshtein($value, $answer) <= 3)
return $key;
475 if (levenshtein($value, $answer) <= 4)
return $key;
478 if (levenshtein($value, $answer) <= 5)
return $key;
506 switch ($a_text_rating)
515 $this->text_rating = $a_text_rating;
543 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
544 array(
'integer',
'integer',
'integer'),
549 $enteredtext =
$data[
"value1"];
551 if ($index !== FALSE)
553 unset($available_answers[$index]);
554 $points += $this->answers[$index]->getPoints();
570 $this->correctanswers = $a_correct_answers;
599 include_once
"./Modules/Test/classes/class.ilObjTest.php";
604 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
605 array(
'integer',
'integer',
'integer'),
610 if (preg_match(
"/^TEXTSUBSET_(\d+)/",
$key, $matches))
614 $next_id = $ilDB->nextId(
'tst_solutions');
615 $affectedRows = $ilDB->insert(
"tst_solutions", array(
616 "solution_id" => array(
"integer", $next_id),
617 "active_fi" => array(
"integer", $active_id),
618 "question_fi" => array(
"integer", $this->
getId()),
619 "value1" => array(
"clob", trim($value)),
620 "value2" => array(
"clob", null),
621 "pass" => array(
"integer",
$pass),
622 "tstamp" => array(
"integer", time())
630 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
638 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
656 return "assTextSubset";
668 foreach ($this->answers as $answer)
670 if (!is_array($join[$answer->getPoints() .
""]))
672 $join[$answer->getPoints() .
""] = array();
674 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
688 foreach ($this->answers as $answer)
690 $len = strlen($answer->getAnswertext());
691 if ($len > $maxwidth) $maxwidth = $len;
693 return $maxwidth + 3;
704 return "qpl_qst_textsubset";
715 return "qpl_a_textsubset";
741 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
746 foreach ($solutions as $solution)
751 return $startrow + $i + 1;