MOBILE-2272 essay: Don't format html if plain text

main
Dani Palou 2020-11-23 08:43:43 +01:00
parent 21eedf544a
commit ab25f60482
1 changed files with 14 additions and 2 deletions

View File

@ -364,7 +364,19 @@ export class AddonQtypeEssayHandler implements CoreQuestionHandler {
question.html, this.questionHelper.getResponseFileAreaFiles(question, 'answer'));
}
// Add some HTML to the text if needed.
answers[textarea.name] = this.textUtils.formatHtmlLines(answers[textarea.name]);
let isPlainText = false;
if (question.isPlainText !== undefined) {
isPlainText = question.isPlainText;
} else if (question.settings) {
isPlainText = question.settings.responseformat == 'monospaced' || question.settings.responseformat == 'plain';
} else {
const questionEl = this.domUtils.convertToElement(question.html);
isPlainText = !!questionEl.querySelector('.qtype_essay_monospaced') || !!questionEl.querySelector('.qtype_essay_plain');
}
if (!isPlainText) {
// Add some HTML to the text if needed.
answers[textarea.name] = this.textUtils.formatHtmlLines(answers[textarea.name]);
}
}
}