Jelajahi Sumber

Answer required for unique answers see BT#6522

Julio Montoya 11 tahun lalu
induk
melakukan
01ee2fcfa1
2 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 3 1
      main/exercice/exercise_submit.php
  2. 7 0
      main/inc/ajax/exercise.ajax.php

+ 3 - 1
main/exercice/exercise_submit.php

@@ -1154,8 +1154,10 @@ if (!empty($error)) {
                             $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
                         } else if (return_value == "error") {
                             $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL)).'");
+                        } else if (return_value == "answer_required") {
+                            $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('warning.png', get_lang('warning'), array(), ICON_SIZE_SMALL).
+                            " ".get_lang('SelectAnAnswerToContinue')).'");
                         } else if (return_value == "one_per_page") {
-
                             var url = "";
                             if ('.$reminder.' == 1) {
                                 url = "'.$urlMainExercise.'exercise_reminder.php?'.$params.'&num='.$current_question.'";

+ 7 - 0
main/inc/ajax/exercise.ajax.php

@@ -444,6 +444,13 @@ switch ($action) {
                 // creates a temporary Question object
                 $objQuestionTmp = Question::read($my_question_id, $course_id);
 
+                if ($objExercise->type == ONE_PER_PAGE && $objQuestionTmp->type == UNIQUE_ANSWER) {
+                    if (empty($my_choice)) {
+                        echo 'answer_required';
+                        exit;
+                    }
+                }
+
                 //Getting free choice data
                 if ($objQuestionTmp->type  == FREE_ANSWER && $type == 'all') {
                     $my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id])? $_REQUEST['free_choice'][$my_question_id]: null;