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 (strlen($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 if( (
int)$testObjId > 0 )
267 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
271 if( (
int)$testObjId > 0 )
273 $clone->setObjId($testObjId);
300 $clone->copyPageOfQuestion($this_id);
302 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
304 $clone->duplicateFeedbackGeneric($this_id);
306 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
325 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
328 $source_questionpool = $this->
getObjId();
329 $clone->setObjId($target_questionpool);
356 return count($this->answers);
370 if ($index < 0)
return NULL;
371 if (count($this->answers) < 1)
return NULL;
372 if ($index >= count($this->answers))
return NULL;
374 return $this->answers[$index];
387 if ($index < 0)
return;
388 if (count($this->answers) < 1)
return;
389 if ($index >= count($this->answers))
return;
390 unset($this->answers[$index]);
391 $this->answers = array_values($this->answers);
392 for ($i = 0; $i < count($this->answers); $i++)
394 if ($this->answers[$i]->getOrder() > $index)
396 $this->answers[$i]->setOrder($i);
409 $this->answers = array();
421 foreach ($this->answers as $answer)
423 if ($answer->getPoints() > 0)
425 array_push(
$points, $answer->getPoints());
432 $maxpoints +=
$points[$counter];
445 $available_answers = array();
446 foreach ($this->answers as $answer)
448 array_push($available_answers, $answer->getAnswertext());
450 return $available_answers;
465 include_once
"./Services/Utilities/classes/class.ilStr.php";
468 foreach (
$answers as $key => $value)
476 if (strcmp($value, $answer) == 0 && $this->answers[$key]->
getPoints() > 0)
return $key;
479 if (levenshtein($value, $answer) <= 1 && $this->answers[$key]->
getPoints() > 0)
return $key;
482 if (levenshtein($value, $answer) <= 2 && $this->answers[$key]->
getPoints() > 0)
return $key;
485 if (levenshtein($value, $answer) <= 3 && $this->answers[$key]->
getPoints() > 0)
return $key;
488 if (levenshtein($value, $answer) <= 4 && $this->answers[$key]->
getPoints() > 0)
return $key;
491 if (levenshtein($value, $answer) <= 5 && $this->answers[$key]->
getPoints() > 0)
return $key;
519 switch ($a_text_rating)
528 $this->text_rating = $a_text_rating;
556 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
557 array(
'integer',
'integer',
'integer'),
562 $enteredtext =
$data[
"value1"];
564 if ($index !== FALSE)
566 unset($available_answers[$index]);
567 $points += $this->answers[$index]->getPoints();
583 $this->correctanswers = $a_correct_answers;
612 include_once
"./Modules/Test/classes/class.ilObjTest.php";
617 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
618 array(
'integer',
'integer',
'integer'),
621 foreach (
$_POST as $key => $value)
623 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
627 $next_id = $ilDB->nextId(
'tst_solutions');
628 $affectedRows = $ilDB->insert(
"tst_solutions", array(
629 "solution_id" => array(
"integer", $next_id),
630 "active_fi" => array(
"integer", $active_id),
631 "question_fi" => array(
"integer", $this->
getId()),
632 "value1" => array(
"clob", trim($value)),
633 "value2" => array(
"clob", null),
634 "pass" => array(
"integer",
$pass),
635 "tstamp" => array(
"integer", time())
643 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
651 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
669 return "assTextSubset";
681 foreach ($this->answers as $answer)
683 if (!is_array($join[$answer->getPoints() .
""]))
685 $join[$answer->getPoints() .
""] = array();
687 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
701 foreach ($this->answers as $answer)
703 $len = strlen($answer->getAnswertext());
704 if ($len > $maxwidth) $maxwidth = $len;
706 return $maxwidth + 3;
717 return "qpl_qst_textsubset";
728 return "qpl_a_textsubset";
754 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
759 foreach ($solutions as $solution)
764 return $startrow + $i + 1;
777 include_once(
"./Services/RTE/classes/class.ilRTE.php");
791 foreach ($this->
getAnswers() as $key => $answer_obj)
794 "answertext" => (
string) $answer_obj->getAnswertext(),
795 "points" => (float)$answer_obj->getPoints(),
796 "order" => (int)$answer_obj->getOrder()