23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
88 $this->maxNumOfChars = 0;
91 $this->matchcondition = 0;
102 if (($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0))
125 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
127 array($this->
getId())
130 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxnumofchars, keywords, textgap_rating, matchcondition) VALUES (%s, %s, %s, %s, %s)",
131 array(
"integer",
"integer",
"text",
"text",
'integer'),
137 $this->matchcondition
159 if ($result->numRows() == 1)
161 $data = $ilDB->fetchAssoc($result);
162 $this->
setId($question_id);
171 include_once(
"./Services/RTE/classes/class.ilRTE.php");
177 $this->matchcondition = (strlen(
$data[
'matchcondition'])) ?
$data[
'matchcondition'] : 0;
196 $this_id = $this->
getId();
198 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
225 $clone->copyPageOfQuestion($this_id);
227 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
229 $clone->duplicateFeedbackGeneric($this_id);
230 $clone->onDuplicate($this_id);
249 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
252 $source_questionpool = $this->
getObjId();
253 $clone->setObjId($target_questionpool);
280 if (strcmp($this->maxNumOfChars,
"") == 0)
299 $this->maxNumOfChars = $maxchars;
332 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
333 array(
'float',
'integer',
'integer',
'integer'),
357 include_once
"./Services/Utilities/classes/class.ilStr.php";
364 if (
ilStr::strPos($answertext, $a_keyword) !==
false)
return TRUE;
367 $answerwords = array();
368 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches))
370 foreach ($matches[1] as $answerword)
372 array_push($answerwords, trim($answerword));
375 foreach ($answerwords as $a_original)
380 if (levenshtein($a_original, $a_keyword) <= 1)
return TRUE;
383 if (levenshtein($a_original, $a_keyword) <= 2)
return TRUE;
386 if (levenshtein($a_original, $a_keyword) <= 3)
return TRUE;
389 if (levenshtein($a_original, $a_keyword) <= 4)
return TRUE;
392 if (levenshtein($a_original, $a_keyword) <= 5)
return TRUE;
417 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
418 array(
'integer',
'integer',
'integer'),
421 if ($result->numRows() == 1)
423 $row = $ilDB->fetchAssoc($result);
433 if ($this->matchcondition == 0)
435 $foundkeyword =
false;
439 $foundkeyword =
true;
443 if ($this->matchcondition == 0)
476 include_once
"./Services/Utilities/classes/class.ilStr.php";
479 include_once
"./Modules/Test/classes/class.ilObjTest.php";
482 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
483 array(
'integer',
'integer',
'integer'),
489 include_once
"./Services/Utilities/classes/class.ilStr.php";
490 $text_without_tags = preg_replace(
"/<[^>*?]>/is",
"", $text);
495 if (!$this->
isHTML($text))
503 $text = preg_replace(
"/<[^>]*$/ims",
"", $text);
512 $next_id = $ilDB->nextId(
'tst_solutions');
513 $affectedRows = $ilDB->insert(
"tst_solutions", array(
514 "solution_id" => array(
"integer", $next_id),
515 "active_fi" => array(
"integer", $active_id),
516 "question_fi" => array(
"integer", $this->
getId()),
517 "value1" => array(
"clob", trim($text)),
518 "value2" => array(
"clob", null),
519 "pass" => array(
"integer",
$pass),
520 "tstamp" => array(
"integer", time())
526 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
534 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
556 return "assTextQuestion";
578 $this->keywords = $a_keywords;
590 if (preg_match_all(
"/([^\s]+)/", $this->keywords, $matches))
592 foreach ($matches[1] as $keyword)
621 switch ($a_text_rating)
630 $this->text_rating = $a_text_rating;
646 return "qpl_qst_essay";
670 $adapter->setCellValue($startrow, 0, $this->lng->txt($this->getQuestionType()),
CELL_FORMAT_TITLE);
673 $adapter->setCellValue($startrow + $i, 0, $this->lng->txt(
"result"),
CELL_FORMAT_BOLD);
674 if (strlen($solutions[0][
"value1"]))
676 $adapter->setCellValue($startrow + $i, 1, $solutions[0][
"value1"]);
679 return $startrow + $i + 1;
687 include_once(
"./Services/RTE/classes/class.ilRTE.php");
689 $result[
'id'] = (int) $this->
getId();
691 $result[
'title'] = (string) $this->
getTitle();
694 $result[
'shuffle'] = (bool) $this->
getShuffle();
696 return json_encode($result);