MOBILE-3019 forum: Display availabilty message
parent
4eeb3de749
commit
12ceba7eac
|
@ -487,6 +487,7 @@
|
||||||
"addon.mod_forum.cannotadddiscussionall": "forum",
|
"addon.mod_forum.cannotadddiscussionall": "forum",
|
||||||
"addon.mod_forum.cannotcreatediscussion": "forum",
|
"addon.mod_forum.cannotcreatediscussion": "forum",
|
||||||
"addon.mod_forum.couldnotadd": "forum",
|
"addon.mod_forum.couldnotadd": "forum",
|
||||||
|
"addon.mod_forum.cutoffdatereached": "forum",
|
||||||
"addon.mod_forum.discussion": "forum",
|
"addon.mod_forum.discussion": "forum",
|
||||||
"addon.mod_forum.discussionlocked": "forum",
|
"addon.mod_forum.discussionlocked": "forum",
|
||||||
"addon.mod_forum.discussionpinned": "forum",
|
"addon.mod_forum.discussionpinned": "forum",
|
||||||
|
@ -521,6 +522,8 @@
|
||||||
"addon.mod_forum.reply": "forum",
|
"addon.mod_forum.reply": "forum",
|
||||||
"addon.mod_forum.replyplaceholder": "forum",
|
"addon.mod_forum.replyplaceholder": "forum",
|
||||||
"addon.mod_forum.subject": "forum",
|
"addon.mod_forum.subject": "forum",
|
||||||
|
"addon.mod_forum.thisforumhasduedate": "forum",
|
||||||
|
"addon.mod_forum.thisforumisdue": "forum",
|
||||||
"addon.mod_forum.unpindiscussion": "forum",
|
"addon.mod_forum.unpindiscussion": "forum",
|
||||||
"addon.mod_forum.unread": "forum",
|
"addon.mod_forum.unread": "forum",
|
||||||
"addon.mod_forum.unreadpostsnumber": "forum",
|
"addon.mod_forum.unreadpostsnumber": "forum",
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
<ion-icon name="warning"></ion-icon> {{ 'core.hasdatatosync' | translate:{$a: moduleName} }}
|
<ion-icon name="warning"></ion-icon> {{ 'core.hasdatatosync' | translate:{$a: moduleName} }}
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
||||||
|
<!-- Cut-off date or due date message -->
|
||||||
|
<ion-card class="core-info-card" icon-start *ngIf="availabilityMessage">
|
||||||
|
<ion-icon name="information-circle"></ion-icon> {{ availabilityMessage }}
|
||||||
|
</ion-card>
|
||||||
|
|
||||||
<ng-container *ngIf="forum && discussions.length > 0">
|
<ng-container *ngIf="forum && discussions.length > 0">
|
||||||
<ion-card *ngFor="let discussion of offlineDiscussions" (click)="openNewDiscussion(discussion.timecreated)" [class.addon-forum-discussion-selected]="discussion.timecreated == -selectedDiscussion">
|
<ion-card *ngFor="let discussion of offlineDiscussions" (click)="openNewDiscussion(discussion.timecreated)" [class.addon-forum-discussion-selected]="discussion.timecreated == -selectedDiscussion">
|
||||||
<ion-item text-wrap>
|
<ion-item text-wrap>
|
||||||
|
|
|
@ -49,6 +49,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
||||||
offlineDiscussions = [];
|
offlineDiscussions = [];
|
||||||
selectedDiscussion = 0; // Disucssion ID or negative timecreated if it's an offline discussion.
|
selectedDiscussion = 0; // Disucssion ID or negative timecreated if it's an offline discussion.
|
||||||
addDiscussionText = this.translate.instant('addon.mod_forum.addanewdiscussion');
|
addDiscussionText = this.translate.instant('addon.mod_forum.addanewdiscussion');
|
||||||
|
availabilityMessage: string;
|
||||||
|
|
||||||
protected syncEventName = AddonModForumSyncProvider.AUTO_SYNCED;
|
protected syncEventName = AddonModForumSyncProvider.AUTO_SYNCED;
|
||||||
protected page = 0;
|
protected page = 0;
|
||||||
|
@ -168,6 +169,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
||||||
if (typeof forum.istracked != 'undefined') {
|
if (typeof forum.istracked != 'undefined') {
|
||||||
this.trackPosts = forum.istracked;
|
this.trackPosts = forum.istracked;
|
||||||
}
|
}
|
||||||
|
this.availabilityMessage = this.forumHelper.getAvailabilityMessage(forum);
|
||||||
|
|
||||||
this.dataRetrieved.emit(forum);
|
this.dataRetrieved.emit(forum);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"cannotadddiscussionall": "You do not have permission to add a new discussion topic for all participants.",
|
"cannotadddiscussionall": "You do not have permission to add a new discussion topic for all participants.",
|
||||||
"cannotcreatediscussion": "Could not create new discussion",
|
"cannotcreatediscussion": "Could not create new discussion",
|
||||||
"couldnotadd": "Could not add your post due to an unknown error",
|
"couldnotadd": "Could not add your post due to an unknown error",
|
||||||
|
"cutoffdatereached": "The cut-off date for posting to this forum is reached so you can no longer post to it.",
|
||||||
"discussion": "Discussion",
|
"discussion": "Discussion",
|
||||||
"discussionlocked": "This discussion has been locked so you can no longer reply to it.",
|
"discussionlocked": "This discussion has been locked so you can no longer reply to it.",
|
||||||
"discussionpinned": "Pinned",
|
"discussionpinned": "Pinned",
|
||||||
|
@ -42,6 +43,8 @@
|
||||||
"reply": "Reply",
|
"reply": "Reply",
|
||||||
"replyplaceholder": "Write your reply...",
|
"replyplaceholder": "Write your reply...",
|
||||||
"subject": "Subject",
|
"subject": "Subject",
|
||||||
|
"thisforumhasduedate": "The due date for posting to this forum is {{$a}}.",
|
||||||
|
"thisforumisdue": "The due date for posting to this forum was {{$a}}.",
|
||||||
"unpindiscussion": "Unpin this discussion",
|
"unpindiscussion": "Unpin this discussion",
|
||||||
"unread": "Unread",
|
"unread": "Unread",
|
||||||
"unreadpostsnumber": "{{$a}} unread posts"
|
"unreadpostsnumber": "{{$a}} unread posts"
|
||||||
|
|
|
@ -32,8 +32,13 @@
|
||||||
<ion-icon name="warning"></ion-icon> {{ 'core.hasdatatosync' | translate:{$a: discussionStr} }}
|
<ion-icon name="warning"></ion-icon> {{ 'core.hasdatatosync' | translate:{$a: discussionStr} }}
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
||||||
<ion-card class="core-warning-card" *ngIf="discussion && discussion.locked">
|
<!-- Cut-off date or due date message -->
|
||||||
<ion-icon name="warning"></ion-icon> {{ 'addon.mod_forum.discussionlocked' | translate }}
|
<ion-card class="core-info-card" icon-start *ngIf="availabilityMessage">
|
||||||
|
<ion-icon name="information-circle"></ion-icon> {{ availabilityMessage }}
|
||||||
|
</ion-card>
|
||||||
|
|
||||||
|
<ion-card class="core-info-card" icon-start *ngIf="discussion && discussion.locked">
|
||||||
|
<ion-icon name="information-circle"></ion-icon> {{ 'addon.mod_forum.discussionlocked' | translate }}
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
||||||
<ion-card *ngIf="discussion" margin-bottom class="highlight">
|
<ion-card *ngIf="discussion" margin-bottom class="highlight">
|
||||||
|
|
|
@ -77,6 +77,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
component = AddonModForumProvider.COMPONENT;
|
component = AddonModForumProvider.COMPONENT;
|
||||||
cmId: number;
|
cmId: number;
|
||||||
canPin = false;
|
canPin = false;
|
||||||
|
availabilityMessage: string;
|
||||||
|
|
||||||
protected forumId: number;
|
protected forumId: number;
|
||||||
protected postId: number;
|
protected postId: number;
|
||||||
|
@ -311,6 +312,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
this.forumId = forum.id;
|
this.forumId = forum.id;
|
||||||
this.cmId = forum.cmid;
|
this.cmId = forum.cmid;
|
||||||
this.forum = forum;
|
this.forum = forum;
|
||||||
|
this.availabilityMessage = this.forumHelper.getAvailabilityMessage(forum);
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
|
@ -460,6 +462,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
this.syncIcon = 'spinner';
|
this.syncIcon = 'spinner';
|
||||||
|
|
||||||
const promises = [
|
const promises = [
|
||||||
|
this.forumProvider.invalidateForumData(this.courseId),
|
||||||
this.forumProvider.invalidateDiscussionPosts(this.discussionId),
|
this.forumProvider.invalidateDiscussionPosts(this.discussionId),
|
||||||
this.forumProvider.invalidateAccessInformation(this.forumId)
|
this.forumProvider.invalidateAccessInformation(this.forumId)
|
||||||
];
|
];
|
||||||
|
|
|
@ -13,9 +13,11 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreFileProvider } from '@providers/file';
|
import { CoreFileProvider } from '@providers/file';
|
||||||
import { CoreFileUploaderProvider } from '@core/fileuploader/providers/fileuploader';
|
import { CoreFileUploaderProvider } from '@core/fileuploader/providers/fileuploader';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
|
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||||
import { CoreUserProvider } from '@core/user/providers/user';
|
import { CoreUserProvider } from '@core/user/providers/user';
|
||||||
import { AddonModForumProvider } from './forum';
|
import { AddonModForumProvider } from './forum';
|
||||||
import { AddonModForumOfflineProvider } from './offline';
|
import { AddonModForumOfflineProvider } from './offline';
|
||||||
|
@ -25,9 +27,11 @@ import { AddonModForumOfflineProvider } from './offline';
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AddonModForumHelperProvider {
|
export class AddonModForumHelperProvider {
|
||||||
constructor(private fileProvider: CoreFileProvider,
|
constructor(private translate: TranslateService,
|
||||||
|
private fileProvider: CoreFileProvider,
|
||||||
private sitesProvider: CoreSitesProvider,
|
private sitesProvider: CoreSitesProvider,
|
||||||
private uploaderProvider: CoreFileUploaderProvider,
|
private uploaderProvider: CoreFileUploaderProvider,
|
||||||
|
private timeUtils: CoreTimeUtilsProvider,
|
||||||
private userProvider: CoreUserProvider,
|
private userProvider: CoreUserProvider,
|
||||||
private forumProvider: AddonModForumProvider,
|
private forumProvider: AddonModForumProvider,
|
||||||
private forumOffline: AddonModForumOfflineProvider) {}
|
private forumOffline: AddonModForumOfflineProvider) {}
|
||||||
|
@ -122,6 +126,28 @@ export class AddonModForumHelperProvider {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the availability message of the given forum.
|
||||||
|
*
|
||||||
|
* @param {any} forum Forum instance.
|
||||||
|
* @return {string} Message or null if the forum has no cut-off or due date.
|
||||||
|
*/
|
||||||
|
getAvailabilityMessage(forum: any): string {
|
||||||
|
if (this.isCutoffDateReached(forum)) {
|
||||||
|
return this.translate.instant('addon.mod_forum.cutoffdatereached');
|
||||||
|
} else if (this.isDueDateReached(forum)) {
|
||||||
|
const dueDate = this.timeUtils.userDate(forum.duedate * 1000);
|
||||||
|
|
||||||
|
return this.translate.instant('addon.mod_forum.thisforumisdue', {$a: dueDate});
|
||||||
|
} else if (forum.duedate > 0) {
|
||||||
|
const dueDate = this.timeUtils.userDate(forum.duedate * 1000);
|
||||||
|
|
||||||
|
return this.translate.instant('addon.mod_forum.thisforumhasduedate', {$a: dueDate});
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a forum discussion by id.
|
* Get a forum discussion by id.
|
||||||
*
|
*
|
||||||
|
@ -207,6 +233,30 @@ export class AddonModForumHelperProvider {
|
||||||
return this.uploaderProvider.areFileListDifferent(post.files, original.files);
|
return this.uploaderProvider.areFileListDifferent(post.files, original.files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the cutoff date for the forum reached?
|
||||||
|
*
|
||||||
|
* @param {any} forum Forum instance.
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
isCutoffDateReached(forum: any): boolean {
|
||||||
|
const now = Date.now() / 1000;
|
||||||
|
|
||||||
|
return forum.cutoffdate > 0 && forum.cutoffdate < now;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the due date for the forum reached?
|
||||||
|
*
|
||||||
|
* @param {any} forum Forum instance.
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
isDueDateReached(forum: any): boolean {
|
||||||
|
const now = Date.now() / 1000;
|
||||||
|
|
||||||
|
return forum.duedate > 0 && forum.duedate < now;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a list of files (either online files or local files), store the local files in a local folder
|
* Given a list of files (either online files or local files), store the local files in a local folder
|
||||||
* to be submitted later.
|
* to be submitted later.
|
||||||
|
|
|
@ -487,6 +487,7 @@
|
||||||
"addon.mod_forum.cannotadddiscussionall": "You do not have permission to add a new discussion topic for all participants.",
|
"addon.mod_forum.cannotadddiscussionall": "You do not have permission to add a new discussion topic for all participants.",
|
||||||
"addon.mod_forum.cannotcreatediscussion": "Could not create new discussion",
|
"addon.mod_forum.cannotcreatediscussion": "Could not create new discussion",
|
||||||
"addon.mod_forum.couldnotadd": "Could not add your post due to an unknown error",
|
"addon.mod_forum.couldnotadd": "Could not add your post due to an unknown error",
|
||||||
|
"addon.mod_forum.cutoffdatereached": "The cut-off date for posting to this forum is reached so you can no longer post to it.",
|
||||||
"addon.mod_forum.discussion": "Discussion",
|
"addon.mod_forum.discussion": "Discussion",
|
||||||
"addon.mod_forum.discussionlocked": "This discussion has been locked so you can no longer reply to it.",
|
"addon.mod_forum.discussionlocked": "This discussion has been locked so you can no longer reply to it.",
|
||||||
"addon.mod_forum.discussionpinned": "Pinned",
|
"addon.mod_forum.discussionpinned": "Pinned",
|
||||||
|
@ -521,6 +522,8 @@
|
||||||
"addon.mod_forum.reply": "Reply",
|
"addon.mod_forum.reply": "Reply",
|
||||||
"addon.mod_forum.replyplaceholder": "Write your reply...",
|
"addon.mod_forum.replyplaceholder": "Write your reply...",
|
||||||
"addon.mod_forum.subject": "Subject",
|
"addon.mod_forum.subject": "Subject",
|
||||||
|
"addon.mod_forum.thisforumhasduedate": "The due date for posting to this forum is {{$a}}.",
|
||||||
|
"addon.mod_forum.thisforumisdue": "The due date for posting to this forum was {{$a}}.",
|
||||||
"addon.mod_forum.unpindiscussion": "Unpin this discussion",
|
"addon.mod_forum.unpindiscussion": "Unpin this discussion",
|
||||||
"addon.mod_forum.unread": "Unread",
|
"addon.mod_forum.unread": "Unread",
|
||||||
"addon.mod_forum.unreadpostsnumber": "{{$a}} unread posts",
|
"addon.mod_forum.unreadpostsnumber": "{{$a}} unread posts",
|
||||||
|
@ -1263,10 +1266,12 @@
|
||||||
"core.course.activitynotyetviewablesiteupgradeneeded": "Your organisation's Moodle installation needs to be updated.",
|
"core.course.activitynotyetviewablesiteupgradeneeded": "Your organisation's Moodle installation needs to be updated.",
|
||||||
"core.course.allsections": "All sections",
|
"core.course.allsections": "All sections",
|
||||||
"core.course.askadmintosupport": "Contact the site administrator and tell them you want to use this activity with the Moodle Mobile app.",
|
"core.course.askadmintosupport": "Contact the site administrator and tell them you want to use this activity with the Moodle Mobile app.",
|
||||||
|
"core.course.availablespace": " You currently have about {{available}} free space.",
|
||||||
"core.course.confirmdeletemodulefiles": "Are you sure you want to delete these files?",
|
"core.course.confirmdeletemodulefiles": "Are you sure you want to delete these files?",
|
||||||
"core.course.confirmdownload": "You are about to download {{size}}. Are you sure you want to continue?",
|
"core.course.confirmdownload": "You are about to download {{size}}.{{availableSpace}} Are you sure you want to continue?",
|
||||||
"core.course.confirmdownloadunknownsize": "It was not possible to calculate the size of the download. Are you sure you want to continue?",
|
"core.course.confirmdownloadunknownsize": "It was not possible to calculate the size of the download.{{availableSpace}} Are you sure you want to continue?",
|
||||||
"core.course.confirmpartialdownloadsize": "You are about to download <strong>at least</strong> {{size}}. Are you sure you want to continue?",
|
"core.course.confirmlimiteddownload": "You are not currently connected to WiFi. ",
|
||||||
|
"core.course.confirmpartialdownloadsize": "You are about to download <strong>at least</strong> {{size}}.{{availableSpace}} Are you sure you want to continue?",
|
||||||
"core.course.contents": "Contents",
|
"core.course.contents": "Contents",
|
||||||
"core.course.couldnotloadsectioncontent": "Could not load the section content. Please try again later.",
|
"core.course.couldnotloadsectioncontent": "Could not load the section content. Please try again later.",
|
||||||
"core.course.couldnotloadsections": "Could not load the sections. Please try again later.",
|
"core.course.couldnotloadsections": "Could not load the sections. Please try again later.",
|
||||||
|
@ -1277,6 +1282,8 @@
|
||||||
"core.course.errorgetmodule": "Error getting activity data.",
|
"core.course.errorgetmodule": "Error getting activity data.",
|
||||||
"core.course.hiddenfromstudents": "Hidden from students",
|
"core.course.hiddenfromstudents": "Hidden from students",
|
||||||
"core.course.hiddenoncoursepage": "Available but not shown on course page",
|
"core.course.hiddenoncoursepage": "Available but not shown on course page",
|
||||||
|
"core.course.insufficientavailablequota": "Your device could not allocate space to save this download. It may be reserving space for app and system updates. Please clear some storage space first.",
|
||||||
|
"core.course.insufficientavailablespace": "You are trying to download {{size}}. This will leave your device with insufficient space to operate normally. Please clear some storage space first.",
|
||||||
"core.course.manualcompletionnotsynced": "Manual completion not synchronised.",
|
"core.course.manualcompletionnotsynced": "Manual completion not synchronised.",
|
||||||
"core.course.nocontentavailable": "No content available at the moment.",
|
"core.course.nocontentavailable": "No content available at the moment.",
|
||||||
"core.course.overriddennotice": "Your final grade from this activity was manually adjusted.",
|
"core.course.overriddennotice": "Your final grade from this activity was manually adjusted.",
|
||||||
|
|
Loading…
Reference in New Issue