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';
10require_once
'Modules/TestQuestionPool/interfaces/interface.ilAssSpecificFeedbackOptionLabelProvider.php';
112 $this->thumb_size = 150;
113 $this->answers = array();
125 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
146 $this->ensureNoInvalidObligation($this->
getId());
159 if (strlen($answer->getImage()))
187 switch (strtoupper($path_info[
'extension']))
220 $this->
setId($question_id);
229 include_once(
"./Services/RTE/classes/class.ilRTE.php");
235 $this->isSingleline = (
$data[
'allow_images']) ?
false :
true;
236 $this->lastChange =
$data[
'tstamp'];
237 $this->feedback_setting =
$data[
'feedback_setting'];
248 $result =
$ilDB->queryF(
"SELECT * FROM qpl_a_mc WHERE question_fi = %s ORDER BY aorder ASC",
252 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
258 if (!@file_exists($imagefilename))
260 $data[
"imagefile"] =
"";
262 include_once(
"./Services/RTE/classes/class.ilRTE.php");
268 parent::loadFromDb($question_id);
282 $this_id = $this->
getId();
286 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
290 if( (
int)$testObjId > 0 )
292 $clone->setObjId($testObjId);
319 $clone->copyPageOfQuestion($this_id);
321 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
323 $clone->duplicateImages($this_id, $thisObjId);
325 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
342 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
345 $source_questionpool_id = $this->
getObjId();
346 $clone->setObjId($target_questionpool_id);
357 $clone->copyImages(
$original_id, $source_questionpool_id);
359 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
372 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
375 $sourceParentId = $this->
getObjId();
381 $clone->setObjId($targetParentId);
383 if ($targetQuestionTitle)
385 $clone->setTitle($targetQuestionTitle);
390 $clone->copyPageOfQuestion($sourceQuestionId);
392 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
394 $clone->copyImages($sourceQuestionId, $sourceParentId);
396 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
440 $points_unchecked = 0.0,
445 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
446 if (array_key_exists($order, $this->answers))
450 $newchoices = array();
451 for ($i = 0; $i < $order; $i++)
453 array_push($newchoices, $this->answers[$i]);
455 array_push($newchoices, $answer);
456 for ($i = $order; $i < count($this->answers); $i++)
462 $this->answers = $newchoices;
468 array_push($this->answers, $answer);
480 return count($this->answers);
493 if ($index < 0)
return NULL;
494 if (count($this->answers) < 1)
return NULL;
495 if ($index >= count($this->answers))
return NULL;
497 return $this->answers[$index];
509 if ($index < 0)
return;
510 if (count($this->answers) < 1)
return;
511 if ($index >= count($this->answers))
return;
512 $answer = $this->answers[$index];
513 if (strlen($answer->getImage())) $this->
deleteImage($answer->getImage());
514 unset($this->answers[$index]);
515 $this->answers = array_values($this->answers);
516 for ($i = 0; $i < count($this->answers); $i++)
518 if ($this->answers[$i]->getOrder() > $index)
520 $this->answers[$i]->setOrder($i);
532 $this->answers = array();
544 foreach ($this->answers as $key => $value)
546 if ($value->getPoints() > $value->getPointsUnchecked())
548 $allpoints += $value->getPoints();
552 $allpoints += $value->getPointsUnchecked();
573 throw new ilTestException(
'return details not implemented for '.__METHOD__);
578 $found_values = array();
586 if (strcmp(
$data[
"value1"],
"") != 0)
588 array_push($found_values,
$data[
"value1"]);
612 include_once
"./Modules/Test/classes/class.ilObjTest.php";
624 foreach($solutionSubmit as $value)
637 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
645 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
664 ) .
" WHERE question_fi = %s",
666 array( $this->
getId() )
671 $oldthumbsize =
$data[
'thumb_size'];
675 if (!$this->isSingleline)
683 array( $this->
getId() )
687 .
" (question_fi, shuffle, allow_images, thumb_size) VALUES (%s, %s, %s, %s)",
688 array(
"integer",
"text",
"text",
"integer" ),
692 ($this->isSingleline) ?
"0" :
"1",
702 $ilDB->manipulateF(
"DELETE FROM qpl_a_mc WHERE question_fi = %s",
704 array( $this->
getId() )
707 foreach ($this->answers as $key => $value)
709 $answer_obj = $this->answers[$key];
710 $next_id =
$ilDB->nextId(
'qpl_a_mc' );
711 $ilDB->manipulateF(
"INSERT INTO qpl_a_mc (answer_id, question_fi, answertext, points, points_unchecked, aorder, imagefile, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
712 array(
'integer',
'integer',
'text',
'float',
'float',
'integer',
'text',
'integer' ),
717 $answer_obj->getPoints(),
718 $answer_obj->getPointsUnchecked(),
719 $answer_obj->getOrder(),
720 $answer_obj->getImage(),
745 parent::syncWithOriginal();
756 return "assMultipleChoice";
786 public function setImageFile($image_filename, $image_tempfilename =
"")
789 if (!empty($image_tempfilename))
791 $image_filename = str_replace(
" ",
"_", $image_filename);
793 if (!file_exists($imagepath))
803 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
805 if (!preg_match(
"/^image/", $mimetype))
807 unlink($imagepath . $image_filename);
831 @unlink($imagepath . $image_filename);
832 $thumbpath = $imagepath . $this->
getThumbPrefix() . $image_filename;
836 function duplicateImages($question_id, $objectId =
null)
842 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
844 if( (
int)$objectId > 0 )
846 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
849 foreach ($this->answers as $answer)
854 if (!file_exists($imagepath))
861 "Could not clone source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
863 $question_id, $this->
id, $objectId, $this->obj_id
866 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
871 "Could not clone thumbnail source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
873 $question_id, $this->
id, $objectId, $this->obj_id
885 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
886 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
887 foreach ($this->answers as $answer)
892 if (!file_exists($imagepath))
898 $ilLog->write(
"image could not be duplicated!!!!",
$ilLog->ERROR);
899 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
901 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
905 $ilLog->write(
"image thumbnail could not be duplicated!!!!",
$ilLog->ERROR);
906 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
923 $originalObjId = parent::lookupParentObjId($this->
getOriginalId());
924 $imagepath_original = $this->
getImagePath($question_id, $originalObjId);
927 foreach ($this->answers as $answer)
932 if (@file_exists($imagepath .
$filename))
934 if (!file_exists($imagepath))
938 if (!file_exists($imagepath_original))
944 $ilLog->write(
"image could not be duplicated!!!!",
$ilLog->ERROR);
945 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
948 if (@file_exists($imagepath . $this->
getThumbPrefix() . $filename))
952 $ilLog->write(
"image thumbnail could not be duplicated!!!!",
$ilLog->ERROR);
953 $ilLog->write(
"object: " . print_r($this, TRUE),
$ilLog->ERROR);
965 $text = parent::getRTETextWithMediaObjects();
966 foreach ($this->answers as $index => $answer)
968 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
969 $answer_obj = $this->answers[$index];
970 $text .= $answer_obj->getAnswertext();
997 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1006 foreach ($solution as $solutionvalue)
1008 if (
$id == $solutionvalue[
"value1"])
1015 $worksheet->write($startrow + $i, 1, 1);
1019 $worksheet->write($startrow + $i, 1, 0);
1023 return $startrow + $i + 1;
1033 $this->thumb_size = $a_size;
1053 require_once
'./Services/RTE/classes/class.ilRTE.php';
1062 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
1063 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
1068 foreach ($this->
getAnswers() as $key => $answer_obj)
1070 if((
string) $answer_obj->getImage())
1075 "answertext" => (
string) $this->
formatSAQuestion($answer_obj->getAnswertext()),
1076 "points_checked" => (
float) $answer_obj->getPointsChecked(),
1077 "points_unchecked" => (
float) $answer_obj->getPointsUnchecked(),
1078 "order" => (
int) $answer_obj->getOrder(),
1079 "image" => (
string) $answer_obj->getImage(),
1080 "feedback" => $this->formatSAQuestion(
1081 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1101 $answer = $this->answers[$index];
1102 if (is_object($answer))
1105 $answer->setImage(
'');
1113 $multilineAnswerSetting =
$ilUser->getPref(
"tst_multiline_answers");
1114 if ($multilineAnswerSetting != 1)
1116 $multilineAnswerSetting = 0;
1118 return $multilineAnswerSetting;
1124 $ilUser->writePref(
"tst_multiline_answers", $a_setting);
1138 $this->feedback_setting = $a_feedback_setting;
1152 if ($this->feedback_setting)
1164 return 'feedback_correct_sc_mc';
1182 return $numExistingSolutionRecords > 0;
1202 SELECT SUM(points) points_for_checked_answers
1204 WHERE question_fi = %s AND points > 0
1211 return $row[
'points_for_checked_answers'] > 0;
1222 public function ensureNoInvalidObligation($questionId)
1228 SELECT SUM(qpl_a_mc.points) points_for_checked_answers,
1231 FROM tst_test_question
1234 ON qpl_a_mc.question_fi = tst_test_question.question_fi
1236 WHERE tst_test_question.question_fi = %s
1237 AND tst_test_question.obligatory = 1
1239 GROUP BY test_question_id
1244 $updateTestQuestionIds = array();
1248 if(
$row[
'points_for_checked_answers'] <= 0 )
1250 $updateTestQuestionIds[] =
$row[
'test_question_id'];
1254 if( count($updateTestQuestionIds) )
1256 $test_question_id__IN__updateTestQuestionIds =
$ilDB->in(
1257 'test_question_id', $updateTestQuestionIds,
false,
'integer'
1261 UPDATE tst_test_question
1263 WHERE $test_question_id__IN__updateTestQuestionIds
1275 $solutionSubmit = array();
1276 foreach(
$_POST as $key => $value)
1278 if(preg_match(
"/^multiple_choice_result_(\d+)/", $key))
1282 $solutionSubmit[] = $value;
1286 return $solutionSubmit;
1297 foreach($this->answers as $key => $answer)
1299 if(in_array($key, $found_values))
1301 $points += $answer->getPoints();
1304 $points += $answer->getPointsUnchecked();
1309 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1311 if(($mc_scoring == 0) && (count($found_values) == 0))
1329 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1361 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1363 if( $maxStep !==
null )
1366 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1367 array(
"integer",
"integer",
"integer",
"integer"),
1368 array($active_id,
$pass, $this->
getId(), $maxStep)
1374 "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
1375 array(
"integer",
"integer",
"integer"),
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked,...
Class for multiple choice tests.
syncImages()
Sync images of a MC question on synchronisation with the original question.
toJSON()
Returns a JSON representation of the question.
getSpecificFeedbackSetting()
Gets the current feedback settings in effect for the question.
copyImages($question_id, $source_questionpool)
saveToDb($original_id="")
Saves a assMultipleChoice object to a database.
loadFromDb($question_id)
Loads a assMultipleChoice object from a database.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assMultipleChoiceQuestion.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getAnswerCount()
Returns the number of answers.
getAnswerTableName()
Returns the name of the answer table in the database.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
isAnswered($active_id, $pass=NULL)
returns boolean wether the question is answered during test pass or not
getAdditionalTableName()
Returns the name of the additional question data table in the database.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
getSpecificFeedbackAllCorrectOptionLabel()
setSpecificFeedbackSetting($a_feedback_setting)
Sets the feedback settings in effect for the question.
removeAnswerImage($index)
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
calculateReachedPointsForSolution($found_values, $active_id=0)
getOutputType()
Gets the multiple choice output type which is either OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1).
setLastChange($lastChange)
copyObject($target_questionpool_id, $title="")
Copies an assMultipleChoice object.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
getMultilineAnswerSetting()
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
setMultilineAnswerSetting($a_setting=0)
isComplete()
Returns true, if a multiple choice question is complete for use.
flushAnswers()
Deletes all answers.
deleteAnswer($index=0)
Deletes an answer with a given index.
getQuestionType()
Returns the question type of the question.
deleteImage($image_filename)
Deletes an image file.
setImageFile($image_filename, $image_tempfilename="")
Sets the image file and uploads the image to the object's image directory.
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $output_type=OUTPUT_ORDER)
assMultipleChoice constructor
setIsSingleline($isSingleline)
setOutputType($output_type=OUTPUT_ORDER)
Sets the output type of the assMultipleChoice object.
getAnswer($index=0)
Returns an answer with a given index.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
generateThumbForFile($path, $file)
getExpressionTypes()
Get all available expression types for a specific question.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
rebuildThumbnails()
Rebuild the thumbnail images with a new thumbnail size.
& getAnswers()
Returns a reference to the answers array.
getOperators($expression)
Get all available operations for a specific question.
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.
setShuffle($shuffle=true)
Sets the shuffle flag.
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.
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
saveQuestionDataToDb($original_id="")
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.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
setAuthor($author="")
Sets the authors name of the assQuestion object.
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
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.
_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.
_getMCScoring($active_id)
Gets the scoring type for multiple choice questions.
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 delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
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
migrateToLmContent($content)
Interface ilObjAnswerScoringAdjustable.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
Interface ilObjQuestionScoringAdjustable.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.