5 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
77 $this->maxNumOfChars = 0;
79 $this->answers = array();
80 $this->matchcondition = 0;
91 if (strlen($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0))
114 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
116 array($this->
getId())
119 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxnumofchars, keywords, textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)",
120 array(
"integer",
"integer",
"text",
"text",
'integer',
'text'),
126 $this->matchcondition,
131 $ilDB->manipulateF(
"DELETE FROM qpl_a_essay WHERE question_fi = %s",
133 array($this->
getId())
136 foreach ($this->answers as $answer)
138 $nextID = $ilDB->nextId(
'qpl_a_essay');
139 $ilDB->manipulateF(
"INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
140 array(
"integer",
"integer",
"text",
'float'),
168 if ($ilDB->numRows(
$result) == 1)
171 $this->
setId($question_id);
178 if(0 != (
int)
$data[
"points"])
183 include_once(
"./Services/RTE/classes/class.ilRTE.php");
188 $this->matchcondition = (strlen($data[
'matchcondition'])) ? $data[
'matchcondition'] : 0;
189 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
193 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_essay WHERE question_fi = %s",
195 array($this->
getId())
220 $this_id = $this->
getId();
222 if( (
int)$testObjId > 0 )
228 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
232 if( (
int)$testObjId > 0 )
234 $clone->setObjId($testObjId);
261 $clone->copyPageOfQuestion($this_id);
263 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
265 $clone->duplicateGenericFeedback($this_id);
266 #$clone->duplicateAnswers($this_id);
268 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
287 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
290 $source_questionpool = $this->
getObjId();
291 $clone->setObjId($target_questionpool);
305 #$clone->duplicateAnswers($original_id);
321 if (strcmp($this->maxNumOfChars,
"") == 0)
340 $this->maxNumOfChars = $maxchars;
351 if( in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion()) )
358 foreach ($this->answers as $answer)
360 if ($answer->points > 0)
371 if( in_array($this->
getKeywordRelation(), self::getScoringModesWithPointsByQuestion()) )
378 foreach ($this->answers as $answer)
380 if ($answer->points < 0)
407 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
408 array(
'float',
'integer',
'integer',
'integer'),
449 include_once
"./Services/Utilities/classes/class.ilStr.php";
456 if (
ilStr::strPos($answertext, $a_keyword) !==
false)
return TRUE;
461 $answertext = strip_tags($answertext);
463 $answerwords = array();
464 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches))
466 foreach ($matches[1] as $answerword)
468 array_push($answerwords, trim($answerword));
471 foreach ($answerwords as $a_original)
476 if (levenshtein($a_original, $a_keyword) <= 1)
return TRUE;
479 if (levenshtein($a_original, $a_keyword) <= 2)
return TRUE;
482 if (levenshtein($a_original, $a_keyword) <= 3)
return TRUE;
485 if (levenshtein($a_original, $a_keyword) <= 4)
return TRUE;
488 if (levenshtein($a_original, $a_keyword) <= 5)
return TRUE;
509 throw new ilTestException(
'return details not implemented for '.__METHOD__);
520 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
521 array(
'integer',
'integer',
'integer'),
526 if ($ilDB->numRows(
$result) == 0)
533 if (
$row[
"points"] != NULL)
535 return $row[
"points"];
560 $qst_answer = $answer->answertext;
561 $user_answer =
' '.$row[
'value1'];
577 $qst_answer = $answer->answertext;
578 $user_answer =
' '.$row[
'value1'];
595 $qst_answer = $answer->answertext;
596 $user_answer =
' '.$row[
'value1'];
625 include_once
"./Services/Utilities/classes/class.ilStr.php";
628 include_once
"./Modules/Test/classes/class.ilObjTest.php";
631 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
632 array(
'integer',
'integer',
'integer'),
638 include_once
"./Services/Utilities/classes/class.ilStr.php";
639 $text_without_tags = preg_replace(
"/<[^>*?]>/is",
"", $text);
644 if (!$this->
isHTML($text))
652 $text = preg_replace(
"/<[^>]*$/ims",
"", $text);
661 $next_id = $ilDB->nextId(
'tst_solutions');
662 $affectedRows = $ilDB->insert(
"tst_solutions", array(
663 "solution_id" => array(
"integer", $next_id),
664 "active_fi" => array(
"integer", $active_id),
665 "question_fi" => array(
"integer", $this->
getId()),
666 "value1" => array(
"clob", trim($text)),
667 "value2" => array(
"clob", null),
668 "pass" => array(
"integer",
$pass),
669 "tstamp" => array(
"integer", time())
675 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
683 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
718 return "assTextQuestion";
742 switch ($a_text_rating)
751 $this->text_rating = $a_text_rating;
767 return "qpl_qst_essay";
793 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
799 if (strlen($solutions[0][
"value1"]))
804 return $startrow + $i + 1;
812 include_once(
"./Services/RTE/classes/class.ilRTE.php");
826 return count($this->answers);
845 $points_unchecked = 0.0,
850 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
854 $this->answers[] = $answer;
873 if ($index < 0)
return NULL;
874 if (count($this->answers) < 1)
return NULL;
875 if ($index >= count($this->answers))
return NULL;
877 return $this->answers[$index];
890 if ($index < 0)
return;
891 if (count($this->answers) < 1)
return;
892 if ($index >= count($this->answers))
return;
893 $answer = $this->answers[$index];
894 if (strlen($answer->getImage())) $this->deleteImage($answer->getImage());
895 unset($this->answers[$index]);
896 $this->answers = array_values($this->answers);
897 for ($i = 0; $i < count($this->answers); $i++)
899 if ($this->answers[$i]->getOrder() > $index)
901 $this->answers[$i]->setOrder($i);
908 return 'qpl_a_essay';
919 $this->answers = array();
937 for( $i = 0; $i < $count; $i++ )
954 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_essay WHERE question_fi = %s",
962 $next_id = $ilDB->nextId(
'qpl_a_essay');
963 $affectedRows = $ilDB->manipulateF(
964 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
965 VALUES (%s, %s, %s, %s)",
966 array(
'integer',
'integer',
'text',
'integer'),
967 array($next_id, $this->
getId(),
$row[
"answertext"],
$row[
"points"])
984 $this->keyword_relation = $a_relation;
993 function saveFeedbackSingleAnswer($answer_index, $feedback)
997 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_essay WHERE question_fi = %s AND answer = %s",
998 array(
'integer',
'integer'),
999 array($this->
getId(), $answer_index)
1001 if (strlen($feedback))
1003 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1004 $next_id = $ilDB->nextId(
'qpl_fb_essay');
1006 $ilDB->insert(
'qpl_fb_essay', array(
1007 'feedback_id' => array(
'integer', $next_id ),
1008 'question_fi' => array(
'integer', $this->
getId() ),
1009 'answer' => array(
'integer', $answer_index ),
1011 'tstamp' => array(
'integer', time() ),
1029 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_essay WHERE question_fi = %s AND answer = %s",
1030 array(
'integer',
'integer'),
1031 array($this->
getId(), $answer_index)
1036 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1048 WHERE question_fi = %s',
1056 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
1061 return array(
'non',
'all',
'one');
1066 return array(
'any');
1081 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_essay WHERE question_fi = %s",
1089 $next_id = $ilDB->nextId(
'qpl_fb_essay');
1091 $ilDB->insert(
'qpl_fb_essay', array(
1092 'feedback_id' => array(
'integer', $next_id ),
1093 'question_fi' => array(
'integer', $this->
getId() ),
1094 'answer' => array(
'integer',
$row[
"answer"] ),
1095 'feedback' => array(
'clob',
$row[
"feedback"] ),
1096 'tstamp' => array(
'integer', time() ),