Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JS error - incorrect questionid #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_
$this->page->requires->string_for_js('draganswerhere', 'qtype_ddmatch');
$this->page->requires->yui_module('moodle-qtype_ddmatch-dragdrop',
'M.qtype.ddmatch.init_dragdrop', array(array(
'questionid' => $qa->get_slot(),
'questionid' => $qa->get_outer_question_div_unique_id(),
'readonly' => $options->readonly,
))
);
Expand Down
2 changes: 1 addition & 1 deletion yui/dragdrop/dragdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ YUI.add('moodle-qtype_ddmatch-dragdrop', function(Y, NAME) {
return;
}

var containerid = 'div#q' + this.get('questionid'),
var containerid = 'div#' + this.get('questionid'),
Copy link

@nexterday nexterday Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new question div ids for 3.7 are compound of 'question-' . $this->usageid . '-' . $this->slot; see

/**
 * When the question is rendered, this unique id is added to the
 * outer div of the question. It can be used to uniquely reference
 * the question from JavaScript.
 *
 * @return string id added to the outer <div class="que ..."> when the question is rendered.
 */
public function get_outer_question_div_unique_id() {
    return 'question-' . $this->usageid . '-' . $this->slot;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update! (@nexterday )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s still working in Moodle 3.9.
Thanks a lot!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re welcome.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, sorry but I am now retired and stopped all programming work. Feel free to fork this repository and make any change you want.

group = containerid + ' .matchtarget';

// Set the container - we use this in various places
Expand Down