4 require_once
'Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once
'Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
6 require_once
'Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
7 require_once
'Modules/TestQuestionPool/interfaces/interface.ilAssSpecificFeedbackOptionLabelProvider.php';
55 $this->shuffleAnswersEnabled =
true;
56 $this->answerType = self::ANSWER_TYPE_SINGLE_LINE;
57 $this->thumbSize = self::DEFAULT_THUMB_SIZE;
58 $this->scorePartialSolutionEnabled =
true;
59 $this->optionLabel = self::OPTION_LABEL_RIGHT_WRONG;
60 $this->customTrueOptionLabel =
'';
61 $this->customFalseOptionLabel =
'';
63 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
66 $this->answers = array();
73 return 'assKprimChoice';
78 return "qpl_qst_kprim";
179 if ($answer->getPosition() == $position) {
189 $this->answers[] = $answer;
196 while (
$data = $this->db->fetchAssoc(
$res)) {
197 $this->
setId($questionId);
211 require_once
'Services/RTE/classes/class.ilRTE.php';
220 if (is_numeric($data[
'thumb_size'])) {
231 if ($data[
'score_partsol'] !== null) {
235 if (isset($data[
'feedback_setting'])) {
247 parent::loadFromDb($questionId);
253 $ilDB = $DIC[
'ilDB'];
255 $res = $this->db->queryF(
256 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
261 require_once
'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
262 require_once
'Services/RTE/classes/class.ilRTE.php';
267 $answer->setPosition(
$data[
'position']);
271 $answer->setImageFile(
$data[
'imagefile']);
276 $answer->setCorrectness(
$data[
'correctness']);
278 $this->answers[$answer->getPosition()] = $answer;
281 for (
$i = count($this->answers);
$i < self::NUM_REQUIRED_ANSWERS;
$i++) {
284 $answer->setPosition(
$i);
286 $this->answers[$answer->getPosition()] = $answer;
297 parent::saveToDb($originalId);
305 'question_fi' => array(
'integer', $this->
getId())
310 'thumb_size' => array(
'integer', (
int) $this->
getThumbSize()),
326 'question_fi' => array(
'integer', (
int) $this->
getId()),
327 'position' => array(
'integer', (
int) $answer->getPosition())
330 'answertext' => array(
'text', $answer->getAnswertext()),
331 'imagefile' => array(
'text', $answer->getImageFile()),
332 'correctness' => array(
'integer', (
int) $answer->getCorrectness())
342 foreach (array($this->title, $this->author, $this->question) as
$text) {
343 if (!strlen($text)) {
355 if (is_null($answer->getCorrectness())) {
359 if (!strlen($answer->getAnswertext()) && !strlen($answer->getImageFile())) {
380 if (is_null(
$pass)) {
381 include_once
"./Modules/Test/classes/class.ilObjTest.php";
387 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id,
$pass, $authorized) {
392 foreach ($solutionSubmit as $answerIndex => $answerValue) {
398 if ($entered_values) {
399 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
404 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
425 if ($returndetails) {
426 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
430 $ilDB = $DIC[
'ilDB'];
432 $found_values = array();
433 if (is_null(
$pass)) {
440 $found_values[(int)
$data[
'value1']] = (
int)
$data[
'value2'];
450 return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
471 self::ANSWER_TYPE_SINGLE_LINE => $lng->
txt(
'answers_singleline'),
472 self::ANSWER_TYPE_MULTI_LINE => $lng->
txt(
'answers_multiline')
479 self::OPTION_LABEL_RIGHT_WRONG,
480 self::OPTION_LABEL_PLUS_MINUS,
481 self::OPTION_LABEL_APPLICABLE_OR_NOT,
482 self::OPTION_LABEL_ADEQUATE_OR_NOT,
483 self::OPTION_LABEL_CUSTOM
490 self::OPTION_LABEL_RIGHT_WRONG => $lng->
txt(
'option_label_right_wrong'),
491 self::OPTION_LABEL_PLUS_MINUS => $lng->
txt(
'option_label_plus_minus'),
492 self::OPTION_LABEL_APPLICABLE_OR_NOT => $lng->
txt(
'option_label_applicable_or_not'),
493 self::OPTION_LABEL_ADEQUATE_OR_NOT => $lng->
txt(
'option_label_adequate_or_not'),
494 self::OPTION_LABEL_CUSTOM => $lng->
txt(
'option_label_custom')
507 case self::OPTION_LABEL_RIGHT_WRONG:
508 return $lng->
txt(
'option_label_right');
510 case self::OPTION_LABEL_PLUS_MINUS:
511 return $lng->
txt(
'option_label_plus');
513 case self::OPTION_LABEL_APPLICABLE_OR_NOT:
514 return $lng->
txt(
'option_label_applicable');
516 case self::OPTION_LABEL_ADEQUATE_OR_NOT:
517 return $lng->
txt(
'option_label_adequate');
519 case self::OPTION_LABEL_CUSTOM:
527 case self::OPTION_LABEL_RIGHT_WRONG:
528 return $lng->
txt(
'option_label_wrong');
530 case self::OPTION_LABEL_PLUS_MINUS:
531 return $lng->
txt(
'option_label_minus');
533 case self::OPTION_LABEL_APPLICABLE_OR_NOT:
534 return $lng->
txt(
'option_label_not_applicable');
536 case self::OPTION_LABEL_ADEQUATE_OR_NOT:
537 return $lng->
txt(
'option_label_not_adequate');
539 case self::OPTION_LABEL_CUSTOM:
547 $lng->
txt(
'kprim_instruction_text'),
555 return $labelValue == self::OPTION_LABEL_CUSTOM;
560 return self::THUMB_PREFIX;
567 if (strlen($answer->getImageFile())) {
581 switch (strtoupper($path_info[
'extension'])) {
601 if (!isset(
$files[$answer->getPosition()])) {
613 if (!file_exists($imagePath)) {
622 if (!ilUtil::moveUploadedFile($fileData[
'tmp_name'], $fileData[
'name'], $answer->
getImageFsPath())) {
633 if (file_exists($answer->getImageFsPath())) {
637 if (file_exists($answer->getThumbFsPath())) {
641 $answer->setImageFile(null);
646 $solutionSubmit = array();
650 if (preg_match(
"/^kprim_choice_result_(\d+)/",
$key, $matches)) {
651 if (strlen($value)) {
652 $solutionSubmit[$matches[1]] = $value;
656 return $solutionSubmit;
664 if (!isset($found_values[$answer->getPosition()])) {
668 if ($found_values[$answer->getPosition()] == $answer->getCorrectness()) {
673 if ($numCorrect >= self::NUM_REQUIRED_ANSWERS) {
682 include_once
"./Modules/Test/classes/class.ilObjTest.php";
684 if (($mc_scoring == 0) && (count($found_values) == 0)) {
693 if ($this->
id <= 0) {
698 $this_id = $this->
getId();
702 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
706 if ((
int) $testObjId > 0) {
707 $clone->setObjId($testObjId);
728 $clone->copyPageOfQuestion($this_id);
730 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
732 $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
734 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
741 if ($this->
id <= 0) {
746 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
749 $sourceParentId = $this->
getObjId();
755 $clone->setObjId($targetParentId);
757 if ($targetQuestionTitle) {
758 $clone->setTitle($targetQuestionTitle);
763 $clone->copyPageOfQuestion($sourceQuestionId);
765 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
767 $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
769 $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
779 if ($this->
id <= 0) {
785 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
788 $source_questionpool_id = $this->
getObjId();
789 $clone->setObjId($target_questionpool_id);
799 $clone->cloneAnswerImages(
$original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
801 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
808 parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
810 $question = self::_instanciateQuestion($origQuestionId);
812 foreach (
$question->getAnswers() as $answer) {
813 $question->removeAnswerImage($answer->getPosition());
819 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
821 $this->cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
824 protected function cloneAnswerImages($sourceQuestionId, $sourceParentId, $targetQuestionId, $targetParentId)
830 $sourcePath = $this->
buildImagePath($sourceQuestionId, $sourceParentId);
831 $targetPath = $this->
buildImagePath($targetQuestionId, $targetParentId);
837 if (!file_exists($targetPath)) {
841 if (file_exists($sourcePath .
$filename)) {
842 if (!copy($sourcePath . $filename, $targetPath . $filename)) {
844 "Could not clone source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
845 $sourcePath . $filename,
846 $targetPath . $filename,
855 if (file_exists($sourcePath . $this->
getThumbPrefix() . $filename)) {
858 "Could not clone thumbnail source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
874 $combinedText = parent::getRTETextWithMediaObjects();
877 $combinedText .= $answer->getAnswertext();
880 return $combinedText;
899 $this->lng->loadLanguageModule(
'assessment');
901 require_once
'./Services/RTE/classes/class.ilRTE.php';
914 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
915 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
927 if (strlen((
string) $answer->getImageFile())) {
933 'correctness' => (
bool) $answer->getCorrectness(),
934 'order' => (int) $answer->getPosition(),
935 'image' => (string) $answer->getImageFile(),
937 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0,
$key)
950 $result[
'mobs'] =
$mobs;
952 return json_encode($result);
958 return self::NUM_REQUIRED_ANSWERS - self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS;
966 return 'feedback_correct_kprim';
978 return $numExistingSolutionRecords >= 4;
986 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
992 $worksheet->setCell($startrow +
$i, 0, $answer->getAnswertext());
993 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow +
$i));
994 $correctness =
false;
995 foreach ($solution as $solutionvalue) {
996 if (
$id == $solutionvalue[
'value1']) {
997 $correctness = $solutionvalue[
'value2'];
1001 $worksheet->setCell($startrow +
$i, 1, $correctness);
1005 return $startrow +
$i + 1;
1010 if ($position < 0 || $position >= (self::NUM_REQUIRED_ANSWERS - 1)) {
1014 for (
$i = 0, $max = count($this->answers);
$i < $max;
$i++) {
1015 if (
$i == $position) {
1016 $movingAnswer = $this->answers[
$i];
1017 $targetAnswer = $this->answers[
$i + 1 ];
1019 $movingAnswer->setPosition($position + 1);
1020 $targetAnswer->setPosition($position);
1022 $this->answers[
$i + 1 ] = $movingAnswer;
1023 $this->answers[
$i] = $targetAnswer;
1030 if ($position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1)) {
1034 for (
$i = 0, $max = count($this->answers);
$i < $max;
$i++) {
1035 if (
$i == $position) {
1036 $movingAnswer = $this->answers[
$i];
1037 $targetAnswer = $this->answers[
$i - 1 ];
1039 $movingAnswer->setPosition($position - 1);
1040 $targetAnswer->setPosition($position);
1042 $this->answers[
$i - 1 ] = $movingAnswer;
1043 $this->answers[
$i] = $targetAnswer;
getValidOptionLabelsTranslated(ilLanguage $lng)
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.
setImageFsDir($imageFsDir)
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
isValidAnswerType($answerType)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
buildHashedImageFilename($plain_image_filename, $unique=false)
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
getRTETextWithMediaObjects()
setScorePartialSolutionEnabled($scorePartialSolutionEnabled)
getPoints()
Returns the maximum available points for the question.
static isObligationPossible($questionId)
const OPTION_LABEL_RIGHT_WRONG
isCustomOptionLabel($labelValue)
Abstract basic class which is to be extended by the concrete assessment question type classes...
__construct($title='', $comment='', $author='', $owner=-1, $question='')
const OPTION_LABEL_ADEQUATE_OR_NOT
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.
const NUM_REQUIRED_ANSWERS
getImagePathWeb()
Returns the web image path for web accessable images of a question.
const PARTIAL_SCORING_NUM_CORRECT_ANSWERS
removeAnswerImage($position)
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
getSpecificFeedbackSetting()
migrateToLmContent($content)
moveAnswerDown($position)
copyObject($target_questionpool_id, $title="")
Copies an assMultipleChoice object.
getSpecificFeedbackAllCorrectOptionLabel()
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
setEstimatedWorkingTimeFromDurationString($durationString)
Sets the estimated working time of a question from a given datetime string.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setCustomTrueOptionLabel($customTrueOptionLabel)
isValidOptionLabel($optionLabel)
loadAnswerData($questionId)
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
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.
beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
addAnswer(ilAssKprimChoiceAnswer $answer)
Base Exception for all Exceptions relating to Modules/Test.
setOptionLabel($optionLabel)
static _getLogLanguage()
retrieve the log language for assessment logging
const ANSWER_TYPE_MULTI_LINE
isScorePartialSolutionEnabled()
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.
foreach($_POST as $key=> $value) $res
isSingleLineAnswerType($answerType)
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getAnswerTypeSelectOptions(ilLanguage $lng)
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
isShuffleAnswersEnabled()
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
setShuffleAnswersEnabled($shuffleAnswersEnabled)
Interface ilObjAnswerScoringAdjustable.
const OPTION_LABEL_APPLICABLE_OR_NOT
getCustomFalseOptionLabel()
handleFileUploads($answers, $files)
getQuestion()
Gets the question string of the question object.
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
isAnswered($active_id, $pass=null)
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
setCustomFalseOptionLabel($customFalseOptionLabel)
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
const OPTION_LABEL_CUSTOM
calculateReachedPointsForSolution($found_values, $active_id=0)
setQuestion($question="")
Sets the question string of the question object.
const FEEDBACK_SETTING_ALL
Interface ilObjQuestionScoringAdjustable.
removeCurrentSolution($active_id, $pass, $authorized=true)
setSpecificFeedbackSetting($specificFeedbackSetting)
static _getMCScoring($active_id)
Gets the scoring type for multiple choice questions.
buildImagePath($questionId, $parentObjectId)
setOriginalId($original_id)
generateThumbForFile($path, $file)
setLastChange($lastChange)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
getCustomTrueOptionLabel()
getTitle()
Gets the title string of the assQuestion object.
handleFileUpload(ilAssKprimChoiceAnswer $answer, $fileData)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
$scorePartialSolutionEnabled
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
const OPTION_LABEL_PLUS_MINUS
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.
setAnswerType($answerType)
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
const ANSWER_TYPE_SINGLE_LINE
toJSON()
Returns a JSON representation of the question.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)