19require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
36 private \ILIAS\TestQuestionPool\InternalRequestService
$request;
88 $this->answers = array();
89 $this->coords = array();
92 $this->request =
$DIC->testQuestionPool()->internal()->request();
123 if (strlen($this->title)
126 && ($this->image_filename)
127 && (count($this->answers))
161 "DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
163 array( $this->
getId() )
167 foreach ($this->answers as
$key => $value) {
168 $answer_obj = $this->answers[
$key];
169 $answer_obj->setOrder(
$key);
170 $next_id =
$ilDB->nextId(
'qpl_a_imagemap');
172 "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)",
173 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"float" ),
174 array( $next_id, $this->
id, $answer_obj->getAnswertext(
175 ), $answer_obj->getPoints(), $answer_obj->getOrder(
176 ), $answer_obj->getCoords(), $answer_obj->getArea(
177 ), $answer_obj->getPointsUnchecked() )
190 array( $this->
getId() )
195 ) .
" (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
196 array(
"integer",
"text",
'integer' ),
199 $this->image_filename,
200 (
int) $this->is_multiple_choice
212 if ($this->
id <= 0) {
217 $this_id = $this->
getId();
221 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
225 if ((
int) $testObjId > 0) {
226 $clone->setObjId($testObjId);
245 $clone->copyPageOfQuestion($this_id);
247 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
249 $clone->duplicateImage($this_id, $thisObjId);
251 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
265 if ($this->
getId() <= 0) {
266 throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
270 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
273 $source_questionpool_id = $this->
getObjId();
274 $clone->setObjId($target_questionpool_id);
285 $clone->copyImage(
$original_id, $source_questionpool_id);
287 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
294 if ($this->
getId() <= 0) {
295 throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
298 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
301 $sourceParentId = $this->
getObjId();
307 $clone->setObjId($targetParentId);
309 if ($targetQuestionTitle) {
310 $clone->setTitle($targetQuestionTitle);
315 $clone->copyPageOfQuestion($sourceQuestionId);
317 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
319 $clone->copyImage($sourceQuestionId, $sourceParentId);
321 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
332 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
334 if ((
int) $objectId > 0) {
335 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
338 if (!file_exists($imagepath)) {
344 if (!file_exists($imagepath_original .
$filename)) {
345 $ilLog->write(
"Could not find an image map file when trying to duplicate image: " . $imagepath_original .
$filename);
346 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
347 $ilLog->write(
"Using fallback source directory:" . $imagepath_original);
351 $ilLog->write(
"Could not duplicate image for image map question: " . $imagepath_original .
$filename);
355 public function copyImage($question_id, $source_questionpool): void
358 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
359 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
360 if (!file_exists($imagepath)) {
365 print
"image could not be copied!!!! ";
383 $result =
$ilDB->queryF(
388 if ($result->numRows() == 1) {
390 $this->
setId($question_id);
393 $this->
setComment((
string) $data[
"description"]);
400 include_once(
"./Services/RTE/classes/class.ilRTE.php");
415 $result =
$ilDB->queryF(
416 "SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
420 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
421 if ($result->numRows() > 0) {
424 $image_map_question->setCoords(
$data[
"coords"]);
425 $image_map_question->setArea(
$data[
"area"]);
426 $image_map_question->setPointsUnchecked(
$data[
'points_unchecked']);
427 array_push($this->answers, $image_map_question);
431 parent::loadFromDb($question_id);
444 if (count($shapes) > 0) {
445 foreach ($shapes as $shape) {
446 $this->
addAnswer($shape->getAnswertext(), 0.0, count($this->answers), $shape->getCoords(), $shape->getArea());
472 if (!empty($image_tempfilename)) {
474 if (!file_exists($imagepath)) {
478 $this->
ilias->raiseError(
"The image could not be uploaded!", $this->
ilias->error_obj->MESSAGE);
498 for (
$i = 0;
$i < count($this->answers);
$i++) {
528 $points_unchecked = 0.0
530 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
531 if (array_key_exists($order, $this->answers)) {
535 $answer->setArea($area);
536 $answer->setPointsUnchecked($points_unchecked);
537 for (
$i = count($this->answers) - 1;
$i >= $order;
$i--) {
538 $this->answers[
$i + 1] = $this->answers[
$i];
539 $this->answers[
$i + 1]->setOrder(
$i + 1);
541 $this->answers[$order] = $answer;
546 $answer->setArea($area);
547 $answer->setPointsUnchecked($points_unchecked);
548 array_push($this->answers, $answer);
563 return count($this->answers);
582 if (count($this->answers) < 1) {
585 if (
$index >= count($this->answers)) {
588 return $this->answers[
$index];
602 return $this->answers;
620 if (count($this->answers) < 1) {
623 if (
$index >= count($this->answers)) {
626 unset($this->answers[
$index]);
627 $this->answers = array_values($this->answers);
628 for (
$i = 0;
$i < count($this->answers);
$i++) {
629 if ($this->answers[
$i]->getOrder() >
$index) {
630 $this->answers[
$i]->setOrder(
$i);
645 $this->answers = array();
659 foreach ($this->answers as
$key => $value) {
660 if ($this->is_multiple_choice) {
661 if ($value->getPoints() > $value->getPointsUnchecked()) {
662 $points += $value->getPoints();
664 $points += $value->getPointsUnchecked();
667 if ($value->getPoints() > $points) {
668 $points = $value->getPoints();
687 if ($returndetails) {
688 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
694 $found_values = array();
695 if (is_null($pass)) {
696 $pass = $this->getSolutionMaxPass($active_id);
698 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
700 if (strcmp(
$data[
"value1"],
"") != 0) {
701 array_push($found_values,
$data[
"value1"]);
705 $points = $this->calculateReachedPointsForSolution($found_values);
714 $reachedPoints = $this->calculateReachedPointsForSolution(is_array($solutionData) ? array_values($solutionData) : array());
715 $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
717 return $this->ensureNonNegativePoints($reachedPoints);
738 if (is_null($pass)) {
739 include_once
"./Modules/Test/classes/class.ilObjTest.php";
743 $solutionSelectionChanged =
false;
745 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$solutionSelectionChanged,
$ilDB, $active_id, $pass, $authorized) {
748 $this->deleteDummySolutionRecord($active_id, $pass);
751 $this->removeCurrentSolution($active_id, $pass,
true);
752 $this->updateCurrentSolutionsAuthorization($active_id, $pass,
true,
true);
754 $solutionSelectionChanged =
true;
756 $this->forceExistingIntermediateSolution(
759 $this->is_multiple_choice
762 if ($this->isReuseSolutionSelectionRequest()) {
763 $selection = $this->getReuseSolutionSelectionParameter();
765 foreach ($selection as $selectedIndex) {
766 $this->saveCurrentSolution($active_id, $pass, (
int) $selectedIndex,
null, $authorized);
767 $solutionSelectionChanged =
true;
769 } elseif ($this->isRemoveSolutionSelectionRequest()) {
770 $selection = $this->getRemoveSolutionSelectionParameter();
772 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array(
773 'value1' => (
int) $selection
776 $solutionSelectionChanged =
true;
777 } elseif ($this->isAddSolutionSelectionRequest()) {
778 $selection = $this->getAddSolutionSelectionParameter();
780 if ($this->is_multiple_choice) {
781 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array(
782 'value1' => (
int) $this->request->raw(
'selImage')
785 $this->removeCurrentSolution($active_id, $pass, $authorized);
788 $this->saveCurrentSolution($active_id, $pass, $this->request->raw(
'selImage'),
null, $authorized);
790 $solutionSelectionChanged =
true;
795 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
797 if ($solutionSelectionChanged) {
800 "log_user_entered_values",
802 ), $active_id, $this->getId());
806 "log_user_not_entered_values",
808 ), $active_id, $this->getId());
819 if ($this->is_multiple_choice && strlen($this->request->raw(
'remImage'))) {
820 unset($solution[(
int) $this->request->raw(
'remImage')]);
823 if (strlen($this->request->raw(
'selImage'))) {
824 if (!$this->is_multiple_choice) {
828 $solution[(
int) $this->request->raw(
'selImage')] = (
int) $this->request->raw(
'selImage');
836 if ($this->getOriginalId()) {
837 parent::syncWithOriginal();
851 return "assImagemapQuestion";
864 return "qpl_qst_imagemap";
877 return "qpl_a_imagemap";
886 $text = parent::getRTETextWithMediaObjects();
887 foreach ($this->answers as
$index => $answer) {
888 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), 0,
$index);
898 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
900 $solution = $this->getSolutionValues($active_id, $pass);
903 foreach ($this->getAnswers() as
$id => $answer) {
904 $worksheet->
setCell($startrow +
$i, 0, $answer->getArea() .
": " . $answer->getCoords());
908 foreach ($solution as $solIndex => $sol) {
909 if ($sol[
'value1'] ==
$id) {
915 $worksheet->
setCell($startrow +
$i, 2, $cellValue);
920 return $startrow +
$i + 1;
928 $file = $this->getImagePath() . $this->getImageFilename();
930 $this->flushAnswers();
931 $this->image_filename =
"";
939 include_once(
"./Services/RTE/classes/class.ilRTE.php");
941 $result[
'id'] = $this->
getId();
942 $result[
'type'] = (string) $this->getQuestionType();
943 $result[
'title'] = $this->getTitleForHTMLOutput();
944 $result[
'question'] = $this->formatSAQuestion($this->getQuestion());
945 $result[
'nr_of_tries'] = $this->getNrOfTries();
946 $result[
'shuffle'] = $this->getShuffle();
947 $result[
'is_multiple'] = $this->getIsMultipleChoice();
948 $result[
'feedback'] = array(
949 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
950 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
952 $result[
'image'] = $this->getImagePathWeb() . $this->getImageFilename();
956 foreach ($this->getAnswers() as
$key => $answer_obj) {
957 array_push($answers, array(
958 "answertext" => (
string) $answer_obj->getAnswertext(),
959 "points" => (
float) $answer_obj->getPoints(),
960 "points_unchecked" => (
float) $answer_obj->getPointsUnchecked(),
962 "coords" => $answer_obj->getCoords(),
963 "state" => $answer_obj->getState(),
964 "area" => $answer_obj->getArea(),
965 "feedback" => $this->formatSAQuestion(
966 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0,
$key)
971 $result[
'answers'] = $answers;
974 $result[
'mobs'] =
$mobs;
976 return json_encode($result);
985 if ($found_values ==
null) {
989 if (count($found_values) > 0) {
990 foreach ($this->answers as
$key => $answer) {
991 if (in_array(
$key, $found_values)) {
992 $points += $answer->getPoints();
993 } elseif ($this->getIsMultipleChoice()) {
994 $points += $answer->getPointsUnchecked();
1044 $maxStep = $this->lookupMaxStep($active_id, $pass);
1046 if ($maxStep !==
null) {
1048 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1049 array(
"integer",
"integer",
"integer",
"integer"),
1050 array($active_id, $pass, $this->
getId(), $maxStep)
1054 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL",
1055 array(
"integer",
"integer",
"integer"),
1056 array($active_id, $pass, $this->
getId())
1061 $result->addKeyValue($row[
"value1"], $row[
"value1"]);
1064 $points = $this->calculateReachedPoints($active_id, $pass);
1065 $max_points = $this->getMaximumPoints();
1067 $result->setReachedPercentage(($points / $max_points) * 100);
1082 return $this->getAnswer(
$index);
1084 return $this->getAnswers();
1091 $solution = parent::getTestOutputSolutions($activeId, $pass);
1093 $this->currentSolution = array();
1094 foreach ($solution as $record) {
1095 $this->currentSolution[] = $record[
'value1'];
1102 if (!$this->isAddSolutionSelectionRequest()) {
1106 return $this->request->raw(
'selImage');
1110 if (!$this->request->isset(
"selImage")) {
1114 if (!strlen($this->request->raw(
'selImage'))) {
1122 if (!$this->isRemoveSolutionSelectionRequest()) {
1126 return $this->request->raw(
'remImage');
1130 if (!$this->is_multiple_choice) {
1134 if (!$this->request->isset(
"remImage")) {
1138 if (!strlen($this->request->raw(
'remImage'))) {
1146 if (!$this->isReuseSolutionSelectionRequest()) {
1154 if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
1158 if (!$this->request->isset(
"reuseSelection")) {
1162 if (!strlen($this->request->raw(
"reuseSelection"))) {
1166 if (!preg_match(
'/\d(,\d)*/', $this->request->raw(
"reuseSelection"))) {
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
uploadImagemap(array $shapes)
Uploads an image map and takes over the areas.
flushAnswers()
Deletes all answers.
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
toJSON()
Returns a JSON representation of the question.
isAddSolutionSelectionRequest()
duplicateImage($question_id, $objectId=null)
setImageFilename($image_filename, $image_tempfilename="")
Sets the image file name.
getAnswer($index=0)
Returns an answer.
getTestOutputSolutions($activeId, $pass)
getAnswerTableName()
Returns the name of the answer table in the database.
ILIAS TestQuestionPool InternalRequestService $request
setExportDetailsXLS(ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
{}
getExpressionTypes()
Get all available expression types for a specific question.
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
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.
getRemoveSolutionSelectionParameter()
deleteArea($index=0)
Deletes an answer.
& getAnswers()
Returns the answer array.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
isReuseSolutionSelectionRequest()
getReuseSolutionSelectionParameter()
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
duplicate(bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
Duplicates an assImagemapQuestion.
getAddSolutionSelectionParameter()
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.
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
const MODE_MULTIPLE_CHOICE
isRemoveSolutionSelectionRequest()
savePreviewData(ilAssQuestionPreviewSession $previewSession)
Abstract basic class which is to be extended by the concrete assessment question type classes.
float $points
The maximum available points for the question.
setOriginalId(?int $original_id)
string $question
The question text.
static logAction(string $logtext, int $active_id, int $question_id)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static _getOriginalId(int $question_id)
ILIAS DI LoggingServices $ilLog
saveQuestionDataToDb(int $original_id=-1)
setAuthor(string $author="")
static explodeKeyValues(string $keyValues)
setComment(string $comment="")
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
static getDraftInstance()
static getInstance($identifier)
getParticipantsSolution()
setParticipantsSolution($participantSolution)
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static _enabledAssessmentLogging()
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getOperatorsByExpression($expression)
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const PercentageResultExpression
const EmptyAnswerExpression
const ExclusiveResultExpression
const NumberOfResultExpression
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
header include for all ilias files.