4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
8 require_once
'./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9 require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
69 $this->answers = array();
70 $this->coords = array();
101 if (strlen($this->title)
104 && ($this->image_filename)
105 && (count($this->answers))
134 $ilDB->manipulateF(
"DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
136 array( $this->
getId() )
140 foreach ($this->answers as $key => $value)
142 $answer_obj = $this->answers[$key];
143 $next_id = $ilDB->nextId(
'qpl_a_imagemap' );
144 $ilDB->manipulateF(
"INSERT INTO qpl_a_imagemap (answer_id, question_fi, answertext, points, aorder, coords, area, points_unchecked) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
145 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"float" ),
146 array( $next_id, $this->
id, $answer_obj->getAnswertext(
147 ), $answer_obj->getPoints(), $answer_obj->getOrder(
148 ), $answer_obj->getCoords(), $answer_obj->getArea(
149 ), $answer_obj->getPointsUnchecked() )
160 array( $this->
getId() )
164 ) .
" (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
165 array(
"integer",
"text",
'integer' ),
168 $this->image_filename,
169 (
int)$this->is_multiple_choice
187 $this_id = $this->
getId();
191 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
195 if( (
int)$testObjId > 0 )
197 $clone->setObjId($testObjId);
222 $clone->copyPageOfQuestion($this_id);
224 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
226 $clone->duplicateImage($this_id, $thisObjId);
228 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
249 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
252 $source_questionpool_id = $this->
getObjId();
253 $clone->setObjId($target_questionpool_id);
265 $clone->copyImage(
$original_id, $source_questionpool_id);
267 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
280 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
283 $sourceParentId = $this->
getObjId();
289 $clone->setObjId($targetParentId);
291 if ($targetQuestionTitle)
293 $clone->setTitle($targetQuestionTitle);
298 $clone->copyPageOfQuestion($sourceQuestionId);
300 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
302 $clone->copyImage($sourceQuestionId, $sourceParentId);
304 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
312 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
314 if( (
int)$objectId > 0 )
316 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
319 if (!file_exists($imagepath)) {
323 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
324 print
"image could not be duplicated!!!! ";
331 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
332 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
333 if (!file_exists($imagepath))
338 if (!copy($imagepath_original .
$filename, $imagepath . $filename))
340 print
"image could not be copied!!!! ";
363 $data = $ilDB->fetchAssoc(
$result);
364 $this->
setId($question_id);
374 include_once(
"./Services/RTE/classes/class.ilRTE.php");
377 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
387 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
391 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
394 while ($data = $ilDB->fetchAssoc(
$result))
396 array_push($this->answers,
new ASS_AnswerImagemap($data[
"answertext"], $data[
"points"], $data[
"aorder"], $data[
"coords"], $data[
"area"], $data[
'question_fi'], $data[
'points_unchecked']));
412 if (!empty($imagemap_filename))
414 $fp = fopen($imagemap_filename,
"r");
415 $contents = fread($fp, filesize($imagemap_filename));
417 if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches))
419 for ($i=0; $i< count($matches[1]); $i++)
421 preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
422 preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i],
$coords);
423 preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
424 $this->
addAnswer($alt[1], 0.0, count($this->answers),
$coords[1], $shape[1]);
451 if (!empty($image_tempfilename))
454 if (!file_exists($imagepath))
460 $this->ilias->raiseError(
"The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
462 global
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
477 for ($i = 0; $i < count($this->answers); $i++) {
481 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
507 $points_unchecked = 0.0
510 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
511 if (array_key_exists($order, $this->answers))
515 for ($i = count($this->answers) - 1; $i >= $order; $i--)
517 $this->answers[$i+1] = $this->answers[$i];
518 $this->answers[$i+1]->setOrder($i+1);
520 $this->answers[$order] = $answer;
526 array_push($this->answers, $answer);
540 return count($this->answers);
555 if ($index < 0)
return NULL;
556 if (count($this->answers) < 1)
return NULL;
557 if ($index >= count($this->answers))
return NULL;
558 return $this->answers[$index];
587 if ($index < 0)
return;
588 if (count($this->answers) < 1)
return;
589 if ($index >= count($this->answers))
return;
590 unset($this->answers[$index]);
591 $this->answers = array_values($this->answers);
592 for ($i = 0; $i < count($this->answers); $i++) {
593 if ($this->answers[$i]->getOrder() > $index) {
594 $this->answers[$i]->setOrder($i);
608 $this->answers = array();
621 foreach ($this->answers as $key => $value) {
622 if($this->is_multiple_choice)
624 if($value->getPoints() > $value->getPointsUnchecked())
626 $points += $value->getPoints();
630 $points += $value->getPointsUnchecked();
635 if($value->getPoints() >
$points)
658 throw new ilTestException(
'return details not implemented for '.__METHOD__);
663 $found_values = array();
668 $result = $this->getCurrentSolutionResultSet($active_id,
$pass);
669 while ($data = $ilDB->fetchAssoc(
$result))
671 if (strcmp($data[
"value1"],
"") != 0)
673 array_push($found_values, $data[
"value1"]);
707 include_once
"./Modules/Test/classes/class.ilObjTest.php";
713 if($this->is_multiple_choice && strlen(
$_GET[
'remImage']))
715 $query =
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s";
716 $types = array(
"integer",
"integer",
"integer",
"integer");
719 if( $this->
getStep() !== NULL )
721 $query .=
" AND step = %s ";
722 $types[] =
'integer';
725 $affectedRows = $ilDB->manipulateF(
$query, $types, $values);
727 elseif(!$this->is_multiple_choice)
729 $affectedRows = $this->removeCurrentSolution($active_id,
$pass);
732 if (strlen(
$_GET[
"selImage"]))
734 $imageWasSelected =
true;
736 $types = array(
'integer',
'integer',
'integer',
'integer');
737 $values = array($active_id, $this->
getId(),
$pass, (
int)
$_GET[
'selImage']);
738 $query =
'DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s';
741 $types[] =
'integer';
743 $query .=
' AND step = %s';
746 $ilDB->manipulateF(
$query, $types, $values);
748 $affectedRows = $this->saveCurrentSolution($active_id,
$pass, $_GET[
'selImage'], null);
752 $imageWasSelected =
false;
757 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
760 if( $imageWasSelected )
777 if( $this->is_multiple_choice && strlen(
$_GET[
'remImage']) )
779 unset($solution[(
int)
$_GET[
'remImage']]);
782 if( strlen(
$_GET[
'selImage']) )
784 if( !$this->is_multiple_choice )
789 $solution[(int)
$_GET[
'selImage']] = (
int)
$_GET[
'selImage'];
826 return "assImagemapQuestion";
839 return "qpl_qst_imagemap";
852 return "qpl_a_imagemap";
862 foreach ($this->answers as $index => $answer)
864 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
883 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
890 $worksheet->writeString($startrow + $i, 0,
ilExcelUtils::_convert_text($answer->getArea() .
": " . $answer->getCoords()), $format_bold);
891 if (
$id == $solution[0][
"value1"])
893 $worksheet->write($startrow + $i, 1, 1);
897 $worksheet->write($startrow + $i, 1, 0);
901 return $startrow + $i + 1;
912 $this->image_filename =
"";
920 include_once(
"./Services/RTE/classes/class.ilRTE.php");
930 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
931 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
937 foreach ($this->
getAnswers() as $key => $answer_obj)
940 "answertext" => (
string)$answer_obj->getAnswertext(),
941 "points" => (float)$answer_obj->getPoints(),
942 "points_unchecked" => (float)$answer_obj->getPointsUnchecked(),
943 "order" => (int)$order,
944 "coords" => $answer_obj->getCoords(),
945 "state" => $answer_obj->getState(),
946 "area" => $answer_obj->getArea(),
948 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0
956 $result[
'mobs'] =
$mobs;
958 return json_encode($result);
968 if(count($found_values) > 0)
970 foreach($this->answers as $key => $answer)
972 if(in_array($key, $found_values))
974 $points += $answer->getPoints();
977 $points += $answer->getPointsUnchecked();
995 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1027 $data = $ilDB->queryF(
1028 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = (
1029 SELECT MAX(step) FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s
1031 array(
"integer",
"integer",
"integer",
"integer",
"integer",
"integer"),
1035 while(
$row = $ilDB->fetchAssoc($data))