Skip to content

Commit

Permalink
MBS-9817: Remove cmid from spellcheck JS module
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed Dec 28, 2024
1 parent ad7ac12 commit 243f0d0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion amd/build/spellcheck.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/spellcheck.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions amd/src/spellcheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ import {getString as getString} from 'core/str';
/**
* Init the module.
*
* @param {int} cmid the course module id of the quiz.
* @param {string} readonlyareaselector the selector for the readonly area to apply the spellchecking
* @param {string} spellcheckeditbuttonselector the selector for the spell check edit button
*/
export const init = (cmid, readonlyareaselector, spellcheckeditbuttonselector) => {
export const init = (readonlyareaselector, spellcheckeditbuttonselector) => {
renderDiff(readonlyareaselector);

if (!document.querySelector(spellcheckeditbuttonselector)) {
Expand All @@ -42,7 +41,7 @@ export const init = (cmid, readonlyareaselector, spellcheckeditbuttonselector) =
document.querySelector(spellcheckeditbuttonselector).addEventListener('click',
async(event) => {
event.preventDefault();
await showModalForm(cmid, readonlyareaselector);
await showModalForm(readonlyareaselector);
});
};

Expand Down Expand Up @@ -86,19 +85,17 @@ export const renderDiff = (readonlyareaselector) => {
/**
* Show the dynamic spellcheck form.
*
* @param {int} cmid the course module id of the quiz
* @param {string} readonlyareaselector the selector for the readonly area
*/
export const showModalForm = async(cmid, readonlyareaselector) => {
export const showModalForm = async(readonlyareaselector) => {
const attemptstepid = document.querySelector(readonlyareaselector).dataset.spellcheckattemptstepid;
const answerstepid = document.querySelector(readonlyareaselector).dataset.spellcheckattemptstepanswerid;
const title = await getString('spellcheckedit', 'qtype_aitext');
const modalForm = new ModalForm({
formClass: "qtype_aitext\\form\\edit_spellcheck",
args: {
attemptstepid,
answerstepid,
cmid
answerstepid
},
modalConfig: {title},
});
Expand Down
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function response_area_read_only($name, $qa, $step, $lines, $context) {
if ($question->spellcheck) {
$this->page->requires->js_call_amd('qtype_aitext/diff');
$this->page->requires->js_call_amd('qtype_aitext/spellcheck', 'init',
[$this->get_page()->cm->id, '#' . $readonlyareaid, '#' . $spellcheckeditbuttonid]);
['#' . $readonlyareaid, '#' . $spellcheckeditbuttonid]);
$stepspellcheck = $qa->get_last_step_with_qt_var('-spellcheckresponse');
$stepanswer = $qa->get_last_step_with_qt_var('answer');
}
Expand Down

0 comments on commit 243f0d0

Please sign in to comment.