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';
67 $this->answers = array();
68 $this->coords = array();
99 if (strlen($this->title)
102 && ($this->image_filename)
103 && (count($this->answers))
132 $ilDB->manipulateF(
"DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
134 array( $this->
getId() )
138 foreach ($this->answers as $key => $value)
140 $answer_obj = $this->answers[$key];
141 $next_id = $ilDB->nextId(
'qpl_a_imagemap' );
142 $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)",
143 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"float" ),
144 array( $next_id, $this->
id, $answer_obj->getAnswertext(
145 ), $answer_obj->getPoints(), $answer_obj->getOrder(
146 ), $answer_obj->getCoords(), $answer_obj->getArea(
147 ), $answer_obj->getPointsUnchecked() )
158 array( $this->
getId() )
162 ) .
" (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
163 array(
"integer",
"text",
'integer' ),
166 $this->image_filename,
167 (
int)$this->is_multiple_choice
185 $this_id = $this->
getId();
189 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
193 if( (
int)$testObjId > 0 )
195 $clone->setObjId($testObjId);
220 $clone->copyPageOfQuestion($this_id);
222 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
224 $clone->duplicateImage($this_id, $thisObjId);
226 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
247 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
250 $source_questionpool_id = $this->
getObjId();
251 $clone->setObjId($target_questionpool_id);
263 $clone->copyImage(
$original_id, $source_questionpool_id);
265 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
278 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
281 $sourceParentId = $this->
getObjId();
287 $clone->setObjId($targetParentId);
289 if ($targetQuestionTitle)
291 $clone->setTitle($targetQuestionTitle);
296 $clone->copyPageOfQuestion($sourceQuestionId);
298 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
300 $clone->copyImage($sourceQuestionId, $sourceParentId);
302 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
310 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
312 if( (
int)$objectId > 0 )
314 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
317 if (!file_exists($imagepath)) {
321 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
322 print
"image could not be duplicated!!!! ";
329 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
330 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
331 if (!file_exists($imagepath))
336 if (!copy($imagepath_original .
$filename, $imagepath . $filename))
338 print
"image could not be copied!!!! ";
362 $this->
setId($question_id);
372 include_once(
"./Services/RTE/classes/class.ilRTE.php");
385 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
389 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
398 parent::loadFromDb($question_id);
410 if (!empty($imagemap_filename))
412 $fp = fopen($imagemap_filename,
"r");
413 $contents = fread($fp, filesize($imagemap_filename));
415 if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches))
417 for ($i=0; $i< count($matches[1]); $i++)
419 preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
420 preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $coords);
421 preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
422 $this->
addAnswer($alt[1], 0.0, count($this->answers), $coords[1], $shape[1]);
444 if (!empty($image_filename))
446 $image_filename = str_replace(
" ",
"_", $image_filename);
449 if (!empty($image_tempfilename))
452 if (!file_exists($imagepath))
458 $this->
ilias->raiseError(
"The image could not be uploaded!", $this->
ilias->error_obj->MESSAGE);
460 global
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
474 $imagemap_contents =
"<map name=\"".$this->title.
"\"> ";
475 for ($i = 0; $i < count($this->answers); $i++) {
476 $imagemap_contents .=
"<area alt=\"".$this->answers[$i]->getAnswertext().
"\" ";
477 $imagemap_contents .=
"shape=\"".$this->answers[$i]->getArea().
"\" ";
478 $imagemap_contents .=
"coords=\"".$this->answers[$i]->getCoords().
"\" ";
479 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
481 $imagemap_contents .=
"</map>";
505 $points_unchecked = 0.0
508 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
509 if (array_key_exists($order, $this->answers))
513 for ($i = count($this->answers) - 1; $i >= $order; $i--)
515 $this->answers[$i+1] = $this->answers[$i];
516 $this->answers[$i+1]->setOrder($i+1);
518 $this->answers[$order] = $answer;
524 array_push($this->answers, $answer);
538 return count($this->answers);
553 if ($index < 0)
return NULL;
554 if (count($this->answers) < 1)
return NULL;
555 if ($index >= count($this->answers))
return NULL;
556 return $this->answers[$index];
585 if ($index < 0)
return;
586 if (count($this->answers) < 1)
return;
587 if ($index >= count($this->answers))
return;
588 unset($this->answers[$index]);
589 $this->answers = array_values($this->answers);
590 for ($i = 0; $i < count($this->answers); $i++) {
591 if ($this->answers[$i]->getOrder() > $index) {
592 $this->answers[$i]->setOrder($i);
606 $this->answers = array();
619 foreach ($this->answers as $key => $value) {
620 if($this->is_multiple_choice)
622 if($value->getPoints() > $value->getPointsUnchecked())
624 $points += $value->getPoints();
628 $points += $value->getPointsUnchecked();
633 if($value->getPoints() >
$points)
656 throw new ilTestException(
'return details not implemented for '.__METHOD__);
661 $found_values = array();
666 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
667 array(
"integer",
"integer",
"integer"),
672 if (strcmp(
$data[
"value1"],
"") != 0)
674 array_push($found_values,
$data[
"value1"]);
678 if (count($found_values) > 0)
680 foreach ($this->answers as $key => $answer)
682 if (in_array($key, $found_values))
684 $points += $answer->getPoints();
688 $points += $answer->getPointsUnchecked();
711 include_once
"./Modules/Test/classes/class.ilObjTest.php";
717 if($this->is_multiple_choice && strlen(
$_GET[
'remImage']))
719 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s",
720 array(
"integer",
"integer",
"integer",
"integer"),
724 elseif(!$this->is_multiple_choice)
726 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
727 array(
"integer",
"integer",
"integer"),
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';
740 $ilDB->manipulateF(
$query, $types, $values);
742 $next_id = $ilDB->nextId(
'tst_solutions');
743 $affectedRows = $ilDB->insert(
"tst_solutions", array(
744 "solution_id" => array(
"integer", $next_id),
745 "active_fi" => array(
"integer", $active_id),
746 "question_fi" => array(
"integer", $this->
getId()),
747 "value1" => array(
"clob", $_GET[
'selImage']),
748 "value2" => array(
"clob", null),
749 "pass" => array(
"integer",
$pass),
750 "tstamp" => array(
"integer", time())
755 $imageWasSelected =
false;
760 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
763 if( $imageWasSelected )
793 parent::syncWithOriginal();
807 return "assImagemapQuestion";
820 return "qpl_qst_imagemap";
833 return "qpl_a_imagemap";
842 $text = parent::getRTETextWithMediaObjects();
843 foreach ($this->answers as $index => $answer)
845 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
864 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
871 $worksheet->writeString($startrow + $i, 0,
ilExcelUtils::_convert_text($answer->getArea() .
": " . $answer->getCoords()), $format_bold);
872 if (
$id == $solution[0][
"value1"])
874 $worksheet->write($startrow + $i, 1, 1);
878 $worksheet->write($startrow + $i, 1, 0);
882 return $startrow + $i + 1;
893 $this->image_filename =
"";
901 include_once(
"./Services/RTE/classes/class.ilRTE.php");
911 "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false),
912 "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true)
918 foreach ($this->
getAnswers() as $key => $answer_obj)
920 array_push($answers, array(
921 "answertext" => (
string)$answer_obj->getAnswertext(),
922 "points" => (float)$answer_obj->getPoints(),
923 "points_unchecked" => (float)$answer_obj->getPointsUnchecked(),
924 "order" => (int)$order,
925 "coords" => $answer_obj->getCoords(),
926 "state" => $answer_obj->getState(),
927 "area" => $answer_obj->getArea(),
929 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
saveWorkingData($active_id, $pass=NULL)
Saves the learners input of the question to the database.
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assImagemapQuestion.
Class for true/false or yes/no answers.
Abstract basic class which is to be extended by the concrete assessment question type classes...
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_convert_text($a_text, $a_target="has been removed")
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $image_filename="")
assImagemapQuestion constructor
setId($id=-1)
Sets the id of the assQuestion object.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question.
deleteArea($index=0)
Deletes an answer.
setNrOfTries($a_nr_of_tries)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
getObjId()
Get the object id of the container object.
getShuffle()
Gets the shuffle flag.
Base Exception for all Exceptions relating to Modules/Test.
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
fetchAssoc($a_set)
Fetch row as associative array from result set.
setAuthor($author="")
Sets the authors name of the assQuestion object.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
getAnswer($index=0)
Returns an answer.
saveToDb($original_id="")
Saves an assImagemapQuestion object to a database.
toJSON()
Returns a JSON representation of the question.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
getQuestion()
Gets the question string of the question object.
uploadImagemap($imagemap_filename="")
Uploads an image map and takes over the areas.
deleteImage()
Deletes the image file.
const MODE_MULTIPLE_CHOICE
redirection script todo: (a better solution should control the processing via a xml file) ...
Class for image map questions.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
isComplete()
Returns true, if a imagemap question is complete for use.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
copyImage($question_id, $source_questionpool)
_getLogLanguage()
retrieve the log language for assessment logging
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
duplicateImage($question_id, $objectId=null)
setIsMultipleChoice($is_multiple_choice)
Set true if the Imagemapquestion is a multiplechoice Question.
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
addAnswer( $answertext="", $points=0.0, $order=0, $coords="", $area="", $points_unchecked=0.0)
Adds a possible answer for a imagemap question.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
saveAdditionalQuestionDataToDb()
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
& getAnswers()
Returns the answer array.
copyObject($target_questionpool_id, $title="")
Copies an assImagemapQuestion object.
getAnswerCount()
Returns the number of answers.
setQuestion($question="")
Sets the question string of the question object.
setImageFilename($image_filename, $image_tempfilename="")
Sets the image file name.
setOriginalId($original_id)
saveAnswerSpecificDataToDb()
getAnswerTableName()
Returns the name of the answer table in the database.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getTitle()
Gets the title string of the assQuestion object.
getQuestionType()
Returns the question type of the question.
flushAnswers()
Deletes all answers.
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
loadFromDb($question_id)
Loads a assImagemapQuestion object from a database.
setComment($comment="")
Sets the comment string of the assQuestion object.
get_imagemap_contents($href="#")
Gets the imagemap file contents.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
calculateReachedPoints($active_id, $pass=NULL, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.