19require_once 
'./Modules/Test/classes/inc.AssessmentConstants.php';
 
  106        $this->answers = array();
 
  108        $this->selectionLimit = 
null;
 
  109        $this->feedback_setting = 0;
 
  136        if (strlen($this->title) and ($this->author) and ($this->question) and (count($this->answers)) and ($this->
getMaximumPoints() > 0)) {
 
  158        $this->ensureNoInvalidObligation($this->
getId());
 
  169                if (strlen($answer->getImage())) {
 
  195            switch (strtoupper($path_info[
'extension'])) {
 
  221        $result = 
$ilDB->queryF(
 
  226        if ($result->numRows() == 1) {
 
  228            $this->
setId($question_id);
 
  237            include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  245            $this->lastChange = 
$data[
'tstamp'];
 
  247            $this->feedback_setting = 
$data[
'feedback_setting'];
 
  261        $result = 
$ilDB->queryF(
 
  262            "SELECT * FROM qpl_a_mc WHERE question_fi = %s ORDER BY aorder ASC",
 
  266        include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
 
  267        if ($result->numRows() > 0) {
 
  270                if (!@file_exists($imagefilename)) {
 
  271                    $data[
"imagefile"] = 
"";
 
  273                include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  282                $answer->setPointsUnchecked(
$data[
"points_unchecked"]);
 
  283                $answer->setImage(
$data[
"imagefile"]);
 
  284                array_push($this->answers, $answer);
 
  288        parent::loadFromDb($question_id);
 
  296        if ($this->
id <= 0) {
 
  301        $this_id = $this->
getId();
 
  305        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  309        if ((
int) $testObjId > 0) {
 
  310            $clone->setObjId($testObjId);
 
  331        $clone->copyPageOfQuestion($this_id);
 
  333        $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
 
  335        $clone->duplicateImages($this_id, $thisObjId);
 
  337        $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
 
  347        if ($this->
getId() <= 0) {
 
  348            throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
 
  352        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  355        $source_questionpool_id = $this->
getObjId();
 
  356        $clone->setObjId($target_questionpool_id);
 
  366        $clone->copyImages(
$original_id, $source_questionpool_id);
 
  368        $clone->onCopy($source_questionpool_id, 
$original_id, $clone->getObjId(), $clone->getId());
 
  375        if ($this->
getId() <= 0) {
 
  376            throw new RuntimeException(
'The question has not been saved. It cannot be duplicated');
 
  379        include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
 
  382        $sourceParentId = $this->
getObjId();
 
  388        $clone->setObjId($targetParentId);
 
  390        if ($targetQuestionTitle) {
 
  391            $clone->setTitle($targetQuestionTitle);
 
  396        $clone->copyPageOfQuestion($sourceQuestionId);
 
  398        $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
 
  400        $clone->copyImages($sourceQuestionId, $sourceParentId);
 
  402        $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
 
  447        $points_unchecked = 0.0,
 
  453        if (array_key_exists($order, $this->answers)) {
 
  456            $answer->setPointsUnchecked($points_unchecked);
 
  457            $answer->setImage($answerimage);
 
  458            $newchoices = array();
 
  459            for (
$i = 0; 
$i < $order; 
$i++) {
 
  460                $newchoices[] = $this->answers[
$i];
 
  462            $newchoices[] = $answer;
 
  463            for (
$i = $order, $iMax = count($this->answers); 
$i < $iMax; 
$i++) {
 
  464                $changed = $this->answers[
$i];
 
  465                $changed->setOrder(
$i + 1);
 
  466                $newchoices[] = $changed;
 
  468            $this->answers = $newchoices;
 
  471            $answer->setPointsUnchecked($points_unchecked);
 
  472            $answer->setImage($answerimage);
 
  473            $this->answers[] = $answer;
 
  485        return count($this->answers);
 
  501        if (count($this->answers) < 1) {
 
  504        if (
$index >= count($this->answers)) {
 
  508        return $this->answers[
$index];
 
  523        if (count($this->answers) < 1) {
 
  526        if (
$index >= count($this->answers)) {
 
  529        $answer = $this->answers[
$index];
 
  530        if (strlen($answer->getImage())) {
 
  531            $this->deleteImage($answer->getImage());
 
  533        unset($this->answers[
$index]);
 
  534        $this->answers = array_values($this->answers);
 
  535        for (
$i = 0, $iMax = count($this->answers); 
$i < $iMax; 
$i++) {
 
  536            if ($this->answers[
$i]->getOrder() > 
$index) {
 
  537                $this->answers[
$i]->setOrder(
$i);
 
  549        $this->answers = array();
 
  561        foreach ($this->answers as 
$key => $value) {
 
  562            if ($value->getPoints() > $value->getPointsUnchecked()) {
 
  563                $allpoints += $value->getPoints();
 
  565                $allpoints += $value->getPointsUnchecked();
 
  584        if ($returndetails) {
 
  585            throw new ilTestException(
'return details not implemented for ' . __METHOD__);
 
  591        $found_values = array();
 
  592        if (is_null($pass)) {
 
  593            $pass = $this->getSolutionMaxPass($active_id);
 
  595        $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
 
  597            if (strcmp(
$data[
"value1"], 
"") != 0) {
 
  598                array_push($found_values, 
$data[
"value1"]);
 
  602        $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
 
  609        $submit = $this->getSolutionSubmit();
 
  611        if ($this->getSelectionLimit()) {
 
  612            if (count($submit) > $this->getSelectionLimit()) {
 
  613                $failureMsg = sprintf(
 
  614                    $this->
lng->txt(
'ass_mc_sel_lim_exhausted_hint'),
 
  615                    $this->getSelectionLimit(),
 
  616                    $this->getAnswerCount()
 
  619                $this->tpl->setOnScreenMessage(
'failure', $failureMsg, 
true);
 
  629        if (!count($solutionSubmit) && !empty($_POST[
'tst_force_form_diff_input'])) {
 
  644    public function saveWorkingData($active_id, $pass = 
null, $authorized = 
true): bool
 
  650        if (is_null($pass)) {
 
  651            include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  657        $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
function () use (&$entered_values, $active_id, $pass, $authorized) {
 
  658            $this->removeCurrentSolution($active_id, $pass, $authorized);
 
  660            $solutionSubmit = $this->getSolutionSubmit();
 
  662            foreach ($solutionSubmit as $value) {
 
  663                if (strlen($value)) {
 
  664                    $this->saveCurrentSolution($active_id, $pass, $value, 
null, $authorized);
 
  670            if ($this->isForcedEmptySolution($solutionSubmit)) {
 
  671                $this->saveCurrentSolution($active_id, $pass, 
'mc_none_above', 
null, $authorized);
 
  677        if ($entered_values) {
 
  678            include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
  682                    "log_user_entered_values",
 
  684                ), $active_id, $this->getId());
 
  687            include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
  691                    "log_user_not_entered_values",
 
  693                ), $active_id, $this->getId());
 
  700    public function saveAdditionalQuestionDataToDb()
 
  706        if ($this->isSingleline && ($this->getThumbSize())) {
 
  708            $result = 
$ilDB->queryF(
 
  709                "SELECT thumb_size FROM " . $this->getAdditionalTableName() . 
" WHERE question_fi = %s",
 
  713            if ($result->numRows() == 1) {
 
  715                $oldthumbsize = 
$data[
'thumb_size'];
 
  719        if (!$this->isSingleline) {
 
  725            $this->getAdditionalTableName(),
 
  727                'shuffle' => array(
'text', $this->getShuffle()),
 
  728                'allow_images' => array(
'text', $this->isSingleline ? 0 : 1),
 
  729                'thumb_size' => array(
'integer', strlen($this->getThumbSize()) ? $this->getThumbSize() : 
null),
 
  730                'selection_limit' => array(
'integer', $this->getSelectionLimit()),
 
  731                'feedback_setting' => array(
'integer', $this->getSpecificFeedbackSetting())
 
  733            [
'question_fi' => array(
'integer', $this->
getId())]
 
  742    public function saveAnswerSpecificDataToDb()
 
  749        $result = 
$ilDB->queryF(
 
  750            "SELECT * FROM qpl_fb_specific WHERE question_fi = %s",
 
  754        $db_feedback = 
$ilDB->fetchAll($result);
 
  757        if (
sizeof($db_feedback) >= 1 && $this->getAdditionalContentEditingMode() == 
'default') {
 
  759            $result = 
$ilDB->queryF(
 
  760                "SELECT answer_id, aorder  FROM qpl_a_mc WHERE question_fi = %s",
 
  764            $db_answers = 
$ilDB->fetchAll($result);
 
  767            $post_answer_order_for_id = [];
 
  768            foreach ($this->answers as $answer) {
 
  770                if ($answer->getId() !== 
null && !in_array($answer->getId(), array_keys($post_answer_order_for_id))) {
 
  772                    if ($answer->getId() == -1) {
 
  775                    $post_answer_order_for_id[$answer->getId()] = $answer->getOrder();
 
  781            if (
sizeof($post_answer_order_for_id) >= 1) {
 
  782                $db_answer_order_for_id = [];
 
  783                $db_answer_id_for_order = [];
 
  784                foreach ($db_answers as $db_answer) {
 
  785                    $db_answer_order_for_id[intval($db_answer[
'answer_id'])] = intval($db_answer[
'aorder']);
 
  786                    $db_answer_id_for_order[intval($db_answer[
'aorder'])] = intval($db_answer[
'answer_id']);
 
  792                $db_answer_ids = array_keys($db_answer_order_for_id);
 
  793                $post_answer_ids = array_keys($post_answer_order_for_id);
 
  794                $diff_db_post_answer_ids = array_diff($db_answer_ids, $post_answer_ids);
 
  795                $unused_answer_ids = array_keys($diff_db_post_answer_ids);
 
  798                $this->feedbackOBJ->deleteSpecificAnswerFeedbacks($this->
getId(), 
false);
 
  800                foreach ($db_feedback as $feedback_option) {
 
  802                    if (in_array(intval($feedback_option[
'answer']), $unused_answer_ids)) {
 
  807                    $feedback_order_db = intval($feedback_option[
'answer']);
 
  808                    $db_answer_id = $db_answer_id_for_order[$feedback_order_db];
 
  812                    if (is_null($db_answer_id) || $db_answer_id < 0) {
 
  815                    $feedback_order_post = $post_answer_order_for_id[$db_answer_id];
 
  816                    $feedback_option[
'answer'] = $feedback_order_post;
 
  819                    $next_id = 
$ilDB->nextId(
'qpl_fb_specific');
 
  821                        "INSERT INTO qpl_fb_specific (feedback_id, question_fi, answer, tstamp, feedback, question) 
  822                            VALUES (%s, %s, %s, %s, %s, %s)",
 
  823                        [
'integer', 
'integer', 
'integer', 
'integer', 
'text', 
'integer'],
 
  826                            $feedback_option[
'question_fi'],
 
  827                            $feedback_option[
'answer'],
 
  829                            $feedback_option[
'feedback'],
 
  830                            $feedback_option[
'question']
 
  839            "DELETE FROM qpl_a_mc WHERE question_fi = %s",
 
  845        foreach ($this->answers as 
$key => $value) {
 
  846            $answer_obj = $this->answers[
$key];
 
  847            $next_id = 
$ilDB->nextId(
'qpl_a_mc');
 
  849                "INSERT INTO qpl_a_mc (answer_id, question_fi, answertext, points, points_unchecked, aorder, imagefile, tstamp) 
  850                        VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
 
  851                [
'integer', 
'integer', 
'text', 
'float', 
'float', 
'integer', 
'text', 
'integer'],
 
  856                    $answer_obj->getPoints(),
 
  857                    $answer_obj->getPointsUnchecked(),
 
  858                    $answer_obj->getOrder(),
 
  859                    $answer_obj->getImage(),
 
  864        $this->rebuildThumbnails();
 
  869        if ($this->getOriginalId()) {
 
  871            parent::syncWithOriginal();
 
  882        return "assMultipleChoice";
 
  915        if (!empty($image_tempfilename)) {
 
  916            $image_filename = str_replace(
" ", 
"_", $image_filename);
 
  917            $imagepath = $this->getImagePath();
 
  918            if (!file_exists($imagepath)) {
 
  924                include_once 
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
  926                if (!preg_match(
"/^image/", $mimetype)) {
 
  927                    unlink($imagepath . $image_filename);
 
  931                    if ($this->isSingleline && ($this->getThumbSize())) {
 
  932                        $this->generateThumbForFile($imagepath, $image_filename);
 
  947        $imagepath = $this->getImagePath();
 
  948        @unlink($imagepath . $image_filename);
 
  949        $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
 
  953    public function duplicateImages($question_id, $objectId = 
null): void
 
  957        $ilLog = 
$DIC[
'ilLog'];
 
  959        $imagepath = $this->getImagePath();
 
  960        $imagepath_original = str_replace(
"/$this->id/images", 
"/$question_id/images", $imagepath);
 
  962        if ((
int) $objectId > 0) {
 
  963            $imagepath_original = str_replace(
"/$this->obj_id/", 
"/$objectId/", $imagepath_original);
 
  966        foreach ($this->answers as $answer) {
 
  969                if (!file_exists($imagepath)) {
 
  973                if (file_exists($imagepath_original . 
$filename)) {
 
  975                        $ilLog->warning(sprintf(
 
  976                            "Could not clone source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
 
  987                if (file_exists($imagepath_original . $this->getThumbPrefix() . 
$filename)) {
 
  988                    if (!copy($imagepath_original . $this->getThumbPrefix() . 
$filename, $imagepath . $this->getThumbPrefix() . 
$filename)) {
 
  989                        $ilLog->warning(sprintf(
 
  990                            "Could not clone thumbnail source image '%s' to '%s' (srcQuestionId: %s|tgtQuestionId: %s|srcParentObjId: %s|tgtParentObjId: %s)",
 
  991                            $imagepath_original . $this->getThumbPrefix() . 
$filename,
 
  992                            $imagepath . $this->getThumbPrefix() . 
$filename,
 
 1004    public function copyImages($question_id, $source_questionpool): void
 
 1007        $ilLog = 
$DIC[
'ilLog'];
 
 1008        $imagepath = $this->getImagePath();
 
 1009        $imagepath_original = str_replace(
"/$this->id/images", 
"/$question_id/images", $imagepath);
 
 1010        $imagepath_original = str_replace(
"/$this->obj_id/", 
"/$source_questionpool/", $imagepath_original);
 
 1011        foreach ($this->answers as $answer) {
 
 1014                if (!file_exists($imagepath)) {
 
 1018                    $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
 
 1019                    $ilLog->write(
"object: " . print_r($this, 
true), $ilLog->ERROR);
 
 1021                if (@file_exists($imagepath_original . $this->getThumbPrefix() . 
$filename)) {
 
 1022                    if (!@copy($imagepath_original . $this->getThumbPrefix() . 
$filename, $imagepath . $this->getThumbPrefix() . 
$filename)) {
 
 1023                        $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
 
 1024                        $ilLog->write(
"object: " . print_r($this, 
true), $ilLog->ERROR);
 
 1037        $ilLog = 
$DIC[
'ilLog'];
 
 1038        $imagepath = $this->getImagePath();
 
 1039        $question_id = $this->getOriginalId();
 
 1040        $originalObjId = parent::lookupParentObjId($this->getOriginalId());
 
 1041        $imagepath_original = $this->getImagePath($question_id, $originalObjId);
 
 1044        foreach ($this->answers as $answer) {
 
 1047                if (@file_exists($imagepath . 
$filename)) {
 
 1048                    if (!file_exists($imagepath)) {
 
 1051                    if (!file_exists($imagepath_original)) {
 
 1055                        $ilLog->write(
"image could not be duplicated!!!!", $ilLog->ERROR);
 
 1056                        $ilLog->write(
"object: " . print_r($this, 
true), $ilLog->ERROR);
 
 1059                if (@file_exists($imagepath . $this->getThumbPrefix() . 
$filename)) {
 
 1060                    if (!@copy($imagepath . $this->getThumbPrefix() . 
$filename, $imagepath_original . $this->getThumbPrefix() . 
$filename)) {
 
 1061                        $ilLog->write(
"image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
 
 1062                        $ilLog->write(
"object: " . print_r($this, 
true), $ilLog->ERROR);
 
 1074        $text = parent::getRTETextWithMediaObjects();
 
 1075        foreach ($this->answers as 
$index => $answer) {
 
 1076            $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), 0, 
$index);
 
 1077            $answer_obj = $this->answers[
$index];
 
 1078            $text .= $answer_obj->getAnswertext();
 
 1088        return $this->answers;
 
 1096        parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
 
 1098        $solution = $this->getSolutionValues($active_id, $pass);
 
 1101        foreach ($this->getAnswers() as 
$id => $answer) {
 
 1102            $worksheet->
setCell($startrow + 
$i, 0, $answer->getAnswertext());
 
 1105            foreach ($solution as $solutionvalue) {
 
 1106                if (
$id == $solutionvalue[
"value1"]) {
 
 1111                $worksheet->
setCell($startrow + 
$i, 2, 1);
 
 1113                $worksheet->
setCell($startrow + 
$i, 2, 0);
 
 1118        return $startrow + 
$i + 1;
 
 1126        foreach ($this->getAnswers() as $answer) {
 
 1137        require_once 
'./Services/RTE/classes/class.ilRTE.php';
 
 1139        $result[
'id'] = $this->
getId();
 
 1140        $result[
'type'] = (string) $this->getQuestionType();
 
 1141        $result[
'title'] = $this->getTitleForHTMLOutput();
 
 1142        $result[
'question'] = $this->formatSAQuestion($this->getQuestion());
 
 1143        $result[
'nr_of_tries'] = $this->getNrOfTries();
 
 1144        $result[
'shuffle'] = $this->getShuffle();
 
 1145        $result[
'selection_limit'] = (
int) $this->getSelectionLimit();
 
 1146        $result[
'feedback'] = array(
 
 1147            'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
false)),
 
 1148            'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), 
true))
 
 1153        foreach ($this->getAnswers() as 
$key => $answer_obj) {
 
 1154            if ((
string) $answer_obj->getImage()) {
 
 1157            array_push($answers, array(
 
 1158                "answertext" => $this->formatSAQuestion($answer_obj->getAnswertext()),
 
 1159                "points_checked" => (
float) $answer_obj->getPointsChecked(),
 
 1160                "points_unchecked" => (
float) $answer_obj->getPointsUnchecked(),
 
 1161                "order" => (
int) $answer_obj->getOrder(),
 
 1162                "image" => (
string) $answer_obj->getImage(),
 
 1163                "feedback" => $this->formatSAQuestion(
 
 1164                    $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, 
$key)
 
 1168        $result[
'answers'] = $answers;
 
 1171            $result[
'path'] = $this->getImagePathWeb();
 
 1172            $result[
'thumb'] = $this->getThumbSize();
 
 1176        $result[
'mobs'] = 
$mobs;
 
 1178        return json_encode($result);
 
 1183        $answer = $this->answers[
$index];
 
 1184        if (is_object($answer)) {
 
 1185            $this->deleteImage($answer->getImage());
 
 1186            $answer->setImage(
'');
 
 1195        $multilineAnswerSetting = 
$ilUser->getPref(
"tst_multiline_answers");
 
 1196        if ($multilineAnswerSetting != 1) {
 
 1197            $multilineAnswerSetting = 0;
 
 1199        return $multilineAnswerSetting;
 
 1206        $ilUser->writePref(
"tst_multiline_answers", $a_setting);
 
 1220        $this->feedback_setting = $a_feedback_setting;
 
 1234        if ($this->feedback_setting) {
 
 1235            return $this->feedback_setting;
 
 1243        return 'feedback_correct_sc_mc';
 
 1261        return $numExistingSolutionRecords > 0;
 
 1275    public static function isObligationPossible(
int $questionId): bool
 
 1282                        SELECT SUM(points) points_for_checked_answers 
 1284                        WHERE question_fi = %s AND points > 0 
 1291        return $row[
'points_for_checked_answers'] > 0;
 
 1302    public function ensureNoInvalidObligation($questionId): void
 
 1309                        SELECT          SUM(qpl_a_mc.points) points_for_checked_answers, 
 1312                        FROM            tst_test_question 
 1315                        ON                      qpl_a_mc.question_fi = tst_test_question.question_fi 
 1317                        WHERE           tst_test_question.question_fi = %s 
 1318                        AND                     tst_test_question.obligatory = 1 
 1320                        GROUP BY        test_question_id 
 1325        $updateTestQuestionIds = array();
 
 1327        while ($row = 
$ilDB->fetchAssoc(
$res)) {
 
 1328            if ($row[
'points_for_checked_answers'] <= 0) {
 
 1329                $updateTestQuestionIds[] = $row[
'test_question_id'];
 
 1333        if (count($updateTestQuestionIds)) {
 
 1334            $test_question_id__IN__updateTestQuestionIds = 
$ilDB->in(
 
 1336                $updateTestQuestionIds,
 
 1342                                UPDATE tst_test_question 
 1344                                WHERE $test_question_id__IN__updateTestQuestionIds 
 1353        $solutionSubmit = [];
 
 1354        $post = $this->dic->http()->wrapper()->post();
 
 1356        foreach ($this->getAnswers() as 
$index => 
$a) {
 
 1357            if (
$post->has(
"multiple_choice_result_$index")) {
 
 1358                $value = 
$post->retrieve(
"multiple_choice_result_$index", $this->dic->refinery()->kindlyTo()->string());
 
 1359                if (is_numeric($value)) {
 
 1360                    $solutionSubmit[] = $value;
 
 1364        return $solutionSubmit;
 
 1374        if ($found_values == 
null) {
 
 1378        foreach ($this->answers as 
$key => $answer) {
 
 1379            if (in_array(
$key, $found_values)) {
 
 1380                $points += $answer->getPoints();
 
 1382                $points += $answer->getPointsUnchecked();
 
 1386            if (count($found_values) == 0) {
 
 1435        $maxStep = $this->lookupMaxStep($active_id, $pass);
 
 1437        if ($maxStep !== 
null) {
 
 1439                "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
 
 1440                array(
"integer", 
"integer", 
"integer",
"integer"),
 
 1441                array($active_id, $pass, $this->
getId(), $maxStep)
 
 1445                "SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
 
 1446                array(
"integer", 
"integer", 
"integer"),
 
 1447                array($active_id, $pass, $this->
getId())
 
 1452            $result->addKeyValue($row[
"value1"], $row[
"value1"]);
 
 1455        $points = $this->calculateReachedPoints($active_id, $pass);
 
 1456        $max_points = $this->getMaximumPoints();
 
 1458        $result->setReachedPercentage(($points / $max_points) * 100);
 
 1472            return $this->getAnswer(
$index);
 
 1474            return $this->getAnswers();
 
 1480        $config = parent::buildTestPresentationConfig();
 
 1481        $config->setUseUnchangedAnswerLabel($this->
lng->txt(
'tst_mc_label_none_above'));
 
 1487        return (
bool) $this->isSingleline;
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
buildTestPresentationConfig()
build basic test question configuration instance
 
syncImages()
Sync images of a MC question on synchronisation with the original question.
 
toJSON()
Returns a JSON representation of the question.
 
getSpecificFeedbackSetting()
Gets the current feedback settings in effect for the question.
 
copyImages($question_id, $source_questionpool)
 
saveToDb($original_id="")
Saves a assMultipleChoice object to a database.
 
loadFromDb($question_id)
Loads a assMultipleChoice object from a database.
 
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
 
getAnswerCount()
Returns the number of answers.
 
getAnswerTableName()
Returns the name of the answer table in the database.
 
isForcedEmptySolution($solutionSubmit)
 
getAdditionalTableName()
Returns the name of the additional question data table in the database.
 
getSpecificFeedbackAllCorrectOptionLabel()
 
setSpecificFeedbackSetting($a_feedback_setting)
Sets the feedback settings in effect for the question.
 
removeAnswerImage($index)
 
setExportDetailsXLS(ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
{}
 
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
 
setSelectionLimit($selectionLimit)
 
calculateReachedPointsForSolution($found_values, $active_id=0)
 
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="", $answer_id=-1)
Adds a possible answer for a multiple choice question.
 
duplicate(bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
Duplicates an assMultipleChoiceQuestion.
 
isAnswered(int $active_id, int $pass)
returns boolean wether the question is answered during test pass or not
 
getOutputType()
Gets the multiple choice output type which is either OUTPUT_ORDER (=0) or OUTPUT_RANDOM (=1).
 
copyObject($target_questionpool_id, $title="")
Copies an assMultipleChoice object.
 
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
 
getMultilineAnswerSetting()
 
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
 
setMultilineAnswerSetting($a_setting=0)
 
isComplete()
Returns true, if a multiple choice question is complete for use.
 
flushAnswers()
Deletes all answers.
 
deleteAnswer($index=0)
Deletes an answer with a given index.
 
getQuestionType()
Returns the question type of the question.
 
deleteImage($image_filename)
Deletes an image file.
 
setImageFile($image_filename, $image_tempfilename="")
Sets the image file and uploads the image to the object's image directory.
 
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $output_type=OUTPUT_ORDER)
assMultipleChoice constructor
 
setIsSingleline($isSingleline)
 
setOutputType($output_type=OUTPUT_ORDER)
Sets the output type of the assMultipleChoice object.
 
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
 
getAnswer($index=0)
Returns an answer with a given index.
 
generateThumbForFile($path, $file)
 
getExpressionTypes()
Get all available expression types for a specific question.
 
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
 
rebuildThumbnails()
Rebuild the thumbnail images with a new thumbnail size.
 
& getAnswers()
Returns a reference to the answers array.
 
getOperators($expression)
Get all available operations for a specific question.
 
Abstract basic class which is to be extended by the concrete assessment question type classes.
 
float $points
The maximum available points for the question.
 
setOriginalId(?int $original_id)
 
string $question
The question text.
 
static logAction(string $logtext, int $active_id, int $question_id)
 
getHtmlQuestionContentPurifier()
 
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
 
setShuffle(?bool $shuffle=true)
 
setQuestion(string $question="")
 
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
 
static _getOriginalId(int $question_id)
 
saveQuestionDataToDb(int $original_id=-1)
 
setAuthor(string $author="")
 
setThumbSize(int $a_size)
 
bool $shuffle
Indicates whether the answers will be shuffled or not.
 
setComment(string $comment="")
 
setNrOfTries(int $a_nr_of_tries)
 
setLifecycle(ilAssQuestionLifecycle $lifecycle)
 
static getNumExistingSolutionRecords(int $activeId, int $pass, int $questionId)
 
setTitle(string $title="")
 
static getDraftInstance()
 
static getInstance($identifier)
 
setBold(string $a_coords)
Set cell(s) to bold.
 
getColumnCoord(int $a_col)
Get column "name" from number.
 
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
 
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
 
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
 
static _enabledAssessmentLogging()
 
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
 
static getOperatorsByExpression($expression)
 
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
 
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const PercentageResultExpression
 
const EmptyAnswerExpression
 
const ExclusiveResultExpression
 
const NumberOfResultExpression
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
migrateToLmContent($content)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
 
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
 
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples