Merge pull request #2623 from dpalou/MOBILE-3523

MOBILE-3523 qtype_calculated: Fallback if unitsleft is null
main
Dani Palou 2020-11-25 16:24:46 +01:00 committed by GitHub
commit 97511e3463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -191,7 +191,7 @@ export class AddonQtypeCalculatedHandler implements CoreQuestionHandler {
let unitsLeft = false;
let match = null;
if (!question.settings) {
if (!question.settings || question.settings.unitsleft === null) {
// We don't know if units should be before or after so we check both.
match = answer.match(new RegExp('^' + regexString));
if (!match) {

View File

@ -108,7 +108,7 @@ export class CoreQuestionBaseComponent {
this.question.select = selectModel;
// Check which one should be displayed first: the select or the input.
if (this.question.settings) {
if (this.question.settings && this.question.settings.unitsleft !== null) {
this.question.selectFirst = this.question.settings.unitsleft == '1';
} else {
const input = questionEl.querySelector('input[type="text"][name*=answer]');
@ -166,7 +166,7 @@ export class CoreQuestionBaseComponent {
}
// Check which one should be displayed first: the options or the input.
if (this.question.settings) {
if (this.question.settings && this.question.settings.unitsleft !== null) {
this.question.optionsFirst = this.question.settings.unitsleft == '1';
} else {
const input = questionEl.querySelector('input[type="text"][name*=answer]');