From 65f18cc6700a55728e5368fe681854947c0251da Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 11 Jun 2021 15:49:16 +0200 Subject: [PATCH 1/8] MOBILE-3320 workshop: Fix attachments not sent in new submissions --- .../pages/edit-submission/edit-submission.html | 2 +- .../workshop/pages/edit-submission/edit-submission.ts | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.html b/src/addons/mod/workshop/pages/edit-submission/edit-submission.html index f66fd99d1..65485c52c 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.html +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.html @@ -37,7 +37,7 @@ elementId="content_editor" [draftExtraParams]="editorExtraParams"> - diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts index b43f9e008..05a0f6218 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts @@ -20,7 +20,6 @@ import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fi import { CanLeave } from '@guards/can-leave'; import { CoreFile } from '@services/file'; import { CoreFileEntry, CoreFileHelper } from '@services/file-helper'; -import { CoreFileSession } from '@services/file-session'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreSync } from '@services/sync'; @@ -67,6 +66,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca textRequired = false; fileAvailable = false; fileRequired = false; + attachments: CoreFileEntry[] = []; protected workshopId!: number; protected submissionId = 0; @@ -211,14 +211,9 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca this.editForm.controls['title'].setValue(this.submission.title); this.editForm.controls['content'].setValue(this.submission.content); + this.attachments = this.submission.attachmentfiles || []; } - CoreFileSession.setFiles( - this.component, - this.getFilesComponentId(), - this.submission?.attachmentfiles || [], - ); - this.loaded = true; } catch (error) { this.loaded = false; @@ -254,7 +249,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca } if (this.fileAvailable) { - values.attachmentfiles = CoreFileSession.getFiles(this.component, this.getFilesComponentId()) || []; + values.attachmentfiles = this.attachments; } return values; From 0075a3880faa3e41571a0b39b877af88bf061d33 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 11 Jun 2021 16:23:40 +0200 Subject: [PATCH 2/8] MOBILE-3320 workshop: Fix filesObject.online.length error --- src/addons/mod/data/services/data-helper.ts | 8 ++++---- .../workshop/pages/edit-submission/edit-submission.ts | 10 ++++++---- src/addons/mod/workshop/services/workshop.ts | 9 ++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts index ee4ef04e3..9fc836dda 100644 --- a/src/addons/mod/data/services/data-helper.ts +++ b/src/addons/mod/data/services/data-helper.ts @@ -802,14 +802,14 @@ export class AddonModDataHelperProvider { offline: boolean, siteId?: string, ): Promise { - if (!files.length) { - return 0; - } - if (offline) { return this.storeFiles(dataId, entryId, fieldId, files, siteId); } + if (!files.length) { + return 0; + } + return CoreFileUploader.uploadOrReuploadFiles(files, AddonModDataProvider.COMPONENT, itemId, siteId); } diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts index 05a0f6218..3cc680eb7 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts @@ -332,7 +332,9 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca // Upload attachments first if any. let allowOffline = !inputData.attachmentfiles.length; try { - let attachmentsId: CoreFileUploaderStoreFilesResult | number | undefined; + let attachmentsId: number | undefined; + let storeFilesResult: CoreFileUploaderStoreFilesResult | undefined; + try { attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( this.workshopId, @@ -344,7 +346,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca saveOffline = true; allowOffline = true; - attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( + storeFilesResult = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( this.workshopId, inputData.attachmentfiles, true, @@ -364,7 +366,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca this.courseId, inputData.title, inputData.content, - attachmentsId as CoreFileUploaderStoreFilesResult, + storeFilesResult, submissionId, AddonModWorkshopAction.UPDATE, ); @@ -391,7 +393,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca this.courseId, inputData.title, inputData.content, - attachmentsId as CoreFileUploaderStoreFilesResult, + storeFilesResult, undefined, AddonModWorkshopAction.ADD, ); diff --git a/src/addons/mod/workshop/services/workshop.ts b/src/addons/mod/workshop/services/workshop.ts index 7946c70c2..ba637e2ff 100644 --- a/src/addons/mod/workshop/services/workshop.ts +++ b/src/addons/mod/workshop/services/workshop.ts @@ -17,7 +17,6 @@ import { CoreError } from '@classes/errors/error'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseLogHelper } from '@features/course/services/log-helper'; -import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; import { CoreGradesMenuItem } from '@features/grades/services/grades-helper'; import { CoreApp } from '@services/app'; import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; @@ -718,7 +717,7 @@ export class AddonModWorkshopProvider { courseId: number, title: string, content: string, - attachmentsId?: number | CoreFileUploaderStoreFilesResult, + attachmentsId?: number, siteId?: string, allowOffline: boolean = false, ): Promise { @@ -731,7 +730,7 @@ export class AddonModWorkshopProvider { courseId, title, content, - attachmentsId as CoreFileUploaderStoreFilesResult, + undefined, undefined, AddonModWorkshopAction.ADD, siteId, @@ -814,7 +813,7 @@ export class AddonModWorkshopProvider { courseId: number, title: string, content: string, - attachmentsId?: CoreFileUploaderStoreFilesResult | number | undefined, + attachmentsId?: number | undefined, siteId?: string, allowOffline: boolean = false, ): Promise { @@ -827,7 +826,7 @@ export class AddonModWorkshopProvider { courseId, title, content, - attachmentsId as CoreFileUploaderStoreFilesResult, + undefined, submissionId, AddonModWorkshopAction.UPDATE, siteId, From 4a34dab79023a626bb7643c120aeb9c410384d58 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 14 Jun 2021 08:56:44 +0200 Subject: [PATCH 3/8] MOBILE-3320 ios: Fix video posters not displayed sometimes --- src/core/directives/external-content.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/directives/external-content.ts b/src/core/directives/external-content.ts index e8a6975d8..7bda6336e 100644 --- a/src/core/directives/external-content.ts +++ b/src/core/directives/external-content.ts @@ -277,6 +277,13 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges { this.loaded = false; this.waitForLoad(); } + + if (targetAttr == 'poster') { + // Setting the poster immediately doesn't display it in some cases. Set it to empty and then set the right one. + this.element.setAttribute(targetAttr, ''); + await CoreUtils.nextTick(); + } + this.element.setAttribute(targetAttr, finalUrl); this.element.setAttribute('data-original-' + targetAttr, url); } From 9ddce87347dbe8664eaaafc7f9640190c041443d Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 14 Jun 2021 10:47:24 +0200 Subject: [PATCH 4/8] MOBILE-3320 android: Fix subtitles in videos not seen --- src/core/directives/external-content.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/directives/external-content.ts b/src/core/directives/external-content.ts index 7bda6336e..188a27ee1 100644 --- a/src/core/directives/external-content.ts +++ b/src/core/directives/external-content.ts @@ -188,7 +188,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges { if (tagName == 'VIDEO' && targetAttr != 'poster') { const video = this.element; if (video.textTracks) { - // It's a video with subtitles. In iOS, subtitles position is wrong so it needs to be fixed. + // It's a video with subtitles. Fix some issues with subtitles. video.textTracks.onaddtrack = (event): void => { const track = event.track; if (track) { @@ -248,6 +248,11 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges { true, downloadUnknown, ); + } else if (tagName === 'TRACK') { + // Download tracks right away. Using an online URL for tracks can give a CORS error in Android. + finalUrl = await CoreFilepool.downloadUrl(site.getId(), url, false, this.component, this.componentId); + + finalUrl = CoreFile.convertFileSrc(finalUrl); } else { finalUrl = await CoreFilepool.getUrlByUrl( site.getId(), From 11f47a7f7c29fb843c095933df02ec20ec0a3207 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 14 Jun 2021 13:09:37 +0200 Subject: [PATCH 5/8] MOBILE-3320 survey: Fix page not updated after auto sync --- src/addons/mod/survey/components/index/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/addons/mod/survey/components/index/index.ts b/src/addons/mod/survey/components/index/index.ts index 8979f9e03..0be63e920 100644 --- a/src/addons/mod/survey/components/index/index.ts +++ b/src/addons/mod/survey/components/index/index.ts @@ -32,7 +32,12 @@ import { } from '../../services/survey'; import { AddonModSurveyHelper, AddonModSurveyQuestionFormatted } from '../../services/survey-helper'; import { AddonModSurveyOffline } from '../../services/survey-offline'; -import { AddonModSurveyAutoSyncData, AddonModSurveySync, AddonModSurveySyncResult } from '../../services/survey-sync'; +import { + AddonModSurveyAutoSyncData, + AddonModSurveySync, + AddonModSurveySyncProvider, + AddonModSurveySyncResult, +} from '../../services/survey-sync'; /** * Component that displays a survey. @@ -52,6 +57,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo answers: Record = {}; protected currentUserId?: number; + protected syncEventName = AddonModSurveySyncProvider.AUTO_SYNCED; constructor( protected content?: IonContent, From ad56eeb203b68b3cba1eecbe697068d2415a8a19 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 14 Jun 2021 14:03:36 +0200 Subject: [PATCH 6/8] MOBILE-3320 wiki: Fix animation when going back to home page --- src/addons/mod/wiki/components/index/index.ts | 2 +- src/core/services/navigator.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/addons/mod/wiki/components/index/index.ts b/src/addons/mod/wiki/components/index/index.ts index 355c38e7b..6fd242ed7 100644 --- a/src/addons/mod/wiki/components/index/index.ts +++ b/src/addons/mod/wiki/components/index/index.ts @@ -590,7 +590,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp if (modalData) { if (modalData.home) { // Go back to the initial page of the wiki. - CoreNavigator.navigateToSitePath(modalData.home); + CoreNavigator.navigateToSitePath(modalData.home, { animationDirection: 'back' }); } else if (modalData.page) { this.goToPage(modalData.page); } diff --git a/src/core/services/navigator.ts b/src/core/services/navigator.ts index b31e38079..7d15cfa9e 100644 --- a/src/core/services/navigator.ts +++ b/src/core/services/navigator.ts @@ -44,8 +44,7 @@ export type CoreRedirectPayload = { /** * Navigation options. */ -export type CoreNavigationOptions = { - animated?: boolean; +export type CoreNavigationOptions = Pick & { params?: Params; reset?: boolean; preferCurrentTab?: boolean; // Default true. @@ -132,6 +131,8 @@ export class CoreNavigatorService { const url: string[] = [/^[./]/.test(path) ? path : `./${path}`]; const navigationOptions: NavigationOptions = CoreObject.withoutEmpty({ animated: options.animated, + animation: options.animation, + animationDirection: options.animationDirection, queryParams: CoreObject.isEmpty(options.params ?? {}) ? null : CoreObject.withoutEmpty(options.params), relativeTo: path.startsWith('/') ? null : this.getCurrentRoute(), }); From 007a7c857e73602afd3265ea4991b49093703e45 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 14 Jun 2021 15:28:04 +0200 Subject: [PATCH 7/8] MOBILE-3320 calendar: Fix days/events not selected using VoiceOver --- .../calendar/components/calendar/addon-calendar-calendar.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/addons/calendar/components/calendar/addon-calendar-calendar.html b/src/addons/calendar/components/calendar/addon-calendar-calendar.html index a0aae3188..93d477d00 100644 --- a/src/addons/calendar/components/calendar/addon-calendar-calendar.html +++ b/src/addons/calendar/components/calendar/addon-calendar-calendar.html @@ -56,11 +56,11 @@ "duration_finish": day.haslastdayofevent }' [class.addon-calendar-event-past-day]="isPastMonth || day.ispast" - role="button cell" + role="cell" tabindex="0" (ariaButtonClick)="dayClicked(day.mday)" > -

