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';
78 $this->maxNumOfChars = 0;
80 $this->answers = array();
81 $this->matchcondition = 0;
91 if (strlen($this->title)
130 if ($ilDB->numRows(
$result) == 1)
132 $data = $ilDB->fetchAssoc(
$result);
133 $this->
setId($question_id);
140 $this->
setPoints((
float) $data[
"points"]);
142 include_once(
"./Services/RTE/classes/class.ilRTE.php");
147 $this->matchcondition = (strlen($data[
'matchcondition'])) ? $data[
'matchcondition'] : 0;
148 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
160 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_essay WHERE question_fi = %s",
162 array($this->
getId())
187 $this_id = $this->
getId();
191 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
195 if( (
int)$testObjId > 0 )
197 $clone->setObjId($testObjId);
224 $clone->copyPageOfQuestion($this_id);
226 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
227 #$clone->duplicateAnswers($this_id);
229 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
248 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
251 $source_questionpool_id = $this->
getObjId();
252 $clone->setObjId($target_questionpool_id);
263 #$clone->duplicateAnswers($original_id);
265 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
278 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
281 $sourceParentId = $this->
getObjId();
287 $clone->setObjId($targetParentId);
289 if ($targetQuestionTitle)
291 $clone->setTitle($targetQuestionTitle);
296 $clone->copyPageOfQuestion($sourceQuestionId);
298 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
300 #$clone->duplicateAnswers($sourceQuestionId);
302 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
316 if (strcmp($this->maxNumOfChars,
"") == 0)
335 $this->maxNumOfChars = $maxchars;
346 if( in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion()) )
353 foreach ($this->answers as $answer)
355 if ($answer->getPoints() > 0)
366 if( in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion()) )
373 foreach ($this->answers as $answer)
375 if ($answer->getPoints() < 0)
402 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
403 array(
'float',
'integer',
'integer',
'integer'),
406 $this->_updateTestPassResults($active_id,
$pass);
444 include_once
"./Services/Utilities/classes/class.ilStr.php";
451 if (
ilStr::strPos($answertext, $a_keyword) !==
false)
return TRUE;
456 $answertext = strip_tags($answertext);
458 $answerwords = array();
459 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches))
461 foreach ($matches[1] as $answerword)
463 array_push($answerwords, trim($answerword));
466 foreach ($answerwords as $a_original)
471 if (levenshtein($a_original, $a_keyword) <= 1)
return TRUE;
474 if (levenshtein($a_original, $a_keyword) <= 2)
return TRUE;
477 if (levenshtein($a_original, $a_keyword) <= 3)
return TRUE;
480 if (levenshtein($a_original, $a_keyword) <= 4)
return TRUE;
483 if (levenshtein($a_original, $a_keyword) <= 5)
return TRUE;
514 $qst_answer = $answer->getAnswertext();
515 $user_answer =
' '.$solution;
519 $points += $answer->getPoints();
531 $qst_answer = $answer->getAnswertext();
532 $user_answer =
' '.$solution;
549 $qst_answer = $answer->getAnswertext();
550 $user_answer =
' '.$solution;
579 throw new ilTestException(
'return details not implemented for '.__METHOD__);
590 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
591 array(
'integer',
'integer',
'integer'),
596 if ($ilDB->numRows(
$result) == 0)
603 if (
$row[
"points"] != NULL)
605 return $row[
"points"];
624 include_once
"./Services/Utilities/classes/class.ilStr.php";
627 include_once
"./Modules/Test/classes/class.ilObjTest.php";
633 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
634 array(
'integer',
'integer',
'integer'),
643 $next_id = $ilDB->nextId(
'tst_solutions');
644 $affectedRows = $ilDB->insert(
"tst_solutions", array(
645 "solution_id" => array(
"integer", $next_id),
646 "active_fi" => array(
"integer", $active_id),
647 "question_fi" => array(
"integer", $this->
getId()),
648 "value1" => array(
"clob", trim($text)),
649 "value2" => array(
"clob", null),
650 "pass" => array(
"integer",
$pass),
651 "tstamp" => array(
"integer", time())
660 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
668 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
686 include_once
"./Services/Utilities/classes/class.ilStr.php";
687 $text_without_tags = preg_replace(
"/<[^>*?]>/is",
"", $text);
700 $text = preg_replace(
"/<[^>]*$/ims",
"", $text);
715 array( $this->
getId()
719 $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxnumofchars, keywords,
720 textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)",
721 array(
"integer",
"integer",
"text",
"text",
'integer',
'text' ),
727 $this->matchcondition,
738 $ilDB->manipulateF(
"DELETE FROM qpl_a_essay WHERE question_fi = %s",
740 array( $this->
getId() )
743 foreach ($this->answers as $answer)
746 $nextID = $ilDB->nextId(
'qpl_a_essay' );
747 $ilDB->manipulateF(
"INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
748 array(
"integer",
"integer",
"text",
'float' ),
752 $answer->getAnswertext(),
784 return "assTextQuestion";
808 switch ($a_text_rating)
817 $this->text_rating = $a_text_rating;
833 return "qpl_qst_essay";
859 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
865 if (strlen($solutions[0][
"value1"]))
870 return $startrow + $i + 1;
878 include_once(
"./Services/RTE/classes/class.ilRTE.php");
892 return count($this->answers);
911 $points_unchecked = 0.0,
916 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
920 $this->answers[] = $answer;
939 if ($index < 0)
return NULL;
940 if (count($this->answers) < 1)
return NULL;
941 if ($index >= count($this->answers))
return NULL;
943 return $this->answers[$index];
956 if ($index < 0)
return;
957 if (count($this->answers) < 1)
return;
958 if ($index >= count($this->answers))
return;
959 $answer = $this->answers[$index];
960 if (strlen($answer->getImage())) $this->deleteImage($answer->getImage());
961 unset($this->answers[$index]);
962 $this->answers = array_values($this->answers);
963 for ($i = 0; $i < count($this->answers); $i++)
965 if ($this->answers[$i]->getOrder() > $index)
967 $this->answers[$i]->setOrder($i);
974 return 'qpl_a_essay';
985 $this->answers = array();
1003 for( $i = 0; $i < $count; $i++ )
1020 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_essay WHERE question_fi = %s",
1028 $next_id = $ilDB->nextId(
'qpl_a_essay');
1029 $affectedRows = $ilDB->manipulateF(
1030 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
1031 VALUES (%s, %s, %s, %s)",
1032 array(
'integer',
'integer',
'text',
'float'),
1033 array($next_id, $this->
getId(),
$row[
"answertext"],
$row[
"points"])
1050 $this->keyword_relation = $a_relation;
1055 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
1060 return array(
'non',
'all',
'one');
1065 return array(
'any');
1083 return $numExistingSolutionRecords > 0;