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)
110 $this->saveAdditionalQuestionDataToDb();
111 $this->saveAnswerSpecificDataToDb();
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;
504 throw new ilTestException(
'return details not implemented for '.__METHOD__);
515 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
516 array(
'integer',
'integer',
'integer'),
521 if ($ilDB->numRows(
$result) == 0)
528 if (
$row[
"points"] != NULL)
530 return $row[
"points"];
555 $qst_answer = $answer->getAnswertext();
556 $user_answer =
' '.$row[
'value1'];
560 $points += $answer->getPoints();
572 $qst_answer = $answer->getAnswertext();
573 $user_answer =
' '.$row[
'value1'];
590 $qst_answer = $answer->getAnswertext();
591 $user_answer =
' '.$row[
'value1'];
620 include_once
"./Services/Utilities/classes/class.ilStr.php";
623 include_once
"./Modules/Test/classes/class.ilObjTest.php";
629 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
630 array(
'integer',
'integer',
'integer'),
636 include_once
"./Services/Utilities/classes/class.ilStr.php";
637 $text_without_tags = preg_replace(
"/<[^>*?]>/is",
"", $text);
642 if (!$this->
isHTML($text))
650 $text = preg_replace(
"/<[^>]*$/ims",
"", $text);
659 $next_id = $ilDB->nextId(
'tst_solutions');
660 $affectedRows = $ilDB->insert(
"tst_solutions", array(
661 "solution_id" => array(
"integer", $next_id),
662 "active_fi" => array(
"integer", $active_id),
663 "question_fi" => array(
"integer", $this->
getId()),
664 "value1" => array(
"clob", trim($text)),
665 "value2" => array(
"clob", null),
666 "pass" => array(
"integer",
$pass),
667 "tstamp" => array(
"integer", time())
676 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
684 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
694 public function saveAdditionalQuestionDataToDb()
700 array( $this->
getId()
704 $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxnumofchars, keywords,
705 textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)",
706 array(
"integer",
"integer",
"text",
"text",
'integer',
'text' ),
712 $this->matchcondition,
718 public function saveAnswerSpecificDataToDb()
723 $ilDB->manipulateF(
"DELETE FROM qpl_a_essay WHERE question_fi = %s",
725 array( $this->
getId() )
728 foreach ($this->answers as $answer)
731 $nextID = $ilDB->nextId(
'qpl_a_essay' );
732 $ilDB->manipulateF(
"INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)",
733 array(
"integer",
"integer",
"text",
'float' ),
737 $answer->getAnswertext(),
769 return "assTextQuestion";
793 switch ($a_text_rating)
802 $this->text_rating = $a_text_rating;
818 return "qpl_qst_essay";
844 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
850 if (strlen($solutions[0][
"value1"]))
855 return $startrow + $i + 1;
863 include_once(
"./Services/RTE/classes/class.ilRTE.php");
877 return count($this->answers);
896 $points_unchecked = 0.0,
901 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
905 $this->answers[] = $answer;
924 if ($index < 0)
return NULL;
925 if (count($this->answers) < 1)
return NULL;
926 if ($index >= count($this->answers))
return NULL;
928 return $this->answers[$index];
941 if ($index < 0)
return;
942 if (count($this->answers) < 1)
return;
943 if ($index >= count($this->answers))
return;
944 $answer = $this->answers[$index];
945 if (strlen($answer->getImage())) $this->deleteImage($answer->getImage());
946 unset($this->answers[$index]);
947 $this->answers = array_values($this->answers);
948 for ($i = 0; $i < count($this->answers); $i++)
950 if ($this->answers[$i]->getOrder() > $index)
952 $this->answers[$i]->setOrder($i);
959 return 'qpl_a_essay';
970 $this->answers = array();
988 for( $i = 0; $i < $count; $i++ )
1005 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_essay WHERE question_fi = %s",
1013 $next_id = $ilDB->nextId(
'qpl_a_essay');
1014 $affectedRows = $ilDB->manipulateF(
1015 "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
1016 VALUES (%s, %s, %s, %s)",
1017 array(
'integer',
'integer',
'text',
'integer'),
1018 array($next_id, $this->
getId(),
$row[
"answertext"],
$row[
"points"])
1035 $this->keyword_relation = $a_relation;
1040 return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
1045 return array(
'non',
'all',
'one');
1050 return array(
'any');