Skip to content

Commit

Permalink
Merge branch 'MDL-77856-400' of https://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
sarjona committed Apr 13, 2023
2 parents 50a79ad + b3eb942 commit e196979
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 68 deletions.
54 changes: 0 additions & 54 deletions question/type/multianswer/module.js

This file was deleted.

42 changes: 29 additions & 13 deletions question/type/multianswer/renderer.php
Expand Up @@ -88,13 +88,6 @@ public function formulation_and_controls(question_attempt $qa,
array('class' => 'validationerror'));
}

$this->page->requires->js_init_call('M.qtype_multianswer.init',
array('#' . $qa->get_outer_question_div_unique_id()), false, array(
'name' => 'qtype_multianswer',
'fullpath' => '/question/type/multianswer/module.js',
'requires' => array('base', 'node', 'event', 'overlay'),
));

return $output;
}

Expand Down Expand Up @@ -202,8 +195,33 @@ protected function feedback_popup(question_graded_automatically $subq,
return '';
}

return html_writer::tag('span', implode('<br />', $feedback),
array('class' => 'feedbackspan accesshide'));
return html_writer::tag('span', implode('<br />', $feedback), [
'class' => 'feedbackspan',
]);
}

/**
* Render the feedback icon for a sub-question which is also the trigger for the feedback popover.
*
* @param string $icon The feedback icon
* @param string $feedbackcontents The feedback contents to be shown on the popover.
* @return string
*/
protected function get_feedback_image(string $icon, string $feedbackcontents): string {
if ($icon === '') {
return '';
}

return html_writer::tag('button', $icon, [
'type' => 'button',
'class' => 'btn btn-link p-0',
'data-toggle' => 'popover',
'data-container' => 'body',
'data-content' => $feedbackcontents,
'data-placement' => 'right',
'data-trigger' => 'focus',
'data-html' => 'true',
]);
}

/**
Expand Down Expand Up @@ -315,8 +333,7 @@ public function subquestion(question_attempt $qa, question_display_options $opti
$output .= html_writer::tag('label', $this->get_answer_label(),
array('class' => 'subq accesshide', 'for' => $inputattributes['id']));
$output .= html_writer::empty_tag('input', $inputattributes);
$output .= $feedbackimg;
$output .= $feedbackpopup;
$output .= $this->get_feedback_image($feedbackimg, $feedbackpopup);
$output .= html_writer::end_tag('span');

return $output;
Expand Down Expand Up @@ -385,8 +402,7 @@ public function subquestion(question_attempt $qa, question_display_options $opti
$output .= html_writer::tag('label', $this->get_answer_label(),
array('class' => 'subq accesshide', 'for' => $inputattributes['id']));
$output .= $select;
$output .= $feedbackimg;
$output .= $feedbackpopup;
$output .= $this->get_feedback_image($feedbackimg, $feedbackpopup);
$output .= html_writer::end_tag('span');

return $output;
Expand Down
2 changes: 1 addition & 1 deletion question/type/multianswer/tests/walkthrough_test.php
Expand Up @@ -41,7 +41,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base {

protected function get_contains_subq_status(question_state $state) {
return new \question_pattern_expectation('~' .
preg_quote($state->default_string(true), '~') . '<br />~');
preg_quote($state->default_string(true), '~') . '~');
}

public function test_deferred_feedback() {
Expand Down

0 comments on commit e196979

Please sign in to comment.