Skip to content

Commit

Permalink
MBS-9817: Remove cmid from spellcheck JS module and editor
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed Dec 28, 2024
1 parent bd05c06 commit 8ced55a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 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
4 changes: 0 additions & 4 deletions classes/form/edit_spellcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public function definition() {

$mform = &$this->_form;

$mform->addElement('hidden', 'cmid');
$mform->setType('cmid', PARAM_INT);

$mform->addElement('hidden', 'attemptstepid');
$mform->setType('attemptstepid', PARAM_INT);

Expand Down Expand Up @@ -141,7 +138,6 @@ public function set_data_for_dynamic_submission(): void {
'test' => $spellcheckrecord->value,
'spellcheck_editor' => ['text' => $spellcheckrecord->value, 'format' => FORMAT_HTML, 'itemid' => $draftitemid],
'attemptstepid' => $this->optional_param('attemptstepid', 0, PARAM_INT),
'cmid' => $this->optional_param('cmid', 0, PARAM_INT),
'student_answer' => $answerrecord->value,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,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 8ced55a

Please sign in to comment.