5 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
76 $this->answers = array();
77 $this->coords = array();
88 if (strlen($this->title) and ($this->author) and ($this->question) and ($this->image_filename) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
113 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
115 array($this->
getId())
117 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, image_file) VALUES (%s, %s)",
118 array(
"integer",
"text"),
121 $this->image_filename
125 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
127 array($this->
getId())
131 foreach ($this->answers as $key => $value)
133 $answer_obj = $this->answers[$key];
134 $next_id = $ilDB->nextId(
'qpl_a_imagemap');
135 $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)",
136 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text"),
137 array($next_id, $this->
id, $answer_obj->getAnswertext(), $answer_obj->getPoints(), $answer_obj->getOrder(), $answer_obj->getCoords(), $answer_obj->getArea())
157 $this_id = $this->
getId();
159 if( (
int)$testObjId > 0 )
165 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
169 if( (
int)$testObjId > 0 )
171 $clone->setObjId($testObjId);
196 $clone->copyPageOfQuestion($this_id);
198 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
200 $clone->duplicateGenericFeedback($this_id);
202 $clone->duplicateFeedbackAnswer($this_id);
205 $clone->duplicateImage($this_id, $thisObjId);
207 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
228 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
231 $source_questionpool = $this->
getObjId();
232 $clone->setObjId($target_questionpool);
257 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
259 if( (
int)$objectId > 0 )
261 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
264 if (!file_exists($imagepath)) {
268 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
269 print
"image could not be duplicated!!!! ";
276 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
277 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
278 if (!file_exists($imagepath))
283 if (!copy($imagepath_original .
$filename, $imagepath . $filename))
285 print
"image could not be copied!!!! ";
309 $this->
setId($question_id);
318 include_once(
"./Services/RTE/classes/class.ilRTE.php");
323 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
327 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
348 if (!empty($imagemap_filename))
350 $fp = fopen($imagemap_filename,
"r");
351 $contents = fread($fp, filesize($imagemap_filename));
353 if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches))
355 for ($i=0; $i< count($matches[1]); $i++)
357 preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
358 preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i],
$coords);
359 preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
360 $this->
addAnswer($alt[1], 0.0, count($this->answers),
$coords[1], $shape[1]);
387 if (!empty($image_tempfilename))
390 if (!file_exists($imagepath))
396 $this->ilias->raiseError(
"The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
398 global
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
413 for ($i = 0; $i < count($this->answers); $i++) {
417 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
445 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
446 if (array_key_exists($order, $this->answers))
450 for ($i = count($this->answers) - 1; $i >= $order; $i--)
452 $this->answers[$i+1] = $this->answers[$i];
453 $this->answers[$i+1]->setOrder($i+1);
455 $this->answers[$order] = $answer;
461 array_push($this->answers, $answer);
475 return count($this->answers);
490 if ($index < 0)
return NULL;
491 if (count($this->answers) < 1)
return NULL;
492 if ($index >= count($this->answers))
return NULL;
493 return $this->answers[$index];
522 if ($index < 0)
return;
523 if (count($this->answers) < 1)
return;
524 if ($index >= count($this->answers))
return;
525 unset($this->answers[$index]);
526 $this->answers = array_values($this->answers);
527 for ($i = 0; $i < count($this->answers); $i++) {
528 if ($this->answers[$i]->getOrder() > $index) {
529 $this->answers[$i]->setOrder($i);
543 $this->answers = array();
556 foreach ($this->answers as $key => $value) {
557 if ($value->getPoints() >
$points)
579 throw new ilTestException(
'return details not implemented for '.__METHOD__);
584 $found_values = array();
589 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
590 array(
"integer",
"integer",
"integer"),
595 if (strcmp(
$data[
"value1"],
"") != 0)
597 array_push($found_values,
$data[
"value1"]);
601 if (count($found_values) > 0)
603 foreach ($this->answers as $key => $answer)
605 if (in_array($key, $found_values))
607 $points += $answer->getPoints();
630 include_once
"./Modules/Test/classes/class.ilObjTest.php";
634 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
635 array(
"integer",
"integer",
"integer"),
639 if (strlen(
$_GET[
"selImage"]))
641 $next_id = $ilDB->nextId(
'tst_solutions');
642 $affectedRows = $ilDB->insert(
"tst_solutions", array(
643 "solution_id" => array(
"integer", $next_id),
644 "active_fi" => array(
"integer", $active_id),
645 "question_fi" => array(
"integer", $this->
getId()),
646 "value1" => array(
"clob",
$_GET[
'selImage']),
647 "value2" => array(
"clob", null),
648 "pass" => array(
"integer",
$pass),
649 "tstamp" => array(
"integer", time())
652 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
660 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
688 $this->syncFeedbackSingleAnswers();
702 return "assImagemapQuestion";
715 return "qpl_qst_imagemap";
728 return "qpl_a_imagemap";
738 function saveFeedbackSingleAnswer($answer_index, $feedback)
742 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_imap WHERE question_fi = %s AND answer = %s",
743 array(
"integer",
"integer"),
744 array($this->
getId(), $answer_index)
746 if (strlen($feedback))
748 include_once(
"./Services/RTE/classes/class.ilRTE.php");
749 $next_id = $ilDB->nextId(
'qpl_fb_imap');
752 $ilDB->insert(
'qpl_fb_imap', array(
753 'feedback_id' => array(
'integer', $next_id ),
754 'question_fi' => array(
'integer', $this->
getId() ),
755 'answer' => array(
'integer', $answer_index ),
757 'tstamp' => array(
'integer', time() ),
768 function syncFeedbackSingleAnswers()
775 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_imap WHERE question_fi = %s",
777 array($this->original_id)
781 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s",
783 array($this->
getId())
791 $next_id = $ilDB->nextId(
'qpl_fb_imap');
793 $ilDB->insert(
'qpl_fb_imap', array(
794 'feedback_id' => array(
'integer', $next_id ),
795 'question_fi' => array(
'integer', $this->original_id ),
796 'answer' => array(
'integer',
$row[
"answer"] ),
797 'feedback' => array(
'clob',
$row[
"feedback"] ),
798 'tstamp' => array(
'integer', time() ),
817 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s AND answer = %s",
818 array(
'integer',
'integer'),
819 array($this->
getId(), $answer_index)
824 include_once(
"./Services/RTE/classes/class.ilRTE.php");
841 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s",
849 $next_id = $ilDB->nextId(
'qpl_fb_imap');
851 $ilDB->insert(
'qpl_fb_imap', array(
852 'feedback_id' => array(
'integer', $next_id ),
853 'question_fi' => array(
'integer', $this->
getId() ),
854 'answer' => array(
'integer',
$row[
"answer"] ),
855 'feedback' => array(
'clob',
$row[
"feedback"] ),
856 'tstamp' => array(
'integer', time() ),
870 foreach ($this->answers as $index => $answer)
891 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
898 $worksheet->writeString($startrow + $i, 0,
ilExcelUtils::_convert_text($answer->getArea() .
": " . $answer->getCoords()), $format_bold);
899 if (
$id == $solution[0][
"value1"])
901 $worksheet->write($startrow + $i, 1, 1);
905 $worksheet->write($startrow + $i, 1, 0);
909 return $startrow + $i + 1;
920 $this->image_filename =
"";
928 include_once(
"./Services/RTE/classes/class.ilRTE.php");
943 foreach ($this->
getAnswers() as $key => $answer_obj)
946 "answertext" => (
string) $answer_obj->getAnswertext(),
947 "points" => (float) $answer_obj->getPoints(),
948 "order" => (int) $answer_obj->getOrder(),
949 "coords" => $answer_obj->getCoords(),
950 "state" => $answer_obj->getState(),
951 "area" => $answer_obj->getArea(),