From 8d6728101b93b159de178096cd3b71816332bad8 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 7 Sep 2018 15:41:48 +0200 Subject: [PATCH] MOBILE-2567 resource: Fix date displayed in course page --- src/addon/mod/resource/lang/en.json | 1 + .../mod/resource/providers/module-handler.ts | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/addon/mod/resource/lang/en.json b/src/addon/mod/resource/lang/en.json index 46a1f7e35..54d284bf5 100644 --- a/src/addon/mod/resource/lang/en.json +++ b/src/addon/mod/resource/lang/en.json @@ -1,5 +1,6 @@ { "errorwhileloadingthecontent": "Error while loading the content.", + "modifieddate": "Modified {{$a}}", "openthefile": "Open the file", "uploadeddate": "Uploaded {{$a}}" } \ No newline at end of file diff --git a/src/addon/mod/resource/providers/module-handler.ts b/src/addon/mod/resource/providers/module-handler.ts index 79700acb2..b44775b42 100644 --- a/src/addon/mod/resource/providers/module-handler.ts +++ b/src/addon/mod/resource/providers/module-handler.ts @@ -156,16 +156,24 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { if (options.showtype) { extra.push(this.mimetypeUtils.getMimetypeDescription(file)); } + + if (options.showdate) { + /* Modified date may be up to several minutes later than uploaded date just because + teacher did not submit the form promptly. Give teacher up to 5 minutes to do it. */ + if (file.timemodified > file.timecreated + CoreConstants.SECONDS_MINUTE * 5) { + extra.push(this.translate.instant('addon.mod_resource.modifieddate', + {$a: moment(file.timemodified * 1000).format('LLL')})); + } else { + extra.push(this.translate.instant('addon.mod_resource.uploadeddate', + {$a: moment(file.timecreated * 1000).format('LLL')})); + } + } } if (resourceData.icon == '') { resourceData.icon = this.courseProvider.getModuleIconSrc(this.modName); } - if (options.showdate) { - extra.push(this.translate.instant('addon.mod_resource.uploadeddate', - {$a: moment(resourceInfo.timemodified * 1000).format('LLL')})); - } resourceData.extra += extra.join(' '); return resourceData;