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';
73 $this->answers =
array();
74 $this->coords =
array();
105 if (strlen($this->title)
108 && ($this->image_filename)
109 && (count($this->answers))
138 $ilDB->manipulateF(
"DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
144 foreach ($this->answers as $key => $value)
146 $answer_obj = $this->answers[$key];
147 $next_id = $ilDB->nextId(
'qpl_a_imagemap' );
148 $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)",
149 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"float" ),
150 array( $next_id, $this->
id, $answer_obj->getAnswertext(
151 ), $answer_obj->getPoints(), $answer_obj->getOrder(
152 ), $answer_obj->getCoords(), $answer_obj->getArea(
153 ), $answer_obj->getPointsUnchecked() )
168 ) .
" (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
169 array(
"integer",
"text",
'integer' ),
172 $this->image_filename,
173 (
int)$this->is_multiple_choice
191 $this_id = $this->
getId();
195 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
199 if( (
int)$testObjId > 0 )
201 $clone->setObjId($testObjId);
226 $clone->copyPageOfQuestion($this_id);
228 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
230 $clone->duplicateImage($this_id, $thisObjId);
232 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
253 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
256 $source_questionpool_id = $this->
getObjId();
257 $clone->setObjId($target_questionpool_id);
269 $clone->copyImage(
$original_id, $source_questionpool_id);
271 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
284 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
287 $sourceParentId = $this->
getObjId();
293 $clone->setObjId($targetParentId);
295 if ($targetQuestionTitle)
297 $clone->setTitle($targetQuestionTitle);
302 $clone->copyPageOfQuestion($sourceQuestionId);
304 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
306 $clone->copyImage($sourceQuestionId, $sourceParentId);
308 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
318 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
320 if( (
int)$objectId > 0 )
322 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
325 if(!file_exists($imagepath))
332 if(!file_exists($imagepath_original .
$filename))
334 $ilLog->write(
"Could not find an image map file when trying to duplicate image: " . $imagepath_original . $filename);
335 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
336 $ilLog->write(
"Using fallback source directory:" . $imagepath_original);
339 if(!file_exists($imagepath_original . $filename) || !copy($imagepath_original . $filename, $imagepath . $filename))
341 $ilLog->write(
"Could not duplicate image for image map question: " . $imagepath_original . $filename);
348 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
349 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
350 if (!file_exists($imagepath))
355 if (!copy($imagepath_original .
$filename, $imagepath . $filename))
357 print
"image could not be copied!!!! ";
381 $this->
setId($question_id);
391 include_once(
"./Services/RTE/classes/class.ilRTE.php");
404 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
408 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
417 parent::loadFromDb($question_id);
430 if(count($shapes) > 0)
432 foreach($shapes as $shape)
434 $this->
addAnswer($shape->getAnswertext(), 0.0, count($this->answers), $shape->getCoords(), $shape->getArea());
456 if (!empty($image_filename))
458 $image_filename = str_replace(
" ",
"_", $image_filename);
461 if (!empty($image_tempfilename))
464 if (!file_exists($imagepath))
470 $this->
ilias->raiseError(
"The image could not be uploaded!", $this->
ilias->error_obj->MESSAGE);
472 global
$ilLog; $ilLog->write(
"gespeichert: " . $imagepath.$image_filename);
486 $imagemap_contents =
"<map name=\"".$this->title.
"\"> ";
487 for ($i = 0; $i < count($this->answers); $i++) {
488 $imagemap_contents .=
"<area alt=\"".$this->answers[$i]->getAnswertext().
"\" ";
489 $imagemap_contents .=
"shape=\"".$this->answers[$i]->getArea().
"\" ";
490 $imagemap_contents .=
"coords=\"".$this->answers[$i]->getCoords().
"\" ";
491 $imagemap_contents .=
"href=\"$href&selimage=" . $this->answers[$i]->getOrder() .
"\" /> ";
493 $imagemap_contents .=
"</map>";
517 $points_unchecked = 0.0
520 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
521 if (array_key_exists($order, $this->answers))
525 for ($i = count($this->answers) - 1; $i >= $order; $i--)
527 $this->answers[$i+1] = $this->answers[$i];
528 $this->answers[$i+1]->setOrder($i+1);
530 $this->answers[$order] = $answer;
536 array_push($this->answers, $answer);
550 return count($this->answers);
565 if ($index < 0)
return NULL;
566 if (count($this->answers) < 1)
return NULL;
567 if ($index >= count($this->answers))
return NULL;
568 return $this->answers[$index];
597 if ($index < 0)
return;
598 if (count($this->answers) < 1)
return;
599 if ($index >= count($this->answers))
return;
600 unset($this->answers[$index]);
601 $this->answers = array_values($this->answers);
602 for ($i = 0; $i < count($this->answers); $i++) {
603 if ($this->answers[$i]->getOrder() > $index) {
604 $this->answers[$i]->setOrder($i);
618 $this->answers =
array();
631 foreach ($this->answers as $key => $value) {
632 if($this->is_multiple_choice)
634 if($value->getPoints() > $value->getPointsUnchecked())
636 $points += $value->getPoints();
640 $points += $value->getPointsUnchecked();
645 if($value->getPoints() >
$points)
668 throw new ilTestException(
'return details not implemented for '.__METHOD__);
673 $found_values =
array();
681 if (strcmp(
$data[
"value1"],
"") != 0)
683 array_push($found_values,
$data[
"value1"]);
721 include_once
"./Modules/Test/classes/class.ilObjTest.php";
725 $solutionSelectionChanged =
false;
727 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function() use (&$solutionSelectionChanged, $ilDB, $active_id,
$pass, $authorized) {
738 $solutionSelectionChanged =
true;
743 $active_id,
$pass, $this->is_multiple_choice
750 foreach($selection as $selectedIndex)
753 $solutionSelectionChanged =
true;
761 'value1' => (
int)$selection
764 $solutionSelectionChanged =
true;
770 if( $this->is_multiple_choice )
773 'value1' => (
int)
$_GET[
'selImage']
783 $solutionSelectionChanged =
true;
788 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
791 if( $solutionSelectionChanged )
808 if( $this->is_multiple_choice && strlen(
$_GET[
'remImage']) )
810 unset($solution[(
int)
$_GET[
'remImage']]);
813 if( strlen(
$_GET[
'selImage']) )
815 if( !$this->is_multiple_choice )
820 $solution[(int)
$_GET[
'selImage']] = (
int)
$_GET[
'selImage'];
838 parent::syncWithOriginal();
852 return "assImagemapQuestion";
865 return "qpl_qst_imagemap";
878 return "qpl_a_imagemap";
887 $text = parent::getRTETextWithMediaObjects();
888 foreach ($this->answers as $index => $answer)
890 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
907 $worksheet->setCell($startrow + $i, 0, $answer->getArea() .
": " . $answer->getCoords());
911 foreach($solution as $solIndex => $sol)
913 if( $sol[
'value1'] ==
$id )
920 $worksheet->setCell($startrow + $i, 1, $cellValue);
925 return $startrow + $i + 1;
936 $this->image_filename =
"";
944 include_once(
"./Services/RTE/classes/class.ilRTE.php");
954 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
955 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
961 foreach ($this->
getAnswers() as $key => $answer_obj)
963 array_push($answers,
array(
964 "answertext" => (
string)$answer_obj->getAnswertext(),
965 "points" => (float)$answer_obj->getPoints(),
966 "points_unchecked" => (float)$answer_obj->getPointsUnchecked(),
967 "order" => (int)$order,
968 "coords" => $answer_obj->getCoords(),
969 "state" => $answer_obj->getState(),
970 "area" => $answer_obj->getArea(),
972 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
980 $result[
'mobs'] =
$mobs;
982 return json_encode($result);
992 if(count($found_values) > 0)
994 foreach($this->answers as $key => $answer)
996 if(in_array($key, $found_values))
998 $points += $answer->getPoints();
1001 $points += $answer->getPointsUnchecked();
1019 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1051 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1053 if( $maxStep !== null )
1055 $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",
1056 array(
"integer",
"integer",
"integer",
"integer"),
1062 $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",
1063 array(
"integer",
"integer",
"integer"),
1104 $solution = parent::getTestOutputSolutions($activeId,
$pass);
1106 $this->currentSolution =
array();
1107 foreach($solution as $record)
1109 $this->currentSolution[] = $record[
'value1'];
1121 return $_GET[
"selImage"];
1125 if( !isset(
$_GET[
"selImage"]) )
1130 if( !strlen(
$_GET[
"selImage"]) )
1144 return $_GET[
"remImage"];
1148 if( !$this->is_multiple_choice )
1153 if( !isset(
$_GET[
"remImage"]) )
1158 if( !strlen(
$_GET[
"remImage"]) )
1181 if( !isset(
$_GET[
"reuseSelection"]) )
1186 if( !strlen(
$_GET[
"reuseSelection"]) )
1191 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 _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.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
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
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. ...
Add rich text string
The name of the decorator.
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
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)
Create styles array
The data for the language used.
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{}
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.
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
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)
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...
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
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.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
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.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const EmptyAnswerExpression