Skip to content

Commit 38f4dcd

Browse files
authored
Merge pull request #3837 from dpalou/MOBILE-4362
Mobile 4362
2 parents 16046c1 + e9601ae commit 38f4dcd

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

src/addons/mod/glossary/services/glossary.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,16 @@ export class AddonModGlossaryProvider {
291291
glossaryId: number,
292292
options: AddonModGlossaryGetEntriesOptions = {},
293293
): Promise<AddonModGlossaryGetEntriesWSResponse> {
294-
options.from = options.from || 0;
295-
options.limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES;
294+
const from = options.from || 0;
295+
const limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES;
296296

297297
const site = await CoreSites.getSite(options.siteId);
298298

299299
const params: AddonModGlossaryGetEntriesByLetterWSParams = {
300300
id: glossaryId,
301301
letter: 'ALL',
302-
from: options.from,
303-
limit: options.limit,
302+
from,
303+
limit,
304304
};
305305
const preSets: CoreSiteWSPreSets = {
306306
cacheKey: this.getEntriesByLetterCacheKey(glossaryId),
@@ -316,9 +316,9 @@ export class AddonModGlossaryProvider {
316316
preSets,
317317
);
318318

319-
if (options.limit == AddonModGlossaryProvider.LIMIT_ENTRIES) {
319+
if (limit === AddonModGlossaryProvider.LIMIT_ENTRIES) {
320320
// Store entries in background, don't block the user for this.
321-
CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, options.from, site.getId()));
321+
CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, from, site.getId()));
322322
}
323323

324324
return result;
@@ -446,13 +446,13 @@ export class AddonModGlossaryProvider {
446446
site: CoreSite,
447447
options: AddonModGlossaryGetCategoriesOptions = {},
448448
): Promise<AddonModGlossaryCategory[]> {
449-
options.from = options.from || 0;
450-
options.limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES;
449+
const from = options.from || 0;
450+
const limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES;
451451

452452
const params: AddonModGlossaryGetCategoriesWSParams = {
453453
id: glossaryId,
454-
from: options.from,
455-
limit: options.limit,
454+
from,
455+
limit,
456456
};
457457
const preSets: CoreSiteWSPreSets = {
458458
cacheKey: this.getCategoriesCacheKey(glossaryId),
@@ -465,11 +465,12 @@ export class AddonModGlossaryProvider {
465465
const response = await site.read<AddonModGlossaryGetCategoriesWSResponse>('mod_glossary_get_categories', params, preSets);
466466

467467
categories = categories.concat(response.categories);
468-
const canLoadMore = (options.from + options.limit) < response.count;
468+
const canLoadMore = (from + limit) < response.count;
469469
if (canLoadMore) {
470-
options.from += options.limit;
471-
472-
return this.getCategories(glossaryId, categories, site, options);
470+
return this.getCategories(glossaryId, categories, site, {
471+
...options,
472+
from: from + limit,
473+
});
473474
}
474475

475476
return categories;

src/addons/mod/workshop/services/workshop.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,23 +1100,25 @@ export class AddonModWorkshopProvider {
11001100
const args: string[] = field.name.split('_');
11011101
const name = args[0];
11021102
const idx = args[3];
1103-
const idy = args[6] || false;
1103+
const idy = args[6];
1104+
const idxNumber = parseInt(args[3], 10);
1105+
const idyNumber = parseInt(args[6], 10);
11041106

1105-
if (parseInt(idx, 10) + '' == idx) {
1107+
if (!isNaN(idxNumber)) {
11061108
if (!parsedFields[idx]) {
11071109
parsedFields[idx] = {
1108-
number: idx + 1, // eslint-disable-line id-blacklist
1110+
number: idxNumber + 1, // eslint-disable-line id-blacklist
11091111
};
11101112
}
11111113

1112-
if (idy && parseInt(idy, 10) + '' == idy) {
1114+
if (!isNaN(idyNumber)) {
11131115
if (!parsedFields[idx].fields) {
11141116
parsedFields[idx].fields = [];
11151117
}
11161118

11171119
if (!parsedFields[idx].fields[idy]) {
11181120
parsedFields[idx].fields[idy] = {
1119-
number: idy + 1, // eslint-disable-line id-blacklist
1121+
number: idyNumber + 1, // eslint-disable-line id-blacklist
11201122
};
11211123
}
11221124
parsedFields[idx].fields[idy][name] = field.value;

src/addons/mod/workshop/tests/behat/basic_usage.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Feature: Test basic usage of workshop activity in app
8383
Then I should find "Task to do" within "Assess peers" "ion-item" in the app
8484

8585
When I press "The Answer" in the app
86-
And I press "Grade for Aspect 01" in the app
86+
And I press "Grade for Aspect 1" in the app
8787
And I press "10 / 10" in the app
8888
And I press "Save" in the app
8989
Then I should find "Assessed submission" in the app

0 commit comments

Comments
 (0)