| @@ 935-956 (lines=22) @@ | ||
| 932 | } |
|
| 933 | ||
| 934 | // Fix correct answers |
|
| 935 | if (in_array($newQuestion->type, [DRAGGABLE, MATCHING, MATCHING_DRAGGABLE])) { |
|
| 936 | $onlyAnswersFlip = array_flip($onlyAnswers); |
|
| 937 | foreach ($correctAnswers as $answer_id => $correct_answer) { |
|
| 938 | $params = array(); |
|
| 939 | if (isset($allAnswers[$correct_answer]) && |
|
| 940 | isset($onlyAnswersFlip[$allAnswers[$correct_answer]]) |
|
| 941 | ) { |
|
| 942 | $params['correct'] = $onlyAnswersFlip[$allAnswers[$correct_answer]]; |
|
| 943 | Database::update( |
|
| 944 | $tableAnswer, |
|
| 945 | $params, |
|
| 946 | array( |
|
| 947 | 'id = ? AND c_id = ? AND question_id = ? ' => array( |
|
| 948 | $answer_id, |
|
| 949 | $courseId, |
|
| 950 | $newQuestionId, |
|
| 951 | ), |
|
| 952 | ) |
|
| 953 | ); |
|
| 954 | } |
|
| 955 | } |
|
| 956 | } |
|
| 957 | } |
|
| 958 | } |
|
| 959 | ||
| @@ 2090-2111 (lines=22) @@ | ||
| 2087 | } |
|
| 2088 | ||
| 2089 | // Fix correct answers |
|
| 2090 | if (in_array($question->quiz_type, [DRAGGABLE, MATCHING, MATCHING_DRAGGABLE])) { |
|
| 2091 | $onlyAnswersFlip = array_flip($onlyAnswers); |
|
| 2092 | foreach ($correctAnswers as $answer_id => $correct_answer) { |
|
| 2093 | $params = array(); |
|
| 2094 | if (isset($allAnswers[$correct_answer]) && |
|
| 2095 | isset($onlyAnswersFlip[$allAnswers[$correct_answer]]) |
|
| 2096 | ) { |
|
| 2097 | $params['correct'] = $onlyAnswersFlip[$allAnswers[$correct_answer]]; |
|
| 2098 | Database::update( |
|
| 2099 | $table_ans, |
|
| 2100 | $params, |
|
| 2101 | array( |
|
| 2102 | 'id = ? AND c_id = ? AND question_id = ? ' => array( |
|
| 2103 | $answer_id, |
|
| 2104 | $this->destination_course_id, |
|
| 2105 | $new_id, |
|
| 2106 | ), |
|
| 2107 | ) |
|
| 2108 | ); |
|
| 2109 | } |
|
| 2110 | } |
|
| 2111 | } |
|
| 2112 | ||
| 2113 | $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
| 2114 | } |
|