|
|
|
|
@ -97,6 +97,7 @@ class Exercise |
|
|
|
|
public $hideExpectedAnswer; |
|
|
|
|
public $forceShowExpectedChoiceColumn; |
|
|
|
|
public $disableHideCorrectAnsweredQuestions; |
|
|
|
|
public $hideAttemptsTableOnStartPage; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Constructor of the class. |
|
|
|
|
@ -142,6 +143,7 @@ class Exercise |
|
|
|
|
$this->hideNoAnswer = false; |
|
|
|
|
$this->hideExpectedAnswer = false; |
|
|
|
|
$this->disableHideCorrectAnsweredQuestions = false; |
|
|
|
|
$this->hideAttemptsTableOnStartPage = 0; |
|
|
|
|
|
|
|
|
|
if (!empty($courseId)) { |
|
|
|
|
$courseInfo = api_get_course_info_by_id($courseId); |
|
|
|
|
@ -227,6 +229,10 @@ class Exercise |
|
|
|
|
$this->hideQuestionNumber = $object->hide_question_number == 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($object->hide_attempts_table)) { |
|
|
|
|
$this->hideAttemptsTableOnStartPage = $object->hide_attempts_table == 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($object->show_previous_button)) { |
|
|
|
|
$this->showPreviousButton = $object->show_previous_button == 1; |
|
|
|
|
} |
|
|
|
|
@ -1680,6 +1686,9 @@ class Exercise |
|
|
|
|
if ($showHideConfiguration) { |
|
|
|
|
$paramsExtra['hide_question_number'] = $this->hideQuestionNumber; |
|
|
|
|
} |
|
|
|
|
if (true === api_get_configuration_value('quiz_hide_attempts_table_on_start_page')) { |
|
|
|
|
$paramsExtra['hide_attempts_table'] = $this->getHideAttemptsTableOnStartPage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$params = array_merge($params, $paramsExtra); |
|
|
|
|
|
|
|
|
|
@ -2466,6 +2475,15 @@ class Exercise |
|
|
|
|
get_lang('UpdateTitleInLps') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$allowHideAttempts = api_get_configuration_value('quiz_hide_attempts_table_on_start_page'); |
|
|
|
|
if ($allowHideAttempts) { |
|
|
|
|
$group = [ |
|
|
|
|
$form->createElement('radio', 'hide_attempts_table', null, get_lang('Yes'), '1'), |
|
|
|
|
$form->createElement('radio', 'hide_attempts_table', null, get_lang('No'), '0'), |
|
|
|
|
]; |
|
|
|
|
$form->addGroup($group, null, get_lang('HideAttemptsTableOnStartPage')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$defaults = []; |
|
|
|
|
if (api_get_setting('search_enabled') === 'true') { |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
|
|
|
@ -2667,6 +2685,7 @@ class Exercise |
|
|
|
|
|
|
|
|
|
$this->setPageResultConfigurationDefaults($defaults); |
|
|
|
|
$this->setHideQuestionNumberDefaults($defaults); |
|
|
|
|
$this->setHideAttemptsTableOnStartPageDefaults($defaults); |
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
|
|
|
|
|
// Freeze some elements. |
|
|
|
|
@ -2840,6 +2859,9 @@ class Exercise |
|
|
|
|
if ($showHideConfiguration) { |
|
|
|
|
$this->setHideQuestionNumber($form->getSubmitValue('hide_question_number')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->setHideAttemptsTableOnStartPage($form->getSubmitValue('hide_attempts_table')); |
|
|
|
|
|
|
|
|
|
$this->preventBackwards = (int) $form->getSubmitValue('prevent_backwards'); |
|
|
|
|
|
|
|
|
|
$this->start_time = null; |
|
|
|
|
@ -8552,6 +8574,34 @@ class Exercise |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set the value to 1 to hide the attempts table on start page. |
|
|
|
|
* |
|
|
|
|
* @param int $value |
|
|
|
|
*/ |
|
|
|
|
public function setHideAttemptsTableOnStartPage($value = 0) |
|
|
|
|
{ |
|
|
|
|
$showHideAttemptsTableOnStartPage = api_get_configuration_value('quiz_hide_attempts_table_on_start_page'); |
|
|
|
|
if ($showHideAttemptsTableOnStartPage) { |
|
|
|
|
$this->hideAttemptsTableOnStartPage = (int) $value; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the value to hide or show the attempts table on start page. If it does not exist, it is set to 0. |
|
|
|
|
* |
|
|
|
|
* @return int 1 if the attempts table must be hidden |
|
|
|
|
*/ |
|
|
|
|
public function getHideAttemptsTableOnStartPage() |
|
|
|
|
{ |
|
|
|
|
$showHideAttemptsTableOnStartPage = api_get_configuration_value('quiz_hide_attempts_table_on_start_page'); |
|
|
|
|
if ($showHideAttemptsTableOnStartPage) { |
|
|
|
|
return (int) $this->hideAttemptsTableOnStartPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param array $values |
|
|
|
|
*/ |
|
|
|
|
@ -8596,6 +8646,19 @@ class Exercise |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the value to show or hide the attempts table on start page in the default settings of the forms. |
|
|
|
|
* |
|
|
|
|
* @param array $defaults |
|
|
|
|
*/ |
|
|
|
|
public function setHideAttemptsTableOnStartPageDefaults(&$defaults) |
|
|
|
|
{ |
|
|
|
|
$configuration = $this->getHideAttemptsTableOnStartPageConfiguration(); |
|
|
|
|
if (!empty($configuration) && !empty($defaults)) { |
|
|
|
|
$defaults = array_merge($defaults, $configuration); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
@ -8627,6 +8690,21 @@ class Exercise |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the value to show or hide the attempts table on start page in the default settings of the forms. |
|
|
|
|
* |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function getHideAttemptsTableOnStartPageConfiguration() |
|
|
|
|
{ |
|
|
|
|
$pageConfig = api_get_configuration_value('quiz_hide_attempts_table_on_start_page'); |
|
|
|
|
if ($pageConfig) { |
|
|
|
|
return ['hide_attempts_table' => $this->hideAttemptsTableOnStartPage]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $attribute |
|
|
|
|
* |
|
|
|
|
|