4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
73 $this->answers = array();
74 $this->correctanswers = 0;
89 count($this->answers) >= $this->correctanswers
132 $data = $ilDB->fetchAssoc(
$result);
133 $this->
setId($question_id);
142 include_once(
"./Services/RTE/classes/class.ilRTE.php");
146 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
158 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
162 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
165 while ($data = $ilDB->fetchAssoc(
$result))
181 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
182 if (array_key_exists($order, $this->answers))
186 $newchoices = array();
187 for ($i = 0; $i < $order; $i++)
189 array_push($newchoices, $this->answers[$i]);
191 array_push($newchoices, $answer);
192 for ($i = $order; $i < count($this->answers); $i++)
198 $this->answers = $newchoices;
220 $this_id = $this->
getId();
224 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
228 if( (
int)$testObjId > 0 )
230 $clone->setObjId($testObjId);
257 $clone->copyPageOfQuestion($this_id);
259 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
261 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
280 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
283 $source_questionpool_id = $this->
getObjId();
284 $clone->setObjId($target_questionpool_id);
295 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
308 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
311 $sourceParentId = $this->
getObjId();
317 $clone->setObjId($targetParentId);
319 if ($targetQuestionTitle)
321 $clone->setTitle($targetQuestionTitle);
326 $clone->copyPageOfQuestion($sourceQuestionId);
328 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
330 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
344 return count($this->answers);
358 if ($index < 0)
return NULL;
359 if (count($this->answers) < 1)
return NULL;
360 if ($index >= count($this->answers))
return NULL;
362 return $this->answers[$index];
375 if ($index < 0)
return;
376 if (count($this->answers) < 1)
return;
377 if ($index >= count($this->answers))
return;
378 unset($this->answers[$index]);
379 $this->answers = array_values($this->answers);
380 for ($i = 0; $i < count($this->answers); $i++)
382 if ($this->answers[$i]->getOrder() > $index)
384 $this->answers[$i]->setOrder($i);
397 $this->answers = array();
409 foreach ($this->answers as $answer)
411 if ($answer->getPoints() > 0)
413 array_push(
$points, $answer->getPoints());
420 $maxpoints +=
$points[$counter];
433 $available_answers = array();
434 foreach ($this->answers as $answer)
436 array_push($available_answers, $answer->getAnswertext());
438 return $available_answers;
453 include_once
"./Services/Utilities/classes/class.ilStr.php";
456 foreach (
$answers as $key => $value)
464 if (strcmp($value, $answer) == 0 && $this->answers[$key]->
getPoints() > 0)
return $key;
467 if (levenshtein($value, $answer) <= 1 && $this->answers[$key]->
getPoints() > 0)
return $key;
470 if (levenshtein($value, $answer) <= 2 && $this->answers[$key]->
getPoints() > 0)
return $key;
473 if (levenshtein($value, $answer) <= 3 && $this->answers[$key]->
getPoints() > 0)
return $key;
476 if (levenshtein($value, $answer) <= 4 && $this->answers[$key]->
getPoints() > 0)
return $key;
479 if (levenshtein($value, $answer) <= 5 && $this->answers[$key]->
getPoints() > 0)
return $key;
507 switch ($a_text_rating)
516 $this->text_rating = $a_text_rating;
538 throw new ilTestException(
'return details not implemented for '.__METHOD__);
550 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
551 array(
'integer',
'integer',
'integer'),
554 while ($data = $ilDB->fetchAssoc(
$result))
556 $enteredtext = $data[
"value1"];
558 if ($index !== FALSE)
560 unset($available_answers[$index]);
561 $points += $this->answers[$index]->getPoints();
576 $this->correctanswers = $a_correct_answers;
605 include_once
"./Modules/Test/classes/class.ilObjTest.php";
612 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
613 array(
'integer',
'integer',
'integer'),
616 require_once
'Services/Utilities/classes/class.ilUtil.php';
617 foreach (
$_POST as $key => $value)
619 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
624 $next_id = $ilDB->nextId(
'tst_solutions');
625 $affectedRows = $ilDB->insert(
"tst_solutions", array(
626 "solution_id" => array(
"integer", $next_id),
627 "active_fi" => array(
"integer", $active_id),
628 "question_fi" => array(
"integer", $this->
getId()),
629 "value1" => array(
"clob", trim($value)),
630 "value2" => array(
"clob", null),
631 "pass" => array(
"integer",
$pass),
632 "tstamp" => array(
"integer", time())
643 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
651 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
669 array( $this->
getId() )
673 ) .
" (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
674 array(
"integer",
"text",
"integer" ),
687 $ilDB->manipulateF(
"DELETE FROM qpl_a_textsubset WHERE question_fi = %s",
689 array( $this->
getId() )
692 foreach ($this->answers as $key => $value)
694 $answer_obj = $this->answers[$key];
695 $next_id = $ilDB->nextId(
'qpl_a_textsubset' );
696 $ilDB->manipulateF(
"INSERT INTO qpl_a_textsubset (answer_id, question_fi, answertext, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
697 array(
'integer',
'integer',
'text',
'float',
'integer',
'integer' ),
701 $answer_obj->getAnswertext(),
702 $answer_obj->getPoints(),
703 $answer_obj->getOrder(),
731 return "assTextSubset";
743 foreach ($this->answers as $answer)
745 if (!is_array($join[$answer->getPoints() .
""]))
747 $join[$answer->getPoints() .
""] = array();
749 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
763 foreach ($this->answers as $answer)
765 $len = strlen($answer->getAnswertext());
766 if ($len > $maxwidth) $maxwidth = $len;
768 return $maxwidth + 3;
779 return "qpl_qst_textsubset";
790 return "qpl_a_textsubset";
816 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
821 foreach ($solutions as $solution)
826 return $startrow + $i + 1;
839 include_once(
"./Services/RTE/classes/class.ilRTE.php");
848 "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false),
849 "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true)
853 foreach ($this->
getAnswers() as $key => $answer_obj)
856 "answertext" => (
string) $answer_obj->getAnswertext(),
857 "points" => (float)$answer_obj->getPoints(),
858 "order" => (int)$answer_obj->getOrder()