24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
104 $this->answers = array();
105 $this->coords = array();
118 if (($this->title) and ($this->author) and ($this->question) and ($this->image_filename) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
147 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
158 include_once(
"./Services/RTE/classes/class.ilRTE.php");
164 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
165 $query = sprintf(
"INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, question_text, working_time, points, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
166 $ilDB->quote($question_type),
167 $ilDB->quote($this->obj_id),
168 $ilDB->quote($this->title),
169 $ilDB->quote($this->comment),
170 $ilDB->quote($this->author),
171 $ilDB->quote($this->owner),
173 $ilDB->quote($estw_time),
175 $ilDB->quote(
"$complete"),
176 $ilDB->quote($created),
179 $result = $ilDB->query($query);
180 if (PEAR::isError($result))
183 $ilias->raiseError($result->getMessage());
187 $this->
id = $ilDB->getLastInsertId();
188 $insertquery = sprintf(
"INSERT INTO qpl_question_imagemap (question_fi, image_file) VALUES (%s, %s)",
189 $ilDB->quote($this->id .
""),
190 $ilDB->quote($this->image_filename)
192 $ilDB->query($insertquery);
205 $query = sprintf(
"UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, working_time = %s, points = %s, complete = %s WHERE question_id = %s",
206 $ilDB->quote($this->obj_id.
""),
207 $ilDB->quote($this->title),
208 $ilDB->quote($this->comment),
209 $ilDB->quote($this->author),
211 $ilDB->quote($estw_time),
213 $ilDB->quote(
"$complete"),
214 $ilDB->quote($this->
id)
216 $result = $ilDB->query($query);
217 $query = sprintf(
"UPDATE qpl_question_imagemap SET image_file = %s WHERE question_fi = %s",
218 $ilDB->quote($this->image_filename),
219 $ilDB->quote($this->
id)
221 $result = $ilDB->query($query);
228 $ilias->raiseError(
$result->getMessage());
232 $query = sprintf(
"DELETE FROM qpl_answer_imagemap WHERE question_fi = %s",
233 $ilDB->quote($this->id)
235 $result = $ilDB->query($query);
237 foreach ($this->answers as $key => $value)
239 $answer_obj = $this->answers[$key];
241 $query = sprintf(
"INSERT INTO qpl_answer_imagemap (answer_id, question_fi, answertext, points, aorder, coords, area) VALUES (NULL, %s, %s, %s, %s, %s, %s)",
242 $ilDB->quote($this->id),
243 $ilDB->quote($answer_obj->getAnswertext() .
""),
244 $ilDB->quote($answer_obj->getPoints() .
""),
245 $ilDB->quote($answer_obj->getOrder() .
""),
246 $ilDB->quote($answer_obj->getCoords() .
""),
247 $ilDB->quote($answer_obj->getArea() .
"")
249 $answer_result = $ilDB->query($query);
270 $this_id = $this->
getId();
272 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
297 $clone->copyPageOfQuestion($this_id);
299 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
301 $clone->duplicateFeedbackGeneric($this_id);
303 $clone->duplicateFeedbackAnswer($this_id);
306 $clone->duplicateImage($this_id);
326 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
329 $source_questionpool = $this->
getObjId();
330 $clone->setObjId($target_questionpool);
354 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
355 if (!file_exists($imagepath)) {
359 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
360 print
"image could not be duplicated!!!! ";
367 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
368 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
369 if (!file_exists($imagepath))
374 if (!copy($imagepath_original .
$filename, $imagepath . $filename))
376 print
"image could not be copied!!!! ";
393 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_imagemap.* FROM qpl_questions, qpl_question_imagemap WHERE question_id = %s AND qpl_questions.question_id = qpl_question_imagemap.question_fi",
394 $ilDB->quote($question_id)
396 $result = $ilDB->query($query);
397 if ($result->numRows() == 1)
399 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
400 $this->
id = $question_id;
401 $this->obj_id =
$data->obj_fi;
402 $this->title =
$data->title;
403 $this->comment =
$data->comment;
404 $this->author =
$data->author;
405 $this->original_id =
$data->original_id;
406 $this->solution_hint =
$data->solution_hint;
407 $this->owner =
$data->owner;
408 include_once(
"./Services/RTE/classes/class.ilRTE.php");
410 $this->image_filename =
$data->image_file;
411 $this->points =
$data->points;
414 $query = sprintf(
"SELECT * FROM qpl_answer_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
415 $ilDB->quote($question_id)
417 $result = $ilDB->query($query);
418 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
419 if ($result->numRows() > 0)
421 while (
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
456 if (!empty($imagemap_tempfilename)) {
457 $fp = fopen($imagemap_tempfilename,
"r");
458 $contents = fread($fp, filesize($imagemap_tempfilename));
460 if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches)) {
461 for ($i=0; $i< count($matches[1]); $i++) {
462 preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
463 preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i],
$coords);
464 preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
465 $this->
addAnswer($alt[1], 0.0, count($this->answers),
$coords[1], $shape[1]);
505 if (!empty($image_tempfilename))
508 if (!file_exists($imagepath))
514 $this->ilias->raiseError(
"The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
516 global
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
531 for ($i = 0; $i < count($this->answers); $i++) {
535 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
563 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
564 if (array_key_exists($order, $this->answers))
568 for ($i = count($this->answers) - 1; $i >= $order; $i--)
570 $this->answers[$i+1] = $this->answers[$i];
571 $this->answers[$i+1]->setOrder($i+1);
573 $this->answers[$order] = $answer;
579 array_push($this->answers, $answer);
593 return count($this->answers);
608 if ($index < 0)
return NULL;
609 if (count($this->answers) < 1)
return NULL;
610 if ($index >= count($this->answers))
return NULL;
611 return $this->answers[$index];
639 if ($index < 0)
return;
640 if (count($this->answers) < 1)
return;
641 if ($index >= count($this->answers))
return;
642 unset($this->answers[$index]);
643 $this->answers = array_values($this->answers);
644 for ($i = 0; $i < count($this->answers); $i++) {
645 if ($this->answers[$i]->getOrder() > $index) {
646 $this->answers[$i]->setOrder($i);
660 $this->answers = array();
673 foreach ($this->answers as $key => $value) {
674 if ($value->getPoints() >
$points)
697 $found_values = array();
702 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
703 $ilDB->quote($active_id .
""),
704 $ilDB->quote($this->
getId() .
""),
705 $ilDB->quote(
$pass .
"")
707 $result = $ilDB->query($query);
708 while (
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
710 if (strcmp(
$data->value1,
"") != 0)
712 array_push($found_values,
$data->value1);
716 if (count($found_values) > 0)
718 foreach ($this->answers as $key => $answer)
720 if (in_array($key, $found_values))
722 $points += $answer->getPoints();
748 include_once
"./Modules/Test/classes/class.ilObjTest.php";
752 $query = sprintf(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
753 $ilDB->quote($active_id .
""),
754 $ilDB->quote($this->
getId() .
""),
755 $ilDB->quote(
$pass .
"")
757 $result = $ilDB->query($query);
759 if (strlen(
$_GET[
"selImage"]))
761 $query = sprintf(
"INSERT INTO tst_solutions (solution_id, active_fi, question_fi, value1, value2, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL, %s, NULL)",
762 $ilDB->quote($active_id),
763 $ilDB->quote($this->
getId()),
764 $ilDB->quote(
$_GET[
"selImage"]),
765 $ilDB->quote(
$pass .
"")
768 $result = $ilDB->query($query);
769 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
777 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
807 return "assImagemapQuestion";
820 return "qpl_question_imagemap";
833 return "qpl_answer_imagemap";
849 $query = sprintf(
"DELETE FROM qpl_feedback_imagemap WHERE question_fi = %s AND answer = %s",
850 $ilDB->quote($this->getId() .
""),
851 $ilDB->quote($answer_index .
"")
853 $result = $ilDB->query($query);
854 if (strlen($feedback))
856 include_once(
"./Services/RTE/classes/class.ilRTE.php");
857 $query = sprintf(
"INSERT INTO qpl_feedback_imagemap VALUES (NULL, %s, %s, %s, NULL)",
858 $ilDB->quote($this->getId() .
""),
859 $ilDB->quote($answer_index .
""),
862 $result = $ilDB->query($query);
880 $deletequery = sprintf(
"DELETE FROM qpl_feedback_imagemap WHERE question_fi = %s",
881 $ilDB->quote($this->original_id .
"")
883 $result = $ilDB->query($deletequery);
886 $query = sprintf(
"SELECT * FROM qpl_feedback_imagemap WHERE question_fi = %s",
887 $ilDB->quote($this->getId() .
"")
889 $result = $ilDB->query($query);
892 if ($result->numRows())
894 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
896 $duplicatequery = sprintf(
"INSERT INTO qpl_feedback_imagemap VALUES (NULL, %s, %s, %s, NULL)",
897 $ilDB->quote($this->original_id .
""),
898 $ilDB->quote($row[
"answer"] .
""),
899 $ilDB->quote($row[
"feedback"] .
"")
901 $duplicateresult = $ilDB->query($duplicatequery);
920 $query = sprintf(
"SELECT * FROM qpl_feedback_imagemap WHERE question_fi = %s AND answer = %s",
921 $ilDB->quote($this->getId() .
""),
922 $ilDB->quote($answer_index .
"")
924 $result = $ilDB->query($query);
925 if ($result->numRows())
927 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
928 include_once(
"./Services/RTE/classes/class.ilRTE.php");
947 $query = sprintf(
"SELECT * FROM qpl_feedback_imagemap WHERE question_fi = %s",
950 $result = $ilDB->query($query);
951 if ($result->numRows())
953 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
955 $duplicatequery = sprintf(
"INSERT INTO qpl_feedback_imagemap VALUES (NULL, %s, %s, %s, NULL)",
956 $ilDB->quote($this->getId() .
""),
957 $ilDB->quote($row[
"answer"] .
""),
958 $ilDB->quote($row[
"feedback"] .
"")
960 $duplicateresult = $ilDB->query($duplicatequery);
972 foreach ($this->answers as $index => $answer)
993 include_once (
"./classes/class.ilExcelUtils.php");
1000 $worksheet->writeString($startrow + $i, 0,
ilExcelUtils::_convert_text($answer->getArea() .
": " . $answer->getCoords()), $format_bold);
1001 if (
$id == $solution[0][
"value1"])
1003 $worksheet->write($startrow + $i, 1, 1);
1007 $worksheet->write($startrow + $i, 1, 0);
1011 return $startrow + $i + 1;