diff --git a/src/addon/mod/forum/providers/module-handler.ts b/src/addon/mod/forum/providers/module-handler.ts index a44a05c3a..6a6d997ae 100644 --- a/src/addon/mod/forum/providers/module-handler.ts +++ b/src/addon/mod/forum/providers/module-handler.ts @@ -77,7 +77,13 @@ export class AddonModForumModuleHandler implements CoreCourseModuleHandler { } }; - this.updateExtraBadge(data, courseId, module.id); + if (typeof module.afterlink != 'undefined') { + data.extraBadgeColor = ''; + const match = />(\d+)[^<]+/.exec(module.afterlink); + data.extraBadge = match ? this.translate.instant('addon.mod_forum.unreadpostsnumber', {$a : match[1] }) : ''; + } else { + this.updateExtraBadge(data, courseId, module.id); + } const event = this.eventsProvider.on(AddonModForumProvider.MARK_READ_EVENT, (eventData) => { if (eventData.courseId == courseId && eventData.moduleId == module.id) { diff --git a/src/addon/mod/resource/providers/module-handler.ts b/src/addon/mod/resource/providers/module-handler.ts index a03592261..e6e9e6278 100644 --- a/src/addon/mod/resource/providers/module-handler.ts +++ b/src/addon/mod/resource/providers/module-handler.ts @@ -134,27 +134,30 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { */ protected getResourceData(module: any, courseId: number, handlerData: CoreCourseModuleHandlerData): Promise { const promises = []; - let resourceInfo; + let infoFiles = [], + options: any = {}; // Check if the button needs to be shown or not. This also loads the module contents. promises.push(this.hideOpenButton(module, courseId).then((hideOpenButton) => { handlerData.buttons[0].hidden = hideOpenButton; })); - if (this.resourceProvider.isGetResourceWSAvailable()) { + if (typeof module.customdata != 'undefined') { + options = this.textUtils.unserialize(this.textUtils.parseJSON(module.customdata)); + } else if (this.resourceProvider.isGetResourceWSAvailable()) { // Get the resource data. promises.push(this.resourceProvider.getResourceData(courseId, module.id).then((info) => { - resourceInfo = info; + infoFiles = info.contentfiles; + options = this.textUtils.unserialize(info.displayoptions); })); } return Promise.all(promises).then(() => { - const files = module.contents && module.contents.length ? module.contents : resourceInfo && resourceInfo.contentfiles, + const files = module.contents && module.contents.length ? module.contents : infoFiles, resourceData = { icon: '', extra: '' }, - options = (resourceInfo && this.textUtils.unserialize(resourceInfo.displayoptions)) || {}, extra = []; if (files && files.length) { @@ -162,19 +165,32 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { resourceData.icon = this.mimetypeUtils.getFileIcon(file.filename); if (options.showsize) { - const size = files.reduce((result, file) => { - return result + file.filesize; - }, 0); + let size; + if (options.filedetails) { + size = options.filedetails.size; + } else { + size = files.reduce((result, file) => { + return result + file.filesize; + }, 0); + } extra.push(this.textUtils.bytesToSize(size, 1)); } + if (options.showtype) { + // We should take it from options.filedetails.size if avalaible ∫but it's already translated. 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) { + if (options.filedetails && options.filedetails.modifieddate) { + extra.push(this.translate.instant('addon.mod_resource.modifieddate', + {$a: moment(options.filedetails.modifieddate * 1000).format('LLL')})); + } else if (options.filedetails && options.filedetails.uploadeddate) { + extra.push(this.translate.instant('addon.mod_resource.uploadeddate', + {$a: moment(options.filedetails.uploadeddate * 1000).format('LLL')})); + } else if (file.timemodified > file.timecreated + CoreConstants.SECONDS_MINUTE * 5) { + /* 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. */ extra.push(this.translate.instant('addon.mod_resource.modifieddate', {$a: moment(file.timemodified * 1000).format('LLL')})); } else { diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index aa708ae69..73ac7e3a4 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -152,11 +152,17 @@ export class CoreCourseHelperProvider { module.completiondata.courseName = courseName; module.completiondata.tracking = module.completion; module.completiondata.cmid = module.id; + + // Use of completionstatus is deprecated, use completiondata instead. + module.completionstatus = module.completiondata; } else if (completionStatus && typeof completionStatus[module.id] != 'undefined') { - // Not in use > 3.6. Check if activity has completions and if it's marked. + // Should not happen on > 3.6. Check if activity has completions and if it's marked. module.completiondata = completionStatus[module.id]; module.completiondata.courseId = courseId; module.completiondata.courseName = courseName; + + // Use of completionstatus is deprecated, use completiondata instead. + module.completionstatus = module.completiondata; } // Check if the module is stealth.