diff --git a/scripts/langindex.json b/scripts/langindex.json index d319bd42f..7d2407912 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -639,6 +639,8 @@ "addon.mod_forum.erroremptysubject": "forum", "addon.mod_forum.errorgetforum": "local_moodlemobileapp", "addon.mod_forum.errorgetgroups": "local_moodlemobileapp", + "addon.mod_forum.errorloadingsortingorder": "local_moodlemobileapp", + "addon.mod_forum.errorloadingsortingorderdetails": "local_moodlemobileapp", "addon.mod_forum.errorposttoallgroups": "local_moodlemobileapp", "addon.mod_forum.favourites": "forum", "addon.mod_forum.favouriteupdated": "forum", diff --git a/src/addons/mod/data/components/index/addon-mod-data-index.html b/src/addons/mod/data/components/index/addon-mod-data-index.html index e18e931ad..f168a9d2f 100644 --- a/src/addons/mod/data/components/index/addon-mod-data-index.html +++ b/src/addons/mod/data/components/index/addon-mod-data-index.html @@ -62,14 +62,14 @@ - + {{ 'addon.mod_data.resetsettings' | translate}} - +

@@ -105,7 +105,7 @@ - + diff --git a/src/addons/mod/data/components/index/index.ts b/src/addons/mod/data/components/index/index.ts index 1feb291b2..894ca5296 100644 --- a/src/addons/mod/data/components/index/index.ts +++ b/src/addons/mod/data/components/index/index.ts @@ -426,8 +426,13 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp /** * Reset all search filters and closes the modal. + * + * @param ev Event. */ - searchReset(): void { + searchReset(ev: Event): void { + ev.preventDefault(); + ev.stopPropagation(); + this.search.sortBy = '0'; this.search.sortDirection = 'DESC'; this.search.text = ''; diff --git a/src/addons/mod/forum/classes/forum-discussions-source.ts b/src/addons/mod/forum/classes/forum-discussions-source.ts index 4b35b9454..06a51ffdd 100644 --- a/src/addons/mod/forum/classes/forum-discussions-source.ts +++ b/src/addons/mod/forum/classes/forum-discussions-source.ts @@ -44,6 +44,7 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource groupInfo?: CoreGroupInfo; allPartsPermissions?: AddonModForumCanAddDiscussion; canAddDiscussionToGroup = true; + errorLoadingDiscussions = false; constructor(courseId: number, cmId: number, discussionsPathPrefix: string) { super(); @@ -222,13 +223,27 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource throw new Error('Can\'t load discussions without a forum or selected sort order'); } - const response = await AddonModForum.getDiscussions(this.forum.id, { - cmId: this.forum.cmid, - sortOrder: this.selectedSortOrder.value, - page, - groupId: this.groupId, - }); - let discussions = response.discussions; + let discussions: AddonModForumDiscussion[] = []; + let canLoadMore = false; + try { + const response = await AddonModForum.getDiscussions(this.forum.id, { + cmId: this.forum.cmid, + sortOrder: this.selectedSortOrder.value, + page, + groupId: this.groupId, + }); + + discussions = response.discussions; + canLoadMore = response.canLoadMore; + this.errorLoadingDiscussions = false; + } catch (error) { + if (page > 0 || CoreUtils.isWebServiceError(error)) { + throw error; + } + + // Error loading first discussions, use an empty list. + this.errorLoadingDiscussions = true; + } if (this.usesGroups) { discussions = await AddonModForum.formatDiscussionsGroups(this.forum.cmid, discussions); @@ -254,7 +269,7 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource } } - return { discussions, canLoadMore: response.canLoadMore }; + return { discussions, canLoadMore }; } /** diff --git a/src/addons/mod/forum/components/index/index.html b/src/addons/mod/forum/components/index/index.html index 4c6b1c123..e4d953a31 100644 --- a/src/addons/mod/forum/components/index/index.html +++ b/src/addons/mod/forum/components/index/index.html @@ -54,17 +54,22 @@
- - - -
+
+ + + + +

{{ 'addon.mod_forum.errorloadingsortingorderdetails' | translate }}

+
+ diff --git a/src/addons/mod/forum/components/index/index.ts b/src/addons/mod/forum/components/index/index.ts index 63d70a8d9..3dd733ad9 100644 --- a/src/addons/mod/forum/components/index/index.ts +++ b/src/addons/mod/forum/components/index/index.ts @@ -152,6 +152,10 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom return !!(this.forum && this.canAddDiscussion && this.discussions?.getSource().canAddDiscussionToGroup); } + get errorLoadingDiscussions(): boolean { + return !!this.discussions?.getSource().errorLoadingDiscussions; + } + /** * Check whether a discussion is online. * diff --git a/src/addons/mod/forum/lang.json b/src/addons/mod/forum/lang.json index fc6d78c16..b3146a6a7 100644 --- a/src/addons/mod/forum/lang.json +++ b/src/addons/mod/forum/lang.json @@ -28,6 +28,8 @@ "erroremptysubject": "Post subject cannot be empty.", "errorgetforum": "Error getting forum data.", "errorgetgroups": "Error getting group settings.", + "errorloadingsortingorder": "Forum not available in this sorting order", + "errorloadingsortingorderdetails": "Try changing the sorting order or going online to view this forum.", "errorposttoallgroups": "Could not create new discussion in all groups.", "favourites": "Starred", "favouriteupdated": "Your star option has been updated.", diff --git a/src/addons/mod/lesson/services/lesson.ts b/src/addons/mod/lesson/services/lesson.ts index 1d5a9ee78..c32b66b77 100644 --- a/src/addons/mod/lesson/services/lesson.ts +++ b/src/addons/mod/lesson/services/lesson.ts @@ -811,13 +811,13 @@ export class AddonModLessonProvider { const matches = studentAnswer.match(new RegExp(expectedAnswer, 'g' + ignoreCase)); if (matches) { isMatch = true; - const nb = matches[0].length; + const nb = matches.length; const original: string[] = []; const marked: string[] = []; for (let j = 0; j < nb; j++) { - original.push(matches[0][j]); - marked.push('' + matches[0][j] + ''); + original.push(matches[j]); + marked.push('' + matches[j] + ''); } for (let j = 0; j < original.length; j++) {