23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
61 $this->errortext =
"";
62 $this->textsize = 100.0;
63 $this->errordata = array();
73 if (($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0))
94 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
99 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, errortext, textsize, points_wrong) VALUES (%s, %s, %s, %s)",
100 array(
"integer",
"text",
"float",
"float"),
109 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_errortext WHERE question_fi = %s",
111 array($this->
getId())
115 foreach ($this->errordata as $object)
117 $next_id = $ilDB->nextId(
'qpl_a_errortext');
118 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_a_errortext (answer_id, question_fi, text_wrong, text_correct, points, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
119 array(
'integer',
'integer',
'text',
'text',
'float',
'integer'),
124 $object->text_correct,
148 if ($result->numRows() == 1)
150 $data = $ilDB->fetchAssoc($result);
151 $this->
setId($question_id);
160 include_once(
"./Services/RTE/classes/class.ilRTE.php");
168 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_errortext WHERE question_fi = %s ORDER BY sequence ASC",
172 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
173 if ($result->numRows() > 0)
175 while (
$data = $ilDB->fetchAssoc($result))
195 $this_id = $this->
getId();
197 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
223 $clone->copyPageOfQuestion($this_id);
225 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
227 $clone->duplicateFeedbackGeneric($this_id);
229 $clone->onDuplicate($this_id);
245 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
248 $source_questionpool = $this->
getObjId();
249 $clone->setObjId($target_questionpool);
276 foreach ($this->errordata as $object)
278 if ($object->points > 0) $maxpoints += $object->points;
295 $found_values = array();
300 $result = $ilDB->queryF(
"SELECT value1 FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
301 array(
'integer',
'integer',
'integer'),
304 while (
$row = $ilDB->fetchAssoc($result))
306 array_push($found_values,
$row[
'value1']);
323 include_once
"./Modules/Test/classes/class.ilObjTest.php";
327 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s",
328 array(
'integer',
'integer',
'integer',
'text'),
329 array($active_id, $this->
getId(),
$pass, $position)
331 if ($affectedRows == 0)
333 $next_id = $ilDB->nextId(
'tst_solutions');
334 $affectedRows = $ilDB->insert(
"tst_solutions", array(
335 "solution_id" => array(
"integer", $next_id),
336 "active_fi" => array(
"integer", $active_id),
337 "question_fi" => array(
"integer", $this->
getId()),
338 "value1" => array(
"clob", $position),
339 "value2" => array(
"clob", null),
340 "pass" => array(
"integer",
$pass),
341 "tstamp" => array(
"integer", time())
344 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
366 include_once
"./Modules/Test/classes/class.ilObjTest.php";
370 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
371 array(
'integer',
'integer',
'integer'),
375 $entered_values =
false;
378 $selected = split(
",",
$_POST[
"qst_" . $this->
getId()]);
379 foreach ($selected as $position)
381 $next_id = $ilDB->nextId(
'tst_solutions');
382 $affectedRows = $ilDB->insert(
"tst_solutions", array(
383 "solution_id" => array(
"integer", $next_id),
384 "active_fi" => array(
"integer", $active_id),
385 "question_fi" => array(
"integer", $this->
getId()),
386 "value1" => array(
"clob", $position),
387 "value2" => array(
"clob", null),
388 "pass" => array(
"integer",
$pass),
389 "tstamp" => array(
"integer", time())
392 $entered_values =
true;
396 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
404 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
421 return "assErrorText";
431 return "qpl_qst_errortext";
473 $adapter->setCellValue($startrow, 0, $this->lng->txt($this->getQuestionType()),
CELL_FORMAT_TITLE);
479 $selections = array();
481 if (is_array($solutions))
483 foreach ($solutions as $solution)
485 array_push($selections, $solution[
'value1']);
487 $errortext_value = join(
",", $selections);
492 $adapter->setCellValue($startrow+$i, 0,
$errortext);
495 return $startrow + $i + 1;
510 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
512 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assErrorTextImport.php";
514 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
523 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
525 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assErrorTextExport.php";
527 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
537 $user_solution = array();
538 return $user_solution;
543 if (strlen($a_text) == 0) $a_text = $this->
getErrorText();
544 preg_match_all(
"/#([^\s]+)/is", $a_text, $matches);
545 if (is_array($matches[1]))
557 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
559 $this->errordata = array();
560 foreach ($a_data as
$error)
564 foreach ($temp as $object)
566 if (strcmp($object->text_wrong, $error) == 0)
568 $text_correct = $object->text_correct;
581 include_once
"./Services/Utilities/classes/class.ilStr.php";
582 if (!is_array($selections)) $selections = array();
583 $textarray = preg_split(
"/[\n\r]+/", $this->
getErrorText());
584 foreach ($textarray as $textidx => $text)
586 $items = preg_split(
"/\s+/", $text);
587 foreach ($items as $idx => $item)
589 if (strpos($item,
'#') === 0)
591 $item = ilStr::substr($item, 1, ilStr::strlen($item));
592 if ($correct_solution)
594 $errorobject = $this->errordata[$errorcounter];
595 if (is_object($errorobject))
597 $item = $errorobject->text_correct;
604 if (in_array($counter, $selections))
606 $class =
' class="sel"';
607 if ($graphicalOutput)
611 $img =
' <img src="' .
ilUtil::getImagePath(
"icon_ok.gif") .
'" alt="' . $this->lng->txt(
"answer_is_right") .
'" title="' . $this->lng->txt(
"answer_is_right") .
'" /> ';
615 $img =
' <img src="' .
ilUtil::getImagePath(
"icon_not_ok.gif") .
'" alt="' . $this->lng->txt(
"answer_is_wrong") .
'" title="' . $this->lng->txt(
"answer_is_wrong") .
'" /> ';
619 $items[$idx] =
'<a' . $class .
' href="#HREF' . $idx .
'" onclick="javascript: return false;">' .
ilUtil::prepareFormOutput($item) .
'</a>' .
$img;
622 $textarray[$textidx] =
'<p>' . join($items,
" ") .
'</p>';
624 return join($textarray,
"\n");
631 include_once
"./Services/Utilities/classes/class.ilStr.php";
632 if (!is_array($selections)) $selections = array();
633 $textarray = preg_split(
"/[\n\r]+/", $this->
getErrorText());
634 foreach ($textarray as $textidx => $text)
636 $items = preg_split(
"/\s+/", $text);
637 foreach ($items as $idx => $item)
639 if (strpos($item,
'#') === 0)
641 $item = ilStr::substr($item, 1, ilStr::strlen($item));
642 if ($correct_solution)
644 $errorobject = $this->errordata[$errorcounter];
645 if (is_object($errorobject))
647 $item = $errorobject->text_correct;
653 if (in_array($counter, $selections))
658 if (in_array($counter, $selections))
662 $items[$idx] = $word;
665 $textarray[$textidx] = join($items,
" ");
667 return join($textarray,
"\n");
675 $textarray = preg_split(
"/[\n\r]+/", $this->
getErrorText());
676 foreach ($textarray as $textidx => $text)
678 $items = preg_split(
"/\s+/", $text);
679 foreach ($items as $word)
682 if (strpos($word,
'#') === 0)
684 $errorobject = $this->errordata[$errorcounter];
685 if (is_object($errorobject))
687 $points = $errorobject->points;
691 $words[$counter] = array(
"word" => $word,
"points" =>
$points);
695 $selections = array();
696 foreach ($words as $idx => $word)
698 if ($word[
'points'] > 0)
700 array_push($selections, $idx);
711 $textarray = preg_split(
"/[\n\r]+/", $this->
getErrorText());
712 foreach ($textarray as $textidx => $text)
714 $items = preg_split(
"/\s+/", $text);
715 foreach ($items as $word)
718 if (strpos($word,
'#') === 0)
720 $errorobject = $this->errordata[$errorcounter];
721 if (is_object($errorobject))
723 $points = $errorobject->points;
727 $words[$counter] = array(
"word" => $word,
"points" =>
$points);
732 foreach ($positions as $position)
734 $total += $words[$position][
'points'];
744 $this->errordata = array();
749 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
780 $this->errortext = $a_value;
800 $this->textsize = $a_value;
820 $this->points_wrong = $a_value;