MDL-57239 qbehaviour_interactive: fix Try again button when reviewing

This commit is contained in:
Tim Hunt
2019-08-02 11:44:51 +01:00
parent f622ee97e3
commit 1f60ddcebc
3 changed files with 77 additions and 19 deletions
+9 -3
View File
@@ -36,14 +36,19 @@ defined('MOODLE_INTERNAL') || die();
*/
class qbehaviour_interactive_renderer extends qbehaviour_renderer {
public function controls(question_attempt $qa, question_display_options $options) {
if ($options->readonly === qbehaviour_interactive::READONLY_EXCEPT_TRY_AGAIN) {
if ($options->readonly === qbehaviour_interactive::TRY_AGAIN_VISIBLE ||
$options->readonly === qbehaviour_interactive::TRY_AGAIN_VISIBLE_READONLY) {
// We are in the try again state, so no submit button.
return '';
}
return $this->submit_button($qa, $options);
}
public function feedback(question_attempt $qa, question_display_options $options) {
if (!$qa->get_state()->is_active() || !$options->readonly) {
// Show the Try again button if we are in try-again state.
if (!$qa->get_state()->is_active() ||
($options->readonly !== qbehaviour_interactive::TRY_AGAIN_VISIBLE &&
$options->readonly !== qbehaviour_interactive::TRY_AGAIN_VISIBLE_READONLY)) {
return '';
}
@@ -54,7 +59,8 @@ class qbehaviour_interactive_renderer extends qbehaviour_renderer {
'value' => get_string('tryagain', 'qbehaviour_interactive'),
'class' => 'submit btn',
);
if ($options->readonly !== qbehaviour_interactive::READONLY_EXCEPT_TRY_AGAIN) {
if ($options->readonly === qbehaviour_interactive::TRY_AGAIN_VISIBLE_READONLY) {
// This means the question really was rendered with read-only option.
$attributes['disabled'] = 'disabled';
}
$output = html_writer::empty_tag('input', $attributes);