diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 3968a6d4efe..ff1c906f1ef 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -76,6 +76,7 @@ class Exercise public $sessionId = 0; public $questionFeedbackEnabled = false; public $questionTypeWithFeedback; + public $showPreviousButton; /** * Constructor of the class @@ -121,6 +122,7 @@ public function __construct($courseId = 0) // ALTER TABLE c_quiz_question ADD COLUMN feedback text; $this->questionFeedbackEnabled = api_get_configuration_value('allow_quiz_question_feedback'); + $this->showPreviousButton = true; } /** @@ -134,14 +136,14 @@ public function __construct($courseId = 0) */ public function read($id, $parseQuestionList = true) { - $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); - $table_lp_item = Database::get_course_table(TABLE_LP_ITEM); + $table = Database::get_course_table(TABLE_QUIZ_TEST); + $tableLpItem = Database::get_course_table(TABLE_LP_ITEM); $id = (int) $id; if (empty($this->course_id)) { return false; } - $sql = "SELECT * FROM $TBL_EXERCISES + $sql = "SELECT * FROM $table WHERE c_id = ".$this->course_id." AND id = ".$id; $result = Database::query($sql); @@ -176,11 +178,16 @@ public function read($id, $parseQuestionList = true) $this->questionSelectionType = isset($object->question_selection_type) ? $object->question_selection_type : null; $this->hideQuestionTitle = isset($object->hide_question_title) ? (int) $object->hide_question_title : 0; + if (isset($object->show_previous_button)) { + $this->showPreviousButton = $object->show_previous_button == 1 ? true : false; + } + $sql = "SELECT lp_id, max_score - FROM $table_lp_item - WHERE c_id = {$this->course_id} AND - item_type = '".TOOL_QUIZ."' AND - path = '".$id."'"; + FROM $tableLpItem + WHERE + c_id = {$this->course_id} AND + item_type = '".TOOL_QUIZ."' AND + path = '".$id."'"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { @@ -1607,6 +1614,11 @@ public function save($type_e = '') 'question_selection_type' => $this->getQuestionSelectionType(), 'hide_question_title' => $this->getHideQuestionTitle() ]; + + $allow = api_get_configuration_value('allow_quiz_show_previous_button_setting'); + if ($allow === true) { + $paramsExtra['show_previous_button'] = $this->showPreviousButton(); + } } $params = array_merge($params, $paramsExtra); @@ -2163,6 +2175,29 @@ public function createForm($form, $type = 'full') ); $form->addGroup($group, null, get_lang('HideQuestionTitle')); + $allow = api_get_configuration_value('allow_quiz_show_previous_button_setting'); + + if ($allow === true) { + // Hide question title. + $group = array( + $form->createElement( + 'radio', + 'show_previous_button', + null, + get_lang('Yes'), + '1' + ), + $form->createElement( + 'radio', + 'show_previous_button', + null, + get_lang('No'), + '0' + ) + ); + $form->addGroup($group, null, get_lang('ShowPreviousButton')); + } + // Attempts $attempt_option = range(0, 10); $attempt_option[0] = get_lang('Infinite'); @@ -2176,7 +2211,13 @@ public function createForm($form, $type = 'full') ); // Exercise time limit - $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); + $form->addElement( + 'checkbox', + 'activate_start_date_check', + null, + get_lang('EnableStartTime'), + array('onclick' => 'activate_start_date()') + ); $var = self::selectTimeLimit(); @@ -2188,7 +2229,13 @@ public function createForm($form, $type = 'full') $form->addElement('date_time_picker', 'start_time'); $form->addElement('html', ''); - $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); + $form->addElement( + 'checkbox', + 'activate_end_date_check', + null, + get_lang('EnableEndTime'), + array('onclick' => 'activate_end_date()') + ); if (!empty($this->end_time)) { $form->addElement('html', '