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';
10 require_once
'Modules/TestQuestionPool/interfaces/interface.ilAssSpecificFeedbackOptionLabelProvider.php';
85 $this->thumb_size = 150;
87 $this->answers = array();
89 $this->feedback_setting = 2;
100 if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->
getMaximumPoints() > 0))
102 foreach ($this->answers as $answer)
104 if ((strlen($answer->getAnswertext()) == 0) && (strlen($answer->getImage()) == 0))
return false;
134 array($this->
getId())
139 $oldthumbsize =
$data[
'thumb_size'];
160 if (strlen($answer->getImage()))
181 switch (strtoupper($path_info[
'extension']))
217 $this->
setId($question_id);
226 include_once(
"./Services/RTE/classes/class.ilRTE.php");
232 $this->isSingleline = (
$data[
'allow_images']) ?
false :
true;
233 $this->lastChange =
$data[
'tstamp'];
234 $this->feedback_setting =
$data[
'feedback_setting'];
245 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_sc WHERE question_fi = %s ORDER BY aorder ASC",
249 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
255 if (!@file_exists($imagefilename))
257 $data[
"imagefile"] =
"";
259 include_once(
"./Services/RTE/classes/class.ilRTE.php");
265 parent::loadFromDb($question_id);
281 $this_id = $this->
getId();
285 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
289 if( (
int)$testObjId > 0 )
291 $clone->setObjId($testObjId);
317 $clone->copyPageOfQuestion($this_id);
320 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
322 $clone->duplicateImages($this_id, $thisObjId);
324 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
343 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
346 $source_questionpool_id = $this->
getObjId();
347 $clone->setObjId($target_questionpool_id);
358 $clone->copyImages(
$original_id, $source_questionpool_id);
360 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
373 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
376 $sourceParentId = $this->
getObjId();
382 $clone->setObjId($targetParentId);
384 if ($targetQuestionTitle)
386 $clone->setTitle($targetQuestionTitle);
391 $clone->copyPageOfQuestion($sourceQuestionId);
393 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
395 $clone->copyImages($sourceQuestionId, $sourceParentId);
397 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
446 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
447 if (array_key_exists($order, $this->answers))
451 $newchoices = array();
452 for ($i = 0; $i < $order; $i++)
454 array_push($newchoices, $this->answers[$i]);
456 array_push($newchoices, $answer);
457 for ($i = $order; $i < count($this->answers); $i++)
463 $this->answers = $newchoices;
469 array_push($this->answers, $answer);
482 return count($this->answers);
496 if ($index < 0)
return NULL;
497 if (count($this->answers) < 1)
return NULL;
498 if ($index >= count($this->answers))
return NULL;
500 return $this->answers[$index];
513 if ($index < 0)
return;
514 if (count($this->answers) < 1)
return;
515 if ($index >= count($this->answers))
return;
516 $answer = $this->answers[$index];
517 if (strlen($answer->getImage())) $this->
deleteImage($answer->getImage());
518 unset($this->answers[$index]);
519 $this->answers = array_values($this->answers);
520 for ($i = 0; $i < count($this->answers); $i++)
522 if ($this->answers[$i]->getOrder() > $index)
524 $this->answers[$i]->setOrder($i);
537 $this->answers = array();
549 foreach ($this->answers as $key => $value)
551 if ($value->getPoints() >
$points)
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"]);
592 foreach ($this->answers as $key => $answer)
594 if (count($found_values) > 0)
596 if (in_array($key, $found_values))
598 $points += $answer->getPoints();
609 foreach ($this->answers as $key => $answer)
611 if( is_numeric($participantSolution) && $key == $participantSolution )
613 return $answer->getPoints();
635 include_once
"./Modules/Test/classes/class.ilObjTest.php";
644 $update =
$row[
"solution_id"];
648 if (strlen(
$_POST[
"multiple_choice_result"]))
660 if (strlen(
$_POST[
"multiple_choice_result"]))
671 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
679 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
691 if( strlen(
$_POST[
'multiple_choice_result'.$this->
getId().
'ID']) )
709 array( $this->
getId() )
713 ) .
" (question_fi, shuffle, allow_images, thumb_size) VALUES (%s, %s, %s, %s)",
714 array(
"integer",
"text",
"text",
"integer" ),
718 ($this->isSingleline) ?
"0" :
"1",
728 if (!$this->isSingleline)
732 $ilDB->manipulateF(
"DELETE FROM qpl_a_sc WHERE question_fi = %s",
734 array( $this->
getId() )
737 foreach ($this->answers as $key => $value)
740 $answer_obj = $this->answers[$key];
741 $next_id = $ilDB->nextId(
'qpl_a_sc' );
742 $ilDB->manipulateF(
"INSERT INTO qpl_a_sc (answer_id, question_fi, answertext, points, aorder, imagefile, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
743 array(
'integer',
'integer',
'text',
'float',
'integer',
'text',
'integer' ),
748 $answer_obj->getPoints(),
749 $answer_obj->getOrder(),
750 $answer_obj->getImage(),
779 return "assSingleChoice";
815 if (!empty($image_tempfilename))
817 $image_filename = str_replace(
" ",
"_", $image_filename);
819 if (!file_exists($imagepath))
830 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
832 if (!preg_match(
"/^image/", $mimetype))
834 unlink($imagepath . $image_filename);
859 @unlink($imagepath . $image_filename);
860 $thumbpath = $imagepath . $this->
getThumbPrefix() . $image_filename;
868 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
870 if( (
int)$objectId > 0 )
872 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $imagepath_original);
875 foreach ($this->answers as $answer)
880 if (!file_exists($imagepath))
884 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
886 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
887 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
889 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
893 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
894 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
901 function copyImages($question_id, $source_questionpool)
907 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
908 $imagepath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $imagepath_original);
909 foreach ($this->answers as $answer)
914 if (!file_exists($imagepath))
918 if (!@copy($imagepath_original .
$filename, $imagepath . $filename))
920 $ilLog->warning(sprintf(
921 "Could not clone source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
922 $imagepath_original . $filename, $imagepath . $filename,
923 $question_id, $this->
id, $source_questionpool, $this->obj_id
926 if (@file_exists($imagepath_original. $this->getThumbPrefix().
$filename))
930 $ilLog->warning(sprintf(
931 "Could not clone thumbnail source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
933 $question_id, $this->
id, $source_questionpool, $this->obj_id
949 $imagepath_original = str_replace(
"/$this->id/images",
"/$question_id/images", $imagepath);
951 foreach ($this->answers as $answer)
956 if (@file_exists($imagepath .
$filename))
958 if (!file_exists($imagepath))
962 if (!file_exists($imagepath_original))
966 if (!@copy($imagepath . $filename, $imagepath_original . $filename))
968 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
969 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
972 if (@file_exists($imagepath . $this->
getThumbPrefix() . $filename))
976 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
977 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
990 $text = parent::getRTETextWithMediaObjects();
991 foreach ($this->answers as $index => $answer)
993 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $index);
994 $answer_obj = $this->answers[$index];
995 $text .= $answer_obj->getAnswertext();
1022 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
1031 count($solution) > 0 &&
1032 isset($solution[0]) &&
1033 is_array($solution[0]) &&
1034 strlen($solution[0][
'value1']) > 0 &&
$id == $solution[0][
'value1'])
1036 $worksheet->write($startrow + $i, 1, 1);
1040 $worksheet->write($startrow + $i, 1, 0);
1044 return $startrow + $i + 1;
1054 $this->thumb_size = $a_size;
1074 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1084 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
1085 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
1090 foreach ($this->
getAnswers() as $key => $answer_obj)
1092 if((
string) $answer_obj->getImage())
1096 array_push($answers, array(
1097 "answertext" => (
string) $this->
formatSAQuestion($answer_obj->getAnswertext()),
1098 "points" => (
float)$answer_obj->getPoints(),
1099 "order" => (int)$answer_obj->getOrder(),
1100 "image" => (string) $answer_obj->getImage(),
1102 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1121 $answer = $this->answers[$index];
1122 if (is_object($answer))
1125 $answer->setImage(
'');
1131 $value = rand(0, count($this->answers)-1);
1132 $_POST[
"multiple_choice_result"] = (strlen($value)) ? (
string)$value :
'0';
1141 $multilineAnswerSetting = $ilUser->getPref(
"tst_multiline_answers");
1142 if ($multilineAnswerSetting != 1)
1144 $multilineAnswerSetting = 0;
1146 return $multilineAnswerSetting;
1152 $ilUser->writePref(
"tst_multiline_answers", $a_setting);
1166 $this->feedback_setting = $a_feedback_setting;
1180 if ($this->feedback_setting)
1192 return 'feedback_correct_sc_mc';
1209 return $numExistingSolutionRecords > 0;
1237 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1268 $maxStep = $this->lookupMaxStep($active_id,
$pass);
1270 if( $maxStep !== null )
1272 $data = $ilDB->queryF(
1273 "SELECT * FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1274 array(
"integer",
"integer",
"integer",
"integer"),
1275 array($active_id,
$pass, $this->
getId(), $maxStep)
1280 $data = $ilDB->queryF(
1281 "SELECT * FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
1282 array(
"integer",
"integer",
"integer"),
1328 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1330 $origImagePath = $this->
buildImagePath($origQuestionId, $origParentObjId);
1331 $dupImagePath = $this->
buildImagePath($dupQuestionId, $dupParentObjId);
1334 if(is_dir($dupImagePath))
getSpecificFeedbackAllCorrectOptionLabel()
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getOutputType()
Gets the single choice output type which is either OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1)...
getId()
Gets the id of the assQuestion object.
saveToDb($original_id="")
Saves the question to the database.
generateThumbForFile($path, $file)
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
const PercentageResultExpression
removeAnswerImage($index)
Class iQuestionCondition.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
const NumberOfResultExpression
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
Abstract basic class which is to be extended by the concrete assessment question type classes...
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
Class for answers with a binary state indicator.
_convert_text($a_text, $a_target="has been removed")
setOutputType($output_type=OUTPUT_ORDER)
Sets the output type of the assSingleChoice object.
setMultilineAnswerSetting($a_setting=0)
& getAnswers()
Returns a reference to the answers array.
afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
{}
getAnswerCount()
Returns the number of answers.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
isComplete()
Returns true, if a single choice question is complete for use.
setId($id=-1)
Sets the id of the assQuestion object.
copyObject($target_questionpool_id, $title="")
Copies an assSingleChoice object.
getQuestionType()
Returns the question type of the question.
getAnswerTableName()
Returns the name of the answer table in the database.
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. ...
migrateToLmContent($content)
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true)
loadFromDb($question_id)
Loads a assSingleChoice object from a database.
getParticipantsSolution()
calculateResultsFromSolution($active_id, $pass=NULL, $obligationsEnabled=false)
Calculates the question results from a previously saved question solution.
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
setNrOfTries($a_nr_of_tries)
setSpecificFeedbackSetting($a_feedback_setting)
Sets the feedback settings in effect for the question.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assSingleChoiceQuestion.
getAnswer($index=0)
Returns an answer with a given index.
setShuffle($shuffle=true)
Sets the shuffle flag.
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...
getOperators($expression)
Get all available operations for a specific question.
getObjId()
Get the object id of the container object.
getShuffle()
Gets the shuffle flag.
Base Exception for all Exceptions relating to Modules/Test.
getMultilineAnswerSetting()
getSpecificFeedbackSetting()
Gets the current feedback settings in effect for the question.
setParticipantsSolution($participantSolution)
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
isAnswered($active_id, $pass=NULL)
returns boolean wether the question is answered during test pass or not
removeSolutionRecordById($solutionId)
deleteImage($image_filename)
Deletes an image file.
setAuthor($author="")
Sets the authors name of the assQuestion object.
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
Class ilUserQuestionResult.
createRandomSolution($active_id, $pass)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
Class for single choice questions.
deleteAnswer($index=0)
Deletes an answer with a given index.
Interface ilObjAnswerScoringAdjustable.
toJSON()
Returns a JSON representation of the question.
addAnswer( $answertext="", $points=0.0, $order=0, $answerimage="")
Adds a possible answer for a single choice question.
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $output_type=OUTPUT_ORDER)
assSingleChoice constructor
getQuestion()
Gets the question string of the question object.
syncImages()
Sync images of a MC question on synchronisation with the original question.
flushAnswers()
Deletes all answers.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
updateCurrentSolution($solutionId, $value1, $value2, $authorized=true)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
_getLogLanguage()
retrieve the log language for assessment logging
static getOperatorsByExpression($expression)
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
setImageFile($image_filename, $image_tempfilename="")
Sets the image file and uploads the image to the object's image directory.
setQuestion($question="")
Sets the question string of the question object.
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
duplicateImages($question_id, $objectId=null)
Interface ilObjQuestionScoringAdjustable.
buildImagePath($questionId, $parentObjectId)
setOriginalId($original_id)
getExpressionTypes()
Get all available expression types for a specific question.
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getTitle()
Gets the title string of the assQuestion object.
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
setComment($comment="")
Sets the comment string of the assQuestion object.
savePreviewData(ilAssQuestionPreviewSession $previewSession)
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const EmptyAnswerExpression