From e958210df04843c13d6712325c9352d961c32a1e Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 25 Oct 2023 10:13:24 +0200 Subject: [PATCH 1/2] MOBILE-4362 workshop: Fix dimension number It displayed 01, 11, 21 instead of 1, 2, 3 --- src/addons/mod/workshop/services/workshop.ts | 12 +++++++----- .../mod/workshop/tests/behat/basic_usage.feature | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/addons/mod/workshop/services/workshop.ts b/src/addons/mod/workshop/services/workshop.ts index 5e551e376..a866a4c8e 100644 --- a/src/addons/mod/workshop/services/workshop.ts +++ b/src/addons/mod/workshop/services/workshop.ts @@ -1100,23 +1100,25 @@ export class AddonModWorkshopProvider { const args: string[] = field.name.split('_'); const name = args[0]; 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]) { 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) { parsedFields[idx].fields = []; } if (!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; diff --git a/src/addons/mod/workshop/tests/behat/basic_usage.feature b/src/addons/mod/workshop/tests/behat/basic_usage.feature index 9d6aee8f5..ad5a2ac4c 100644 --- a/src/addons/mod/workshop/tests/behat/basic_usage.feature +++ b/src/addons/mod/workshop/tests/behat/basic_usage.feature @@ -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 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 "Save" in the app Then I should find "Assessed submission" in the app From e9601aee13e845353592c7614e79a808116b43c5 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 25 Oct 2023 15:48:42 +0200 Subject: [PATCH 2/2] MOBILE-4362 glossary: Fix some pages not prefetched --- src/addons/mod/glossary/services/glossary.ts | 29 ++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/addons/mod/glossary/services/glossary.ts b/src/addons/mod/glossary/services/glossary.ts index fef56bab5..bb5e1eb0f 100644 --- a/src/addons/mod/glossary/services/glossary.ts +++ b/src/addons/mod/glossary/services/glossary.ts @@ -291,16 +291,16 @@ export class AddonModGlossaryProvider { glossaryId: number, options: AddonModGlossaryGetEntriesOptions = {}, ): Promise { - options.from = options.from || 0; - options.limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES; + const from = options.from || 0; + const limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES; const site = await CoreSites.getSite(options.siteId); const params: AddonModGlossaryGetEntriesByLetterWSParams = { id: glossaryId, letter: 'ALL', - from: options.from, - limit: options.limit, + from, + limit, }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getEntriesByLetterCacheKey(glossaryId), @@ -316,9 +316,9 @@ export class AddonModGlossaryProvider { preSets, ); - if (options.limit == AddonModGlossaryProvider.LIMIT_ENTRIES) { + if (limit === AddonModGlossaryProvider.LIMIT_ENTRIES) { // Store entries in background, don't block the user for this. - CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, options.from, site.getId())); + CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, from, site.getId())); } return result; @@ -446,13 +446,13 @@ export class AddonModGlossaryProvider { site: CoreSite, options: AddonModGlossaryGetCategoriesOptions = {}, ): Promise { - options.from = options.from || 0; - options.limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES; + const from = options.from || 0; + const limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES; const params: AddonModGlossaryGetCategoriesWSParams = { id: glossaryId, - from: options.from, - limit: options.limit, + from, + limit, }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getCategoriesCacheKey(glossaryId), @@ -465,11 +465,12 @@ export class AddonModGlossaryProvider { const response = await site.read('mod_glossary_get_categories', params, preSets); categories = categories.concat(response.categories); - const canLoadMore = (options.from + options.limit) < response.count; + const canLoadMore = (from + limit) < response.count; if (canLoadMore) { - options.from += options.limit; - - return this.getCategories(glossaryId, categories, site, options); + return this.getCategories(glossaryId, categories, site, { + ...options, + from: from + limit, + }); } return categories;