marcusgreen / moodle-qtype_wordselect

langHighlight words by clicking e.g. select all nouns in this sentence
2 stars 10 forks source link

Multiple questions with question type - qtype_wordselect not working #29

Closed hdagheda closed 4 years ago

hdagheda commented 4 years ago

Thank you @marcusgreen for such great plugin, However I am unable to add multiple questions of qtype_wordselect on same page. when I click on word, its not getting selected. Its works when I have only one question of qtype_wordselect on page.

Please let me know will there be any future updates to fix this issue? Thank you

hdagheda commented 4 years ago

In version 2.42 moodle version 3.4.9

marcusgreen commented 4 years ago

Hi, this issue was fixed in the last release https://github.com/marcusgreen/moodle-qtype_wordselect/releases But unfortunately the fix only works in Moodle 3.7 and above. You may find the question works correctly where you have an odd number of the questions on a single page. That is not a good solution I know. My apologies but I am not able to apply the fix for earlier versions of Moodle.

hdagheda commented 4 years ago

Thank you @marcusgreen , I understand.

hdagheda commented 4 years ago

adding below code in renderer.php has solved the issue.

// Initialize JS only once per page.
        static $jsinit = false;
        if (!$jsinit) {
            $this->page->requires->js_call_amd('qtype_wordselect/navigation', 'init');
            $this->page->requires->js_call_amd('qtype_wordselect/selection', 'init');
            $jsinit = true;
        }