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 (strlen($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 if( (
int)$testObjId > 0 )
180 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
184 if( (
int)$testObjId > 0 )
186 $clone->setObjId($testObjId);
211 $clone->copyPageOfQuestion($this_id);
213 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
215 $clone->duplicateFeedbackGeneric($this_id);
217 $clone->duplicateFeedbackAnswer($this_id);
220 $clone->duplicateImage($this_id, $thisObjId);
222 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
243 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
246 $source_questionpool = $this->
getObjId();
247 $clone->setObjId($target_questionpool);
272 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
274 if( (
int)$objectId > 0 )
276 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
279 if (!file_exists($imagepath)) {
283 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
284 print
"image could not be duplicated!!!! ";
291 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
292 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
293 if (!file_exists($imagepath))
298 if (!copy($imagepath_original .
$filename, $imagepath . $filename))
300 print
"image could not be copied!!!! ";
324 $this->
setId($question_id);
333 include_once(
"./Services/RTE/classes/class.ilRTE.php");
338 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
342 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
363 if (!empty($imagemap_filename))
365 $fp = fopen($imagemap_filename,
"r");
366 $contents = fread($fp, filesize($imagemap_filename));
368 if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches))
370 for ($i=0; $i< count($matches[1]); $i++)
372 preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
373 preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i],
$coords);
374 preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
375 $this->
addAnswer($alt[1], 0.0, count($this->answers),
$coords[1], $shape[1]);
402 if (!empty($image_tempfilename))
405 if (!file_exists($imagepath))
411 $this->ilias->raiseError(
"The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
413 global
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
428 for ($i = 0; $i < count($this->answers); $i++) {
432 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
460 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
461 if (array_key_exists($order, $this->answers))
465 for ($i = count($this->answers) - 1; $i >= $order; $i--)
467 $this->answers[$i+1] = $this->answers[$i];
468 $this->answers[$i+1]->setOrder($i+1);
470 $this->answers[$order] = $answer;
476 array_push($this->answers, $answer);
490 return count($this->answers);
505 if ($index < 0)
return NULL;
506 if (count($this->answers) < 1)
return NULL;
507 if ($index >= count($this->answers))
return NULL;
508 return $this->answers[$index];
537 if ($index < 0)
return;
538 if (count($this->answers) < 1)
return;
539 if ($index >= count($this->answers))
return;
540 unset($this->answers[$index]);
541 $this->answers = array_values($this->answers);
542 for ($i = 0; $i < count($this->answers); $i++) {
543 if ($this->answers[$i]->getOrder() > $index) {
544 $this->answers[$i]->setOrder($i);
558 $this->answers = array();
571 foreach ($this->answers as $key => $value) {
572 if ($value->getPoints() >
$points)
595 $found_values = array();
600 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
601 array(
"integer",
"integer",
"integer"),
606 if (strcmp(
$data[
"value1"],
"") != 0)
608 array_push($found_values,
$data[
"value1"]);
612 if (count($found_values) > 0)
614 foreach ($this->answers as $key => $answer)
616 if (in_array($key, $found_values))
618 $points += $answer->getPoints();
644 include_once
"./Modules/Test/classes/class.ilObjTest.php";
648 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
649 array(
"integer",
"integer",
"integer"),
653 if (strlen(
$_GET[
"selImage"]))
655 $next_id = $ilDB->nextId(
'tst_solutions');
656 $affectedRows = $ilDB->insert(
"tst_solutions", array(
657 "solution_id" => array(
"integer", $next_id),
658 "active_fi" => array(
"integer", $active_id),
659 "question_fi" => array(
"integer", $this->
getId()),
660 "value1" => array(
"clob",
$_GET[
'selImage']),
661 "value2" => array(
"clob", null),
662 "pass" => array(
"integer",
$pass),
663 "tstamp" => array(
"integer", time())
666 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
674 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
690 $this->syncFeedbackSingleAnswers();
704 return "assImagemapQuestion";
717 return "qpl_qst_imagemap";
730 return "qpl_a_imagemap";
740 function saveFeedbackSingleAnswer($answer_index, $feedback)
744 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_imap WHERE question_fi = %s AND answer = %s",
745 array(
"integer",
"integer"),
746 array($this->
getId(), $answer_index)
748 if (strlen($feedback))
750 include_once(
"./Services/RTE/classes/class.ilRTE.php");
751 $next_id = $ilDB->nextId(
'qpl_fb_imap');
754 $ilDB->insert(
'qpl_fb_imap', array(
755 'feedback_id' => array(
'integer', $next_id ),
756 'question_fi' => array(
'integer', $this->
getId() ),
757 'answer' => array(
'integer', $answer_index ),
759 'tstamp' => array(
'integer', time() ),
771 function syncFeedbackSingleAnswers()
778 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_imap WHERE question_fi = %s",
780 array($this->original_id)
784 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s",
786 array($this->
getId())
794 $next_id = $ilDB->nextId(
'qpl_fb_imap');
797 $ilDB->insert(
'qpl_fb_imap', array(
798 'feedback_id' => array(
'integer', $next_id ),
799 'question_fi' => array(
'integer', $this->original_id ),
800 'answer' => array(
'integer',
$row[
"answer"] ),
801 'feedback' => array(
'clob',
$row[
"feedback"] ),
802 'tstamp' => array(
'integer', time() ),
821 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s AND answer = %s",
822 array(
'integer',
'integer'),
823 array($this->
getId(), $answer_index)
828 include_once(
"./Services/RTE/classes/class.ilRTE.php");
845 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_imap WHERE question_fi = %s",
853 $next_id = $ilDB->nextId(
'qpl_fb_imap');
856 $ilDB->insert(
'qpl_fb_imap', array(
857 'feedback_id' => array(
'integer', $next_id ),
858 'question_fi' => array(
'integer', $this->
getId() ),
859 'answer' => array(
'integer',
$row[
"answer"] ),
860 'feedback' => array(
'clob',
$row[
"feedback"] ),
861 'tstamp' => array(
'integer', time() ),
876 foreach ($this->answers as $index => $answer)
897 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
904 $worksheet->writeString($startrow + $i, 0,
ilExcelUtils::_convert_text($answer->getArea() .
": " . $answer->getCoords()), $format_bold);
905 if (
$id == $solution[0][
"value1"])
907 $worksheet->write($startrow + $i, 1, 1);
911 $worksheet->write($startrow + $i, 1, 0);
915 return $startrow + $i + 1;
926 $this->image_filename =
"";
934 include_once(
"./Services/RTE/classes/class.ilRTE.php");
949 foreach ($this->
getAnswers() as $key => $answer_obj)
952 "answertext" => (
string) $answer_obj->getAnswertext(),
953 "points" => (float) $answer_obj->getPoints(),
954 "order" => (int) $answer_obj->getOrder(),
955 "coords" => $answer_obj->getCoords(),
956 "state" => $answer_obj->getState(),
957 "area" => $answer_obj->getArea(),