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';
54 $this->shuffleAnswersEnabled =
true;
55 $this->answerType = self::ANSWER_TYPE_SINGLE_LINE;
56 $this->thumbSize = self::DEFAULT_THUMB_SIZE;
57 $this->scorePartialSolutionEnabled =
true;
58 $this->optionLabel = self::OPTION_LABEL_RIGHT_WRONG;
59 $this->customTrueOptionLabel =
'';
60 $this->customFalseOptionLabel =
'';
62 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
65 $this->answers = array();
72 return 'assKprimChoice';
77 return "qpl_qst_kprim";
179 if($answer->getPosition() == $position)
190 $this->answers[] = $answer;
197 while(
$data = $this->db->fetchAssoc(
$res))
199 $this->
setId($questionId);
213 require_once
'Services/RTE/classes/class.ilRTE.php';
223 if( is_numeric($data[
'thumb_size']) )
236 if( $data[
'score_partsol'] !== null )
241 if( isset($data[
'feedback_setting']) )
257 parent::loadFromDb($questionId);
264 $res = $this->db->queryF(
265 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
266 array(
'integer'), array($questionId)
269 require_once
'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
270 require_once
'Services/RTE/classes/class.ilRTE.php';
276 $answer->setPosition(
$data[
'position']);
280 $answer->setImageFile(
$data[
'imagefile']);
285 $answer->setCorrectness(
$data[
'correctness']);
287 $this->answers[$answer->getPosition()] = $answer;
290 for( $i = count($this->answers); $i < self::NUM_REQUIRED_ANSWERS; $i++ )
294 $answer->setPosition($i);
296 $this->answers[$answer->getPosition()] = $answer;
307 parent::saveToDb($originalId);
315 'question_fi' => array(
'integer', $this->
getId())
320 'thumb_size' => array(
'integer', (
int)$this->
getThumbSize()),
337 'question_fi' => array(
'integer', (
int)$this->
getId()),
338 'position' => array(
'integer', (
int)$answer->getPosition())
341 'answertext' => array(
'text', $answer->getAnswertext()),
342 'imagefile' => array(
'text', $answer->getImageFile()),
343 'correctness' => array(
'integer', (
int)$answer->getCorrectness())
353 foreach( array($this->title, $this->author, $this->question) as $text )
370 if( is_null($answer->getCorrectness()) )
375 if( !strlen($answer->getAnswertext()) && !strlen($answer->getImageFile()) )
399 include_once
"./Modules/Test/classes/class.ilObjTest.php";
407 $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
408 array(
'integer',
'integer',
'integer'),
413 foreach($solutionSubmit as $answerIndex => $answerValue)
415 $next_id = $ilDB->nextId(
'tst_solutions');
416 $ilDB->insert(
"tst_solutions", array(
417 "solution_id" => array(
"integer", $next_id),
418 "active_fi" => array(
"integer", $active_id),
419 "question_fi" => array(
"integer", $this->
getId()),
420 "value1" => array(
"clob", (
int)$answerIndex),
421 "value2" => array(
"clob", (
int)$answerValue),
422 "pass" => array(
"integer",
$pass),
423 "tstamp" => array(
"integer", time())
432 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
440 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
477 throw new ilTestException(
'return details not implemented for '.__METHOD__);
482 $found_values = array();
487 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
488 array(
'integer',
'integer',
'integer'),
493 $found_values[(int)
$data[
'value1']] = (
int)
$data[
'value2'];
503 return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
524 self::ANSWER_TYPE_SINGLE_LINE => $lng->
txt(
'answers_singleline'),
525 self::ANSWER_TYPE_MULTI_LINE => $lng->
txt(
'answers_multiline')
532 self::OPTION_LABEL_RIGHT_WRONG,
533 self::OPTION_LABEL_PLUS_MINUS,
534 self::OPTION_LABEL_APPLICABLE_OR_NOT,
535 self::OPTION_LABEL_ADEQUATE_OR_NOT,
536 self::OPTION_LABEL_CUSTOM
543 self::OPTION_LABEL_RIGHT_WRONG => $lng->
txt(
'option_label_right_wrong'),
544 self::OPTION_LABEL_PLUS_MINUS => $lng->
txt(
'option_label_plus_minus'),
545 self::OPTION_LABEL_APPLICABLE_OR_NOT => $lng->
txt(
'option_label_applicable_or_not'),
546 self::OPTION_LABEL_ADEQUATE_OR_NOT => $lng->
txt(
'option_label_adequate_or_not'),
547 self::OPTION_LABEL_CUSTOM => $lng->
txt(
'option_label_custom')
561 case self::OPTION_LABEL_RIGHT_WRONG:
562 return $lng->
txt(
'option_label_right');
564 case self::OPTION_LABEL_PLUS_MINUS:
565 return $lng->
txt(
'option_label_plus');
567 case self::OPTION_LABEL_APPLICABLE_OR_NOT:
568 return $lng->
txt(
'option_label_applicable');
570 case self::OPTION_LABEL_ADEQUATE_OR_NOT:
571 return $lng->
txt(
'option_label_adequate');
573 case self::OPTION_LABEL_CUSTOM:
582 case self::OPTION_LABEL_RIGHT_WRONG:
583 return $lng->
txt(
'option_label_wrong');
585 case self::OPTION_LABEL_PLUS_MINUS:
586 return $lng->
txt(
'option_label_minus');
588 case self::OPTION_LABEL_APPLICABLE_OR_NOT:
589 return $lng->
txt(
'option_label_not_applicable');
591 case self::OPTION_LABEL_ADEQUATE_OR_NOT:
592 return $lng->
txt(
'option_label_not_adequate');
594 case self::OPTION_LABEL_CUSTOM:
602 $lng->
txt(
'kprim_instruction_text'),
610 return $labelValue == self::OPTION_LABEL_CUSTOM;
615 return self::THUMB_PREFIX;
624 if (strlen($answer->getImageFile()))
640 switch (strtoupper($path_info[
'extension']))
662 if( !isset($files[$answer->getPosition()]) )
675 if( !file_exists($imagePath) )
697 if( file_exists($answer->getImageFsPath()) )
699 unlink($answer->getImageFsPath());
702 if( file_exists($answer->getThumbFsPath()) )
704 unlink($answer->getThumbFsPath());
707 $answer->setImageFile(null);
712 $solutionSubmit = array();
713 foreach(
$_POST as $key => $value)
717 if(preg_match(
"/^kprim_choice_result_(\d+)/", $key, $matches))
721 $solutionSubmit[$matches[1]] = $value;
725 return $solutionSubmit;
732 foreach($this->
getAnswers() as $key => $answer)
734 if( !isset($found_values[$answer->getPosition()]) )
739 if( $found_values[$answer->getPosition()] == $answer->getCorrectness() )
745 if( $numCorrect >= self::NUM_REQUIRED_ANSWERS )
760 include_once
"./Modules/Test/classes/class.ilObjTest.php";
762 if(($mc_scoring == 0) && (count($found_values) == 0))
778 $this_id = $this->
getId();
782 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
786 if( (
int)$testObjId > 0 )
788 $clone->setObjId($testObjId);
815 $clone->copyPageOfQuestion($this_id);
817 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
819 $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
821 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
834 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
837 $sourceParentId = $this->
getObjId();
843 $clone->setObjId($targetParentId);
845 if ($targetQuestionTitle)
847 $clone->setTitle($targetQuestionTitle);
852 $clone->copyPageOfQuestion($sourceQuestionId);
854 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
856 $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
858 $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
875 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
878 $source_questionpool_id = $this->
getObjId();
879 $clone->setObjId($target_questionpool_id);
890 $clone->cloneAnswerImages(
$original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
892 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
899 parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
901 $question = self::_instanciateQuestion($origQuestionId);
903 foreach(
$question->getAnswers() as $answer)
905 $question->removeAnswerImage($answer->getPosition());
911 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
913 $this->
cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
916 protected function cloneAnswerImages($sourceQuestionId, $sourceParentId, $targetQuestionId, $targetParentId)
920 $sourcePath = $this->
buildImagePath($sourceQuestionId, $sourceParentId);
921 $targetPath = $this->
buildImagePath($targetQuestionId, $targetParentId);
929 if (!file_exists($targetPath))
934 if (!@copy($sourcePath.$filename, $targetPath.$filename))
936 $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
937 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
940 if (@file_exists($sourcePath.$this->getThumbPrefix().$filename))
942 if (!@copy($sourcePath.$this->getThumbPrefix().$filename, $targetPath.$this->getThumbPrefix().$filename))
944 $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
945 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
954 $combinedText = parent::getRTETextWithMediaObjects();
958 $combinedText .= $answer->getAnswertext();
961 return $combinedText;
969 $this->lng->loadLanguageModule(
'assessment');
971 require_once
'./Services/RTE/classes/class.ilRTE.php';
983 'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
984 'allcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
995 foreach( $this->
getAnswers() as $key => $answer )
997 if( strlen((
string)$answer->getImageFile()) )
1003 'answertext' => (
string) $this->
formatSAQuestion($answer->getAnswertext()),
1004 'correctness' => (
bool) $answer->getCorrectness(),
1005 'order' => (int)$answer->getPosition(),
1006 'image' => (string)$answer->getImageFile(),
1008 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
1022 $result[
'mobs'] =
$mobs;
1024 return json_encode($result);
1031 return self::NUM_REQUIRED_ANSWERS - self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS;
1046 return $numExistingSolutionRecords >= 4;
1054 require_once
'Services/Excel/classes/class.ilExcelUtils.php';
1064 $correctness = FALSE;
1065 foreach($solution as $solutionvalue)
1067 if(
$id == $solutionvalue[
'value1'])
1069 $correctness = $solutionvalue[
'value2'];
1073 $worksheet->write($startrow + $i, 1, $correctness);
1076 return $startrow + $i + 1;
1081 if( $position < 0 || $position >= (self::NUM_REQUIRED_ANSWERS - 1) )
1086 for($i = 0, $max = count($this->answers); $i < $max; $i++)
1088 if( $i == $position )
1090 $movingAnswer = $this->answers[$i];
1091 $targetAnswer = $this->answers[ $i + 1 ];
1093 $movingAnswer->setPosition( $position + 1 );
1094 $targetAnswer->setPosition( $position );
1096 $this->answers[ $i + 1 ] = $movingAnswer;
1097 $this->answers[$i] = $targetAnswer;
1104 if( $position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1) )
1109 for($i = 0, $max = count($this->answers); $i < $max; $i++)
1111 if( $i == $position )
1113 $movingAnswer = $this->answers[$i];
1114 $targetAnswer = $this->answers[ $i - 1 ];
1116 $movingAnswer->setPosition( $position - 1 );
1117 $targetAnswer->setPosition( $position );
1119 $this->answers[ $i - 1 ] = $movingAnswer;
1120 $this->answers[$i] = $targetAnswer;
getValidOptionLabelsTranslated(ilLanguage $lng)
static makeDirParents($a_dir)
Create a new directory and all parent directories.
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 getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
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)
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
calculateReachedPoints($active_id, $pass=NULL, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
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.
__construct($title='', $comment='', $author='', $owner=-1, $question='')
_convert_text($a_text, $a_target="has been removed")
const OPTION_LABEL_ADEQUATE_OR_NOT
setId($id=-1)
Sets the id of the assQuestion object.
const NUM_REQUIRED_ANSWERS
_getMCScoring($active_id)
Gets the scoring type for multiple choice questions.
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.
getSpecificFeedbackSetting()
moveAnswerDown($position)
copyObject($target_questionpool_id, $title="")
Copies an assMultipleChoice object.
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)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
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)
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
const ANSWER_TYPE_MULTI_LINE
isScorePartialSolutionEnabled()
setAuthor($author="")
Sets the authors name of the assQuestion object.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
isSingleLineAnswerType($answerType)
getAnswerTypeSelectOptions(ilLanguage $lng)
cloneAnswerImages($sourceQuestionId, $sourceParentId, $targetQuestionId, $targetParentId)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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.
isAnswered($active_id, $pass=null)
_getLogLanguage()
retrieve the log language for assessment logging
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)
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
{}
setQuestion($question="")
Sets the question string of the question object.
const FEEDBACK_SETTING_ALL
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
Interface ilObjQuestionScoringAdjustable.
setSpecificFeedbackSetting($specificFeedbackSetting)
buildImagePath($questionId, $parentObjectId)
setOriginalId($original_id)
generateThumbForFile($path, $file)
setLastChange($lastChange)
getCustomTrueOptionLabel()
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
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.
setComment($comment="")
Sets the comment string of the assQuestion object.
setAnswerType($answerType)
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
createNewImageFileName($image_filename, $unique=false)
const ANSWER_TYPE_SINGLE_LINE
saveWorkingData($active_id, $pass=NULL)
Saves the learners input of the question to the database.
toJSON()
Returns a JSON representation of the question.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)