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))
137 "DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
143 foreach ($this->answers as
$key => $value) {
144 $answer_obj = $this->answers[
$key];
145 $next_id = $ilDB->nextId(
'qpl_a_imagemap');
147 "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)",
148 array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"float" ),
149 array( $next_id, $this->
id, $answer_obj->getAnswertext(
150 ), $answer_obj->getPoints(), $answer_obj->getOrder(
151 ), $answer_obj->getCoords(), $answer_obj->getArea(
152 ), $answer_obj->getPointsUnchecked() )
169 ) .
" (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
170 array(
"integer",
"text",
'integer' ),
173 $this->image_filename,
174 (
int) $this->is_multiple_choice
186 if ($this->
id <= 0) {
191 $this_id = $this->
getId();
195 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
199 if ((
int) $testObjId > 0) {
200 $clone->setObjId($testObjId);
219 $clone->copyPageOfQuestion($this_id);
221 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
223 $clone->duplicateImage($this_id, $thisObjId);
225 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
239 if ($this->
id <= 0) {
245 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
248 $source_questionpool_id = $this->
getObjId();
249 $clone->setObjId($target_questionpool_id);
260 $clone->copyImage(
$original_id, $source_questionpool_id);
262 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
269 if ($this->
id <= 0) {
274 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
277 $sourceParentId = $this->
getObjId();
283 $clone->setObjId($targetParentId);
285 if ($targetQuestionTitle) {
286 $clone->setTitle($targetQuestionTitle);
291 $clone->copyPageOfQuestion($sourceQuestionId);
293 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
295 $clone->copyImage($sourceQuestionId, $sourceParentId);
297 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
307 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
309 if ((
int) $objectId > 0) {
310 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
313 if (!file_exists($imagepath)) {
319 if (!file_exists($imagepath_original .
$filename)) {
320 $ilLog->write(
"Could not find an image map file when trying to duplicate image: " . $imagepath_original . $filename);
321 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
322 $ilLog->write(
"Using fallback source directory:" . $imagepath_original);
325 if (!file_exists($imagepath_original . $filename) || !copy($imagepath_original . $filename, $imagepath . $filename)) {
326 $ilLog->write(
"Could not duplicate image for image map question: " . $imagepath_original . $filename);
330 public function copyImage($question_id, $source_questionpool)
333 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
334 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
335 if (!file_exists($imagepath)) {
339 if (!copy($imagepath_original .
$filename, $imagepath . $filename)) {
340 print
"image could not be copied!!!! ";
364 $this->
setId($question_id);
374 include_once(
"./Services/RTE/classes/class.ilRTE.php");
385 "SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
389 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
396 parent::loadFromDb($question_id);
409 if (count($shapes) > 0) {
410 foreach ($shapes as $shape) {
411 $this->
addAnswer($shape->getAnswertext(), 0.0, count($this->answers), $shape->getCoords(), $shape->getArea());
437 if (!empty($image_tempfilename)) {
439 if (!file_exists($imagepath)) {
443 $this->
ilias->raiseError(
"The image could not be uploaded!", $this->
ilias->error_obj->MESSAGE);
446 $ilLog->write(
"gespeichert: " . $imagepath . $image_filename);
462 for (
$i = 0;
$i < count($this->answers);
$i++) {
492 $points_unchecked = 0.0
494 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
495 if (array_key_exists($order, $this->answers)) {
498 for (
$i = count($this->answers) - 1;
$i >= $order;
$i--) {
499 $this->answers[
$i+1] = $this->answers[
$i];
500 $this->answers[
$i+1]->setOrder(
$i+1);
502 $this->answers[$order] = $answer;
506 array_push($this->answers, $answer);
521 return count($this->answers);
540 if (count($this->answers) < 1) {
543 if (
$index >= count($this->answers)) {
546 return $this->answers[
$index];
578 if (count($this->answers) < 1) {
581 if (
$index >= count($this->answers)) {
584 unset($this->answers[
$index]);
585 $this->answers = array_values($this->answers);
586 for (
$i = 0;
$i < count($this->answers);
$i++) {
587 if ($this->answers[
$i]->getOrder() >
$index) {
588 $this->answers[
$i]->setOrder(
$i);
603 $this->answers =
array();
617 foreach ($this->answers as
$key => $value) {
618 if ($this->is_multiple_choice) {
619 if ($value->getPoints() > $value->getPointsUnchecked()) {
620 $points += $value->getPoints();
622 $points += $value->getPointsUnchecked();
625 if ($value->getPoints() >
$points) {
645 if ($returndetails) {
646 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
651 $found_values =
array();
652 if (is_null(
$pass)) {
657 if (strcmp(
$data[
"value1"],
"") != 0) {
658 array_push($found_values,
$data[
"value1"]);
694 if (is_null(
$pass)) {
695 include_once
"./Modules/Test/classes/class.ilObjTest.php";
699 $solutionSelectionChanged =
false;
701 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$solutionSelectionChanged, $ilDB, $active_id,
$pass, $authorized) {
710 $solutionSelectionChanged =
true;
715 $this->is_multiple_choice
721 foreach ($selection as $selectedIndex) {
723 $solutionSelectionChanged =
true;
729 'value1' => (
int) $selection
732 $solutionSelectionChanged =
true;
736 if ($this->is_multiple_choice) {
738 'value1' => (
int)
$_GET[
'selImage']
746 $solutionSelectionChanged =
true;
751 require_once
'Modules/Test/classes/class.ilObjAssessmentFolder.php';
753 if ($solutionSelectionChanged) {
767 if ($this->is_multiple_choice && strlen(
$_GET[
'remImage'])) {
768 unset($solution[(
int)
$_GET[
'remImage']]);
771 if (strlen(
$_GET[
'selImage'])) {
772 if (!$this->is_multiple_choice) {
776 $solution[(int)
$_GET[
'selImage']] = (
int)
$_GET[
'selImage'];
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) {
844 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(),
$index);
860 $worksheet->setCell($startrow +
$i, 0, $answer->getArea() .
": " . $answer->getCoords());
864 foreach ($solution as $solIndex => $sol) {
865 if ($sol[
'value1'] ==
$id) {
876 return $startrow +
$i + 1;
887 $this->image_filename =
"";
895 include_once(
"./Services/RTE/classes/class.ilRTE.php");
905 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
906 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
914 "answertext" => (
string) $answer_obj->getAnswertext(),
915 "points" => (float) $answer_obj->getPoints(),
916 "points_unchecked" => (float) $answer_obj->getPointsUnchecked(),
917 "order" => (int) $order,
918 "coords" => $answer_obj->getCoords(),
919 "state" => $answer_obj->getState(),
920 "area" => $answer_obj->getArea(),
922 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(),
$key)
930 $result[
'mobs'] =
$mobs;
932 return json_encode($result);
942 if (count($found_values) > 0) {
943 foreach ($this->answers as
$key => $answer) {
944 if (in_array(
$key, $found_values)) {
945 $points += $answer->getPoints();
947 $points += $answer->getPointsUnchecked();
965 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
997 $maxStep = $this->lookupMaxStep($active_id,
$pass);
999 if ($maxStep !== null) {
1000 $data = $ilDB->queryF(
1001 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1002 array(
"integer",
"integer",
"integer",
"integer"),
1006 $data = $ilDB->queryF(
1007 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL",
1008 array(
"integer",
"integer",
"integer"),
1013 while (
$row = $ilDB->fetchAssoc(
$data)) {
1045 $solution = parent::getTestOutputSolutions($activeId,
$pass);
1047 $this->currentSolution =
array();
1048 foreach ($solution as $record) {
1049 $this->currentSolution[] = $record[
'value1'];
1060 return $_GET[
"selImage"];
1064 if (!isset(
$_GET[
"selImage"])) {
1068 if (!strlen(
$_GET[
"selImage"])) {
1080 return $_GET[
"remImage"];
1084 if (!$this->is_multiple_choice) {
1088 if (!isset(
$_GET[
"remImage"])) {
1092 if (!strlen(
$_GET[
"remImage"])) {
1112 if (!isset(
$_GET[
"reuseSelection"])) {
1116 if (!strlen(
$_GET[
"reuseSelection"])) {
1120 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.
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 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.
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)
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.
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