MOBILE-4526 core: Use ContextLevel enum instead of string
parent
8afeac3a94
commit
41e4292c48
|
@ -20,6 +20,7 @@ import { CoreCourseBlock } from '@features/course/services/course';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu';
|
import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block handler.
|
* Block handler.
|
||||||
|
@ -38,8 +39,8 @@ export class AddonBlockCalendarMonthHandlerService extends CoreBlockBaseHandler
|
||||||
* @param instanceId The instance ID associated with the context level.
|
* @param instanceId The instance ID associated with the context level.
|
||||||
* @returns Data or promise resolved with the data.
|
* @returns Data or promise resolved with the data.
|
||||||
*/
|
*/
|
||||||
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData {
|
getDisplayData(block: CoreCourseBlock, contextLevel: ContextLevel, instanceId: number): CoreBlockHandlerData {
|
||||||
const linkParams: Params = contextLevel == 'course' ? { courseId: instanceId } : {};
|
const linkParams: Params = contextLevel === ContextLevel.COURSE ? { courseId: instanceId } : {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: 'addon.block_calendarmonth.pluginname',
|
title: 'addon.block_calendarmonth.pluginname',
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { Params } from '@angular/router';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu';
|
import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block handler.
|
* Block handler.
|
||||||
|
@ -39,10 +40,10 @@ export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandl
|
||||||
* @param instanceId The instance ID associated with the context level.
|
* @param instanceId The instance ID associated with the context level.
|
||||||
* @returns Data or promise resolved with the data.
|
* @returns Data or promise resolved with the data.
|
||||||
*/
|
*/
|
||||||
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData {
|
getDisplayData(block: CoreCourseBlock, contextLevel: ContextLevel, instanceId: number): CoreBlockHandlerData {
|
||||||
const linkParams: Params = { upcoming: true };
|
const linkParams: Params = { upcoming: true };
|
||||||
|
|
||||||
if (contextLevel == 'course' && instanceId !== CoreSites.getCurrentSiteHomeId()) {
|
if (contextLevel === ContextLevel.COURSE && instanceId !== CoreSites.getCurrentSiteHomeId()) {
|
||||||
linkParams.courseId = instanceId;
|
linkParams.courseId = instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler
|
||||||
import { CoreCourseBlock } from '@features/course/services/course';
|
import { CoreCourseBlock } from '@features/course/services/course';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreComments } from '@features/comments/services/comments';
|
import { CoreComments } from '@features/comments/services/comments';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block handler.
|
* Block handler.
|
||||||
|
@ -44,7 +45,7 @@ export class AddonBlockCommentsHandlerService extends CoreBlockBaseHandler {
|
||||||
* @param instanceId The instance ID associated with the context level.
|
* @param instanceId The instance ID associated with the context level.
|
||||||
* @returns Data or promise resolved with the data.
|
* @returns Data or promise resolved with the data.
|
||||||
*/
|
*/
|
||||||
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData {
|
getDisplayData(block: CoreCourseBlock, contextLevel: ContextLevel, instanceId: number): CoreBlockHandlerData {
|
||||||
return {
|
return {
|
||||||
title: 'addon.block_comments.pluginname',
|
title: 'addon.block_comments.pluginname',
|
||||||
class: 'addon-block-comments',
|
class: 'addon-block-comments',
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler
|
||||||
import { CoreCourseBlock } from '@features/course/services/course';
|
import { CoreCourseBlock } from '@features/course/services/course';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
|
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block handler.
|
* Block handler.
|
||||||
|
@ -41,7 +42,7 @@ export class AddonBlockCompletionStatusHandlerService extends CoreBlockBaseHandl
|
||||||
*/
|
*/
|
||||||
async getDisplayData(
|
async getDisplayData(
|
||||||
block: CoreCourseBlock,
|
block: CoreCourseBlock,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
): Promise<undefined | CoreBlockHandlerData> {
|
): Promise<undefined | CoreBlockHandlerData> {
|
||||||
if (contextLevel !== 'course') {
|
if (contextLevel !== 'course') {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { makeSingleton } from '@singletons';
|
||||||
import { CoreCourseBlock } from '@features/course/services/course';
|
import { CoreCourseBlock } from '@features/course/services/course';
|
||||||
import { CORE_SEARCH_PAGE_NAME } from '@features/search/services/handlers/mainmenu';
|
import { CORE_SEARCH_PAGE_NAME } from '@features/search/services/handlers/mainmenu';
|
||||||
import { CoreSearchGlobalSearch } from '@features/search/services/global-search';
|
import { CoreSearchGlobalSearch } from '@features/search/services/global-search';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block handler.
|
* Block handler.
|
||||||
|
@ -40,8 +41,8 @@ export class AddonBlockGlobalSearchHandlerService extends CoreBlockBaseHandler {
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData | undefined {
|
getDisplayData(block: CoreCourseBlock, contextLevel: ContextLevel, instanceId: number): CoreBlockHandlerData | undefined {
|
||||||
const isCourseSearch = contextLevel === 'course';
|
const isCourseSearch = contextLevel === ContextLevel.COURSE;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: isCourseSearch ? 'core.search' : 'addon.block_globalsearch.pluginname',
|
title: isCourseSearch ? 'core.search' : 'addon.block_globalsearch.pluginname',
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { makeSingleton } from '@singletons';
|
||||||
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants';
|
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants';
|
||||||
import { CoreCourseBlock } from '@features/course/services/course';
|
import { CoreCourseBlock } from '@features/course/services/course';
|
||||||
import { CoreSearchGlobalSearch } from '@features/search/services/global-search';
|
import { CoreSearchGlobalSearch } from '@features/search/services/global-search';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block handler.
|
* Block handler.
|
||||||
|
@ -42,10 +43,10 @@ export class AddonBlockSearchForumsHandlerService extends CoreBlockBaseHandler {
|
||||||
*/
|
*/
|
||||||
async getDisplayData(
|
async getDisplayData(
|
||||||
block: CoreCourseBlock,
|
block: CoreCourseBlock,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
): Promise<undefined | CoreBlockHandlerData> {
|
): Promise<undefined | CoreBlockHandlerData> {
|
||||||
if (contextLevel !== 'course') {
|
if (contextLevel !== ContextLevel.COURSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler
|
||||||
import { CoreCourseBlock } from '@features/course/services/course';
|
import { CoreCourseBlock } from '@features/course/services/course';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
|
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block handler.
|
* Block handler.
|
||||||
|
@ -41,10 +42,10 @@ export class AddonBlockSelfCompletionHandlerService extends CoreBlockBaseHandler
|
||||||
*/
|
*/
|
||||||
async getDisplayData(
|
async getDisplayData(
|
||||||
block: CoreCourseBlock,
|
block: CoreCourseBlock,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
): Promise<undefined | CoreBlockHandlerData> {
|
): Promise<undefined | CoreBlockHandlerData> {
|
||||||
if (contextLevel !== 'course') {
|
if (contextLevel !== ContextLevel.COURSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ export class AddonBlogEntriesPage implements OnInit {
|
||||||
*/
|
*/
|
||||||
refresh(refresher?: HTMLIonRefresherElement): void {
|
refresh(refresher?: HTMLIonRefresherElement): void {
|
||||||
const promises = this.entries.map((entry) =>
|
const promises = this.entries.map((entry) =>
|
||||||
CoreComments.invalidateCommentsData('user', entry.userid, this.component, entry.id, 'format_blog'));
|
CoreComments.invalidateCommentsData(ContextLevel.USER, entry.userid, this.component, entry.id, 'format_blog'));
|
||||||
|
|
||||||
promises.push(AddonBlog.invalidateEntries(this.filter));
|
promises.push(AddonBlog.invalidateEntries(this.filter));
|
||||||
|
|
||||||
|
@ -304,6 +304,6 @@ export class AddonBlogEntriesPage implements OnInit {
|
||||||
type AddonBlogPostFormatted = AddonBlogPost & {
|
type AddonBlogPostFormatted = AddonBlogPost & {
|
||||||
publishTranslated?: string; // Calculated in the app. Key of the string to translate the publish state of the post.
|
publishTranslated?: string; // Calculated in the app. Key of the string to translate the publish state of the post.
|
||||||
user?: CoreUserProfile; // Calculated in the app. Data of the user that wrote the post.
|
user?: CoreUserProfile; // Calculated in the app. Data of the user that wrote the post.
|
||||||
contextLevel?: string; // Calculated in the app. The context level of the entry.
|
contextLevel?: ContextLevel; // Calculated in the app. The context level of the entry.
|
||||||
contextInstanceId?: number; // Calculated in the app. The context instance id.
|
contextInstanceId?: number; // Calculated in the app. The context instance id.
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,6 +46,7 @@ import { CoreReminders, CoreRemindersService, CoreRemindersUnits } from '@featur
|
||||||
import { CoreRemindersSetReminderMenuComponent } from '@features/reminders/components/set-reminder-menu/set-reminder-menu';
|
import { CoreRemindersSetReminderMenuComponent } from '@features/reminders/components/set-reminder-menu/set-reminder-menu';
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { ADDON_CALENDAR_COMPONENT } from '@addons/calendar/constants';
|
import { ADDON_CALENDAR_COMPONENT } from '@addons/calendar/constants';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays a form to create/edit an event.
|
* Page that displays a form to create/edit an event.
|
||||||
|
@ -266,7 +267,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
|
||||||
|
|
||||||
const courseFillFullname = async (course: CoreCourseSearchedData | CoreEnrolledCourseData): Promise<void> => {
|
const courseFillFullname = async (course: CoreCourseSearchedData | CoreEnrolledCourseData): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const result = await CoreFilterHelper.getFiltersAndFormatText(course.fullname, 'course', course.id);
|
const result = await CoreFilterHelper.getFiltersAndFormatText(course.fullname, ContextLevel.COURSE, course.id);
|
||||||
course.fullname = result.text;
|
course.fullname = result.text;
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
|
|
|
@ -48,7 +48,7 @@ export class AddonCompetencyCompetenciesPage implements AfterViewInit, OnDestroy
|
||||||
>;
|
>;
|
||||||
|
|
||||||
title = '';
|
title = '';
|
||||||
contextLevel?: string;
|
contextLevel?: ContextLevel;
|
||||||
contextInstanceId?: number;
|
contextInstanceId?: number;
|
||||||
|
|
||||||
protected logView: () => void;
|
protected logView: () => void;
|
||||||
|
|
|
@ -58,7 +58,7 @@ export class AddonCompetencyCompetencyPage implements OnInit, OnDestroy {
|
||||||
user?: CoreUserSummary;
|
user?: CoreUserSummary;
|
||||||
competency?: AddonCompetencyDataForUserCompetencySummaryWSResponse;
|
competency?: AddonCompetencyDataForUserCompetencySummaryWSResponse;
|
||||||
userCompetency?: AddonCompetencyUserCompetencyPlan | AddonCompetencyUserCompetency | AddonCompetencyUserCompetencyCourse;
|
userCompetency?: AddonCompetencyUserCompetencyPlan | AddonCompetencyUserCompetency | AddonCompetencyUserCompetencyCourse;
|
||||||
contextLevel?: string;
|
contextLevel?: ContextLevel;
|
||||||
contextInstanceId?: number;
|
contextInstanceId?: number;
|
||||||
|
|
||||||
protected logView: () => void;
|
protected logView: () => void;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { AddonModAssignFeedbackDelegate } from '@addons/mod/assign/services/feed
|
||||||
import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offline';
|
import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offline';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component';
|
import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
/**
|
/**
|
||||||
* Component to render a comments feedback plugin.
|
* Component to render a comments feedback plugin.
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +70,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
|
||||||
component: this.component,
|
component: this.component,
|
||||||
componentId: this.assign.cmid,
|
componentId: this.assign.cmid,
|
||||||
filter: true,
|
filter: true,
|
||||||
contextLevel: 'module',
|
contextLevel: ContextLevel.MODULE,
|
||||||
instanceId: this.assign.cmid,
|
instanceId: this.assign.cmid,
|
||||||
courseId: this.assign.course,
|
courseId: this.assign.course,
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,6 +36,7 @@ import { CoreFormFields } from '@singletons/form';
|
||||||
import { CoreFileHelper } from '@services/file-helper';
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
import { CoreIonicColorNames } from '@singletons/colors';
|
import { CoreIonicColorNames } from '@singletons/colors';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'mmaModAssign:';
|
const ROOT_CACHE_KEY = 'mmaModAssign:';
|
||||||
|
|
||||||
|
@ -757,7 +758,7 @@ export class AddonModAssignProvider {
|
||||||
promises.push(this.invalidateAssignmentUserMappingsData(assign.id, siteId));
|
promises.push(this.invalidateAssignmentUserMappingsData(assign.id, siteId));
|
||||||
promises.push(this.invalidateAssignmentGradesData(assign.id, siteId));
|
promises.push(this.invalidateAssignmentGradesData(assign.id, siteId));
|
||||||
promises.push(this.invalidateListParticipantsData(assign.id, siteId));
|
promises.push(this.invalidateListParticipantsData(assign.id, siteId));
|
||||||
promises.push(CoreComments.invalidateCommentsByInstance('module', assign.id, siteId));
|
promises.push(CoreComments.invalidateCommentsByInstance(ContextLevel.MODULE, assign.id, siteId));
|
||||||
promises.push(this.invalidateAssignmentData(courseId, siteId));
|
promises.push(this.invalidateAssignmentData(courseId, siteId));
|
||||||
promises.push(CoreGrades.invalidateAllCourseGradesData(courseId));
|
promises.push(CoreGrades.invalidateAllCourseGradesData(courseId));
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component';
|
import { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component';
|
||||||
import { Component, ViewChild } from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import { CoreCommentsCommentsComponent } from '@features/comments/components/comments/comments';
|
import { CoreCommentsCommentsComponent } from '@features/comments/components/comments/comments';
|
||||||
|
@ -43,7 +44,7 @@ export class AddonModAssignSubmissionCommentsComponent extends AddonModAssignSub
|
||||||
*/
|
*/
|
||||||
invalidate(): Promise<void> {
|
invalidate(): Promise<void> {
|
||||||
return CoreComments.invalidateCommentsData(
|
return CoreComments.invalidateCommentsData(
|
||||||
'module',
|
ContextLevel.MODULE,
|
||||||
this.assign.cmid,
|
this.assign.cmid,
|
||||||
'assignsubmission_comments',
|
'assignsubmission_comments',
|
||||||
this.submission.id,
|
this.submission.id,
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreComments } from '@features/comments/services/comments';
|
import { CoreComments } from '@features/comments/services/comments';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModAssignSubmissionCommentsComponent } from '../component/comments';
|
import { AddonModAssignSubmissionCommentsComponent } from '../component/comments';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for comments submission plugin.
|
* Handler for comments submission plugin.
|
||||||
|
@ -68,7 +69,7 @@ export class AddonModAssignSubmissionCommentsHandlerService implements AddonModA
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await CoreComments.getComments(
|
await CoreComments.getComments(
|
||||||
'module',
|
ContextLevel.MODULE,
|
||||||
assign.cmid,
|
assign.cmid,
|
||||||
'assignsubmission_comments',
|
'assignsubmission_comments',
|
||||||
submission.id,
|
submission.id,
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModAssignSubmissionOnlineTextPluginData } from '../services/handler';
|
import { AddonModAssignSubmissionOnlineTextPluginData } from '../services/handler';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to render an onlinetext submission plugin.
|
* Component to render an onlinetext submission plugin.
|
||||||
|
@ -86,7 +87,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS
|
||||||
component: this.component,
|
component: this.component,
|
||||||
componentId: this.assign.cmid,
|
componentId: this.assign.cmid,
|
||||||
filter: true,
|
filter: true,
|
||||||
contextLevel: 'module',
|
contextLevel: ContextLevel.MODULE,
|
||||||
instanceId: this.assign.cmid,
|
instanceId: this.assign.cmid,
|
||||||
courseId: this.assign.course,
|
courseId: this.assign.course,
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModDataProvider, AddonModDataEntry, AddonModData, AddonModDataData } from '../data';
|
import { AddonModDataProvider, AddonModDataEntry, AddonModData, AddonModDataData } from '../data';
|
||||||
import { AddonModDataSync, AddonModDataSyncResult } from '../data-sync';
|
import { AddonModDataSync, AddonModDataSyncResult } from '../data-sync';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to prefetch databases.
|
* Handler to prefetch databases.
|
||||||
|
@ -249,7 +250,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
|
||||||
|
|
||||||
if (commentsEnabled && database.comments) {
|
if (commentsEnabled && database.comments) {
|
||||||
promises.push(CoreComments.getComments(
|
promises.push(CoreComments.getComments(
|
||||||
'module',
|
ContextLevel.MODULE,
|
||||||
database.coursemodule,
|
database.coursemodule,
|
||||||
'mod_data',
|
'mod_data',
|
||||||
entry.id,
|
entry.id,
|
||||||
|
|
|
@ -170,15 +170,25 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
|
|
||||||
// Listen for offline ratings saved and synced.
|
// Listen for offline ratings saved and synced.
|
||||||
this.observers.push(CoreEvents.on(CoreRatingProvider.RATING_SAVED_EVENT, (data) => {
|
this.observers.push(CoreEvents.on(CoreRatingProvider.RATING_SAVED_EVENT, (data) => {
|
||||||
if (this.glossary && data.component == 'mod_glossary' && data.ratingArea == 'entry' && data.contextLevel == 'module'
|
if (
|
||||||
&& data.instanceId == this.glossary.coursemodule) {
|
this.glossary &&
|
||||||
|
data.component == 'mod_glossary' &&
|
||||||
|
data.ratingArea == 'entry' &&
|
||||||
|
data.contextLevel == ContextLevel.MODULE &&
|
||||||
|
data.instanceId == this.glossary.coursemodule
|
||||||
|
) {
|
||||||
this.hasOfflineRatings = true;
|
this.hasOfflineRatings = true;
|
||||||
this.hasOffline = true;
|
this.hasOffline = true;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
this.observers.push(CoreEvents.on(CoreRatingSyncProvider.SYNCED_EVENT, (data) => {
|
this.observers.push(CoreEvents.on(CoreRatingSyncProvider.SYNCED_EVENT, (data) => {
|
||||||
if (this.glossary && data.component == 'mod_glossary' && data.ratingArea == 'entry' && data.contextLevel == 'module'
|
if (
|
||||||
&& data.instanceId == this.glossary.coursemodule) {
|
this.glossary &&
|
||||||
|
data.component == 'mod_glossary' &&
|
||||||
|
data.ratingArea == 'entry' &&
|
||||||
|
data.contextLevel == ContextLevel.MODULE &&
|
||||||
|
data.instanceId == this.glossary.coursemodule
|
||||||
|
) {
|
||||||
this.hasOfflineRatings = false;
|
this.hasOfflineRatings = false;
|
||||||
this.hasOffline = this.hasOfflineEntries;
|
this.hasOffline = this.hasOfflineEntries;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModGlossary, AddonModGlossaryEntry, AddonModGlossaryGlossary, AddonModGlossaryProvider } from '../glossary';
|
import { AddonModGlossary, AddonModGlossaryEntry, AddonModGlossaryGlossary, AddonModGlossaryProvider } from '../glossary';
|
||||||
import { AddonModGlossarySync, AddonModGlossarySyncResult } from '../glossary-sync';
|
import { AddonModGlossarySync, AddonModGlossarySyncResult } from '../glossary-sync';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to prefetch forums.
|
* Handler to prefetch forums.
|
||||||
|
@ -161,7 +162,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
|
||||||
// Don't fetch individual entries, it's too many WS calls.
|
// Don't fetch individual entries, it's too many WS calls.
|
||||||
if (glossary.allowcomments && commentsEnabled) {
|
if (glossary.allowcomments && commentsEnabled) {
|
||||||
promises.push(CoreComments.getComments(
|
promises.push(CoreComments.getComments(
|
||||||
'module',
|
ContextLevel.MODULE,
|
||||||
glossary.coursemodule,
|
glossary.coursemodule,
|
||||||
'mod_glossary',
|
'mod_glossary',
|
||||||
entry.id,
|
entry.id,
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||||
import { CoreWSExternalWarning } from '@services/ws';
|
import { CoreWSExternalWarning } from '@services/ws';
|
||||||
import { CoreSite } from '@classes/sites/site';
|
import { CoreSite } from '@classes/sites/site';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'mmaFiles:';
|
const ROOT_CACHE_KEY = 'mmaFiles:';
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ export class AddonPrivateFilesProvider {
|
||||||
contextid: -1,
|
contextid: -1,
|
||||||
component: 'user',
|
component: 'user',
|
||||||
filearea: 'private',
|
filearea: 'private',
|
||||||
contextlevel: 'user',
|
contextlevel: ContextLevel.USER,
|
||||||
instanceid: CoreSites.getCurrentSite()?.getUserId(),
|
instanceid: CoreSites.getCurrentSite()?.getUserId(),
|
||||||
itemid: 0,
|
itemid: 0,
|
||||||
filepath: '',
|
filepath: '',
|
||||||
|
@ -428,7 +429,7 @@ export type AddonPrivateFilesGetFilesWSParams = {
|
||||||
filepath: string; // File path.
|
filepath: string; // File path.
|
||||||
filename: string; // File name.
|
filename: string; // File name.
|
||||||
modified?: number; // Timestamp to return files changed after this time.
|
modified?: number; // Timestamp to return files changed after this time.
|
||||||
contextlevel?: string; // The context level for the file location.
|
contextlevel?: ContextLevel; // The context level for the file location.
|
||||||
instanceid?: number; // The instance id for where the file is located.
|
instanceid?: number; // The instance id for where the file is located.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
import { CoreQuestionBehaviourButton, CoreQuestionQuestion } from '@features/question/services/question-helper';
|
import { CoreQuestionBehaviourButton, CoreQuestionQuestion } from '@features/question/services/question-helper';
|
||||||
|
@ -30,7 +31,7 @@ export class AddonQbehaviourDeferredCBMComponent {
|
||||||
@Input() componentId?: number; // ID of the component the question belongs to.
|
@Input() componentId?: number; // ID of the component the question belongs to.
|
||||||
@Input() attemptId?: number; // Attempt ID.
|
@Input() attemptId?: number; // Attempt ID.
|
||||||
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
||||||
@Input() review?: boolean; // Whether the user is in review mode.
|
@Input() review?: boolean; // Whether the user is in review mode.
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
import { CoreQuestionBehaviourButton, CoreQuestionQuestion } from '@features/question/services/question-helper';
|
import { CoreQuestionBehaviourButton, CoreQuestionQuestion } from '@features/question/services/question-helper';
|
||||||
|
@ -30,7 +31,7 @@ export class AddonQbehaviourInformationItemComponent {
|
||||||
@Input() componentId?: number; // ID of the component the question belongs to.
|
@Input() componentId?: number; // ID of the component the question belongs to.
|
||||||
@Input() attemptId?: number; // Attempt ID.
|
@Input() attemptId?: number; // Attempt ID.
|
||||||
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
||||||
@Input() review?: boolean; // Whether the user is in review mode.
|
@Input() review?: boolean; // Whether the user is in review mode.
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, Input, OnDestroy, OnInit, ElementRef, OnChanges, ViewChild, SimpleChange } from '@angular/core';
|
import { Component, Input, OnDestroy, OnInit, ElementRef, OnChanges, ViewChild, SimpleChange } from '@angular/core';
|
||||||
import { CoreFilter } from '@features/filter/services/filter';
|
import { CoreFilter } from '@features/filter/services/filter';
|
||||||
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
||||||
|
@ -50,7 +51,7 @@ export class CoreChartComponent implements OnDestroy, OnInit, OnChanges {
|
||||||
@Input() legend?: ChartLegendOptions; // Legend options.
|
@Input() legend?: ChartLegendOptions; // Legend options.
|
||||||
@Input() height = 300; // Height of the chart element.
|
@Input() height = 300; // Height of the chart element.
|
||||||
@Input() filter?: boolean | string; // Whether to filter labels. If not defined, true if contextLevel and instanceId are set.
|
@Input() filter?: boolean | string; // Whether to filter labels. If not defined, true if contextLevel and instanceId are set.
|
||||||
@Input() contextLevel?: string; // The context level of the text.
|
@Input() contextLevel?: ContextLevel; // The context level of the text.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
||||||
@Input() wsNotFiltered?: boolean | string; // If true it means the WS didn't filter the labels for some reason.
|
@Input() wsNotFiltered?: boolean | string; // If true it means the WS didn't filter the labels for some reason.
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChange } from '@angular/core';
|
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChange } from '@angular/core';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ export class CoreNavigationBarComponent implements OnChanges {
|
||||||
@Input() nextTranslate = 'core.next'; // Next translatable text, can admit $a variable.
|
@Input() nextTranslate = 'core.next'; // Next translatable text, can admit $a variable.
|
||||||
@Input() component?: string; // Component the bar belongs to.
|
@Input() component?: string; // Component the bar belongs to.
|
||||||
@Input() componentId?: number; // Component ID.
|
@Input() componentId?: number; // Component ID.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ import { MediaElementController } from '@classes/element-controllers/MediaElemen
|
||||||
import { FrameElement, FrameElementController } from '@classes/element-controllers/FrameElementController';
|
import { FrameElement, FrameElementController } from '@classes/element-controllers/FrameElementController';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreIcons } from '@singletons/icons';
|
import { CoreIcons } from '@singletons/icons';
|
||||||
|
import { ContextLevel } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directive to format text rendered. It renders the HTML and treats all links and media, using CoreLinkDirective
|
* Directive to format text rendered. It renders the HTML and treats all links and media, using CoreLinkDirective
|
||||||
|
@ -81,7 +82,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
|
||||||
@Input() singleLine?: boolean | string; // Whether new lines should be removed (all text in single line). Only if clean=true.
|
@Input() singleLine?: boolean | string; // Whether new lines should be removed (all text in single line). Only if clean=true.
|
||||||
@Input() highlight?: string; // Text to highlight.
|
@Input() highlight?: string; // Text to highlight.
|
||||||
@Input() filter?: boolean | string; // Whether to filter the text. If not defined, true if contextLevel and instanceId are set.
|
@Input() filter?: boolean | string; // Whether to filter the text. If not defined, true if contextLevel and instanceId are set.
|
||||||
@Input() contextLevel?: string; // The context level of the text.
|
@Input() contextLevel?: ContextLevel; // The context level of the text.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
||||||
@Input() wsNotFiltered?: boolean | string; // If true it means the WS didn't filter the text for some reason.
|
@Input() wsNotFiltered?: boolean | string; // If true it means the WS didn't filter the text for some reason.
|
||||||
|
@ -397,11 +398,13 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
|
||||||
|
|
||||||
const siteId = site?.getId();
|
const siteId = site?.getId();
|
||||||
|
|
||||||
if (site && this.contextLevel == 'course' && this.contextInstanceId !== undefined && this.contextInstanceId <= 0) {
|
if (
|
||||||
|
site && this.contextLevel === ContextLevel.COURSE && this.contextInstanceId !== undefined && this.contextInstanceId <= 0
|
||||||
|
) {
|
||||||
this.contextInstanceId = site.getSiteHomeId();
|
this.contextInstanceId = site.getSiteHomeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.contextLevel === 'course' && this.contextInstanceId === undefined && this.courseId !== undefined) {
|
if (this.contextLevel === ContextLevel.COURSE && this.contextInstanceId === undefined && this.courseId !== undefined) {
|
||||||
this.contextInstanceId = this.courseId;
|
this.contextInstanceId = this.courseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +425,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
|
||||||
if (filter) {
|
if (filter) {
|
||||||
const filterResult = await CoreFilterHelper.getFiltersAndFormatText(
|
const filterResult = await CoreFilterHelper.getFiltersAndFormatText(
|
||||||
this.text || '',
|
this.text || '',
|
||||||
this.contextLevel || '',
|
this.contextLevel || ContextLevel.SYSTEM,
|
||||||
this.contextInstanceId ?? -1,
|
this.contextInstanceId ?? -1,
|
||||||
options,
|
options,
|
||||||
siteId,
|
siteId,
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { CoreSites } from '@services/sites';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
|
||||||
import { mock, mockSingleton, RenderConfig, renderTemplate, renderWrapperComponent } from '@/testing/utils';
|
import { mock, mockSingleton, RenderConfig, renderTemplate, renderWrapperComponent } from '@/testing/utils';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
describe('CoreFormatTextDirective', () => {
|
describe('CoreFormatTextDirective', () => {
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ describe('CoreFormatTextDirective', () => {
|
||||||
expect(CoreFilterHelper.getFiltersAndFormatText).toHaveBeenCalledTimes(1);
|
expect(CoreFilterHelper.getFiltersAndFormatText).toHaveBeenCalledTimes(1);
|
||||||
expect(CoreFilterHelper.getFiltersAndFormatText).toHaveBeenCalledWith(
|
expect(CoreFilterHelper.getFiltersAndFormatText).toHaveBeenCalledWith(
|
||||||
'Lorem ipsum dolor',
|
'Lorem ipsum dolor',
|
||||||
'course',
|
ContextLevel.COURSE,
|
||||||
42,
|
42,
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
undefined,
|
undefined,
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import { CoreCourseBlock } from '@features/course/services/course';
|
import { CoreCourseBlock } from '@features/course/services/course';
|
||||||
import { CoreBlockHandler, CoreBlockHandlerData } from '../services/block-delegate';
|
import { CoreBlockHandler, CoreBlockHandlerData } from '../services/block-delegate';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base handler for blocks.
|
* Base handler for blocks.
|
||||||
|
@ -45,7 +46,7 @@ export class CoreBlockBaseHandler implements CoreBlockHandler {
|
||||||
*/
|
*/
|
||||||
getDisplayData(
|
getDisplayData(
|
||||||
block: CoreCourseBlock, // eslint-disable-line @typescript-eslint/no-unused-vars
|
block: CoreCourseBlock, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
contextLevel: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
contextLevel: ContextLevel, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
instanceId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
instanceId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData> {
|
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData> {
|
||||||
// To be overridden.
|
// To be overridden.
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-comp
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { CoreCourseBlock } from '@/core/features/course/services/course';
|
import { CoreCourseBlock } from '@/core/features/course/services/course';
|
||||||
import type { ICoreBlockComponent } from '@features/block/classes/base-block-component';
|
import type { ICoreBlockComponent } from '@features/block/classes/base-block-component';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to render a block.
|
* Component to render a block.
|
||||||
|
@ -32,7 +33,7 @@ export class CoreBlockComponent implements OnChanges, OnDestroy {
|
||||||
@ViewChild(CoreDynamicComponent) dynamicComponent?: CoreDynamicComponent<ICoreBlockComponent>;
|
@ViewChild(CoreDynamicComponent) dynamicComponent?: CoreDynamicComponent<ICoreBlockComponent>;
|
||||||
|
|
||||||
@Input() block!: CoreCourseBlock; // The block to render.
|
@Input() block!: CoreCourseBlock; // The block to render.
|
||||||
@Input() contextLevel!: string; // The context where the block will be used.
|
@Input() contextLevel!: ContextLevel; // The context where the block will be used.
|
||||||
@Input() instanceId!: number; // The instance ID associated with the context level.
|
@Input() instanceId!: number; // The instance ID associated with the context level.
|
||||||
@Input() extraData!: Record<string, unknown>; // Any extra data to be passed to the block.
|
@Input() extraData!: Record<string, unknown>; // Any extra data to be passed to the block.
|
||||||
@Input() labelledBy?: string;
|
@Input() labelledBy?: string;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import { OnInit, Component, HostBinding } from '@angular/core';
|
import { OnInit, Component, HostBinding } from '@angular/core';
|
||||||
import { CoreBlockBaseComponent } from '../../classes/base-block-component';
|
import { CoreBlockBaseComponent } from '../../classes/base-block-component';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to render blocks with pre-rendered HTML.
|
* Component to render blocks with pre-rendered HTML.
|
||||||
|
@ -36,7 +37,7 @@ export class CoreBlockPreRenderedComponent extends CoreBlockBaseComponent implem
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.courseId = this.contextLevel == 'course' ? this.instanceId : undefined;
|
this.courseId = this.contextLevel === ContextLevel.COURSE ? this.instanceId : undefined;
|
||||||
this.fetchContentDefaultError = 'Error getting ' + this.block.contents?.title + ' data.';
|
this.fetchContentDefaultError = 'Error getting ' + this.block.contents?.title + ' data.';
|
||||||
this.id = `block-${this.block.instanceid}`;
|
this.id = `block-${this.block.instanceid}`;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreDom } from '@singletons/dom';
|
import { CoreDom } from '@singletons/dom';
|
||||||
import { CoreBlockSideBlocksTourComponent } from '../side-blocks-tour/side-blocks-tour';
|
import { CoreBlockSideBlocksTourComponent } from '../side-blocks-tour/side-blocks-tour';
|
||||||
import { CoreBlockSideBlocksComponent } from '../side-blocks/side-blocks';
|
import { CoreBlockSideBlocksComponent } from '../side-blocks/side-blocks';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a button to open blocks.
|
* Component that displays a button to open blocks.
|
||||||
|
@ -31,7 +32,7 @@ import { CoreBlockSideBlocksComponent } from '../side-blocks/side-blocks';
|
||||||
})
|
})
|
||||||
export class CoreBlockSideBlocksButtonComponent implements OnInit, OnDestroy {
|
export class CoreBlockSideBlocksButtonComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@Input() contextLevel!: string;
|
@Input() contextLevel!: ContextLevel;
|
||||||
@Input() instanceId!: number;
|
@Input() instanceId!: number;
|
||||||
@Input() myDashboardPage?: string;
|
@Input() myDashboardPage?: string;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreCoursesDashboard } from '@features/courses/services/dashboard';
|
import { CoreCoursesDashboard } from '@features/courses/services/dashboard';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreDom } from '@singletons/dom';
|
import { CoreDom } from '@singletons/dom';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays the list of side blocks.
|
* Component that displays the list of side blocks.
|
||||||
|
@ -33,7 +34,7 @@ import { CoreDom } from '@singletons/dom';
|
||||||
})
|
})
|
||||||
export class CoreBlockSideBlocksComponent implements OnInit {
|
export class CoreBlockSideBlocksComponent implements OnInit {
|
||||||
|
|
||||||
@Input() contextLevel!: string;
|
@Input() contextLevel!: ContextLevel;
|
||||||
@Input() instanceId!: number;
|
@Input() instanceId!: number;
|
||||||
@Input() initialBlockInstanceId?: number;
|
@Input() initialBlockInstanceId?: number;
|
||||||
@Input() myDashboardPage?: string;
|
@Input() myDashboardPage?: string;
|
||||||
|
@ -64,7 +65,7 @@ export class CoreBlockSideBlocksComponent implements OnInit {
|
||||||
async invalidateBlocks(): Promise<void> {
|
async invalidateBlocks(): Promise<void> {
|
||||||
const promises: Promise<void>[] = [];
|
const promises: Promise<void>[] = [];
|
||||||
|
|
||||||
if (this.contextLevel === 'course') {
|
if (this.contextLevel === ContextLevel.COURSE) {
|
||||||
promises.push(CoreCourse.invalidateCourseBlocks(this.instanceId));
|
promises.push(CoreCourse.invalidateCourseBlocks(this.instanceId));
|
||||||
} else {
|
} else {
|
||||||
promises.push(CoreCoursesDashboard.invalidateDashboardBlocks());
|
promises.push(CoreCoursesDashboard.invalidateDashboardBlocks());
|
||||||
|
@ -87,7 +88,7 @@ export class CoreBlockSideBlocksComponent implements OnInit {
|
||||||
*/
|
*/
|
||||||
async loadContent(): Promise<void> {
|
async loadContent(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (this.contextLevel === 'course') {
|
if (this.contextLevel === ContextLevel.COURSE) {
|
||||||
this.blocks = await CoreBlockHelper.getCourseBlocks(this.instanceId);
|
this.blocks = await CoreBlockHelper.getCourseBlocks(this.instanceId);
|
||||||
} else {
|
} else {
|
||||||
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, undefined, this.myDashboardPage);
|
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, undefined, this.myDashboardPage);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { makeSingleton } from '@singletons';
|
||||||
import { CoreBlockDefaultHandler } from './handlers/default-block';
|
import { CoreBlockDefaultHandler } from './handlers/default-block';
|
||||||
import { CoreNavigationOptions } from '@services/navigator';
|
import { CoreNavigationOptions } from '@services/navigator';
|
||||||
import type { ICoreBlockComponent } from '@features/block/classes/base-block-component';
|
import type { ICoreBlockComponent } from '@features/block/classes/base-block-component';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that all blocks must implement.
|
* Interface that all blocks must implement.
|
||||||
|
@ -43,7 +44,7 @@ export interface CoreBlockHandler extends CoreDelegateHandler {
|
||||||
*/
|
*/
|
||||||
getDisplayData?(
|
getDisplayData?(
|
||||||
block: CoreCourseBlock,
|
block: CoreCourseBlock,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData>;
|
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData>;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ export class CoreBlockDelegateService extends CoreDelegate<CoreBlockHandler> {
|
||||||
*/
|
*/
|
||||||
async getBlockDisplayData(
|
async getBlockDisplayData(
|
||||||
block: CoreCourseBlock,
|
block: CoreCourseBlock,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
): Promise<CoreBlockHandlerData | undefined> {
|
): Promise<CoreBlockHandlerData | undefined> {
|
||||||
return this.executeFunctionOnEnabled(
|
return this.executeFunctionOnEnabled(
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { CoreSites } from '@services/sites';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { COMMENTS_TABLE, COMMENTS_DELETED_TABLE, CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
|
import { COMMENTS_TABLE, COMMENTS_DELETED_TABLE, CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to handle offline comments.
|
* Service to handle offline comments.
|
||||||
|
@ -52,7 +53,7 @@ export class CoreCommentsOfflineProvider {
|
||||||
* @returns Promise resolved with the comments.
|
* @returns Promise resolved with the comments.
|
||||||
*/
|
*/
|
||||||
async getComment(
|
async getComment(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -86,7 +87,7 @@ export class CoreCommentsOfflineProvider {
|
||||||
* @returns Promise resolved with the comments.
|
* @returns Promise resolved with the comments.
|
||||||
*/
|
*/
|
||||||
async getComments(
|
async getComments(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -131,7 +132,7 @@ export class CoreCommentsOfflineProvider {
|
||||||
* @returns Promise resolved with the comments.
|
* @returns Promise resolved with the comments.
|
||||||
*/
|
*/
|
||||||
async getDeletedComments(
|
async getDeletedComments(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -165,7 +166,7 @@ export class CoreCommentsOfflineProvider {
|
||||||
* @returns Promise resolved if deleted, rejected if failure.
|
* @returns Promise resolved if deleted, rejected if failure.
|
||||||
*/
|
*/
|
||||||
async removeComment(
|
async removeComment(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -195,7 +196,7 @@ export class CoreCommentsOfflineProvider {
|
||||||
* @returns Promise resolved if deleted, rejected if failure.
|
* @returns Promise resolved if deleted, rejected if failure.
|
||||||
*/
|
*/
|
||||||
async removeDeletedComments(
|
async removeDeletedComments(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -227,7 +228,7 @@ export class CoreCommentsOfflineProvider {
|
||||||
*/
|
*/
|
||||||
async saveComment(
|
async saveComment(
|
||||||
content: string,
|
content: string,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -265,7 +266,7 @@ export class CoreCommentsOfflineProvider {
|
||||||
*/
|
*/
|
||||||
async deleteComment(
|
async deleteComment(
|
||||||
commentId: number,
|
commentId: number,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||||
import { CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
|
import { CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
|
||||||
import { CoreSyncResult } from '@services/sync';
|
import { CoreSyncResult } from '@services/sync';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to sync omments.
|
* Service to sync omments.
|
||||||
|
@ -121,7 +122,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
|
||||||
* @returns Promise resolved when the comments are synced or if they don't need to be synced.
|
* @returns Promise resolved when the comments are synced or if they don't need to be synced.
|
||||||
*/
|
*/
|
||||||
private async syncCommentsIfNeeded(
|
private async syncCommentsIfNeeded(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -149,7 +150,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
|
||||||
* @returns Promise resolved if sync is successful, rejected otherwise.
|
* @returns Promise resolved if sync is successful, rejected otherwise.
|
||||||
*/
|
*/
|
||||||
syncComments(
|
syncComments(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -185,7 +186,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
|
||||||
* @returns Promise resolved if sync is successful, rejected otherwise.
|
* @returns Promise resolved if sync is successful, rejected otherwise.
|
||||||
*/
|
*/
|
||||||
private async performSyncComments(
|
private async performSyncComments(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -312,7 +313,13 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
|
||||||
* @param area String comment area. Default empty.
|
* @param area String comment area. Default empty.
|
||||||
* @returns Sync ID.
|
* @returns Sync ID.
|
||||||
*/
|
*/
|
||||||
protected getSyncId(contextLevel: string, instanceId: number, component: string, itemId: number, area: string = ''): string {
|
protected getSyncId(
|
||||||
|
contextLevel: ContextLevel,
|
||||||
|
instanceId: number,
|
||||||
|
component: string,
|
||||||
|
itemId: number,
|
||||||
|
area: string = '',
|
||||||
|
): string {
|
||||||
return contextLevel + '#' + instanceId + '#' + component + '#' + itemId + '#' + area;
|
return contextLevel + '#' + instanceId + '#' + component + '#' + itemId + '#' + area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +332,7 @@ export type CoreCommentsSyncResult = CoreSyncResult;
|
||||||
* Data passed to AUTO_SYNCED event.
|
* Data passed to AUTO_SYNCED event.
|
||||||
*/
|
*/
|
||||||
export type CoreCommentsSyncAutoSyncData = {
|
export type CoreCommentsSyncAutoSyncData = {
|
||||||
contextLevel: string;
|
contextLevel: ContextLevel;
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
componentName: string;
|
componentName: string;
|
||||||
itemId: number;
|
itemId: number;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { CoreEvents } from '@singletons/events';
|
||||||
import { CoreCommentsOffline } from './comments-offline';
|
import { CoreCommentsOffline } from './comments-offline';
|
||||||
import { CoreCommentsSyncAutoSyncData, CoreCommentsSyncProvider } from './comments-sync';
|
import { CoreCommentsSyncAutoSyncData, CoreCommentsSyncProvider } from './comments-sync';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'mmComments:';
|
const ROOT_CACHE_KEY = 'mmComments:';
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ export class CoreCommentsProvider {
|
||||||
*/
|
*/
|
||||||
async addComment(
|
async addComment(
|
||||||
content: string,
|
content: string,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -128,7 +129,7 @@ export class CoreCommentsProvider {
|
||||||
*/
|
*/
|
||||||
async addCommentOnline(
|
async addCommentOnline(
|
||||||
content: string,
|
content: string,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -318,7 +319,7 @@ export class CoreCommentsProvider {
|
||||||
*/
|
*/
|
||||||
async deleteCommentsOnline(
|
async deleteCommentsOnline(
|
||||||
commentIds: number[],
|
commentIds: number[],
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -367,7 +368,7 @@ export class CoreCommentsProvider {
|
||||||
* @returns Cache key.
|
* @returns Cache key.
|
||||||
*/
|
*/
|
||||||
protected getCommentsCacheKey(
|
protected getCommentsCacheKey(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -383,7 +384,7 @@ export class CoreCommentsProvider {
|
||||||
* @param instanceId The Instance id of item associated with the context level.
|
* @param instanceId The Instance id of item associated with the context level.
|
||||||
* @returns Cache key.
|
* @returns Cache key.
|
||||||
*/
|
*/
|
||||||
protected getCommentsPrefixCacheKey(contextLevel: string, instanceId: number): string {
|
protected getCommentsPrefixCacheKey(contextLevel: ContextLevel, instanceId: number): string {
|
||||||
return ROOT_CACHE_KEY + 'comments:' + contextLevel + ':' + instanceId;
|
return ROOT_CACHE_KEY + 'comments:' + contextLevel + ':' + instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +401,7 @@ export class CoreCommentsProvider {
|
||||||
* @returns Promise resolved with the comments.
|
* @returns Promise resolved with the comments.
|
||||||
*/
|
*/
|
||||||
async getComments(
|
async getComments(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -449,7 +450,7 @@ export class CoreCommentsProvider {
|
||||||
* @returns Comments count with plus sign if needed.
|
* @returns Comments count with plus sign if needed.
|
||||||
*/
|
*/
|
||||||
async getCommentsCount(
|
async getCommentsCount(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -514,7 +515,7 @@ export class CoreCommentsProvider {
|
||||||
* @returns Promise resolved when the data is invalidated.
|
* @returns Promise resolved when the data is invalidated.
|
||||||
*/
|
*/
|
||||||
async invalidateCommentsData(
|
async invalidateCommentsData(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
component: string,
|
component: string,
|
||||||
itemId: number,
|
itemId: number,
|
||||||
|
@ -545,7 +546,7 @@ export class CoreCommentsProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @returns Promise resolved when the data is invalidated.
|
* @returns Promise resolved when the data is invalidated.
|
||||||
*/
|
*/
|
||||||
async invalidateCommentsByInstance(contextLevel: string, instanceId: number, siteId?: string): Promise<void> {
|
async invalidateCommentsByInstance(contextLevel: ContextLevel, instanceId: number, siteId?: string): Promise<void> {
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
||||||
await site.invalidateWsCacheForKeyStartingWith(this.getCommentsPrefixCacheKey(contextLevel, instanceId));
|
await site.invalidateWsCacheForKeyStartingWith(this.getCommentsPrefixCacheKey(contextLevel, instanceId));
|
||||||
|
@ -587,7 +588,7 @@ type CoreCommentsAddCommentsWSParams = {
|
||||||
|
|
||||||
export type CoreCommentsCommentBasicData = {
|
export type CoreCommentsCommentBasicData = {
|
||||||
id?: number; // Comment ID.
|
id?: number; // Comment ID.
|
||||||
contextlevel: string; // Contextlevel system, course, user...
|
contextlevel: ContextLevel; // Contextlevel system, course, user...
|
||||||
instanceid: number; // The id of item associated with the contextlevel.
|
instanceid: number; // The id of item associated with the contextlevel.
|
||||||
component: string; // Component.
|
component: string; // Component.
|
||||||
content: string; // Component.
|
content: string; // Component.
|
||||||
|
@ -628,7 +629,7 @@ type CoreCommentsDeleteCommentsWSParams = {
|
||||||
* Params of core_comment_get_comments WS.
|
* Params of core_comment_get_comments WS.
|
||||||
*/
|
*/
|
||||||
type CoreCommentsGetCommentsWSParams = {
|
type CoreCommentsGetCommentsWSParams = {
|
||||||
contextlevel: string; // Contextlevel system, course, user...
|
contextlevel: ContextLevel; // Contextlevel system, course, user...
|
||||||
instanceid: number; // The Instance id of item associated with the context level.
|
instanceid: number; // The Instance id of item associated with the context level.
|
||||||
component: string; // Component.
|
component: string; // Component.
|
||||||
itemid: number; // Associated id.
|
itemid: number; // Associated id.
|
||||||
|
@ -652,7 +653,7 @@ export type CoreCommentsGetCommentsWSResponse = {
|
||||||
* Data sent by COMMENTS_COUNT_CHANGED_EVENT event.
|
* Data sent by COMMENTS_COUNT_CHANGED_EVENT event.
|
||||||
*/
|
*/
|
||||||
export type CoreCommentsCountChangedEventData = {
|
export type CoreCommentsCountChangedEventData = {
|
||||||
contextLevel: string;
|
contextLevel: ContextLevel;
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
component: string;
|
component: string;
|
||||||
itemId: number;
|
itemId: number;
|
||||||
|
@ -664,7 +665,7 @@ export type CoreCommentsCountChangedEventData = {
|
||||||
* Data sent by REFRESH_COMMENTS_EVENT event.
|
* Data sent by REFRESH_COMMENTS_EVENT event.
|
||||||
*/
|
*/
|
||||||
export type CoreCommentsRefreshCommentsEventData = {
|
export type CoreCommentsRefreshCommentsEventData = {
|
||||||
contextLevel?: string;
|
contextLevel?: ContextLevel;
|
||||||
instanceId?: number;
|
instanceId?: number;
|
||||||
component?: string;
|
component?: string;
|
||||||
itemId?: number;
|
itemId?: number;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { CoreSiteSchema } from '@services/sites';
|
import { CoreSiteSchema } from '@services/sites';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +96,7 @@ export const COMMENTS_OFFLINE_SITE_SCHEMA: CoreSiteSchema = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CoreCommentsDBRecord = {
|
export type CoreCommentsDBRecord = {
|
||||||
contextlevel: string; // Primary key.
|
contextlevel: ContextLevel; // Primary key.
|
||||||
instanceid: number; // Primary key.
|
instanceid: number; // Primary key.
|
||||||
component: string; // Primary key.
|
component: string; // Primary key.
|
||||||
itemid: number; // Primary key.
|
itemid: number; // Primary key.
|
||||||
|
@ -106,7 +107,7 @@ export type CoreCommentsDBRecord = {
|
||||||
|
|
||||||
export type CoreCommentsDeletedDBRecord = {
|
export type CoreCommentsDeletedDBRecord = {
|
||||||
commentid: number; // Primary key.
|
commentid: number; // Primary key.
|
||||||
contextlevel: string;
|
contextlevel: ContextLevel;
|
||||||
instanceid: number;
|
instanceid: number;
|
||||||
component: string;
|
component: string;
|
||||||
itemid: number;
|
itemid: number;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { DownloadStatus } from '@/core/constants';
|
import { DownloadStatus, ContextLevel } from '@/core/constants';
|
||||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||||
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
|
@ -118,7 +118,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
CoreCourse.getModuleBasicInfo(module.id, { siteId }),
|
CoreCourse.getModuleBasicInfo(module.id, { siteId }),
|
||||||
CoreCourse.getModule(module.id, courseId, undefined, false, true, siteId),
|
CoreCourse.getModule(module.id, courseId, undefined, false, true, siteId),
|
||||||
CoreFilterHelper.getFilters('module', module.id, { courseId }),
|
CoreFilterHelper.getFilters(ContextLevel.MODULE, module.id, { courseId }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Call the download function.
|
// Call the download function.
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { CoreWSFile } from '@services/ws';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData } from '../services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '../services/course';
|
||||||
import { CoreCourseModuleData } from '../services/course-helper';
|
import { CoreCourseModuleData } from '../services/course-helper';
|
||||||
import { CoreCourseModulePrefetchHandlerBase } from './module-prefetch-handler';
|
import { CoreCourseModulePrefetchHandlerBase } from './module-prefetch-handler';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base prefetch handler to be registered in CoreCourseModulePrefetchDelegate. It is useful to minimize the amount of
|
* Base prefetch handler to be registered in CoreCourseModulePrefetchDelegate. It is useful to minimize the amount of
|
||||||
|
@ -131,7 +132,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
promises.push(CoreFilterHelper.getFilters('module', module.id, { courseId }));
|
promises.push(CoreFilterHelper.getFilters(ContextLevel.MODULE, module.id, { courseId }));
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ import { CoreDom } from '@singletons/dom';
|
||||||
import { CoreUserTourDirectiveOptions } from '@directives/user-tour';
|
import { CoreUserTourDirectiveOptions } from '@directives/user-tour';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { CoreBlockSideBlocksComponent } from '@features/block/components/side-blocks/side-blocks';
|
import { CoreBlockSideBlocksComponent } from '@features/block/components/side-blocks/side-blocks';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to display course contents using a certain format. If the format isn't found, use default one.
|
* Component to display course contents using a certain format. If the format isn't found, use default one.
|
||||||
|
@ -318,7 +319,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
CoreDomUtils.openSideModal({
|
CoreDomUtils.openSideModal({
|
||||||
component: CoreBlockSideBlocksComponent,
|
component: CoreBlockSideBlocksComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
contextLevel: 'course',
|
contextLevel: ContextLevel.COURSE,
|
||||||
instanceId: this.course.id,
|
instanceId: this.course.id,
|
||||||
initialBlockInstanceId: this.initialBlockInstanceId,
|
initialBlockInstanceId: this.initialBlockInstanceId,
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classe
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle activity completion in sites previous to 3.11.
|
* Component to handle activity completion in sites previous to 3.11.
|
||||||
|
@ -112,7 +113,7 @@ export class CoreCourseModuleCompletionLegacyComponent extends CoreCourseModuleC
|
||||||
|
|
||||||
const result = await CoreFilterHelper.getFiltersAndFormatText(
|
const result = await CoreFilterHelper.getFiltersAndFormatText(
|
||||||
moduleName,
|
moduleName,
|
||||||
'module',
|
ContextLevel.MODULE,
|
||||||
this.moduleId,
|
this.moduleId,
|
||||||
{ clean: true, singleLine: true, shortenLength: 50, courseId: this.completion.courseId },
|
{ clean: true, singleLine: true, shortenLength: 50, courseId: this.completion.courseId },
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, HostBinding, Input } from '@angular/core';
|
import { Component, HostBinding, Input } from '@angular/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +44,7 @@ export class CoreCourseModuleDescriptionComponent {
|
||||||
@Input() component?: string; // Component for format text directive.
|
@Input() component?: string; // Component for format text directive.
|
||||||
@Input() componentId?: string | number; // Component ID to use in conjunction with the component.
|
@Input() componentId?: string | number; // Component ID to use in conjunction with the component.
|
||||||
@Input() showFull?: string | boolean; // Whether to always display the full description.
|
@Input() showFull?: string | boolean; // Whether to always display the full description.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import {
|
||||||
CoreCourseModuleCompletionStatus,
|
CoreCourseModuleCompletionStatus,
|
||||||
CoreCourseGetContentsWSModule,
|
CoreCourseGetContentsWSModule,
|
||||||
} from './course';
|
} from './course';
|
||||||
import { CoreConstants, DownloadStatus, TDownloadStatus } from '@/core/constants';
|
import { CoreConstants, DownloadStatus, TDownloadStatus, ContextLevel } from '@/core/constants';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { ApplicationInit, makeSingleton, Translate } from '@singletons';
|
import { ApplicationInit, makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
|
@ -1636,7 +1636,7 @@ export class CoreCourseHelperProvider {
|
||||||
promises.push(CoreCourse.getActivitiesCompletionStatus(course.id));
|
promises.push(CoreCourse.getActivitiesCompletionStatus(course.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
promises.push(CoreFilterHelper.getFilters('course', course.id));
|
promises.push(CoreFilterHelper.getFilters(ContextLevel.COURSE, course.id));
|
||||||
|
|
||||||
await CoreUtils.allPromises(promises);
|
await CoreUtils.allPromises(promises);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from './course';
|
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from './course';
|
||||||
import { CoreCache } from '@classes/cache';
|
import { CoreCache } from '@classes/cache';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
import { DownloadStatus, TDownloadStatus, TDownloadedStatus } from '@/core/constants';
|
import { DownloadStatus, TDownloadStatus, TDownloadedStatus, ContextLevel } from '@/core/constants';
|
||||||
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreEvents, CoreEventSectionStatusChangedData } from '@singletons/events';
|
import { CoreEvents, CoreEventSectionStatusChangedData } from '@singletons/events';
|
||||||
|
@ -132,7 +132,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
if (canUse) {
|
if (canUse) {
|
||||||
// Can use check updates, add it to the tocheck list.
|
// Can use check updates, add it to the tocheck list.
|
||||||
result.toCheck.push({
|
result.toCheck.push({
|
||||||
contextlevel: 'module',
|
contextlevel: ContextLevel.MODULE,
|
||||||
id: module.id,
|
id: module.id,
|
||||||
since: data.downloadTime || 0,
|
since: data.downloadTime || 0,
|
||||||
});
|
});
|
||||||
|
@ -888,7 +888,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
courseid: courseId,
|
courseid: courseId,
|
||||||
tocheck: [
|
tocheck: [
|
||||||
{
|
{
|
||||||
contextlevel: 'module',
|
contextlevel: ContextLevel.MODULE,
|
||||||
id: module.id,
|
id: module.id,
|
||||||
since: data.downloadTime || 0,
|
since: data.downloadTime || 0,
|
||||||
},
|
},
|
||||||
|
@ -1611,7 +1611,7 @@ export type CoreCourseCheckUpdatesWSParams = {
|
||||||
* Data to send in tocheck parameter.
|
* Data to send in tocheck parameter.
|
||||||
*/
|
*/
|
||||||
type CheckUpdatesToCheckWSParam = {
|
type CheckUpdatesToCheckWSParam = {
|
||||||
contextlevel: string; // The context level for the file location. Only module supported right now.
|
contextlevel: ContextLevel.MODULE; // The context level for the file location. Only module supported right now.
|
||||||
id: number; // Context instance id.
|
id: number; // Context instance id.
|
||||||
since: number; // Check updates since this time stamp.
|
since: number; // Check updates since this time stamp.
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,6 +44,7 @@ import { CoreDom } from '@singletons/dom';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
import { Swiper } from 'swiper';
|
import { Swiper } from 'swiper';
|
||||||
import { SwiperOptions } from 'swiper/types';
|
import { SwiperOptions } from 'swiper/types';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to display a rich text editor if enabled.
|
* Component to display a rich text editor if enabled.
|
||||||
|
@ -71,7 +72,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
@Input() component?: string; // The component to link the files to.
|
@Input() component?: string; // The component to link the files to.
|
||||||
@Input() componentId?: number; // An ID to use in conjunction with the component.
|
@Input() componentId?: number; // An ID to use in conjunction with the component.
|
||||||
@Input() autoSave?: boolean | string; // Whether to auto-save the contents in a draft. Defaults to true.
|
@Input() autoSave?: boolean | string; // Whether to auto-save the contents in a draft. Defaults to true.
|
||||||
@Input() contextLevel?: string; // The context level of the text.
|
@Input() contextLevel?: ContextLevel; // The context level of the text.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() elementId?: string; // An ID to set to the element.
|
@Input() elementId?: string; // An ID to set to the element.
|
||||||
@Input() draftExtraParams?: Record<string, unknown>; // Extra params to identify the draft.
|
@Input() draftExtraParams?: Record<string, unknown>; // Extra params to identify the draft.
|
||||||
|
@ -267,7 +268,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
// Save a draft so the original content is saved.
|
// Save a draft so the original content is saved.
|
||||||
this.lastDraft = newValue ?? '';
|
this.lastDraft = newValue ?? '';
|
||||||
CoreEditorOffline.saveDraft(
|
CoreEditorOffline.saveDraft(
|
||||||
this.contextLevel || '',
|
this.contextLevel || ContextLevel.SYSTEM,
|
||||||
this.contextInstanceId || 0,
|
this.contextInstanceId || 0,
|
||||||
this.elementId || '',
|
this.elementId || '',
|
||||||
this.draftExtraParams || {},
|
this.draftExtraParams || {},
|
||||||
|
@ -923,7 +924,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
protected async restoreDraft(): Promise<void> {
|
protected async restoreDraft(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const entry = await CoreEditorOffline.resumeDraft(
|
const entry = await CoreEditorOffline.resumeDraft(
|
||||||
this.contextLevel || '',
|
this.contextLevel || ContextLevel.SYSTEM,
|
||||||
this.contextInstanceId || 0,
|
this.contextInstanceId || 0,
|
||||||
this.elementId || '',
|
this.elementId || '',
|
||||||
this.draftExtraParams || {},
|
this.draftExtraParams || {},
|
||||||
|
@ -983,7 +984,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await CoreEditorOffline.saveDraft(
|
await CoreEditorOffline.saveDraft(
|
||||||
this.contextLevel || '',
|
this.contextLevel || ContextLevel.SYSTEM,
|
||||||
this.contextInstanceId || 0,
|
this.contextInstanceId || 0,
|
||||||
this.elementId || '',
|
this.elementId || '',
|
||||||
this.draftExtraParams || {},
|
this.draftExtraParams || {},
|
||||||
|
@ -1011,7 +1012,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
if (data.form && form && data.form == form) {
|
if (data.form && form && data.form == form) {
|
||||||
try {
|
try {
|
||||||
await CoreEditorOffline.deleteDraft(
|
await CoreEditorOffline.deleteDraft(
|
||||||
this.contextLevel || '',
|
this.contextLevel || ContextLevel.SYSTEM,
|
||||||
this.contextInstanceId || 0,
|
this.contextInstanceId || 0,
|
||||||
this.elementId || '',
|
this.elementId || '',
|
||||||
this.draftExtraParams || {},
|
this.draftExtraParams || {},
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { CoreSiteSchema } from '@services/sites';
|
import { CoreSiteSchema } from '@services/sites';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +76,7 @@ export const SITE_SCHEMA: CoreSiteSchema = {
|
||||||
* Primary data to identify a stored draft.
|
* Primary data to identify a stored draft.
|
||||||
*/
|
*/
|
||||||
export type CoreEditorDraftPrimaryData = {
|
export type CoreEditorDraftPrimaryData = {
|
||||||
contextlevel: string; // Context level.
|
contextlevel: ContextLevel; // Context level.
|
||||||
contextinstanceid: number; // The instance ID related to the context.
|
contextinstanceid: number; // The instance ID related to the context.
|
||||||
elementid: string; // Element ID.
|
elementid: string; // Element ID.
|
||||||
extraparams: string; // Extra params stringified.
|
extraparams: string; // Extra params stringified.
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreEditorDraft, CoreEditorDraftPrimaryData, DRAFT_TABLE } from './database/editor';
|
import { CoreEditorDraft, CoreEditorDraftPrimaryData, DRAFT_TABLE } from './database/editor';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service with features regarding rich text editor in offline.
|
* Service with features regarding rich text editor in offline.
|
||||||
|
@ -44,7 +45,7 @@ export class CoreEditorOfflineProvider {
|
||||||
* @returns Promise resolved when done.
|
* @returns Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async deleteDraft(
|
async deleteDraft(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
contextInstanceId: number,
|
contextInstanceId: number,
|
||||||
elementId: string,
|
elementId: string,
|
||||||
extraParams: Record<string, unknown>,
|
extraParams: Record<string, unknown>,
|
||||||
|
@ -71,7 +72,7 @@ export class CoreEditorOfflineProvider {
|
||||||
* @returns Object with the fixed primary data.
|
* @returns Object with the fixed primary data.
|
||||||
*/
|
*/
|
||||||
protected fixDraftPrimaryData(
|
protected fixDraftPrimaryData(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
contextInstanceId: number,
|
contextInstanceId: number,
|
||||||
elementId: string,
|
elementId: string,
|
||||||
extraParams: Record<string, unknown>,
|
extraParams: Record<string, unknown>,
|
||||||
|
@ -96,7 +97,7 @@ export class CoreEditorOfflineProvider {
|
||||||
* @returns Promise resolved with the draft data. Undefined if no draft stored.
|
* @returns Promise resolved with the draft data. Undefined if no draft stored.
|
||||||
*/
|
*/
|
||||||
async getDraft(
|
async getDraft(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
contextInstanceId: number,
|
contextInstanceId: number,
|
||||||
elementId: string,
|
elementId: string,
|
||||||
extraParams: Record<string, unknown>,
|
extraParams: Record<string, unknown>,
|
||||||
|
@ -123,7 +124,7 @@ export class CoreEditorOfflineProvider {
|
||||||
* @returns Promise resolved with the draft data. Undefined if no draft stored.
|
* @returns Promise resolved with the draft data. Undefined if no draft stored.
|
||||||
*/
|
*/
|
||||||
async resumeDraft(
|
async resumeDraft(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
contextInstanceId: number,
|
contextInstanceId: number,
|
||||||
elementId: string,
|
elementId: string,
|
||||||
extraParams: Record<string, unknown>,
|
extraParams: Record<string, unknown>,
|
||||||
|
@ -183,7 +184,7 @@ export class CoreEditorOfflineProvider {
|
||||||
* @returns Promise resolved when done.
|
* @returns Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async saveDraft(
|
async saveDraft(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
contextInstanceId: number,
|
contextInstanceId: number,
|
||||||
elementId: string,
|
elementId: string,
|
||||||
extraParams: Record<string, unknown>,
|
extraParams: Record<string, unknown>,
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { CoreFilterDefaultHandler } from './handlers/default-filter';
|
||||||
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||||
import { CoreSite } from '@classes/sites/site';
|
import { CoreSite } from '@classes/sites/site';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that all filter handlers must implement.
|
* Interface that all filter handlers must implement.
|
||||||
|
@ -156,7 +157,7 @@ export class CoreFilterDelegateService extends CoreDelegate<CoreFilterHandler> {
|
||||||
* @param instanceId Instance ID.
|
* @param instanceId Instance ID.
|
||||||
* @returns Filters.
|
* @returns Filters.
|
||||||
*/
|
*/
|
||||||
getEnabledFilters(contextLevel: string, instanceId: number): CoreFilterFilter[] {
|
getEnabledFilters(contextLevel: ContextLevel, instanceId: number): CoreFilterFilter[] {
|
||||||
const filters: CoreFilterFilter[] = [];
|
const filters: CoreFilterFilter[] = [];
|
||||||
|
|
||||||
for (const name in this.enabledHandlers) {
|
for (const name in this.enabledHandlers) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreSite } from '@classes/sites/site';
|
import { CoreSite } from '@classes/sites/site';
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||||
import { firstValueFrom } from 'rxjs';
|
import { firstValueFrom } from 'rxjs';
|
||||||
import { CoreBlockHelper } from '@features/block/services/block-helper';
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper service to provide filter functionalities.
|
* Helper service to provide filter functionalities.
|
||||||
|
@ -80,7 +80,7 @@ export class CoreFilterHelperProvider {
|
||||||
* @returns Promise resolved with the filters.
|
* @returns Promise resolved with the filters.
|
||||||
*/
|
*/
|
||||||
protected async getCacheableFilters(
|
protected async getCacheableFilters(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
getFilters: () => Promise<CoreFiltersGetAvailableInContextWSParamContext[]>,
|
getFilters: () => Promise<CoreFiltersGetAvailableInContextWSParamContext[]>,
|
||||||
options: CoreFilterFormatTextOptions,
|
options: CoreFilterFormatTextOptions,
|
||||||
|
@ -118,7 +118,7 @@ export class CoreFilterHelperProvider {
|
||||||
|
|
||||||
courseIds.forEach((courseId) => {
|
courseIds.forEach((courseId) => {
|
||||||
contexts.push({
|
contexts.push({
|
||||||
contextlevel: 'course',
|
contextlevel: ContextLevel.COURSE,
|
||||||
instanceid: courseId,
|
instanceid: courseId,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -148,7 +148,7 @@ export class CoreFilterHelperProvider {
|
||||||
section.modules.forEach((module) => {
|
section.modules.forEach((module) => {
|
||||||
if (CoreCourseHelper.canUserViewModule(module, section)) {
|
if (CoreCourseHelper.canUserViewModule(module, section)) {
|
||||||
contexts.push({
|
contexts.push({
|
||||||
contextlevel: 'module',
|
contextlevel: ContextLevel.MODULE,
|
||||||
instanceid: module.id,
|
instanceid: module.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ export class CoreFilterHelperProvider {
|
||||||
* @returns Promise resolved with the filters.
|
* @returns Promise resolved with the filters.
|
||||||
*/
|
*/
|
||||||
async getFilters(
|
async getFilters(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
options: CoreFilterFormatTextOptions = {},
|
options: CoreFilterFormatTextOptions = {},
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
|
@ -201,7 +201,10 @@ export class CoreFilterHelperProvider {
|
||||||
const courseId = options.courseId;
|
const courseId = options.courseId;
|
||||||
let hasFilters = true;
|
let hasFilters = true;
|
||||||
|
|
||||||
if (contextLevel == 'system' || (contextLevel == 'course' && instanceId == site.getSiteHomeId())) {
|
if (
|
||||||
|
contextLevel === ContextLevel.SYSTEM ||
|
||||||
|
(contextLevel === ContextLevel.COURSE && instanceId == site.getSiteHomeId())
|
||||||
|
) {
|
||||||
// No need to check the site filters because we're requesting the same context, so we'd do the same twice.
|
// No need to check the site filters because we're requesting the same context, so we'd do the same twice.
|
||||||
} else {
|
} else {
|
||||||
// Check if site has any filter to treat.
|
// Check if site has any filter to treat.
|
||||||
|
@ -214,13 +217,13 @@ export class CoreFilterHelperProvider {
|
||||||
|
|
||||||
options.filter = true;
|
options.filter = true;
|
||||||
|
|
||||||
if (contextLevel == 'module' && courseId) {
|
if (contextLevel === ContextLevel.MODULE && courseId) {
|
||||||
// Get all the modules filters with a single call to decrease the number of WS calls.
|
// Get all the modules filters with a single call to decrease the number of WS calls.
|
||||||
const getFilters = () => this.getCourseModulesContexts(courseId, siteId);
|
const getFilters = () => this.getCourseModulesContexts(courseId, siteId);
|
||||||
|
|
||||||
return await this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site);
|
return await this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site);
|
||||||
|
|
||||||
} else if (contextLevel == 'course') {
|
} else if (contextLevel === ContextLevel.COURSE) {
|
||||||
// If enrolled, get all enrolled courses filters with a single call to decrease number of WS calls.
|
// If enrolled, get all enrolled courses filters with a single call to decrease number of WS calls.
|
||||||
const getFilters = () => this.getCourseContexts(instanceId, siteId);
|
const getFilters = () => this.getCourseContexts(instanceId, siteId);
|
||||||
|
|
||||||
|
@ -247,7 +250,7 @@ export class CoreFilterHelperProvider {
|
||||||
*/
|
*/
|
||||||
async getFiltersAndFormatText(
|
async getFiltersAndFormatText(
|
||||||
text: string,
|
text: string,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
options?: CoreFilterFormatTextOptions,
|
options?: CoreFilterFormatTextOptions,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
|
@ -271,7 +274,7 @@ export class CoreFilterHelperProvider {
|
||||||
*/
|
*/
|
||||||
protected getFromMemoryCache(
|
protected getFromMemoryCache(
|
||||||
courseId: number,
|
courseId: number,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
site: CoreSite,
|
site: CoreSite,
|
||||||
): CoreFilterFilter[] | undefined {
|
): CoreFilterFilter[] | undefined {
|
||||||
|
@ -304,7 +307,7 @@ export class CoreFilterHelperProvider {
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
||||||
// Get filters at site level.
|
// Get filters at site level.
|
||||||
const filters = await CoreFilter.getAvailableInContext('system', 0, site.getId());
|
const filters = await CoreFilter.getAvailableInContext(ContextLevel.SYSTEM, 0, site.getId());
|
||||||
|
|
||||||
return CoreFilterDelegate.shouldBeApplied(filters, options, site);
|
return CoreFilterDelegate.shouldBeApplied(filters, options, site);
|
||||||
}
|
}
|
||||||
|
@ -319,7 +322,7 @@ export class CoreFilterHelperProvider {
|
||||||
*/
|
*/
|
||||||
protected storeInMemoryCache(
|
protected storeInMemoryCache(
|
||||||
courseId: number,
|
courseId: number,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
contexts: CoreFilterClassifiedFilters,
|
contexts: CoreFilterClassifiedFilters,
|
||||||
siteId: string,
|
siteId: string,
|
||||||
): void {
|
): void {
|
||||||
|
|
|
@ -141,7 +141,7 @@ export class CoreFilterProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
filters.forEach((filter) => {
|
filters.forEach((filter) => {
|
||||||
if (hadSystemContext && filter.contextlevel == 'course' && filter.instanceid == site.getSiteHomeId()) {
|
if (hadSystemContext && filter.contextlevel === ContextLevel.COURSE && filter.instanceid == site.getSiteHomeId()) {
|
||||||
if (hadSiteHomeContext) {
|
if (hadSiteHomeContext) {
|
||||||
// We need to return both site home and system. Add site home first.
|
// We need to return both site home and system. Add site home first.
|
||||||
classified[filter.contextlevel][filter.instanceid].push(filter);
|
classified[filter.contextlevel][filter.instanceid].push(filter);
|
||||||
|
@ -151,7 +151,7 @@ export class CoreFilterProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate the system context based on the inherited data.
|
// Simulate the system context based on the inherited data.
|
||||||
filter.contextlevel = 'system';
|
filter.contextlevel = ContextLevel.SYSTEM;
|
||||||
filter.instanceid = 0;
|
filter.instanceid = 0;
|
||||||
filter.contextid = -1;
|
filter.contextid = -1;
|
||||||
filter.localstate = filter.inheritedstate;
|
filter.localstate = filter.inheritedstate;
|
||||||
|
@ -172,10 +172,10 @@ export class CoreFilterProvider {
|
||||||
* @returns Context to use.
|
* @returns Context to use.
|
||||||
*/
|
*/
|
||||||
convertContext(
|
convertContext(
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
options: {courseId?: number} = {},
|
options: {courseId?: number} = {},
|
||||||
): {contextLevel: string; instanceId: number} {
|
): {contextLevel: ContextLevel; instanceId: number} {
|
||||||
if (contextLevel === ContextLevel.BLOCK || contextLevel === ContextLevel.USER) {
|
if (contextLevel === ContextLevel.BLOCK || contextLevel === ContextLevel.USER) {
|
||||||
// Blocks and users cannot have specific filters, use the parent context instead.
|
// Blocks and users cannot have specific filters, use the parent context instead.
|
||||||
return options.courseId ?
|
return options.courseId ?
|
||||||
|
@ -321,7 +321,7 @@ export class CoreFilterProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @returns Promise resolved with the filters.
|
* @returns Promise resolved with the filters.
|
||||||
*/
|
*/
|
||||||
async getAvailableInContext(contextLevel: string, instanceId: number, siteId?: string): Promise<CoreFilterFilter[]> {
|
async getAvailableInContext(contextLevel: ContextLevel, instanceId: number, siteId?: string): Promise<CoreFilterFilter[]> {
|
||||||
const result = await this.getAvailableInContexts([{ contextlevel: contextLevel, instanceid: instanceId }], siteId);
|
const result = await this.getAvailableInContexts([{ contextlevel: contextLevel, instanceid: instanceId }], siteId);
|
||||||
|
|
||||||
return result[contextLevel][instanceId] || [];
|
return result[contextLevel][instanceId] || [];
|
||||||
|
@ -406,7 +406,7 @@ export class CoreFilterProvider {
|
||||||
* @param siteId Site ID (empty for current site).
|
* @param siteId Site ID (empty for current site).
|
||||||
* @returns Promise resolved when the data is invalidated.
|
* @returns Promise resolved when the data is invalidated.
|
||||||
*/
|
*/
|
||||||
async invalidateAvailableInContext(contextLevel: string, instanceId: number, siteId?: string): Promise<void> {
|
async invalidateAvailableInContext(contextLevel: ContextLevel, instanceId: number, siteId?: string): Promise<void> {
|
||||||
await this.invalidateAvailableInContexts([{ contextlevel: contextLevel, instanceid: instanceId }], siteId);
|
await this.invalidateAvailableInContexts([{ contextlevel: contextLevel, instanceid: instanceId }], siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ export class CoreFilterProvider {
|
||||||
for (let i = 0; i < contexts.length; i++) {
|
for (let i = 0; i < contexts.length; i++) {
|
||||||
const context = contexts[i];
|
const context = contexts[i];
|
||||||
|
|
||||||
if (context.contextlevel != 'system') {
|
if (context.contextlevel !== ContextLevel.SYSTEM) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ export class CoreFilterProvider {
|
||||||
|
|
||||||
// Use course site home instead. Check if it's already in the list.
|
// Use course site home instead. Check if it's already in the list.
|
||||||
result.hadSiteHomeContext = contexts.some((context) =>
|
result.hadSiteHomeContext = contexts.some((context) =>
|
||||||
context.contextlevel == 'course' && context.instanceid == site.getSiteHomeId());
|
context.contextlevel === ContextLevel.COURSE && context.instanceid == site.getSiteHomeId());
|
||||||
|
|
||||||
if (result.hadSiteHomeContext) {
|
if (result.hadSiteHomeContext) {
|
||||||
// Site home is already in list, remove this context from the list.
|
// Site home is already in list, remove this context from the list.
|
||||||
|
@ -447,7 +447,7 @@ export class CoreFilterProvider {
|
||||||
} else {
|
} else {
|
||||||
// Site home not in list, use it instead of system.
|
// Site home not in list, use it instead of system.
|
||||||
contexts[i] = {
|
contexts[i] = {
|
||||||
contextlevel: 'course',
|
contextlevel: ContextLevel.COURSE,
|
||||||
instanceid: site.getSiteHomeId(),
|
instanceid: site.getSiteHomeId(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ export type CoreFiltersGetAvailableInContextWSParams = {
|
||||||
* Data about a context sent to core_filters_get_available_in_context.
|
* Data about a context sent to core_filters_get_available_in_context.
|
||||||
*/
|
*/
|
||||||
export type CoreFiltersGetAvailableInContextWSParamContext = {
|
export type CoreFiltersGetAvailableInContextWSParamContext = {
|
||||||
contextlevel: string; // The context level where the filters are: (coursecat, course, module).
|
contextlevel: ContextLevel; // The context level where the filters are: (coursecat, course, module).
|
||||||
instanceid: number; // The instance id of item associated with the context.
|
instanceid: number; // The instance id of item associated with the context.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ export type CoreFiltersGetAvailableInContextWSParamContext = {
|
||||||
* Filter object returned by core_filters_get_available_in_context.
|
* Filter object returned by core_filters_get_available_in_context.
|
||||||
*/
|
*/
|
||||||
export type CoreFilterFilter = {
|
export type CoreFilterFilter = {
|
||||||
contextlevel: string; // The context level where the filters are: (coursecat, course, module).
|
contextlevel: ContextLevel; // The context level where the filters are: (coursecat, course, module).
|
||||||
instanceid: number; // The instance id of item associated with the context.
|
instanceid: number; // The instance id of item associated with the context.
|
||||||
contextid: number; // The context id.
|
contextid: number; // The context id.
|
||||||
filter: string; // Filter plugin name.
|
filter: string; // Filter plugin name.
|
||||||
|
@ -522,7 +522,7 @@ export type CoreFilterGetAvailableInContextResult = {
|
||||||
* Options that can be passed to format text.
|
* Options that can be passed to format text.
|
||||||
*/
|
*/
|
||||||
export type CoreFilterFormatTextOptions = {
|
export type CoreFilterFormatTextOptions = {
|
||||||
contextLevel?: string; // The context level where the text is.
|
contextLevel?: ContextLevel; // The context level where the text is.
|
||||||
instanceId?: number; // The instance id related to the context.
|
instanceId?: number; // The instance id related to the context.
|
||||||
clean?: boolean; // If true all HTML will be removed. Default false.
|
clean?: boolean; // If true all HTML will be removed. Default false.
|
||||||
filter?: boolean; // If true the string will be run through applicable filters as well. Default true.
|
filter?: boolean; // If true the string will be run through applicable filters as well. Default true.
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { CoreWSFile } from '@services/ws';
|
||||||
import { CoreIonicColorNames } from '@singletons/colors';
|
import { CoreIonicColorNames } from '@singletons/colors';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreQuestionBehaviourButton, CoreQuestionHelper, CoreQuestionQuestion } from '../services/question-helper';
|
import { CoreQuestionBehaviourButton, CoreQuestionHelper, CoreQuestionQuestion } from '../services/question-helper';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for components to render a question.
|
* Base class for components to render a question.
|
||||||
|
@ -37,7 +38,7 @@ export class CoreQuestionBaseComponent<T extends AddonModQuizQuestion = AddonMod
|
||||||
@Input() componentId?: number; // ID of the component the question belongs to.
|
@Input() componentId?: number; // ID of the component the question belongs to.
|
||||||
@Input() attemptId?: number; // Attempt ID.
|
@Input() attemptId?: number; // Attempt ID.
|
||||||
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // The course the question belongs to (if any).
|
@Input() courseId?: number; // The course the question belongs to (if any).
|
||||||
@Input() review?: boolean; // Whether the user is in review mode.
|
@Input() review?: boolean; // Whether the user is in review mode.
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, Input, Output, OnInit, EventEmitter, ChangeDetectorRef, Type, ElementRef } from '@angular/core';
|
import { Component, Input, Output, OnInit, EventEmitter, ChangeDetectorRef, Type, ElementRef } from '@angular/core';
|
||||||
import { AsyncDirective } from '@classes/async-directive';
|
import { AsyncDirective } from '@classes/async-directive';
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
|
@ -41,7 +42,7 @@ export class CoreQuestionComponent implements OnInit, AsyncDirective {
|
||||||
@Input() attemptId?: number; // Attempt ID.
|
@Input() attemptId?: number; // Attempt ID.
|
||||||
@Input() usageId?: number; // Usage ID.
|
@Input() usageId?: number; // Usage ID.
|
||||||
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
||||||
@Input() review?: boolean; // Whether the user is in review mode.
|
@Input() review?: boolean; // Whether the user is in review mode.
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { CoreQuestion, CoreQuestionProvider, CoreQuestionQuestionParsed, CoreQue
|
||||||
import { CoreQuestionDelegate } from './question-delegate';
|
import { CoreQuestionDelegate } from './question-delegate';
|
||||||
import { CoreIcons } from '@singletons/icons';
|
import { CoreIcons } from '@singletons/icons';
|
||||||
import { CoreUrlUtils } from '@services/utils/url';
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service with some common functions to handle questions.
|
* Service with some common functions to handle questions.
|
||||||
|
@ -868,7 +869,7 @@ export class CoreQuestionHelperProvider {
|
||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
component?: string,
|
component?: string,
|
||||||
componentId?: number,
|
componentId?: number,
|
||||||
contextLevel?: string,
|
contextLevel?: ContextLevel,
|
||||||
contextInstanceId?: number,
|
contextInstanceId?: number,
|
||||||
courseId?: number,
|
courseId?: number,
|
||||||
): void {
|
): void {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreTime } from '@singletons/time';
|
import { CoreTime } from '@singletons/time';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { CoreBlockSideBlocksComponent } from '@features/block/components/side-blocks/side-blocks';
|
import { CoreBlockSideBlocksComponent } from '@features/block/components/side-blocks/side-blocks';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays site home index.
|
* Page that displays site home index.
|
||||||
|
@ -233,7 +234,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
|
||||||
CoreDomUtils.openSideModal({
|
CoreDomUtils.openSideModal({
|
||||||
component: CoreBlockSideBlocksComponent,
|
component: CoreBlockSideBlocksComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
contextLevel: 'course',
|
contextLevel: ContextLevel.COURSE,
|
||||||
instanceId: this.siteHomeId,
|
instanceId: this.siteHomeId,
|
||||||
initialBlockInstanceId: blockInstanceId,
|
initialBlockInstanceId: blockInstanceId,
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { CoreSitePluginsOnlyTitleBlockComponent } from '@features/siteplugins/co
|
||||||
import { CoreSitePluginsBlockHandlerData, CoreSitePluginsContent } from '@features/siteplugins/services/siteplugins';
|
import { CoreSitePluginsBlockHandlerData, CoreSitePluginsContent } from '@features/siteplugins/services/siteplugins';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreSitePluginsBaseHandler } from './base-handler';
|
import { CoreSitePluginsBaseHandler } from './base-handler';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to support a block using a site plugin.
|
* Handler to support a block using a site plugin.
|
||||||
|
@ -48,7 +49,7 @@ export class CoreSitePluginsBlockHandler extends CoreSitePluginsBaseHandler impl
|
||||||
*/
|
*/
|
||||||
async getDisplayData(
|
async getDisplayData(
|
||||||
block: CoreCourseBlock,
|
block: CoreCourseBlock,
|
||||||
contextLevel: string,
|
contextLevel: ContextLevel,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
): Promise<CoreBlockHandlerData> {
|
): Promise<CoreBlockHandlerData> {
|
||||||
const className = this.handlerSchema.displaydata?.class || 'block_' + block.name;
|
const className = this.handlerSchema.displaydata?.class || 'block_' + block.name;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
import { CoreQuestionBehaviourDelegate } from '@features/question/services/behaviour-delegate';
|
import { CoreQuestionBehaviourDelegate } from '@features/question/services/behaviour-delegate';
|
||||||
|
@ -33,7 +34,7 @@ export class CoreSitePluginsQuestionBehaviourComponent extends CoreSitePluginsCo
|
||||||
@Input() componentId?: number; // ID of the component the question belongs to.
|
@Input() componentId?: number; // ID of the component the question belongs to.
|
||||||
@Input() attemptId?: number; // Attempt ID.
|
@Input() attemptId?: number; // Attempt ID.
|
||||||
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
||||||
@Input() review?: boolean; // Whether the user is in review mode.
|
@Input() review?: boolean; // Whether the user is in review mode.
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
import { AddonModQuizQuestion } from '@features/question/classes/base-question-component';
|
import { AddonModQuizQuestion } from '@features/question/classes/base-question-component';
|
||||||
|
@ -34,7 +35,7 @@ export class CoreSitePluginsQuestionComponent extends CoreSitePluginsCompileInit
|
||||||
@Input() componentId?: number; // ID of the component the question belongs to.
|
@Input() componentId?: number; // ID of the component the question belongs to.
|
||||||
@Input() attemptId?: number; // Attempt ID.
|
@Input() attemptId?: number; // Attempt ID.
|
||||||
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
@Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters.
|
||||||
@Input() review?: boolean; // Whether the user is in review mode.
|
@Input() review?: boolean; // Whether the user is in review mode.
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ export class CoreSitePluginsUserProfileFieldComponent extends CoreSitePluginsCom
|
||||||
@Input() disabled = false; // True if disabled. Defaults to false.
|
@Input() disabled = false; // True if disabled. Defaults to false.
|
||||||
@Input() form?: FormGroup; // Form where to add the form control. Required if edit=true or signup=true.
|
@Input() form?: FormGroup; // Form where to add the form control. Required if edit=true or signup=true.
|
||||||
@Input() registerAuth?: string; // Register auth method. E.g. 'email'.
|
@Input() registerAuth?: string; // Register auth method. E.g. 'email'.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the field belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the field belongs to (if any). It can be used to improve performance with filters.
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { CoreSitePluginsModuleIndexComponent } from '../../components/module-ind
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
|
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
|
||||||
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page to render the index page of a module site plugin.
|
* Page to render the index page of a module site plugin.
|
||||||
|
@ -57,7 +58,7 @@ export class CoreSitePluginsModuleIndexPage implements OnInit, CanLeave {
|
||||||
|
|
||||||
const filteredTitle = await CoreFilterHelper.getFiltersAndFormatText(
|
const filteredTitle = await CoreFilterHelper.getFiltersAndFormatText(
|
||||||
this.title.trim(),
|
this.title.trim(),
|
||||||
'module',
|
ContextLevel.MODULE,
|
||||||
this.module?.id ?? -1,
|
this.module?.id ?? -1,
|
||||||
options,
|
options,
|
||||||
siteId,
|
siteId,
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { FormGroup, Validators, FormControl } from '@angular/forms';
|
import { FormGroup, Validators, FormControl } from '@angular/forms';
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ export abstract class CoreUserProfileFieldBaseComponent<T = string> implements O
|
||||||
@Input() disabled = false; // True if disabled. Defaults to false.
|
@Input() disabled = false; // True if disabled. Defaults to false.
|
||||||
@Input() form?: FormGroup; // Form where to add the form control. Required if edit=true or signup=true.
|
@Input() form?: FormGroup; // Form where to add the form control. Required if edit=true or signup=true.
|
||||||
@Input() registerAuth?: string; // Register auth method. E.g. 'email'.
|
@Input() registerAuth?: string; // Register auth method. E.g. 'email'.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the field belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the field belongs to (if any). It can be used to improve performance with filters.
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { AuthEmailSignupProfileField } from '@features/login/services/login-help
|
||||||
import { CoreUserProfileField } from '@features/user/services/user';
|
import { CoreUserProfileField } from '@features/user/services/user';
|
||||||
import { CoreUserProfileFieldDelegate } from '@features/user/services/user-profile-field-delegate';
|
import { CoreUserProfileFieldDelegate } from '@features/user/services/user-profile-field-delegate';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directive to render user profile field.
|
* Directive to render user profile field.
|
||||||
|
@ -34,7 +35,7 @@ export class CoreUserProfileFieldComponent implements OnInit {
|
||||||
@Input() edit = false; // True if editing the field. Defaults to false.
|
@Input() edit = false; // True if editing the field. Defaults to false.
|
||||||
@Input() form?: FormGroup; // Form where to add the form control. Required if edit=true or signup=true.
|
@Input() form?: FormGroup; // Form where to add the form control. Required if edit=true or signup=true.
|
||||||
@Input() registerAuth?: string; // Register auth method. E.g. 'email'.
|
@Input() registerAuth?: string; // Register auth method. E.g. 'email'.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
@Input() contextInstanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the field belongs to (if any). It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the field belongs to (if any). It can be used to improve performance with filters.
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ export type CoreUserProfileFieldComponentData = {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
form?: FormGroup;
|
form?: FormGroup;
|
||||||
registerAuth?: string;
|
registerAuth?: string;
|
||||||
contextLevel?: string;
|
contextLevel?: ContextLevel;
|
||||||
contextInstanceId?: number;
|
contextInstanceId?: number;
|
||||||
courseId?: number;
|
courseId?: number;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { CoreFileEntry } from '@services/file-helper';
|
import { CoreFileEntry } from '@services/file-helper';
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ export class CoreViewerTextComponent {
|
||||||
@Input() componentId?: string | number; // Component ID to use in format-text.
|
@Input() componentId?: string | number; // Component ID to use in format-text.
|
||||||
@Input() files?: CoreFileEntry[]; // List of files.
|
@Input() files?: CoreFileEntry[]; // List of files.
|
||||||
@Input() filter?: boolean; // Whether to filter the text.
|
@Input() filter?: boolean; // Whether to filter the text.
|
||||||
@Input() contextLevel?: string; // The context level.
|
@Input() contextLevel?: ContextLevel; // The context level.
|
||||||
@Input() instanceId?: number; // The instance ID related to the context.
|
@Input() instanceId?: number; // The instance ID related to the context.
|
||||||
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
@Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
||||||
@Input() displayCopyButton?: boolean; // Whether to display a button to copy the contents.
|
@Input() displayCopyButton?: boolean; // Whether to display a button to copy the contents.
|
||||||
|
|
|
@ -27,6 +27,7 @@ import { CoreUrl } from '@singletons/url';
|
||||||
import { AlertButton } from '@ionic/angular';
|
import { AlertButton } from '@ionic/angular';
|
||||||
import { CorePath } from '@singletons/path';
|
import { CorePath } from '@singletons/path';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Different type of errors the app can treat.
|
* Different type of errors the app can treat.
|
||||||
|
@ -1048,7 +1049,7 @@ export type CoreTextUtilsViewTextOptions = {
|
||||||
componentId?: string | number; // An ID to use in conjunction with the component.
|
componentId?: string | number; // An ID to use in conjunction with the component.
|
||||||
files?: CoreWSFile[]; // List of files to display along with the text.
|
files?: CoreWSFile[]; // List of files to display along with the text.
|
||||||
filter?: boolean; // Whether the text should be filtered.
|
filter?: boolean; // Whether the text should be filtered.
|
||||||
contextLevel?: string; // The context level.
|
contextLevel?: ContextLevel; // The context level.
|
||||||
instanceId?: number; // The instance ID related to the context.
|
instanceId?: number; // The instance ID related to the context.
|
||||||
courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
|
||||||
displayCopyButton?: boolean; // Whether to display a button to copy the text.
|
displayCopyButton?: boolean; // Whether to display a button to copy the text.
|
||||||
|
|
Loading…
Reference in New Issue