Merge branch 'MDL-82465-master' of https://github.com/danghieu1407/moodle

This commit is contained in:
Huong Nguyen 2024-08-01 10:35:17 +07:00
commit 784fb45459
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A
6 changed files with 18 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -107,6 +107,7 @@ define([
if (existingmarkertext.length) {
if (dropZone.markertext !== '') {
existingmarkertext.html(dropZone.markertext);
filterEvent.notifyFilterContentUpdated(existingmarkertext);
} else {
existingmarkertext.remove();
}
@ -127,6 +128,7 @@ define([
.data('originY', markerspan.position().top / bgRatio);
this.handleElementScale(markerspan, 'center');
}
filterEvent.notifyFilterContentUpdated(markerspan);
}
var shapeSVG = shape.makeSvg(svg[0]);

View File

@ -95,22 +95,19 @@ class qtype_ddmarker_renderer extends qtype_ddtoimage_renderer_base {
$output .= html_writer::div($dragitems, 'dd-original d-none');
$output .= html_writer::end_div();
if ($question->showmisplaced && $qa->get_state()->is_finished()) {
$visibledropzones = $question->get_drop_zones_without_hit($response);
} else {
$visibledropzones = [];
}
if ($qa->get_state() == question_state::$invalid) {
$output .= html_writer::div($question->get_validation_error($qa->get_last_qt_data()), 'validationerror');
}
$visibledropzones = [];
if ($question->showmisplaced && $qa->get_state()->is_finished()) {
$wrongparts = $question->get_drop_zones_without_hit($response);
if (count($wrongparts) !== 0) {
$visibledropzones = $question->get_drop_zones_without_hit($response);
if (count($visibledropzones) !== 0) {
$wrongpartsstringspans = [];
foreach ($wrongparts as $wrongpart) {
$wrongpartsstringspans[] = html_writer::span($wrongpart->markertext, 'wrongpart');
foreach ($visibledropzones as $visibledropzone) {
$visibledropzone->markertext = question_utils::format_question_fragment(
$visibledropzone->markertext, $this->page->context);
$wrongpartsstringspans[] = html_writer::span($visibledropzone->markertext, 'wrongpart');
}
$wrongpartsstring = join(', ', $wrongpartsstringspans);
$output .= html_writer::span(get_string('followingarewrongandhighlighted', 'qtype_ddmarker', $wrongpartsstring),

View File

@ -63,6 +63,10 @@ Feature: Preview a drag-drop marker question
Given the "mathjaxloader" filter is "on"
And the "mathjaxloader" filter applies to "content and headings"
And I am on the "Drag to mathjax equation" "core_question > preview" page logged in as teacher
And I press "Fill in correct responses"
When I press "Submit and finish"
Then ".filter_mathjaxloader_equation" "css_element" should exist in the ".droparea" "css_element"
Then ".markertexts .markertext .MathJax_Display" "css_element" should exist in the ".droparea" "css_element"
And I press "Start again"
And I press "Fill in correct responses"
And I press "Submit and finish"
And ".filter_mathjaxloader_equation" "css_element" should exist in the ".droparea" "css_element"
And ".markertexts .markertext .MathJax_Display" "css_element" should not exist in the ".droparea" "css_element"

View File

@ -225,6 +225,7 @@ class qtype_ddmarker_test_helper extends question_test_helper {
$fromform->defaultmark = 1;
$fromform->generalfeedback = ['text' => 'The right answer is: "y = x^2"', 'format' => FORMAT_HTML];
$fromform->showmisplaced = 1;
$fromform->bgimage = $bgdraftitemid;
$fromform->shuffleanswers = 0;
$fromform->drags = [