+

{{ day.periodName | translate }}

From b2a051723bb91508028550b38850e3a749d649d2 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 15 Jun 2021 08:40:02 +0200 Subject: [PATCH 8/8] MOBILE-3320 quiz: Fix scroll after clicking Check button --- src/addons/mod/quiz/pages/player/player.page.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/addons/mod/quiz/pages/player/player.page.ts b/src/addons/mod/quiz/pages/player/player.page.ts index 8740e8d7d..27ea916c6 100644 --- a/src/addons/mod/quiz/pages/player/player.page.ts +++ b/src/addons/mod/quiz/pages/player/player.page.ts @@ -215,7 +215,6 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { // Reload the current page. const scrollElement = await this.content?.getScrollElement(); const scrollTop = scrollElement?.scrollTop || -1; - const scrollLeft = scrollElement?.scrollLeft || -1; this.loaded = false; this.content?.scrollToTop(); // Scroll top so the spinner is seen. @@ -224,8 +223,11 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { await this.loadPage(this.attempt!.currentpage!); } finally { this.loaded = true; - if (scrollTop != -1 && scrollLeft != -1) { - this.content?.scrollToPoint(scrollLeft, scrollTop); + if (scrollTop != -1) { + // Wait for content to be rendered. + setTimeout(() => { + this.content?.scrollToPoint(0, scrollTop); + }, 50); } } } catch (error) {