4require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
8require_once
'./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
9require_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());
314 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
316 if( (
int)$objectId > 0 )
318 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
321 if(!file_exists($imagepath))
328 if(!file_exists($imagepath_original .
$filename))
330 $ilLog->write(
"Could not find an image map file when trying to duplicate image: " . $imagepath_original .
$filename);
331 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
332 $ilLog->write(
"Using fallback source directory:" . $imagepath_original);
337 $ilLog->write(
"Could not duplicate image for image map question: " . $imagepath_original .
$filename);
344 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
345 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
346 if (!file_exists($imagepath))
353 print "image could not be copied!!!! ";
377 $this->
setId($question_id);
387 include_once(
"./Services/RTE/classes/class.ilRTE.php");
400 $result =
$ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
404 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
413 parent::loadFromDb($question_id);
425 if (!empty($imagemap_filename))
427 $fp = fopen($imagemap_filename,
"r");
428 $contents = fread($fp, filesize($imagemap_filename));
430 if (preg_match_all(
"/<area(.+)>/siU", $contents, $matches))
432 for ($i=0; $i< count($matches[1]); $i++)
434 preg_match(
"/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
435 preg_match(
"/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i],
$coords);
436 preg_match(
"/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
437 $this->
addAnswer($alt[1], 0.0, count($this->answers),
$coords[1], $shape[1]);
464 if (!empty($image_tempfilename))
467 if (!file_exists($imagepath))
473 $this->
ilias->raiseError(
"The image could not be uploaded!", $this->
ilias->error_obj->MESSAGE);
475 global
$ilLog;
$ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
490 for ($i = 0; $i < count($this->answers); $i++) {
494 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
520 $points_unchecked = 0.0
523 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
524 if (array_key_exists($order, $this->answers))
528 for ($i = count($this->answers) - 1; $i >= $order; $i--)
530 $this->answers[$i+1] = $this->answers[$i];
531 $this->answers[$i+1]->setOrder($i+1);
533 $this->answers[$order] = $answer;
539 array_push($this->answers, $answer);
553 return count($this->answers);
568 if ($index < 0)
return NULL;
569 if (count($this->answers) < 1)
return NULL;
570 if ($index >= count($this->answers))
return NULL;
571 return $this->answers[$index];
600 if ($index < 0)
return;
601 if (count($this->answers) < 1)
return;
602 if ($index >= count($this->answers))
return;
603 unset($this->answers[$index]);
604 $this->answers = array_values($this->answers);
605 for ($i = 0; $i < count($this->answers); $i++) {
606 if ($this->answers[$i]->getOrder() > $index) {
607 $this->answers[$i]->setOrder($i);
621 $this->answers = array();
634 foreach ($this->answers as $key => $value) {
635 if($this->is_multiple_choice)
637 if($value->getPoints() > $value->getPointsUnchecked())
639 $points += $value->getPoints();
643 $points += $value->getPointsUnchecked();
648 if($value->getPoints() >
$points)
671 throw new ilTestException(
'return details not implemented for '.__METHOD__);
676 $found_values = array();
684 if (strcmp(
$data[
"value1"],
"") != 0)
686 array_push($found_values,
$data[
"value1"]);
720 include_once
"./Modules/Test/classes/class.ilObjTest.php";
730 if(0 == count($solutions))
735 foreach($solutions as $solution)
741 if($this->is_multiple_choice && strlen(
$_GET[
'remImage']))
743 $query =
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s AND authorized = %s";
744 $types = array(
"integer",
"integer",
"integer",
"integer",
'integer');
745 $values = array($active_id, $this->
getId(),
$pass,
$_GET[
'remImage'], (
int)$authorized);
749 $query .=
" AND step = %s ";
750 $types[] =
'integer';
753 $ilDB->manipulateF(
$query, $types, $values);
755 elseif(!$this->is_multiple_choice)
760 if(!$authorized && strlen(
$_GET[
"selImage"]))
762 $imageWasSelected =
true;
764 $types = array(
'integer',
'integer',
'integer',
'integer',
'integer');
765 $values = array($active_id, $this->
getId(),
$pass, (
int)
$_GET[
'selImage'], (
int)$authorized);
766 $query =
'DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s AND authorized = %s';
769 $types[] =
'integer';
771 $query .=
' AND step = %s';
774 $ilDB->manipulateF(
$query, $types, $values);
780 $imageWasSelected =
false;
788 foreach($solutions as $solution)
796 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
799 if( $imageWasSelected )
816 if( $this->is_multiple_choice && strlen(
$_GET[
'remImage']) )
818 unset($solution[(
int)
$_GET[
'remImage']]);
821 if( strlen(
$_GET[
'selImage']) )
823 if( !$this->is_multiple_choice )
828 $solution[(int)
$_GET[
'selImage']] = (
int)
$_GET[
'selImage'];
851 parent::syncWithOriginal();
865 return "assImagemapQuestion";
878 return "qpl_qst_imagemap";
891 return "qpl_a_imagemap";
900 $text = parent::getRTETextWithMediaObjects();
901 foreach ($this->answers as $index => $answer)
903 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
922 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
929 $worksheet->writeString($startrow + $i, 0,
ilExcelUtils::_convert_text($answer->getArea() .
": " . $answer->getCoords()), $format_bold);
930 if (
$id == $solution[0][
"value1"])
932 $worksheet->write($startrow + $i, 1, 1);
936 $worksheet->write($startrow + $i, 1, 0);
940 return $startrow + $i + 1;
951 $this->image_filename =
"";
959 include_once(
"./Services/RTE/classes/class.ilRTE.php");
969 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
970 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
976 foreach ($this->
getAnswers() as $key => $answer_obj)
979 "answertext" => (
string)$answer_obj->getAnswertext(),
980 "points" => (
float)$answer_obj->getPoints(),
981 "points_unchecked" => (
float)$answer_obj->getPointsUnchecked(),
982 "order" => (
int)$order,
983 "coords" => $answer_obj->getCoords(),
984 "state" => $answer_obj->getState(),
985 "area" => $answer_obj->getArea(),
986 "feedback" => $this->formatSAQuestion(
987 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1007 if(count($found_values) > 0)
1009 foreach($this->answers as $key => $answer)
1011 if(in_array($key, $found_values))
1013 $points += $answer->getPoints();
1016 $points += $answer->getPointsUnchecked();
1034 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1066 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1068 if( $maxStep !==
null )
1070 $data =
$ilDB->queryF(
"SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1071 array(
"integer",
"integer",
"integer",
"integer"),
1072 array($active_id,
$pass, $this->
getId(), $maxStep)
1077 $data =
$ilDB->queryF(
"SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL",
1078 array(
"integer",
"integer",
"integer"),
Class for true/false or yes/no answers.
Class for image map questions.
uploadImagemap($imagemap_filename="")
Uploads an image map and takes over the areas.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
getQuestionType()
Returns the question type of the question.
setIsMultipleChoice($is_multiple_choice)
Set true if the Imagemapquestion is a multiplechoice Question.
flushAnswers()
Deletes all answers.
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
toJSON()
Returns a JSON representation of the question.
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
duplicateImage($question_id, $objectId=null)
setImageFilename($image_filename, $image_tempfilename="")
Sets the image file name.
getAnswer($index=0)
Returns an answer.
getAnswerTableName()
Returns the name of the answer table in the database.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assImagemapQuestion.
getExpressionTypes()
Get all available expression types for a specific question.
copyObject($target_questionpool_id, $title="")
Copies an assImagemapQuestion object.
deleteImage()
Deletes the image file.
calculateReachedPointsForSolution($found_values)
isComplete()
Returns true, if a imagemap question is complete for use.
getOperators($expression)
Get all available operations for a specific question.
deleteArea($index=0)
Deletes an answer.
& getAnswers()
Returns the answer array.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
copyImage($question_id, $source_questionpool)
loadFromDb($question_id)
Loads a assImagemapQuestion object from a database.
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $image_filename="")
assImagemapQuestion constructor
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveToDb($original_id="")
Saves an assImagemapQuestion object to a database.
addAnswer( $answertext="", $points=0.0, $order=0, $coords="", $area="", $points_unchecked=0.0)
Adds a possible answer for a imagemap question.
getAnswerCount()
Returns the number of answers.
get_imagemap_contents($href="#")
Gets the imagemap file contents.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
const MODE_MULTIPLE_CHOICE
savePreviewData(ilAssQuestionPreviewSession $previewSession)
Reworks the allready saved working data if neccessary.
Abstract basic class which is to be extended by the concrete assessment question type classes.
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass.
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
saveQuestionDataToDb($original_id="")
getUserSolutionPreferingIntermediate($active_id, $pass=NULL)
getId()
Gets the id of the assQuestion object.
getObjId()
Get the object id of the container object.
setTitle($title="")
Sets the title string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
setAuthor($author="")
Sets the authors name of the assQuestion object.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
getShuffle()
Gets the shuffle flag.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true, $ignoredSolutionIds=array())
getTitle()
Gets the title string of the assQuestion object.
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
getQuestion()
Gets the question string of the question object.
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true)
setQuestion($question="")
Sets the question string of the question object.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getParticipantsSolution()
setParticipantsSolution($participantSolution)
_convert_text($a_text, $a_target="has been removed")
_getLogLanguage()
retrieve the log language for assessment logging
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getOperatorsByExpression($expression)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Base Exception for all Exceptions relating to Modules/Test.
Class ilUserQuestionResult.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Class iQuestionCondition.
const PercentageResultExpression
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
const EmptyAnswerExpression
const ExclusiveResultExpression
const NumberOfResultExpression
Interface ilObjAnswerScoringAdjustable.
Interface ilObjQuestionScoringAdjustable.
redirection script todo: (a better solution should control the processing via a xml file)