4require_once 
'Modules/TestQuestionPool/classes/class.assQuestion.php';
 
    5require_once 
'Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
 
    6require_once 
'Modules/TestQuestionPool/interfaces/interface.ilObjAnswerScoringAdjustable.php';
 
    7require_once 
'Modules/TestQuestionPool/interfaces/interface.ilAssSpecificFeedbackOptionLabelProvider.php';
 
   55        $this->shuffleAnswersEnabled = 
true;
 
   58        $this->scorePartialSolutionEnabled = 
true;
 
   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);
 
  254        $res = $this->db->queryF(
 
  255            "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
 
  260        require_once 
'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
 
  261        require_once 
'Services/RTE/classes/class.ilRTE.php';
 
  266            $answer->setPosition(
$data[
'position']);
 
  270            $answer->setImageFile(
$data[
'imagefile']);
 
  275            $answer->setCorrectness(
$data[
'correctness']);
 
  277            $this->answers[$answer->getPosition()] = $answer;
 
  283            $answer->setPosition(
$i);
 
  285            $this->answers[$answer->getPosition()] = $answer;
 
  296        parent::saveToDb($originalId);
 
  304                'question_fi' => array(
'integer', $this->
getId())
 
  309                'thumb_size' => array(
'integer', (
int) $this->
getThumbSize()),
 
  325                    'question_fi' => array(
'integer', (
int) $this->
getId()),
 
  326                    'position' => array(
'integer', (
int) $answer->getPosition())
 
  329                    'answertext' => array(
'text', $answer->getAnswertext()),
 
  330                    'imagefile' => array(
'text', $answer->getImageFile()),
 
  331                    'correctness' => array(
'integer', (
int) $answer->getCorrectness())
 
  341        foreach (array($this->title, $this->author, $this->question) as 
$text) {
 
  342            if (!strlen(
$text)) {
 
  354            if (is_null($answer->getCorrectness())) {
 
  358            if (!strlen($answer->getAnswertext()) && !strlen($answer->getImageFile())) {
 
  379        if (is_null(
$pass)) {
 
  380            include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  386        $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id, 
$pass, $authorized) {
 
  391            foreach ($solutionSubmit as $answerIndex => $answerValue) {
 
  397        if ($entered_values) {
 
  398            include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
  403            include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
  432        if ($returndetails) {
 
  433            throw new ilTestException(
'return details not implemented for ' . __METHOD__);
 
  438        $found_values = array();
 
  439        if (is_null(
$pass)) {
 
  446            $found_values[(int) 
$data[
'value1']] = (
int) 
$data[
'value2'];
 
  456        return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
 
  477            self::ANSWER_TYPE_SINGLE_LINE => 
$lng->txt(
'answers_singleline'),
 
  478            self::ANSWER_TYPE_MULTI_LINE => 
$lng->txt(
'answers_multiline')
 
  485            self::OPTION_LABEL_RIGHT_WRONG,
 
  486            self::OPTION_LABEL_PLUS_MINUS,
 
  487            self::OPTION_LABEL_APPLICABLE_OR_NOT,
 
  488            self::OPTION_LABEL_ADEQUATE_OR_NOT,
 
  489            self::OPTION_LABEL_CUSTOM
 
  496            self::OPTION_LABEL_RIGHT_WRONG => 
$lng->txt(
'option_label_right_wrong'),
 
  497            self::OPTION_LABEL_PLUS_MINUS => 
$lng->txt(
'option_label_plus_minus'),
 
  498            self::OPTION_LABEL_APPLICABLE_OR_NOT => 
$lng->txt(
'option_label_applicable_or_not'),
 
  499            self::OPTION_LABEL_ADEQUATE_OR_NOT => 
$lng->txt(
'option_label_adequate_or_not'),
 
  500            self::OPTION_LABEL_CUSTOM => 
$lng->txt(
'option_label_custom')
 
  514                return $lng->txt(
'option_label_right');
 
  517                return $lng->txt(
'option_label_plus');
 
  520                return $lng->txt(
'option_label_applicable');
 
  523                return $lng->txt(
'option_label_adequate');
 
  534                return $lng->txt(
'option_label_wrong');
 
  537                return $lng->txt(
'option_label_minus');
 
  540                return $lng->txt(
'option_label_not_applicable');
 
  543                return $lng->txt(
'option_label_not_adequate');
 
  553            $lng->txt(
'kprim_instruction_text'),
 
  573                if (strlen($answer->getImageFile())) {
 
  587            switch (strtoupper($path_info[
'extension'])) {
 
  607            if (!isset(
$files[$answer->getPosition()])) {
 
  619        if (!file_exists($imagePath)) {
 
  628        if (!ilUtil::moveUploadedFile($fileData[
'tmp_name'], $fileData[
'name'], $answer->
getImageFsPath())) {
 
  639        if (file_exists($answer->getImageFsPath())) {
 
  643        if (file_exists($answer->getThumbFsPath())) {
 
  647        $answer->setImageFile(
null);
 
  652        $solutionSubmit = array();
 
  656            if (preg_match(
"/^kprim_choice_result_(\d+)/", 
$key, $matches)) {
 
  657                if (strlen($value)) {
 
  658                    $solutionSubmit[$matches[1]] = $value;
 
  662        return $solutionSubmit;
 
  670            if (!isset($found_values[$answer->getPosition()])) {
 
  674            if ($found_values[$answer->getPosition()] == $answer->getCorrectness()) {
 
  679        if ($numCorrect >= self::NUM_REQUIRED_ANSWERS) {
 
  688            include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  690            if (($mc_scoring == 0) && (count($found_values) == 0)) {
 
  699        if ($this->
id <= 0) {
 
  704        $this_id = $this->
getId();
 
  708        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  712        if ((
int) $testObjId > 0) {
 
  713            $clone->setObjId($testObjId);
 
  734        $clone->copyPageOfQuestion($this_id);
 
  736        $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
 
  738        $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
 
  740        $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
 
  747        if ($this->
id <= 0) {
 
  752        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  755        $sourceParentId = $this->
getObjId();
 
  761        $clone->setObjId($targetParentId);
 
  763        if ($targetQuestionTitle) {
 
  764            $clone->setTitle($targetQuestionTitle);
 
  769        $clone->copyPageOfQuestion($sourceQuestionId);
 
  771        $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
 
  773        $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
 
  775        $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
 
  785        if ($this->
id <= 0) {
 
  791        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  794        $source_questionpool_id = $this->
getObjId();
 
  795        $clone->setObjId($target_questionpool_id);
 
  805        $clone->cloneAnswerImages(
$original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
 
  807        $clone->onCopy($source_questionpool_id, 
$original_id, $clone->getObjId(), $clone->getId());
 
  814        parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
 
  818        foreach (
$question->getAnswers() as $answer) {
 
  819            $question->removeAnswerImage($answer->getPosition());
 
  825        parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
 
  827        $this->cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
 
  830    protected function cloneAnswerImages($sourceQuestionId, $sourceParentId, $targetQuestionId, $targetParentId)
 
  835        $sourcePath = $this->
buildImagePath($sourceQuestionId, $sourceParentId);
 
  836        $targetPath = $this->
buildImagePath($targetQuestionId, $targetParentId);
 
  842                if (!file_exists($targetPath)) {
 
  846                if (file_exists($sourcePath . 
$filename)) {
 
  849                            "Could not clone source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
 
  860                if (file_exists($sourcePath . $this->
getThumbPrefix() . $filename)) {
 
  863                            "Could not clone thumbnail source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
 
  879        $combinedText = parent::getRTETextWithMediaObjects();
 
  882            $combinedText .= $answer->getAnswertext();
 
  885        return $combinedText;
 
  904        $this->lng->loadLanguageModule(
'assessment');
 
  906        require_once 
'./Services/RTE/classes/class.ilRTE.php';
 
  919            'onenotcorrect' => $this->
formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
false)),
 
  920            'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
true))
 
  932            if (strlen((
string) $answer->getImageFile())) {
 
  938                'correctness' => (
bool) $answer->getCorrectness(),
 
  939                'order' => (
int) $answer->getPosition(),
 
  940                'image' => (
string) $answer->getImageFile(),
 
  941                'feedback' => $this->formatSAQuestion(
 
  942                    $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 
$key)
 
  971        return 'feedback_correct_kprim';
 
  983        return $numExistingSolutionRecords >= 4;
 
  997            $worksheet->setCell($startrow + 
$i, 0, $answer->getAnswertext());
 
  999            $correctness = 
false;
 
 1000            foreach ($solution as $solutionvalue) {
 
 1001                if (
$id == $solutionvalue[
'value1']) {
 
 1002                    $correctness = $solutionvalue[
'value2'];
 
 1010        return $startrow + 
$i + 1;
 
 1015        if ($position < 0 || $position >= (self::NUM_REQUIRED_ANSWERS - 1)) {
 
 1019        for (
$i = 0, $max = count($this->answers); 
$i < $max; 
$i++) {
 
 1020            if (
$i == $position) {
 
 1021                $movingAnswer = $this->answers[
$i];
 
 1022                $targetAnswer = $this->answers[ 
$i + 1 ];
 
 1024                $movingAnswer->setPosition($position + 1);
 
 1025                $targetAnswer->setPosition($position);
 
 1027                $this->answers[ 
$i + 1 ] = $movingAnswer;
 
 1028                $this->answers[
$i] = $targetAnswer;
 
 1035        if ($position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1)) {
 
 1039        for (
$i = 0, $max = count($this->answers); 
$i < $max; 
$i++) {
 
 1040            if (
$i == $position) {
 
 1041                $movingAnswer = $this->answers[
$i];
 
 1042                $targetAnswer = $this->answers[ 
$i - 1 ];
 
 1044                $movingAnswer->setPosition($position - 1);
 
 1045                $targetAnswer->setPosition($position);
 
 1047                $this->answers[ 
$i - 1 ] = $movingAnswer;
 
 1048                $this->answers[
$i] = $targetAnswer;
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
$scorePartialSolutionEnabled
getSpecificFeedbackAllCorrectOptionLabel()
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.
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)
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.
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{Reworks the allready saved working data if neccessary.}
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)
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{Creates an Excel worksheet for the detailed cumulated results of this question.object}
const OPTION_LABEL_PLUS_MINUS
isValidOptionLabel($optionLabel)
isCustomOptionLabel($labelValue)
isValidAnswerType($answerType)
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
setOptionLabel($optionLabel)
isShuffleAnswersEnabled()
moveAnswerDown($position)
getSpecificFeedbackSetting()
loadFromDb($questionId)
Loads the question from the database.
isComplete()
Returns true, if a question is complete for use.
getAnswerTypeSelectOptions(ilLanguage $lng)
setShuffleAnswersEnabled($shuffleAnswersEnabled)
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
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.
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.
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="")
getId()
Gets the id of the assQuestion object.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
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)
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
removeCurrentSolution($active_id, $pass, $authorized=true)
buildHashedImageFilename($plain_image_filename, $unique=false)
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.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
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)
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static _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 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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
migrateToLmContent($content)
Interface ilObjAnswerScoringAdjustable.
Interface ilObjQuestionScoringAdjustable.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
foreach($_POST as $key=> $value) $res