MOBILE-4362 workshop: Fix dimension number

It displayed 01, 11, 21 instead of 1, 2, 3
main
Dani Palou 2023-10-25 10:13:24 +02:00
parent 132c597e81
commit e958210df0
2 changed files with 8 additions and 6 deletions

View File

@ -1100,23 +1100,25 @@ export class AddonModWorkshopProvider {
const args: string[] = field.name.split('_'); const args: string[] = field.name.split('_');
const name = args[0]; const name = args[0];
const idx = args[3]; const idx = args[3];
const idy = args[6] || false; const idy = args[6];
const idxNumber = parseInt(args[3], 10);
const idyNumber = parseInt(args[6], 10);
if (parseInt(idx, 10) + '' == idx) { if (!isNaN(idxNumber)) {
if (!parsedFields[idx]) { if (!parsedFields[idx]) {
parsedFields[idx] = { parsedFields[idx] = {
number: idx + 1, // eslint-disable-line id-blacklist number: idxNumber + 1, // eslint-disable-line id-blacklist
}; };
} }
if (idy && parseInt(idy, 10) + '' == idy) { if (!isNaN(idyNumber)) {
if (!parsedFields[idx].fields) { if (!parsedFields[idx].fields) {
parsedFields[idx].fields = []; parsedFields[idx].fields = [];
} }
if (!parsedFields[idx].fields[idy]) { if (!parsedFields[idx].fields[idy]) {
parsedFields[idx].fields[idy] = { parsedFields[idx].fields[idy] = {
number: idy + 1, // eslint-disable-line id-blacklist number: idyNumber + 1, // eslint-disable-line id-blacklist
}; };
} }
parsedFields[idx].fields[idy][name] = field.value; parsedFields[idx].fields[idy][name] = field.value;

View File

@ -82,7 +82,7 @@ Feature: Test basic usage of workshop activity in app
Then I should find "Task to do" within "Assess peers" "ion-item" in the app Then I should find "Task to do" within "Assess peers" "ion-item" in the app
When I press "The Answer" in the app When I press "The Answer" in the app
And I press "Grade for Aspect 01" in the app And I press "Grade for Aspect 1" in the app
And I press "10 / 10" in the app And I press "10 / 10" in the app
And I press "Save" in the app And I press "Save" in the app
Then I should find "Assessed submission" in the app Then I should find "Assessed submission" in the app