diff --git a/public/main/exercise/exercise.class.php b/public/main/exercise/exercise.class.php index c2cdfc2cd9..703a7a6fe4 100644 --- a/public/main/exercise/exercise.class.php +++ b/public/main/exercise/exercise.class.php @@ -93,6 +93,7 @@ class Exercise public $autolaunch; public $exerciseCategoryId; public $pageResultConfiguration; + public $hideQuestionNumber; public $preventBackwards; public $currentQuestion; public $hideComment; @@ -140,6 +141,7 @@ class Exercise $this->notifications = []; $this->exerciseCategoryId = 0; $this->pageResultConfiguration = null; + $this->hideQuestionNumber = 0; $this->preventBackwards = 0; $this->hideComment = false; $this->hideNoAnswer = false; @@ -227,6 +229,8 @@ class Exercise //$this->pageResultConfiguration = $object->page_result_configuration; } + $this->hideQuestionNumber = $object->hide_question_number == 1; + if (isset($object->show_previous_button)) { $this->showPreviousButton = 1 == $object->show_previous_button ? true : false; } @@ -1633,7 +1637,9 @@ class Exercise ->setSaveCorrectAnswers($saveCorrectAnswers) ->setPropagateNeg($propagate_neg) ->setHideQuestionTitle(1 === (int) $this->getHideQuestionTitle()) - ->setQuestionSelectionType($this->getQuestionSelectionType()); + ->setQuestionSelectionType($this->getQuestionSelectionType()) + ->setHideQuestionNumber((int) $this->hideQuestionNumber) + ; $allow = api_get_configuration_value('allow_exercise_categories'); if (true === $allow && !empty($this->getExerciseCategoryId())) { @@ -2102,6 +2108,13 @@ class Exercise ), ]; $form->addGroup($group, null, get_lang('Results and feedback page configuration')); + + $group = [ + $form->createElement('radio', 'hide_question_number', null, get_lang('Yes'), '1'), + $form->createElement('radio', 'hide_question_number', null, get_lang('No'), '0'), + ]; + $form->addGroup($group, null, get_lang('HideQuestionNumber')); + $displayMatrix = 'none'; $displayRandom = 'none'; $selectionType = $this->getQuestionSelectionType(); @@ -2422,6 +2435,7 @@ class Exercise $defaults['show_previous_button'] = $this->showPreviousButton(); $defaults['exercise_category_id'] = $this->getExerciseCategoryId(); $defaults['prevent_backwards'] = $this->getPreventBackwards(); + $defaults['hide_question_number'] = $this->getHideQuestionNumber(); if (!empty($this->start_time)) { $defaults['activate_start_date_check'] = 1; @@ -2503,6 +2517,11 @@ class Exercise { // Feedback type. $feedback = []; + $warning = sprintf( + get_lang('TheSettingXWillChangeToX'), + get_lang('ShowResultsToStudents'), + get_lang('ShowScoreAndRightAnswer') + ); $endTest = $form->createElement( 'radio', 'exerciseFeedbackType', @@ -2511,7 +2530,8 @@ class Exercise EXERCISE_FEEDBACK_TYPE_END, [ 'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_END, - 'onclick' => 'check_feedback()', + //'onclick' => 'if confirm() check_feedback()', + 'onclick' => 'javascript:if(confirm('."'".addslashes($warning)."'".')) { check_feedback(); } else { return false;} ', ] ); @@ -2640,6 +2660,7 @@ class Exercise $this->setNotifications($form->getSubmitValue('notifications')); $this->setExerciseCategoryId($form->getSubmitValue('exercise_category_id')); $this->setPageResultConfiguration($form->getSubmitValues()); + $this->setHideQuestionNumber($form->getSubmitValue('hide_question_number')); $this->preventBackwards = (int) $form->getSubmitValue('prevent_backwards'); $this->start_time = null; @@ -3282,10 +3303,15 @@ class Exercise ] ); } else { + $attributes = ['type' => 'button', 'class' => $class, 'data-question' => $question_id]; + $name = 'save_now'; + if ($endTest && api_get_configuration_value('quiz_check_all_answers_before_end_test')) { + $name = 'check_answers'; + } $buttonList[] = Display::button( - 'save_now', + $name, $label, - ['type' => 'button', 'class' => $class, 'data-question' => $question_id] + $attributes ); } $buttonList[] = ''; @@ -3380,6 +3406,7 @@ class Exercise * So the time control will work. * * @param int $timeLeft + * @param string $redirectToUrl * * @return string */ @@ -3394,6 +3421,10 @@ class Exercise $(\'[name="save_now"]\').trigger(\'click\');'; } + $exerciseSubmitRedirect = ''; + if (!empty($redirectToUrl)) { + $exerciseSubmitRedirect = "window.location = '$redirectToUrl'"; + } return "