23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
87 $this->maxNumOfChars = 0;
102 if (($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0))
130 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
142 include_once(
"./Services/RTE/classes/class.ilRTE.php");
148 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
149 $query = sprintf(
"INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, points, question_text, working_time, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
150 $ilDB->quote($question_type),
151 $ilDB->quote($this->obj_id),
152 $ilDB->quote($this->title),
153 $ilDB->quote($this->comment),
154 $ilDB->quote($this->author),
155 $ilDB->quote($this->owner),
158 $ilDB->quote($estw_time),
159 $ilDB->quote(
"$complete"),
160 $ilDB->quote($created),
163 $result = $ilDB->query($query);
165 if (PEAR::isError($result))
168 $ilias->raiseError($result->getMessage());
172 $this->
id = $ilDB->getLastInsertId();
173 $query = sprintf(
"INSERT INTO qpl_question_essay (question_fi, maxNumOfChars, keywords, textgap_rating) VALUES (%s, %s, %s, %s)",
174 $ilDB->quote($this->id .
""),
179 $ilDB->query($query);
193 $query = sprintf(
"UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, points = %s, question_text = %s, working_time=%s, complete = %s WHERE question_id = %s",
194 $ilDB->quote($this->obj_id.
""),
195 $ilDB->quote($this->title),
196 $ilDB->quote($this->comment),
197 $ilDB->quote($this->author),
200 $ilDB->quote($estw_time),
201 $ilDB->quote(
"$complete"),
202 $ilDB->quote($this->
id)
204 $result = $ilDB->query($query);
205 $query = sprintf(
"UPDATE qpl_question_essay SET maxNumOfChars = %s, keywords = %s, textgap_rating = %s WHERE question_fi = %s",
206 $ilDB->quote($this->getMaxNumOfChars()),
207 $ilDB->quote($this->getKeywords() .
""),
208 $ilDB->quote($this->getTextRating() .
""),
209 $ilDB->quote($this->id .
"")
211 $result = $ilDB->query($query);
229 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_essay.* FROM qpl_questions, qpl_question_essay WHERE question_id = %s AND qpl_questions.question_id = qpl_question_essay.question_fi",
230 $ilDB->quote($question_id)
232 $result = $ilDB->query($query);
233 if ($result->numRows() == 1)
235 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
236 $this->
id = $question_id;
237 $this->title =
$data->title;
238 $this->comment =
$data->comment;
239 $this->solution_hint =
$data->solution_hint;
240 $this->original_id =
$data->original_id;
241 $this->obj_id =
$data->obj_fi;
242 $this->author =
$data->author;
243 $this->owner =
$data->owner;
244 include_once(
"./Services/RTE/classes/class.ilRTE.php");
246 $this->maxNumOfChars =
$data->maxNumOfChars;
247 $this->keywords =
$data->keywords;
248 $this->text_rating =
$data->textgap_rating;
249 $this->points =
$data->points;
270 $this_id = $this->
getId();
272 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
299 $clone->copyPageOfQuestion($this_id);
301 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
303 $clone->duplicateFeedbackGeneric($this_id);
324 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
327 $source_questionpool = $this->
getObjId();
328 $clone->setObjId($target_questionpool);
356 if (strcmp($this->maxNumOfChars,
"") == 0)
377 $this->maxNumOfChars = $maxchars;
414 $query = sprintf(
"UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
416 $ilDB->quote($active_id .
""),
417 $ilDB->quote($this->
getId() .
""),
418 $ilDB->quote(
$pass .
"")
420 $result = $ilDB->query($query);
444 include_once
"./Services/Utilities/classes/class.ilStr.php";
451 if (
ilStr::strPos($answertext, $a_keyword) !==
false)
return TRUE;
454 $answerwords = array();
455 if (preg_match_all(
"/([^\s.]+)/", $answertext, $matches))
457 foreach ($matches[1] as $answerword)
459 array_push($answerwords, trim($answerword));
462 foreach ($answerwords as $a_original)
467 if (levenshtein($a_original, $a_keyword) <= 1)
return TRUE;
470 if (levenshtein($a_original, $a_keyword) <= 2)
return TRUE;
473 if (levenshtein($a_original, $a_keyword) <= 3)
return TRUE;
476 if (levenshtein($a_original, $a_keyword) <= 4)
return TRUE;
479 if (levenshtein($a_original, $a_keyword) <= 5)
return TRUE;
506 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
507 $ilDB->quote($active_id .
""),
508 $ilDB->quote($this->
getId() .
""),
509 $ilDB->quote(
$pass .
"")
511 $result = $ilDB->query($query);
512 if ($result->numRows() == 1)
514 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
524 $foundkeyword =
false;
531 $foundkeyword =
true;
561 include_once
"./Modules/Test/classes/class.ilObjTest.php";
564 $query = sprintf(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
565 $ilDB->quote($active_id .
""),
566 $ilDB->quote($this->
getId() .
""),
567 $ilDB->quote(
$pass .
"")
569 $result = $ilDB->query($query);
573 include_once
"./Services/Utilities/classes/class.ilStr.php";
574 $text_without_tags = preg_replace(
"/<[^>*?]>/is",
"", $text);
579 if (!$this->
isHTML($text))
593 $text = preg_replace(
"/<[^>]*$/ims",
"", $text);
602 $query = sprintf(
"INSERT INTO tst_solutions (solution_id, active_fi, question_fi, value1, value2, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL, %s, NULL)",
603 $ilDB->quote($active_id .
""),
604 $ilDB->quote($this->
getId() .
""),
605 $ilDB->quote(trim($text) .
""),
606 $ilDB->quote(
$pass .
"")
608 $result = $ilDB->query($query);
613 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
621 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
645 return "assTextQuestion";
671 $this->keywords = $a_keywords;
685 if (preg_match_all(
"/([^\s]+)/", $this->keywords, $matches))
687 foreach ($matches[1] as $keyword)
720 switch ($a_text_rating)
729 $this->text_rating = $a_text_rating;
747 return "qpl_question_essay";
773 include_once (
"./classes/class.ilExcelUtils.php");
779 if (strlen($solutions[0][
"value1"]))
784 return $startrow + $i + 1;