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';
72 $this->answers = array();
73 $this->coords = array();
104 if (strlen($this->title)
107 && ($this->image_filename)
108 && (count($this->answers))
136 $ilDB = $DIC[
'ilDB'];
138 "DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
140 array( $this->
getId() )
144 foreach ($this->answers as $key => $value) {
145 $answer_obj = $this->answers[$key];
146 $answer_obj->setOrder($key);
147 $next_id =
$ilDB->nextId(
'qpl_a_imagemap');
149 "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)",
150 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"float" ),
151 array( $next_id, $this->
id, $answer_obj->getAnswertext(
152 ), $answer_obj->getPoints(), $answer_obj->getOrder(
153 ), $answer_obj->getCoords(), $answer_obj->getArea(
154 ), $answer_obj->getPointsUnchecked() )
162 $ilDB = $DIC[
'ilDB'];
167 array( $this->
getId() )
172 ) .
" (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
173 array(
"integer",
"text",
'integer' ),
176 $this->image_filename,
177 (
int) $this->is_multiple_choice
189 if ($this->
id <= 0) {
194 $this_id = $this->
getId();
198 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
202 if ((
int) $testObjId > 0) {
203 $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());
242 if ($this->
id <= 0) {
248 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
251 $source_questionpool_id = $this->
getObjId();
252 $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());
272 if ($this->
id <= 0) {
277 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
280 $sourceParentId = $this->
getObjId();
286 $clone->setObjId($targetParentId);
288 if ($targetQuestionTitle) {
289 $clone->setTitle($targetQuestionTitle);
294 $clone->copyPageOfQuestion($sourceQuestionId);
296 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
298 $clone->copyImage($sourceQuestionId, $sourceParentId);
300 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
311 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
313 if ((
int) $objectId > 0) {
314 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
317 if (!file_exists($imagepath)) {
323 if (!file_exists($imagepath_original .
$filename)) {
324 $ilLog->write(
"Could not find an image map file when trying to duplicate image: " . $imagepath_original . $filename);
325 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
326 $ilLog->write(
"Using fallback source directory:" . $imagepath_original);
329 if (!file_exists($imagepath_original . $filename) || !copy($imagepath_original . $filename, $imagepath . $filename)) {
330 $ilLog->write(
"Could not duplicate image for image map question: " . $imagepath_original . $filename);
334 public function copyImage($question_id, $source_questionpool)
337 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
338 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
339 if (!file_exists($imagepath)) {
343 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
344 print
"image could not be copied!!!! ";
360 $ilDB = $DIC[
'ilDB'];
369 $this->
setId($question_id);
379 include_once(
"./Services/RTE/classes/class.ilRTE.php");
396 "SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
400 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
407 parent::loadFromDb($question_id);
420 if (count($shapes) > 0) {
421 foreach ($shapes as $shape) {
422 $this->
addAnswer($shape->getAnswertext(), 0.0, count($this->answers), $shape->getCoords(), $shape->getArea());
448 if (!empty($image_tempfilename)) {
450 if (!file_exists($imagepath)) {
454 $this->
ilias->raiseError(
"The image could not be uploaded!", $this->
ilias->error_obj->MESSAGE);
458 $ilLog->write(
"gespeichert: " . $imagepath . $image_filename);
474 for (
$i = 0;
$i < count($this->answers);
$i++) {
504 $points_unchecked = 0.0
506 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
507 if (array_key_exists($order, $this->answers)) {
510 for (
$i = count($this->answers) - 1;
$i >= $order;
$i--) {
511 $this->answers[
$i + 1] = $this->answers[
$i];
512 $this->answers[
$i + 1]->setOrder(
$i + 1);
514 $this->answers[$order] = $answer;
518 array_push($this->answers, $answer);
533 return count($this->answers);
552 if (count($this->answers) < 1) {
555 if (
$index >= count($this->answers)) {
558 return $this->answers[
$index];
590 if (count($this->answers) < 1) {
593 if (
$index >= count($this->answers)) {
596 unset($this->answers[
$index]);
597 $this->answers = array_values($this->answers);
598 for (
$i = 0;
$i < count($this->answers);
$i++) {
599 if ($this->answers[
$i]->getOrder() >
$index) {
600 $this->answers[
$i]->setOrder(
$i);
615 $this->answers = array();
629 foreach ($this->answers as $key => $value) {
630 if ($this->is_multiple_choice) {
631 if ($value->getPoints() > $value->getPointsUnchecked()) {
632 $points += $value->getPoints();
634 $points += $value->getPointsUnchecked();
637 if ($value->getPoints() >
$points) {
657 if ($returndetails) {
658 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
662 $ilDB = $DIC[
'ilDB'];
664 $found_values = array();
665 if (is_null(
$pass)) {
670 if (strcmp(
$data[
"value1"],
"") != 0) {
671 array_push($found_values,
$data[
"value1"]);
706 $ilDB = $DIC[
'ilDB'];
708 if (is_null(
$pass)) {
709 include_once
"./Modules/Test/classes/class.ilObjTest.php";
713 $solutionSelectionChanged =
false;
715 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$solutionSelectionChanged,
$ilDB, $active_id,
$pass, $authorized) {
724 $solutionSelectionChanged =
true;
729 $this->is_multiple_choice
735 foreach ($selection as $selectedIndex) {
737 $solutionSelectionChanged =
true;
743 'value1' => (
int) $selection
746 $solutionSelectionChanged =
true;
750 if ($this->is_multiple_choice) {
752 'value1' => (
int)
$_GET[
'selImage']
760 $solutionSelectionChanged =
true;
765 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
767 if ($solutionSelectionChanged) {
781 if ($this->is_multiple_choice && strlen(
$_GET[
'remImage'])) {
782 unset($solution[(
int)
$_GET[
'remImage']]);
785 if (strlen(
$_GET[
'selImage'])) {
786 if (!$this->is_multiple_choice) {
790 $solution[(int)
$_GET[
'selImage']] = (
int)
$_GET[
'selImage'];
799 parent::syncWithOriginal();
813 return "assImagemapQuestion";
826 return "qpl_qst_imagemap";
839 return "qpl_a_imagemap";
848 $text = parent::getRTETextWithMediaObjects();
849 foreach ($this->answers as
$index => $answer) {
850 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), 0,
$index);
860 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
866 $worksheet->setCell($startrow +
$i, 0, $answer->getArea() .
": " . $answer->getCoords());
867 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow +
$i));
870 foreach ($solution as $solIndex => $sol) {
871 if ($sol[
'value1'] ==
$id) {
877 $worksheet->setCell($startrow +
$i, 1, $cellValue);
882 return $startrow +
$i + 1;
893 $this->image_filename =
"";
901 include_once(
"./Services/RTE/classes/class.ilRTE.php");
911 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
912 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
918 foreach ($this->
getAnswers() as $key => $answer_obj) {
920 "answertext" => (
string) $answer_obj->getAnswertext(),
921 "points" => (float) $answer_obj->getPoints(),
922 "points_unchecked" => (float) $answer_obj->getPointsUnchecked(),
923 "order" => (int) $order,
924 "coords" => $answer_obj->getCoords(),
925 "state" => $answer_obj->getState(),
926 "area" => $answer_obj->getArea(),
928 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
936 $result[
'mobs'] =
$mobs;
938 return json_encode($result);
948 if (count($found_values) > 0) {
949 foreach ($this->answers as $key => $answer) {
950 if (in_array($key, $found_values)) {
951 $points += $answer->getPoints();
953 $points += $answer->getPointsUnchecked();
971 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1001 $ilDB = $DIC[
'ilDB'];
1004 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1006 if ($maxStep !== null) {
1008 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1009 array(
"integer",
"integer",
"integer",
"integer"),
1010 array($active_id,
$pass, $this->
getId(), $maxStep)
1014 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL",
1015 array(
"integer",
"integer",
"integer"),
1021 $result->addKeyValue($row[
"value1"], $row[
"value1"]);
1052 $solution = parent::getTestOutputSolutions($activeId,
$pass);
1054 $this->currentSolution = array();
1055 foreach ($solution as $record) {
1056 $this->currentSolution[] = $record[
'value1'];
1067 return $_GET[
"selImage"];
1071 if (!isset(
$_GET[
"selImage"])) {
1075 if (!strlen(
$_GET[
"selImage"])) {
1087 return $_GET[
"remImage"];
1091 if (!$this->is_multiple_choice) {
1095 if (!isset(
$_GET[
"remImage"])) {
1099 if (!strlen(
$_GET[
"remImage"])) {
1119 if (!isset(
$_GET[
"reuseSelection"])) {
1123 if (!strlen(
$_GET[
"reuseSelection"])) {
1127 if (!preg_match(
'/\d(,\d)*/',
$_GET[
"reuseSelection"])) {
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
static getInstance($identifier)
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
calculateReachedPointsForSolution($found_values)
const PercentageResultExpression
Class iQuestionCondition.
forceExistingIntermediateSolution($activeId, $passIndex, $considerDummyRecordCreation)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
const NumberOfResultExpression
savePreviewData(ilAssQuestionPreviewSession $previewSession)
const ExclusiveResultExpression
getRemoveSolutionSelectionParameter()
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...
getOperators($expression)
Get all available operations for a specific question.
ensureNonNegativePoints($points)
deleteDummySolutionRecord($activeId, $passIndex)
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $image_filename="")
assImagemapQuestion constructor
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
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 from given hour, minute and second. ...
getParticipantsSolution()
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
deleteArea($index=0)
Deletes an answer.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
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...
getObjId()
Get the object id of the container object.
getAddSolutionSelectionParameter()
getShuffle()
Gets the shuffle flag.
Base Exception for all Exceptions relating to Modules/Test.
setParticipantsSolution($participantSolution)
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
static _getLogLanguage()
retrieve the log language for assessment logging
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getTestOutputSolutions($activeId, $pass)
setAuthor($author="")
Sets the authors name of the assQuestion object.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
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.
uploadImagemap(array $shapes)
Uploads an image map and takes over the areas.
toJSON()
Returns a JSON representation of the question.
Class ilUserQuestionResult.
updateCurrentSolutionsAuthorization($activeId, $pass, $authorized, $keepTime=false)
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static explodeKeyValues($keyValues)
Interface ilObjAnswerScoringAdjustable.
getQuestion()
Gets the question string of the question object.
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.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
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)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
static getOperatorsByExpression($expression)
duplicateImage($question_id, $objectId=null)
setIsMultipleChoice($is_multiple_choice)
Set true if the Imagemapquestion is a multiplechoice Question.
getExpressionTypes()
Get all available expression types for a specific question.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
isRemoveSolutionSelectionRequest()
addAnswer( $answertext="", $points=0.0, $order=0, $coords="", $area="", $points_unchecked=0.0)
Adds a possible answer for a imagemap question.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
& 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.
Interface ilObjQuestionScoringAdjustable.
removeCurrentSolution($active_id, $pass, $authorized=true)
__construct(Container $dic, ilPlugin $plugin)
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
deleteSolutionRecordByValues($activeId, $passIndex, $authorized, $matchValues)
getTestPresentationConfig()
Get the test question configuration (initialised once)
setImageFilename($image_filename, $image_tempfilename="")
Sets the image file name.
setOriginalId($original_id)
isReuseSolutionSelectionRequest()
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
setLifecycle(ilAssQuestionLifecycle $lifecycle)
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
getAnswerTableName()
Returns the name of the answer table in the database.
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.
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
loadFromDb($question_id)
Loads a assImagemapQuestion object from a database.
setComment($comment="")
Sets the comment string of the assQuestion object.
getReuseSolutionSelectionParameter()
get_imagemap_contents($href="#")
Gets the imagemap file contents.
isAddSolutionSelectionRequest()
getAdditionalTableName()
Returns the name of the additional question data table in the database.
static getDraftInstance()
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const EmptyAnswerExpression