MOBILE-4143 question: Fix replace TeX images in questions
parent
e6b9ad7c24
commit
d7ce9998a6
|
@ -291,13 +291,18 @@ export class CoreQuestionHelperProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
matches.forEach((match: string) => {
|
||||
matches.forEach((scriptCode) => {
|
||||
if (scriptCode.match(/<script[^>]+type="math\/tex"/m)) {
|
||||
// Don't remove math/tex scripts, they're needed to render the math expressions.
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the script to scriptsCode and remove it from html.
|
||||
question.scriptsCode += match;
|
||||
question.html = question.html.replace(match, '');
|
||||
question.scriptsCode += scriptCode;
|
||||
question.html = question.html.replace(scriptCode, '');
|
||||
|
||||
// Search init_question functions for this type.
|
||||
const initMatches = match.match(new RegExp('M.qtype_' + question.type + '.init_question\\(.*?}\\);', 'mg'));
|
||||
const initMatches = scriptCode.match(new RegExp('M.qtype_' + question.type + '.init_question\\(.*?}\\);', 'mg'));
|
||||
if (initMatches) {
|
||||
let initMatch = initMatches.pop()!;
|
||||
|
||||
|
@ -312,7 +317,7 @@ export class CoreQuestionHelperProvider {
|
|||
const amdRegExp = new RegExp('require\\(\\[["\']qtype_' + question.type + '/question["\']\\],[^f]*' +
|
||||
'function\\(amd\\)[^\\{]*\\{[^a]*amd\\.init\\((["\'](q|question-' + usageId + '-)' + question.slot +
|
||||
'["\'].*?)\\);', 'm');
|
||||
const amdMatch = match.match(amdRegExp);
|
||||
const amdMatch = scriptCode.match(amdRegExp);
|
||||
|
||||
if (amdMatch) {
|
||||
// Try to convert the arguments to an array and add them to the question.
|
||||
|
|
Loading…
Reference in New Issue