Skip to content

Commit

Permalink
Display the REGEX types on the Clozergx question only.
Browse files Browse the repository at this point in the history
  • Loading branch information
srobotta committed Oct 12, 2024
1 parent 37c3dff commit 1827c15
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion amd/build/commands.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/commands.min.js.map

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

4 changes: 2 additions & 2 deletions amd/build/options.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/options.min.js.map

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

22 changes: 17 additions & 5 deletions amd/src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ import {
clozeeditButtonName,
icon,
} from './common';
import {displayDialogue, displayDialogueForEdit, resolveSubquestion, onInit, onBeforeGetContent, onSubmit} from './ui';
import {
displayDialogue,
displayDialogueForEdit,
resolveSubquestion,
onInit,
onBeforeGetContent,
onSubmit
} from './ui';
import {disableQtypeMultianswerrgx} from './options';

/**
* Get the setup function for the buttons.
Expand All @@ -49,15 +57,19 @@ export const getSetup = async() => {

return (editor) => {
// Check whether we are editing a question.
const body = document.querySelector('body#page-question-type-multianswer form, ' +
'body#page-question-type-multianswerwiris form,' +
'body#page-question-type-multianswerrgx form'
const body = document.querySelector('body#page-question-type-multianswer, ' +
'body#page-question-type-multianswerwiris,' +
'body#page-question-type-multianswerrgx'
);
// And if the editor is used on the question text.
if (!body || editor.id.indexOf('questiontext') === -1) {
return;
}
// Only if both conditions are valid, then continue setting up the plugin.
// Only if all conditions are valid, then continue setting up the plugin.
// However, if we have not a body#page-question-type-multianswerrgx then disable the regex types.
if (body.id.indexOf('multianswerrgx') === -1) {
disableQtypeMultianswerrgx(editor);
}

// Register the Moodle SVG as an icon suitable for use as a TinyMCE toolbar button.
editor.ui.registry.addIcon(icon, buttonImage.html);
Expand Down
3 changes: 2 additions & 1 deletion amd/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export const register = (editor) => {
});
};

export const hasQtypeMultianswerrgx = (editor) => editor.options.get(multianswerrgx);
export const hasQtypeMultianswerrgx = (editor) => editor.options.get(multianswerrgx);
export const disableQtypeMultianswerrgx = (editor) => editor.options.set(multianswerrgx, false);

0 comments on commit 1827c15

Please sign in to comment.