23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
88 $this->answers = array();
89 $this->correctanswers = 0;
102 if (($this->title) and ($this->author) and ($this->question) and (count($this->answers) >= $this->correctanswers) 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, question_text, points, 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_textsubset (question_fi, textgap_rating, correctanswers) VALUES (%s, %s, %s)",
174 $ilDB->quote($this->id .
""),
178 $ilDB->query($query);
193 $query = sprintf(
"UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, points = %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_textsubset SET textgap_rating = %s, correctanswers = %s WHERE question_fi = %s",
206 $ilDB->quote($this->getTextRating() .
""),
207 $ilDB->quote($this->getCorrectAnswers() .
""),
208 $ilDB->quote($this->id .
"")
210 $result = $ilDB->query($query);
215 $ilias->raiseError(
$result->getMessage());
222 $query = sprintf(
"DELETE FROM qpl_answer_textsubset WHERE question_fi = %s",
223 $ilDB->quote($this->id)
225 $result = $ilDB->query($query);
228 foreach ($this->answers as $key => $value)
230 $answer_obj = $this->answers[$key];
231 $query = sprintf(
"INSERT INTO qpl_answer_textsubset (answer_id, question_fi, answertext, points, aorder) VALUES (NULL, %s, %s, %s, %s)",
232 $ilDB->quote($this->id),
233 $ilDB->quote($answer_obj->getAnswertext()),
234 $ilDB->quote($answer_obj->getPoints() .
""),
235 $ilDB->quote($answer_obj->getOrder() .
"")
237 $answer_result = $ilDB->query($query);
256 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_textsubset.* FROM qpl_questions, qpl_question_textsubset WHERE question_id = %s AND qpl_questions.question_id = qpl_question_textsubset.question_fi",
257 $ilDB->quote($question_id)
259 $result = $ilDB->query($query);
260 if ($result->numRows() == 1)
262 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
263 $this->
id = $question_id;
264 $this->title =
$data->title;
265 $this->comment =
$data->comment;
266 $this->solution_hint =
$data->solution_hint;
267 $this->original_id =
$data->original_id;
268 $this->obj_id =
$data->obj_fi;
269 $this->author =
$data->author;
270 $this->owner =
$data->owner;
271 $this->points =
$data->points;
272 include_once(
"./Services/RTE/classes/class.ilRTE.php");
274 $this->correctanswers =
$data->correctanswers;
275 $this->text_rating =
$data->textgap_rating;
278 $query = sprintf(
"SELECT * FROM qpl_answer_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
279 $ilDB->quote($question_id)
281 $result = $ilDB->query($query);
283 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerSimple.php";
284 if ($result->numRows() > 0)
286 while (
$data = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
304 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerSimple.php";
323 $this_id = $this->
getId();
325 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
352 $clone->copyPageOfQuestion($this_id);
354 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
356 $clone->duplicateFeedbackGeneric($this_id);
377 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
380 $source_questionpool = $this->
getObjId();
381 $clone->setObjId($target_questionpool);
409 return count($this->answers);
425 if ($index < 0)
return NULL;
426 if (count($this->answers) < 1)
return NULL;
427 if ($index >= count($this->answers))
return NULL;
429 return $this->answers[$index];
444 if ($index < 0)
return;
445 if (count($this->answers) < 1)
return;
446 if ($index >= count($this->answers))
return;
447 unset($this->answers[$index]);
448 $this->answers = array_values($this->answers);
449 for ($i = 0; $i < count($this->answers); $i++)
451 if ($this->answers[$i]->getOrder() > $index)
453 $this->answers[$i]->setOrder($i);
468 $this->answers = array();
482 foreach ($this->answers as $answer)
484 if ($answer->getPoints() > 0)
486 array_push(
$points, $answer->getPoints());
493 $maxpoints +=
$points[$counter];
508 $available_answers = array();
509 foreach ($this->answers as $answer)
511 array_push($available_answers, $answer->getAnswertext());
513 return $available_answers;
530 include_once
"./Services/Utilities/classes/class.ilStr.php";
533 foreach (
$answers as $key => $value)
541 if (strcmp($value, $answer) == 0)
return $key;
544 if (levenshtein($value, $answer) <= 1)
return $key;
547 if (levenshtein($value, $answer) <= 2)
return $key;
550 if (levenshtein($value, $answer) <= 3)
return $key;
553 if (levenshtein($value, $answer) <= 4)
return $key;
556 if (levenshtein($value, $answer) <= 5)
return $key;
588 switch ($a_text_rating)
597 $this->text_rating = $a_text_rating;
627 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
628 $ilDB->quote($active_id .
""),
629 $ilDB->quote($this->
getId() .
""),
630 $ilDB->quote(
$pass .
"")
632 $result = $ilDB->query($query);
634 while (
$data = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
636 $enteredtext =
$data[
"value1"];
638 if ($index !== FALSE)
640 unset($available_answers[$index]);
641 $points += $this->answers[$index]->getPoints();
659 $this->correctanswers = $a_correct_answers;
692 include_once
"./Modules/Test/classes/class.ilObjTest.php";
697 $query = sprintf(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
698 $ilDB->quote($active_id .
""),
699 $ilDB->quote($this->
getId() .
""),
700 $ilDB->quote(
$pass .
"")
702 $result = $ilDB->query($query);
703 foreach ($_POST as $key => $value)
705 if (preg_match(
"/^TEXTSUBSET_(\d+)/", $key, $matches))
709 $query = sprintf(
"INSERT INTO tst_solutions (solution_id, active_fi, question_fi, value1, value2, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL, %s, NULL)",
710 $ilDB->quote($active_id),
711 $ilDB->quote($this->
getId()),
712 $ilDB->quote(trim($value)),
713 $ilDB->quote(
$pass .
"")
715 $result = $ilDB->query($query);
722 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
730 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
750 return "assTextSubset";
764 foreach ($this->answers as $answer)
766 if (!is_array($join[$answer->getPoints() .
""]))
768 $join[$answer->getPoints() .
""] = array();
770 array_push($join[$answer->getPoints() .
""], $answer->getAnswertext());
786 foreach ($this->answers as $answer)
788 $len = strlen($answer->getAnswertext());
789 if ($len > $maxwidth) $maxwidth = $len;
791 return $maxwidth + 3;
804 return "qpl_question_textsubset";
817 return "qpl_answer_textsubset";
843 include_once (
"./classes/class.ilExcelUtils.php");
848 foreach ($solutions as $solution)
853 return $startrow + $i + 1;