24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
91 $this->answers = array();
92 $this->coords = array();
103 if (($this->title) and ($this->author) and ($this->question) and ($this->image_filename) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
128 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
130 array($this->
getId())
132 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, image_file) VALUES (%s, %s)",
133 array(
"integer",
"text"),
136 $this->image_filename
140 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
142 array($this->
getId())
146 foreach ($this->answers as $key => $value)
148 $answer_obj = $this->answers[$key];
149 $next_id = $ilDB->nextId(
'qpl_a_imagemap');
150 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_a_imagemap (answer_id, question_fi, answertext, points, aorder, coords, area) VALUES (%s, %s, %s, %s, %s, %s, %s)",
151 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text"),
152 array($next_id, $this->
id, $answer_obj->getAnswertext(), $answer_obj->getPoints(), $answer_obj->getOrder(), $answer_obj->getCoords(), $answer_obj->getArea())
172 $this_id = $this->
getId();
174 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
199 $clone->copyPageOfQuestion($this_id);
201 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
203 $clone->duplicateFeedbackGeneric($this_id);
205 $clone->duplicateFeedbackAnswer($this_id);
208 $clone->duplicateImage($this_id);
209 $clone->onDuplicate($this_id);
229 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
232 $source_questionpool = $this->
getObjId();
233 $clone->setObjId($target_questionpool);
258 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
259 if (!file_exists($imagepath)) {
263 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
264 print
"image could not be duplicated!!!! ";
271 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
272 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
273 if (!file_exists($imagepath))
278 if (!copy($imagepath_original .
$filename, $imagepath . $filename))
280 print
"image could not be copied!!!! ";
301 if ($result->numRows() == 1)
303 $data = $ilDB->fetchAssoc($result);
304 $this->
setId($question_id);
313 include_once(
"./Services/RTE/classes/class.ilRTE.php");
318 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
322 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
323 if ($result->numRows() > 0)
325 while (
$data = $ilDB->fetchAssoc($result))
343 if (!empty($imagemap_filename))
345 $fp = fopen($imagemap_filename,
"r");
346 $contents = fread($fp, filesize($imagemap_filename));
348 if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches))
350 for ($i=0; $i< count($matches[1]); $i++)
352 preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
353 preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i],
$coords);
354 preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
355 $this->
addAnswer($alt[1], 0.0, count($this->answers),
$coords[1], $shape[1]);
382 if (!empty($image_tempfilename))
385 if (!file_exists($imagepath))
391 $this->ilias->raiseError(
"The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
393 global
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
408 for ($i = 0; $i < count($this->answers); $i++) {
412 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
440 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
441 if (array_key_exists($order, $this->answers))
445 for ($i = count($this->answers) - 1; $i >= $order; $i--)
447 $this->answers[$i+1] = $this->answers[$i];
448 $this->answers[$i+1]->setOrder($i+1);
450 $this->answers[$order] = $answer;
456 array_push($this->answers, $answer);
470 return count($this->answers);
485 if ($index < 0)
return NULL;
486 if (count($this->answers) < 1)
return NULL;
487 if ($index >= count($this->answers))
return NULL;
488 return $this->answers[$index];
517 if ($index < 0)
return;
518 if (count($this->answers) < 1)
return;
519 if ($index >= count($this->answers))
return;
520 unset($this->answers[$index]);
521 $this->answers = array_values($this->answers);
522 for ($i = 0; $i < count($this->answers); $i++) {
523 if ($this->answers[$i]->getOrder() > $index) {
524 $this->answers[$i]->setOrder($i);
538 $this->answers = array();
551 foreach ($this->answers as $key => $value) {
552 if ($value->getPoints() >
$points)
575 $found_values = array();
580 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
581 array(
"integer",
"integer",
"integer"),
584 while (
$data = $ilDB->fetchAssoc($result))
586 if (strcmp(
$data[
"value1"],
"") != 0)
588 array_push($found_values,
$data[
"value1"]);
592 if (count($found_values) > 0)
594 foreach ($this->answers as $key => $answer)
596 if (in_array($key, $found_values))
598 $points += $answer->getPoints();
624 include_once
"./Modules/Test/classes/class.ilObjTest.php";
628 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
629 array(
"integer",
"integer",
"integer"),
633 if (strlen(
$_GET[
"selImage"]))
635 $next_id = $ilDB->nextId(
'tst_solutions');
636 $affectedRows = $ilDB->insert(
"tst_solutions", array(
637 "solution_id" => array(
"integer", $next_id),
638 "active_fi" => array(
"integer", $active_id),
639 "question_fi" => array(
"integer", $this->
getId()),
640 "value1" => array(
"clob",
$_GET[
'selImage']),
641 "value2" => array(
"clob", null),
642 "pass" => array(
"integer",
$pass),
643 "tstamp" => array(
"integer", time())
646 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
654 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
684 return "assImagemapQuestion";
697 return "qpl_qst_imagemap";
710 return "qpl_a_imagemap";
724 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_imap WHERE question_fi = %s AND answer = %s",
725 array(
"integer",
"integer"),
726 array($this->
getId(), $answer_index)
728 if (strlen($feedback))
730 include_once(
"./Services/RTE/classes/class.ilRTE.php");
731 $next_id = $ilDB->nextId(
'qpl_fb_imap');
732 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_imap (feedback_id, question_fi, answer, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
733 array(
"integer",
"integer",
"integer",
"text",
"integer"),
751 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_imap WHERE question_fi = %s",
753 array($this->original_id)
757 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s",
759 array($this->
getId())
763 if ($result->numRows())
765 while (
$row = $ilDB->fetchAssoc($result))
767 $next_id = $ilDB->nextId(
'qpl_fb_imap');
768 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_imap (feedback_id, question_fi, answer, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
769 array(
"integer",
"integer",
"integer",
"text",
"integer"),
770 array($next_id, $this->original_id,
$row[
"answer"],
$row[
"feedback"], time())
788 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s AND answer = %s",
789 array(
'integer',
'integer'),
790 array($this->
getId(), $answer_index)
792 if ($result->numRows())
794 $row = $ilDB->fetchAssoc($result);
795 include_once(
"./Services/RTE/classes/class.ilRTE.php");
812 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s",
816 if ($result->numRows())
818 while (
$row = $ilDB->fetchAssoc($result))
820 $next_id = $ilDB->nextId(
'qpl_fb_imap');
821 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_imap (feedback_id, question_fi, answer, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
822 array(
"integer",
"integer",
"integer",
"text",
"integer"),
823 array($next_id, $this->
getId(),
$row[
"answer"],
$row[
"feedback"], time())
836 foreach ($this->answers as $index => $answer)
855 $adapter->setCellValue($startrow, 0, $this->lng->txt($this->getQuestionType()),
CELL_FORMAT_TITLE);
862 $adapter->setCellValue($startrow + $i, 0, $answer->getArea() .
": " . $answer->getCoords(),
CELL_FORMAT_BOLD);
864 if (
$id == $solution[0][
"value1"])
866 $adapter->setCellValue($startrow + $i, 1, 1);
871 $adapter->setCellValue($startrow + $i, 1, 0);
876 return $startrow + $i + 1;
887 $this->image_filename =
"";
895 include_once(
"./Services/RTE/classes/class.ilRTE.php");
897 $result[
'id'] = (int) $this->
getId();
899 $result[
'title'] = (string) $this->
getTitle();
902 $result[
'shuffle'] = (bool) $this->
getShuffle();
903 $result[
'feedback'] = array(
910 foreach ($this->
getAnswers() as $key => $answer_obj)
913 "answertext" => (
string) $answer_obj->getAnswertext(),
914 "points" => (float) $answer_obj->getPoints(),
915 "order" => (int) $answer_obj->getOrder(),
916 "coords" => $answer_obj->getCoords(),
917 "state" => $answer_obj->getState(),
918 "area" => $answer_obj->getArea(),
924 $result[
'mobs'] =
$mobs;
925 return json_encode($result);