4require_once
'Modules/TestQuestionPool/classes/class.assQuestion.php';
5require_once
'Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
6require_once
'Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
54 $this->shuffleAnswersEnabled =
true;
57 $this->scorePartialSolutionEnabled =
true;
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;
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')
562 return $lng->txt(
'option_label_right');
565 return $lng->txt(
'option_label_plus');
568 return $lng->txt(
'option_label_applicable');
571 return $lng->txt(
'option_label_adequate');
583 return $lng->txt(
'option_label_wrong');
586 return $lng->txt(
'option_label_minus');
589 return $lng->txt(
'option_label_not_applicable');
592 return $lng->txt(
'option_label_not_adequate');
602 $lng->txt(
'kprim_instruction_text'),
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);
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(),
1007 'feedback' => $this->formatSAQuestion(
1008 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
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;
$scorePartialSolutionEnabled
getQuestionType()
Returns the question type of the question.
const PARTIAL_SCORING_NUM_CORRECT_ANSWERS
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
toJSON()
Returns a JSON representation of the question.
beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
const OPTION_LABEL_RIGHT_WRONG
isSingleLineAnswerType($answerType)
setCustomTrueOptionLabel($customTrueOptionLabel)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
{Creates an Excel worksheet for the detailed cumulated results of this question.}
handleFileUpload(ilAssKprimChoiceAnswer $answer, $fileData)
const ANSWER_TYPE_MULTI_LINE
handleFileUploads($answers, $files)
setCustomFalseOptionLabel($customFalseOptionLabel)
const NUM_REQUIRED_ANSWERS
getAnswerTableName()
Returns the name of the answer table in the database.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
const ANSWER_TYPE_SINGLE_LINE
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
isScorePartialSolutionEnabled()
addAnswer(ilAssKprimChoiceAnswer $answer)
generateThumbForFile($path, $file)
calculateReachedPoints($active_id, $pass=NULL, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
removeAnswerImage($position)
copyObject($target_questionpool_id, $title="")
Copies an assMultipleChoice object.
afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
const OPTION_LABEL_ADEQUATE_OR_NOT
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
loadAnswerData($questionId)
const OPTION_LABEL_CUSTOM
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
setSpecificFeedbackSetting($specificFeedbackSetting)
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
getValidOptionLabelsTranslated(ilLanguage $lng)
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
isAnswered($active_id, $pass=null)
returns boolean wether the question is answered during test pass or not
getCustomFalseOptionLabel()
setAnswerType($answerType)
saveToDb($originalId='')
Saves the question to the database.
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
calculateReachedPointsForSolution($found_values, $active_id=0)
const OPTION_LABEL_PLUS_MINUS
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
isValidOptionLabel($optionLabel)
isCustomOptionLabel($labelValue)
isValidAnswerType($answerType)
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
setOptionLabel($optionLabel)
isShuffleAnswersEnabled()
moveAnswerDown($position)
getSpecificFeedbackSetting()
loadFromDb($questionId)
Loads the question from the database.
cloneAnswerImages($sourceQuestionId, $sourceParentId, $targetQuestionId, $targetParentId)
isComplete()
Returns true, if a question is complete for use.
getAnswerTypeSelectOptions(ilLanguage $lng)
setShuffleAnswersEnabled($shuffleAnswersEnabled)
const OPTION_LABEL_APPLICABLE_OR_NOT
__construct($title='', $comment='', $author='', $owner=-1, $question='')
assQuestion constructor
setScorePartialSolutionEnabled($scorePartialSolutionEnabled)
getCustomTrueOptionLabel()
Abstract basic class which is to be extended by the concrete assessment question type classes.
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
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.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
saveQuestionDataToDb($original_id="")
createNewImageFileName($image_filename, $unique=false)
saveWorkingData($active_id, $pass=NULL)
Saves the learners input of the question to the database.
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.
setEstimatedWorkingTimeFromDurationString($durationString)
Sets the estimated working time of a question from a given datetime string.
buildImagePath($questionId, $parentObjectId)
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.
getPoints()
Returns the maximum available points for the question.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
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
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
setQuestion($question="")
Sets the question string of the question object.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
setLastChange($lastChange)
const FEEDBACK_SETTING_ALL
setImageFsDir($imageFsDir)
_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 _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.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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.
Interface ilObjAnswerScoringAdjustable.
Interface ilObjQuestionScoringAdjustable.