commit
4fb700b985
|
@ -83,7 +83,7 @@ export class AddonBadgesProvider {
|
|||
badge.alignment = badge.alignment || badge.competencies;
|
||||
|
||||
// Check that the alignment is valid, they were broken in 3.7.
|
||||
if (badge.alignment && badge.alignment[0] && typeof badge.alignment[0].targetname == 'undefined') {
|
||||
if (badge.alignment && badge.alignment[0] && badge.alignment[0].targetname === undefined) {
|
||||
// If any badge lacks targetname it means they are affected by the Moodle bug, don't display them.
|
||||
delete badge.alignment;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ export class AddonBadgesUserHandlerService implements CoreUserProfileHandler {
|
|||
courseId: number,
|
||||
navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
|
||||
): Promise<boolean> {
|
||||
if (navOptions && typeof navOptions.badges != 'undefined') {
|
||||
if (navOptions && navOptions.badges !== undefined) {
|
||||
return navOptions.badges;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,13 +67,13 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i
|
|||
|
||||
section.modules.forEach((mod) => {
|
||||
if (mod.uservisible === false || !CoreCourse.moduleHasView(mod) ||
|
||||
typeof modFullNames[mod.modname] != 'undefined') {
|
||||
modFullNames[mod.modname] !== undefined) {
|
||||
// Ignore this module.
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the archetype of the module type.
|
||||
if (typeof archetypes[mod.modname] == 'undefined') {
|
||||
if (archetypes[mod.modname] === undefined) {
|
||||
archetypes[mod.modname] = CoreCourseModuleDelegate.supportsFeature<number>(
|
||||
mod.modname,
|
||||
CoreConstants.FEATURE_MOD_ARCHETYPE,
|
||||
|
|
|
@ -62,7 +62,7 @@ export class AddonBlogCourseOptionHandlerService implements CoreCourseOptionsHan
|
|||
): Promise<boolean> {
|
||||
const enabled = await CoreCourseHelper.hasABlockNamed(courseId, 'blog_menu');
|
||||
|
||||
if (enabled && navOptions && typeof navOptions.blogs != 'undefined') {
|
||||
if (enabled && navOptions && navOptions.blogs !== undefined) {
|
||||
return navOptions.blogs;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
this.filter.courseId = CoreNavigator.getRouteNumberParam('courseId');
|
||||
this.filter.categoryId = CoreNavigator.getRouteNumberParam('categoryId');
|
||||
|
||||
this.filter.filtered = typeof this.filter.courseId != 'undefined' || types.some((name) => !this.filter[name]);
|
||||
this.filter.filtered = this.filter.courseId !== undefined || types.some((name) => !this.filter[name]);
|
||||
|
||||
const month = CoreNavigator.getRouteNumberParam('month');
|
||||
const source = new AddonCalendarDaySlidesItemsManagerSource(this, moment({
|
||||
|
|
|
@ -538,7 +538,7 @@ export class AddonCalendarProvider {
|
|||
// Ignore errors.
|
||||
}
|
||||
|
||||
if (typeof value == 'undefined' || value === null) {
|
||||
if (value === undefined || value === null) {
|
||||
value = site.getStoredConfig('calendar_lookahead');
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ export class AddonCompetencyCompetencySummaryPage implements OnInit {
|
|||
protected async fetchCompetency(): Promise<void> {
|
||||
try {
|
||||
const result = await AddonCompetency.getCompetencySummary(this.competencyId);
|
||||
if (!this.contextLevel || typeof this.contextInstanceId == 'undefined') {
|
||||
if (!this.contextLevel || this.contextInstanceId === undefined) {
|
||||
// Context not specified, use user context.
|
||||
this.contextLevel = ContextLevel.USER;
|
||||
this.contextInstanceId = result.usercompetency!.userid;
|
||||
|
|
|
@ -55,7 +55,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
|
|||
return false; // Not enabled for guests.
|
||||
}
|
||||
|
||||
if (navOptions && typeof navOptions.competencies != 'undefined') {
|
||||
if (navOptions && navOptions.competencies !== undefined) {
|
||||
return navOptions.competencies;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
|
|||
* @inheritdoc
|
||||
*/
|
||||
async invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
|
||||
if (navOptions && typeof navOptions.competencies != 'undefined') {
|
||||
if (navOptions && navOptions.competencies !== undefined) {
|
||||
// No need to invalidate anything.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -172,12 +172,12 @@ export class AddonCourseCompletionProvider {
|
|||
const course = await CoreCourses.getUserCourse(courseId, preferCache);
|
||||
|
||||
if (course) {
|
||||
if (typeof course.enablecompletion != 'undefined' && !course.enablecompletion) {
|
||||
if (course.enablecompletion !== undefined && !course.enablecompletion) {
|
||||
// Completion not enabled for the course.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof course.completionhascriteria != 'undefined' && !course.completionhascriteria) {
|
||||
if (course.completionhascriteria !== undefined && !course.completionhascriteria) {
|
||||
// No criteria, cannot view completion.
|
||||
return false;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ export class AddonCourseCompletionProvider {
|
|||
|
||||
// If the site is returning the completionhascriteria then the user can view his own completion.
|
||||
// We already checked the value in isPluginViewEnabledForCourse.
|
||||
if (course && typeof course.completionhascriteria != 'undefined') {
|
||||
if (course && course.completionhascriteria !== undefined) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
|
|||
|
||||
// Update MathJax locale if app language changes.
|
||||
CoreEvents.on(CoreEvents.LANGUAGE_CHANGED, (lang: string) => {
|
||||
if (typeof this.window.MathJax == 'undefined') {
|
||||
if (this.window.MathJax === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
|
|||
if (!this._configured) {
|
||||
const lang = this._lang;
|
||||
|
||||
if (typeof that.window.MathJax != 'undefined') {
|
||||
if (that.window.MathJax !== undefined) {
|
||||
that.window.MathJax.Hub.Queue(() => {
|
||||
that.window.MathJax.Localization.setLocale(lang);
|
||||
});
|
||||
|
@ -238,7 +238,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
|
|||
this._setLocale();
|
||||
}
|
||||
|
||||
if (typeof that.window.MathJax != 'undefined') {
|
||||
if (that.window.MathJax !== undefined) {
|
||||
const processDelay = that.window.MathJax.Hub.processSectionDelay;
|
||||
// Set the process section delay to 0 when updating the formula.
|
||||
that.window.MathJax.Hub.processSectionDelay = 0;
|
||||
|
|
|
@ -205,7 +205,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
|
|||
message.useridfrom;
|
||||
|
||||
let added = false;
|
||||
if (typeof this.keepMessageMap[message.hash] === 'undefined') {
|
||||
if (this.keepMessageMap[message.hash] === undefined) {
|
||||
// Message not added to the list. Add it now.
|
||||
this.messages.push(message);
|
||||
added = message.useridfrom != this.currentUserId;
|
||||
|
@ -1277,7 +1277,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
|
|||
},
|
||||
});
|
||||
|
||||
if (typeof userId != 'undefined') {
|
||||
if (userId !== undefined) {
|
||||
const splitViewLoaded = CoreNavigator.isCurrentPathInTablet('**/messages/**/discussion');
|
||||
|
||||
// Open user conversation.
|
||||
|
|
|
@ -77,7 +77,7 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy {
|
|||
if (data.userId && this.discussions) {
|
||||
const discussion = this.discussions.find((disc) => disc.message!.user == data.userId);
|
||||
|
||||
if (typeof discussion == 'undefined') {
|
||||
if (discussion === undefined) {
|
||||
this.loaded = false;
|
||||
this.refreshData().finally(() => {
|
||||
this.loaded = true;
|
||||
|
@ -99,7 +99,7 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy {
|
|||
if (data.userId && this.discussions) {
|
||||
const discussion = this.discussions.find((disc) => disc.message!.user == data.userId);
|
||||
|
||||
if (typeof discussion != 'undefined') {
|
||||
if (discussion !== undefined) {
|
||||
// A discussion has been read reset counter.
|
||||
discussion.unread = false;
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
|||
// Search the conversation to update.
|
||||
const conversation = this.findConversation(data.conversationId, data.userId, expandedOption);
|
||||
|
||||
if (typeof conversation == 'undefined') {
|
||||
if (conversation === undefined) {
|
||||
// Probably a new conversation, refresh the list.
|
||||
this.loaded = false;
|
||||
this.refreshData().finally(() => {
|
||||
|
@ -152,7 +152,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
|||
if (data.conversationId) {
|
||||
const conversation = this.findConversation(data.conversationId);
|
||||
|
||||
if (typeof conversation != 'undefined') {
|
||||
if (conversation !== undefined) {
|
||||
// A conversation has been read reset counter.
|
||||
conversation.unreadcount = 0;
|
||||
|
||||
|
@ -318,7 +318,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
|||
await Promise.all(promises);
|
||||
|
||||
// The expanded status hasn't been initialized. Do it now.
|
||||
if (typeof this.favourites.expanded == 'undefined' && (this.selectedConversationId || this.selectedUserId)) {
|
||||
if (this.favourites.expanded === undefined && (this.selectedConversationId || this.selectedUserId)) {
|
||||
// A certain conversation should be opened.
|
||||
// We don't know which option it belongs to, so we need to fetch the data for all of them.
|
||||
const promises: Promise<void>[] = [];
|
||||
|
@ -355,7 +355,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected async fetchDataForExpandedOption(): Promise<void> {
|
||||
if (typeof this.favourites.expanded == 'undefined') {
|
||||
if (this.favourites.expanded === undefined) {
|
||||
// Calculate which option should be expanded initially.
|
||||
this.favourites.expanded = this.favourites.count != 0 && !this.group.unread && !this.individual.unread;
|
||||
this.group.expanded = !this.favourites.expanded && this.group.count != 0 && !this.individual.unread;
|
||||
|
@ -572,7 +572,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
|||
|
||||
if (conversation) {
|
||||
// Check if it's the last message. Offline messages are considered more recent than sent messages.
|
||||
if (typeof conversation.lastmessage === 'undefined' || conversation.lastmessage === null ||
|
||||
if (conversation.lastmessage === undefined || conversation.lastmessage === null ||
|
||||
!conversation.lastmessagepending || (conversation.lastmessagedate || 0) <= message.timecreated / 1000) {
|
||||
|
||||
this.addLastOfflineMessage(conversation, message);
|
||||
|
|
|
@ -69,12 +69,12 @@ export class AddonMessagesDiscussionLinkHandlerService extends CoreContentLinksH
|
|||
return false;
|
||||
}
|
||||
|
||||
if (typeof params.id == 'undefined' && typeof params.user2 == 'undefined') {
|
||||
if (params.id === undefined && params.user2 === undefined) {
|
||||
// Other user not defined, cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof params.user1 != 'undefined') {
|
||||
if (params.user1 !== undefined) {
|
||||
// Check if user1 is the current user, since the app only supports current user.
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
// Sync all conversations.
|
||||
conversationIds.forEach((conversationId) => {
|
||||
promises.push(this.syncDiscussion(conversationId, undefined, siteId).then((result) => {
|
||||
if (typeof result == 'undefined') {
|
||||
if (result === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
|
||||
userIds.forEach((userId) => {
|
||||
promises.push(this.syncDiscussion(undefined, userId, siteId).then((result) => {
|
||||
if (typeof result == 'undefined') {
|
||||
if (result === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ export class AddonMessagesProvider {
|
|||
userid: userId,
|
||||
};
|
||||
|
||||
if (typeof read != 'undefined') {
|
||||
if (read !== undefined) {
|
||||
params.read = read;
|
||||
}
|
||||
|
||||
|
@ -1075,10 +1075,10 @@ export class AddonMessagesProvider {
|
|||
preSets.getFromCache = false;
|
||||
preSets.emergencyCache = false;
|
||||
}
|
||||
if (typeof type != 'undefined' && type != null) {
|
||||
if (type !== undefined && type != null) {
|
||||
params.type = type;
|
||||
}
|
||||
if (typeof favourites != 'undefined' && favourites != null) {
|
||||
if (favourites !== undefined && favourites != null) {
|
||||
params.favourites = !!favourites;
|
||||
}
|
||||
if (site.isVersionGreaterEqualThan('3.7') && type != AddonMessagesProvider.MESSAGE_CONVERSATION_TYPE_GROUP) {
|
||||
|
@ -1244,7 +1244,7 @@ export class AddonMessagesProvider {
|
|||
userId: number,
|
||||
userFullname: string,
|
||||
): void => {
|
||||
if (typeof discussions[userId] === 'undefined') {
|
||||
if (discussions[userId] === undefined) {
|
||||
discussions[userId] = {
|
||||
fullname: userFullname,
|
||||
profileimageurl: '',
|
||||
|
@ -1259,7 +1259,7 @@ export class AddonMessagesProvider {
|
|||
|
||||
// Extract the most recent message. Pending messages are considered more recent than messages already sent.
|
||||
const discMessage = discussions[userId].message;
|
||||
if (typeof discMessage === 'undefined' || (!discMessage.pending && message.pending) ||
|
||||
if (discMessage === undefined || (!discMessage.pending && message.pending) ||
|
||||
(discMessage.pending == message.pending && (discMessage.timecreated < message.timecreated ||
|
||||
(discMessage.timecreated == message.timecreated && discMessage.id < messageId)))) {
|
||||
|
||||
|
@ -2646,7 +2646,7 @@ export class AddonMessagesProvider {
|
|||
conversationid: conversationId,
|
||||
messages: messages.map((message) => ({
|
||||
text: message.text,
|
||||
textformat: typeof message.textformat != 'undefined' ? message.textformat : 1,
|
||||
textformat: message.textformat !== undefined ? message.textformat : 1,
|
||||
})),
|
||||
};
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ export class AddonModAssignFeedbackPluginBaseComponent {
|
|||
},
|
||||
});
|
||||
|
||||
if (typeof modalData == 'undefined') {
|
||||
if (modalData === undefined) {
|
||||
throw new CoreCanceledError(); // User cancelled.
|
||||
}
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
|
|||
* @param hasSubmissions If the status has any submission.
|
||||
*/
|
||||
goToSubmissionList(status?: string, hasSubmissions = false): void {
|
||||
if (typeof status != 'undefined' && !hasSubmissions) {
|
||||
if (status !== undefined && !hasSubmissions) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
|
|||
groupId: this.group || 0,
|
||||
moduleName: this.moduleName,
|
||||
};
|
||||
if (typeof status != 'undefined') {
|
||||
if (status !== undefined) {
|
||||
params.status = status;
|
||||
}
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
|||
for (const x in this.gradeInfo.outcomes) {
|
||||
const outcome = this.gradeInfo.outcomes[x];
|
||||
|
||||
if (this.originalGrades.outcomes[outcome.id] == 'undefined' ||
|
||||
if (this.originalGrades.outcomes[outcome.id] === undefined ||
|
||||
this.originalGrades.outcomes[outcome.id] != outcome.selectedId) {
|
||||
return true;
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
|||
|
||||
if (submissionGrade.outcomes && Object.keys(submissionGrade.outcomes).length && this.gradeInfo?.outcomes) {
|
||||
this.gradeInfo.outcomes.forEach((outcome) => {
|
||||
if (typeof submissionGrade.outcomes[outcome.itemNumber!] != 'undefined') {
|
||||
if (submissionGrade.outcomes[outcome.itemNumber!] !== undefined) {
|
||||
// If outcome has been modified from gradebook, do not use offline.
|
||||
if (outcome.modified! < submissionGrade.timemodified) {
|
||||
outcome.selectedId = submissionGrade.outcomes[outcome.itemNumber!];
|
||||
|
@ -944,7 +944,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
|||
|
||||
// Check if grading method is simple or not.
|
||||
if (this.gradeInfo.advancedgrading && this.gradeInfo.advancedgrading[0] &&
|
||||
typeof this.gradeInfo.advancedgrading[0].method != 'undefined') {
|
||||
this.gradeInfo.advancedgrading[0].method !== undefined) {
|
||||
this.grade.method = this.gradeInfo.advancedgrading[0].method || 'simple';
|
||||
} else {
|
||||
this.grade.method = 'simple';
|
||||
|
@ -1039,7 +1039,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
|||
}
|
||||
|
||||
const submissionStatementMissing = !!this.assign!.requiresubmissionstatement &&
|
||||
typeof this.assign!.submissionstatement == 'undefined';
|
||||
this.assign!.submissionstatement === undefined;
|
||||
|
||||
this.canSubmit = !this.isSubmittedForGrading && !this.submittedOffline && (submissionStatus.lastattempt.cansubmit ||
|
||||
(this.hasOffline && AddonModAssign.canSubmitOffline(this.assign!, submissionStatus)));
|
||||
|
|
|
@ -69,7 +69,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
|
|||
*/
|
||||
discardDraft(assignId: number, userId: number, siteId?: string): void {
|
||||
const id = this.getDraftId(assignId, userId, siteId);
|
||||
if (typeof this.drafts[id] != 'undefined') {
|
||||
if (this.drafts[id] !== undefined) {
|
||||
delete this.drafts[id];
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
|
|||
getDraft(assignId: number, userId: number, siteId?: string): AddonModAssignFeedbackCommentsDraftData | undefined {
|
||||
const id = this.getDraftId(assignId, userId, siteId);
|
||||
|
||||
if (typeof this.drafts[id] != 'undefined') {
|
||||
if (this.drafts[id] !== undefined) {
|
||||
return this.drafts[id];
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
|
|||
const initialText = AddonModAssign.getSubmissionPluginText(plugin);
|
||||
const newText = AddonModAssignFeedbackCommentsHandler.getTextFromInputData(plugin, inputData);
|
||||
|
||||
if (typeof newText == 'undefined') {
|
||||
if (newText === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ export class AddonModAssignSubmissionReviewPage implements OnInit, OnDestroy, Ca
|
|||
|
||||
// Grades can be saved if simple grading.
|
||||
if (gradeInfo.advancedgrading && gradeInfo.advancedgrading[0] &&
|
||||
typeof gradeInfo.advancedgrading[0].method != 'undefined') {
|
||||
gradeInfo.advancedgrading[0].method !== undefined) {
|
||||
|
||||
const method = gradeInfo.advancedgrading[0].method || 'simple';
|
||||
this.canSaveGrades = method == 'simple';
|
||||
|
|
|
@ -406,7 +406,7 @@ export class AddonModAssignHelperProvider {
|
|||
|
||||
submissions.forEach((submission) => {
|
||||
submission.submitid = submission.userid && submission.userid > 0 ? submission.userid : submission.blindid;
|
||||
if (typeof submission.submitid == 'undefined' || submission.submitid <= 0) {
|
||||
if (submission.submitid === undefined || submission.submitid <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
|
|||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../assign-helper';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreGroups } from '@services/groups';
|
||||
|
@ -243,7 +242,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
|
|||
|
||||
promises.push(this.prefetchSubmissions(assign, courseId, module.id, userId, siteId));
|
||||
|
||||
promises.push(CoreCourseHelper.getModuleCourseIdByInstance(assign.id, 'assign', siteId));
|
||||
promises.push(CoreCourse.getModuleBasicInfoByInstance(assign.id, 'assign', { siteId }));
|
||||
// Get course data, needed to determine upload max size if it's configured to be course limit.
|
||||
promises.push(CoreUtils.ignoreErrors(CoreCourses.getCourseByField('id', courseId, siteId)));
|
||||
|
||||
|
@ -254,7 +253,6 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
|
|||
promises.push(CoreFilepool.addFilesToQueue(siteId, files, this.component, module.id));
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -515,7 +513,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModAssignSyncResult> {
|
||||
return AddonModAssignSync.syncAssign(module.instance!, siteId);
|
||||
return AddonModAssignSync.syncAssign(module.instance, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { CoreConstants } from '@/core/constants';
|
||||
import { Injectable, Type } from '@angular/core';
|
||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||
import { CoreSitePluginsModuleHandler } from '@features/siteplugins/classes/handlers/module-handler';
|
||||
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
||||
|
@ -72,7 +72,7 @@ export class AddonModBBBModuleHandlerService extends CoreModuleHandlerBase imple
|
|||
* @inheritdoc
|
||||
*/
|
||||
async getData(
|
||||
module: CoreCourseModule,
|
||||
module: CoreCourseModuleData,
|
||||
courseId: number,
|
||||
sectionId?: number,
|
||||
forCoursePage?: boolean,
|
||||
|
|
|
@ -223,7 +223,7 @@ export class AddonModBookProvider {
|
|||
* @return The toc.
|
||||
*/
|
||||
getToc(contents: CoreCourseModuleContentFile[]): AddonModBookTocChapterParsed[] {
|
||||
if (!contents || !contents.length || typeof contents[0].content == 'undefined') {
|
||||
if (!contents || !contents.length || contents[0].content === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||
import { CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
||||
import { CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -39,7 +40,7 @@ export class AddonModBookPrefetchHandlerService extends CoreCourseResourcePrefet
|
|||
* @param prefetch True to prefetch, false to download right away.
|
||||
* @return Promise resolved when all content is downloaded. Data returned is not reliable.
|
||||
*/
|
||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
const promises: Promise<unknown>[] = [];
|
||||
|
||||
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
||||
|
|
|
@ -17,6 +17,7 @@ import { CoreCourse } from '@features/course/services/course';
|
|||
import { CoreTagFeedComponent } from '@features/tag/components/feed/feed';
|
||||
import { CoreTagAreaHandler } from '@features/tag/services/tag-area-delegate';
|
||||
import { CoreTagFeedElement, CoreTagHelper } from '@features/tag/services/tag-helper';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreUrlUtils } from '@services/utils/url';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModBook } from '../book';
|
||||
|
@ -49,16 +50,17 @@ export class AddonModBookTagAreaHandlerService implements CoreTagAreaHandler {
|
|||
const items = CoreTagHelper.parseFeedContent(content);
|
||||
|
||||
// Find module ids of the returned books, they are needed by the link delegate.
|
||||
await Promise.all(items.map((item) => {
|
||||
await Promise.all(items.map(async (item) => {
|
||||
const params = item.url ? CoreUrlUtils.extractUrlParams(item.url) : {};
|
||||
if (params.b && !params.id) {
|
||||
const bookId = parseInt(params.b, 10);
|
||||
|
||||
return CoreCourse.getModuleBasicInfoByInstance(bookId, 'book').then((module) => {
|
||||
item.url += '&id=' + module.id;
|
||||
|
||||
return;
|
||||
});
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(
|
||||
bookId,
|
||||
'book',
|
||||
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
item.url += '&id=' + module.id;
|
||||
}
|
||||
}));
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid
|
|||
|
||||
// Data has been sent to server, prefetch choice if needed.
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(choiceId, 'choice', siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(choiceId, 'choice', { siteId });
|
||||
|
||||
await this.prefetchAfterUpdate(AddonModChoicePrefetchHandler.instance, module, courseId, undefined, siteId);
|
||||
} catch {
|
||||
|
|
|
@ -147,7 +147,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModChoiceSyncResult> {
|
||||
return AddonModChoiceSync.syncChoice(module.instance!, undefined, siteId);
|
||||
return AddonModChoiceSync.syncChoice(module.instance, undefined, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Params } from '@angular/router';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreTag } from '@features/tag/services/tag';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
@ -44,8 +43,8 @@ export class AddonModDataActionComponent implements OnInit {
|
|||
@Input() action!: AddonModDataAction; // The field to render.
|
||||
@Input() entry!: AddonModDataEntry; // The value of the field.
|
||||
@Input() database!: AddonModDataData; // Database object.
|
||||
@Input() module!: CoreCourseModule; // Module object.
|
||||
@Input() group = 0; // Module object.
|
||||
@Input() title = ''; // Name of the module.
|
||||
@Input() group = 0; // Module group.
|
||||
@Input() offset?: number; // Offset of the entry.
|
||||
|
||||
siteId: string;
|
||||
|
@ -92,13 +91,13 @@ export class AddonModDataActionComponent implements OnInit {
|
|||
* Go to the edit page of the entry.
|
||||
*/
|
||||
editEntry(): void {
|
||||
const params = {
|
||||
courseId: this.database.course,
|
||||
module: this.module,
|
||||
const params: Params = {
|
||||
title: this.title,
|
||||
};
|
||||
|
||||
const basePath = AddonModDataModuleHandlerService.PAGE_NAME;
|
||||
CoreNavigator.navigateToSitePath(
|
||||
`${AddonModDataModuleHandlerService.PAGE_NAME}/${this.module.course}/${this.module.id}/edit/${this.entry.id}`,
|
||||
`${basePath}/${this.database.course}/${this.database.coursemodule}/edit/${this.entry.id}`,
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
@ -108,15 +107,14 @@ export class AddonModDataActionComponent implements OnInit {
|
|||
*/
|
||||
viewEntry(): void {
|
||||
const params: Params = {
|
||||
courseId: this.database.course,
|
||||
module: this.module,
|
||||
entryId: this.entry.id,
|
||||
title: this.title,
|
||||
group: this.group,
|
||||
offset: this.offset,
|
||||
};
|
||||
|
||||
const basePath = AddonModDataModuleHandlerService.PAGE_NAME;
|
||||
CoreNavigator.navigateToSitePath(
|
||||
`${AddonModDataModuleHandlerService.PAGE_NAME}/${this.module.course}/${this.module.id}/${this.entry.id}`,
|
||||
`${basePath}/${this.database.course}/${this.database.coursemodule}/${this.entry.id}`,
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import { Component, OnDestroy, OnInit, Optional, Type } from '@angular/core';
|
|||
import { Params } from '@angular/router';
|
||||
import { CoreCommentsProvider } from '@features/comments/services/comments';
|
||||
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
|
||||
import { CoreCourseModule } from '@features/course/course.module';
|
||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreRatingProvider } from '@features/rating/services/rating';
|
||||
|
@ -95,7 +94,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
fields: Record<number, AddonModDataField>;
|
||||
entries: Record<number, AddonModDataEntry>;
|
||||
database: AddonModDataData;
|
||||
module: CoreCourseModule;
|
||||
title: string;
|
||||
group: number;
|
||||
gotoEntry: (a: number) => void;
|
||||
};
|
||||
|
@ -191,7 +190,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
* @return True if refresh is needed, false otherwise.
|
||||
*/
|
||||
protected isRefreshSyncNeeded(syncEventData: AddonModDataAutoSyncData): boolean {
|
||||
if (this.database && syncEventData.dataId == this.database.id && typeof syncEventData.entryId == 'undefined') {
|
||||
if (this.database && syncEventData.dataId == this.database.id && syncEventData.entryId === undefined) {
|
||||
this.loaded = false;
|
||||
// Refresh the data.
|
||||
this.content?.scrollToTop();
|
||||
|
@ -309,7 +308,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
|
||||
this.entriesRendered = '';
|
||||
|
||||
this.foundRecordsTranslationData = typeof entries.maxcount != 'undefined'
|
||||
this.foundRecordsTranslationData = entries.maxcount !== undefined
|
||||
? {
|
||||
num: entries.totalcount,
|
||||
max: entries.maxcount,
|
||||
|
@ -371,7 +370,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
fields: this.fields,
|
||||
entries: entriesById,
|
||||
database: this.database!,
|
||||
module: this.module,
|
||||
title: this.module.name,
|
||||
group: this.selectedGroup,
|
||||
gotoEntry: this.gotoEntry.bind(this),
|
||||
};
|
||||
|
@ -474,8 +473,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
*/
|
||||
gotoAddEntries(): void {
|
||||
const params: Params = {
|
||||
module: this.module,
|
||||
courseId: this.courseId,
|
||||
title: this.module.name,
|
||||
group: this.selectedGroup,
|
||||
};
|
||||
|
||||
|
@ -492,8 +490,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
*/
|
||||
gotoEntry(entryId: number): void {
|
||||
const params: Params = {
|
||||
module: this.module,
|
||||
courseId: this.courseId,
|
||||
title: this.module.name,
|
||||
group: this.selectedGroup,
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ export class AddonModDataSearchComponent implements OnInit {
|
|||
ngOnInit(): void {
|
||||
this.advancedIndexed = {};
|
||||
this.search.advanced?.forEach((field) => {
|
||||
if (typeof field != 'undefined') {
|
||||
if (field !== undefined) {
|
||||
this.advancedIndexed[field.name] = field.value
|
||||
? CoreTextUtils.parseJSON(field.value, '')
|
||||
: '';
|
||||
|
|
|
@ -48,7 +48,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
|
|||
* @return Readable Latitude and logitude.
|
||||
*/
|
||||
formatLatLong(north?: number, east?: number): string {
|
||||
if (typeof north !== 'undefined' || typeof east !== 'undefined') {
|
||||
if (north !== undefined || east !== undefined) {
|
||||
north = north || 0;
|
||||
east = east || 0;
|
||||
const northFixed = Math.abs(north).toFixed(4);
|
||||
|
@ -69,7 +69,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
|
|||
*/
|
||||
getLatLongLink(north?: number, east?: number): SafeUrl {
|
||||
let url = '';
|
||||
if (typeof north !== 'undefined' || typeof east !== 'undefined') {
|
||||
if (north !== undefined || east !== undefined) {
|
||||
const northFixed = north ? north.toFixed(4) : '0.0000';
|
||||
const eastFixed = east ? east.toFixed(4) : '0.0000';
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ export class AddonModDataFieldLatlongHandlerService implements AddonModDataField
|
|||
|
||||
// The lat long class has two values that need to be checked.
|
||||
inputData.forEach((value) => {
|
||||
if (typeof value.value != 'undefined' && value.value != '') {
|
||||
if (value.value !== undefined && value.value != '') {
|
||||
valueCount++;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -135,7 +135,7 @@ export class AddonModDataFieldPictureHandlerService implements AddonModDataField
|
|||
}
|
||||
|
||||
const found = inputData.some((input) => {
|
||||
if (typeof input.subfield != 'undefined' && input.subfield == 'file') {
|
||||
if (input.subfield !== undefined && input.subfield == 'file') {
|
||||
return !!input.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</ion-buttons>
|
||||
<ion-title>
|
||||
<h1>
|
||||
<core-format-text [text]="title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
|
||||
<core-format-text [text]="title" contextLevel="module" [contextInstanceId]="moduleId" [courseId]="courseId">
|
||||
</core-format-text>
|
||||
</h1>
|
||||
</ion-title>
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
import { Component, OnInit, ViewChild, ElementRef, Type } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreTag } from '@features/tag/services/tag';
|
||||
import { IonContent } from '@ionic/angular';
|
||||
|
@ -66,7 +65,7 @@ export class AddonModDataEditPage implements OnInit {
|
|||
entry?: AddonModDataEntry;
|
||||
fields: Record<number, AddonModDataField> = {};
|
||||
courseId!: number;
|
||||
module!: CoreCourseModule;
|
||||
moduleId = 0;
|
||||
database?: AddonModDataData;
|
||||
title = '';
|
||||
component = AddonModDataProvider.COMPONENT;
|
||||
|
@ -97,9 +96,10 @@ export class AddonModDataEditPage implements OnInit {
|
|||
*/
|
||||
ngOnInit(): void {
|
||||
try {
|
||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||
this.moduleId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||
this.title = CoreNavigator.getRouteParam<string>('title') || '';
|
||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModal(error);
|
||||
|
@ -110,9 +110,7 @@ export class AddonModDataEditPage implements OnInit {
|
|||
}
|
||||
|
||||
// If entryId is lower than 0 or null, it is a new entry or an offline entry.
|
||||
this.isEditing = typeof this.entryId != 'undefined' && this.entryId > 0;
|
||||
|
||||
this.title = this.module.name;
|
||||
this.isEditing = this.entryId !== undefined && this.entryId > 0;
|
||||
|
||||
this.fetchEntryData(true);
|
||||
}
|
||||
|
@ -134,7 +132,7 @@ export class AddonModDataEditPage implements OnInit {
|
|||
|
||||
if (changed) {
|
||||
// Show confirmation if some data has been modified.
|
||||
await CoreDomUtils.showConfirm(Translate.instant('coentryre.confirmcanceledit'));
|
||||
await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit'));
|
||||
}
|
||||
|
||||
// Delete the local files from the tmp folder.
|
||||
|
@ -154,11 +152,11 @@ export class AddonModDataEditPage implements OnInit {
|
|||
*/
|
||||
protected async fetchEntryData(refresh = false): Promise<void> {
|
||||
try {
|
||||
this.database = await AddonModData.getDatabase(this.courseId, this.module.id);
|
||||
this.database = await AddonModData.getDatabase(this.courseId, this.moduleId);
|
||||
this.title = this.database.name || this.title;
|
||||
this.cssClass = 'addon-data-entries-' + this.database.id;
|
||||
|
||||
this.fieldsArray = await AddonModData.getFields(this.database.id, { cmId: this.module.id });
|
||||
this.fieldsArray = await AddonModData.getFields(this.database.id, { cmId: this.moduleId });
|
||||
this.fields = CoreUtils.arrayToObject(this.fieldsArray, 'id');
|
||||
|
||||
const entry = await AddonModDataHelper.fetchEntry(this.database, this.fieldsArray, this.entryId || 0);
|
||||
|
@ -183,7 +181,7 @@ export class AddonModDataEditPage implements OnInit {
|
|||
|
||||
await Promise.all(this.groupInfo.groups.map(async (group) => {
|
||||
const accessData = await AddonModData.getDatabaseAccessInformation(this.database!.id, {
|
||||
cmId: this.module.id, groupId: group.id });
|
||||
cmId: this.moduleId, groupId: group.id });
|
||||
|
||||
canAddGroup[group.id] = accessData.canaddentry;
|
||||
}));
|
||||
|
@ -196,7 +194,7 @@ export class AddonModDataEditPage implements OnInit {
|
|||
haveAccess = true;
|
||||
}
|
||||
} else {
|
||||
const accessData = await AddonModData.getDatabaseAccessInformation(this.database.id, { cmId: this.module.id });
|
||||
const accessData = await AddonModData.getDatabaseAccessInformation(this.database.id, { cmId: this.moduleId });
|
||||
haveAccess = accessData.canaddentry;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</ion-buttons>
|
||||
<ion-title>
|
||||
<h1>
|
||||
<core-format-text [text]="title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
|
||||
<core-format-text [text]="title" contextLevel="module" [contextInstanceId]="moduleId" [courseId]="courseId">
|
||||
</core-format-text>
|
||||
</h1>
|
||||
</ion-title>
|
||||
|
|
|
@ -16,7 +16,6 @@ import { Component, OnDestroy, ViewChild, ChangeDetectorRef, OnInit, Type } from
|
|||
import { CoreCommentsCommentsComponent } from '@features/comments/components/comments/comments';
|
||||
import { CoreComments } from '@features/comments/services/comments';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreRatingInfo } from '@features/rating/services/rating';
|
||||
import { IonContent, IonRefresher } from '@ionic/angular';
|
||||
import { CoreGroups, CoreGroupInfo } from '@services/groups';
|
||||
|
@ -57,7 +56,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
protected fields: Record<number, AddonModDataField> = {};
|
||||
protected fieldsArray: AddonModDataField[] = [];
|
||||
|
||||
module!: CoreCourseModule;
|
||||
moduleId = 0;
|
||||
courseId!: number;
|
||||
offset?: number;
|
||||
title = '';
|
||||
|
@ -82,7 +81,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
fields: Record<number, AddonModDataField>;
|
||||
entries: Record<number, AddonModDataEntry>;
|
||||
database: AddonModDataData;
|
||||
module: CoreCourseModule;
|
||||
title: string;
|
||||
group: number;
|
||||
};
|
||||
|
||||
|
@ -98,7 +97,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
|
||||
// Refresh data if this discussion is synchronized automatically.
|
||||
this.syncObserver = CoreEvents.on(AddonModDataSyncProvider.AUTO_SYNCED, (data) => {
|
||||
if (typeof data.entryId == 'undefined') {
|
||||
if (data.entryId === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -133,9 +132,10 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
*/
|
||||
async ngOnInit(): Promise<void> {
|
||||
try {
|
||||
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||
this.moduleId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||
this.title = CoreNavigator.getRouteParam<string>('title') || '';
|
||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||
this.offset = CoreNavigator.getRouteNumberParam('offset');
|
||||
} catch (error) {
|
||||
|
@ -146,8 +146,6 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
return;
|
||||
}
|
||||
|
||||
this.title = this.module.name;
|
||||
|
||||
this.commentsEnabled = !CoreComments.areCommentsDisabledInSite();
|
||||
|
||||
await this.fetchEntryData();
|
||||
|
@ -165,15 +163,15 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
this.isPullingToRefresh = isPtr;
|
||||
|
||||
try {
|
||||
this.database = await AddonModData.getDatabase(this.courseId, this.module.id);
|
||||
this.database = await AddonModData.getDatabase(this.courseId, this.moduleId);
|
||||
this.title = this.database.name || this.title;
|
||||
|
||||
this.fieldsArray = await AddonModData.getFields(this.database.id, { cmId: this.module.id });
|
||||
this.fieldsArray = await AddonModData.getFields(this.database.id, { cmId: this.moduleId });
|
||||
this.fields = CoreUtils.arrayToObject(this.fieldsArray, 'id');
|
||||
|
||||
await this.setEntryFromOffset();
|
||||
|
||||
this.access = await AddonModData.getDatabaseAccessInformation(this.database.id, { cmId: this.module.id });
|
||||
this.access = await AddonModData.getDatabaseAccessInformation(this.database.id, { cmId: this.moduleId });
|
||||
|
||||
this.groupInfo = await CoreGroups.getActivityGroupInfo(this.database.coursemodule);
|
||||
this.selectedGroup = CoreGroups.validateGroupId(this.selectedGroup, this.groupInfo);
|
||||
|
@ -200,7 +198,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
fields: this.fields,
|
||||
entries: entries,
|
||||
database: this.database,
|
||||
module: this.module,
|
||||
title: this.title,
|
||||
group: this.selectedGroup,
|
||||
};
|
||||
} catch (error) {
|
||||
|
@ -299,7 +297,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
* @return Resolved when done.
|
||||
*/
|
||||
protected async setEntryFromOffset(): Promise<void> {
|
||||
if (typeof this.offset == 'undefined' && typeof this.entryId != 'undefined') {
|
||||
if (this.offset === undefined && this.entryId !== undefined) {
|
||||
// Entry id passed as navigation parameter instead of the offset.
|
||||
// We don't display next/previous buttons in this case.
|
||||
this.hasNext = false;
|
||||
|
@ -313,7 +311,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
const perPage = AddonModDataProvider.PER_PAGE;
|
||||
const page = typeof this.offset != 'undefined' && this.offset >= 0
|
||||
const page = this.offset !== undefined && this.offset >= 0
|
||||
? Math.floor(this.offset / perPage)
|
||||
: 0;
|
||||
|
||||
|
@ -329,7 +327,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
|
||||
// Index of the entry when concatenating offline and online page entries.
|
||||
let pageIndex = 0;
|
||||
if (typeof this.offset == 'undefined') {
|
||||
if (this.offset === undefined) {
|
||||
// No offset passed, display the first entry.
|
||||
pageIndex = 0;
|
||||
} else if (this.offset > 0) {
|
||||
|
@ -363,7 +361,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
|
||||
if (this.entryId > 0) {
|
||||
// Online entry, we need to fetch the the rating info.
|
||||
const entry = await AddonModData.getEntry(this.database!.id, this.entryId, { cmId: this.module.id });
|
||||
const entry = await AddonModData.getEntry(this.database!.id, this.entryId, { cmId: this.moduleId });
|
||||
this.ratingInfo = entry.ratinginfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreCourse } from '@features/course/services/course';
|
|||
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreRatingOffline } from '@features/rating/services/rating-offline';
|
||||
import { FileEntry } from '@ionic-native/file/ngx';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreFormFields } from '@singletons/form';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -86,7 +86,7 @@ export class AddonModDataHelperProvider {
|
|||
record.groupid = action.groupid;
|
||||
|
||||
action.fields.forEach((offlineContent) => {
|
||||
if (typeof offlineContents[offlineContent.fieldid] == 'undefined') {
|
||||
if (offlineContents[offlineContent.fieldid] === undefined) {
|
||||
offlineContents[offlineContent.fieldid] = {};
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ export class AddonModDataHelperProvider {
|
|||
render = Translate.instant('addon.mod_data.' + (entry.approved ? 'approved' : 'notapproved'));
|
||||
} else {
|
||||
render = '<addon-mod-data-action action="' + action + '" [entry]="entries[' + entry.id + ']" mode="' + mode +
|
||||
'" [database]="database" [module]="module" [offset]="' + offset + '" [group]="group" ></addon-mod-data-action>';
|
||||
'" [database]="database" [title]="title" [offset]="' + offset + '" [group]="group" ></addon-mod-data-action>';
|
||||
}
|
||||
template = template.replace(replaceRegex, render);
|
||||
} else {
|
||||
|
@ -270,7 +270,7 @@ export class AddonModDataHelperProvider {
|
|||
result.hasOfflineActions = !!actions.length;
|
||||
|
||||
actions.forEach((action) => {
|
||||
if (typeof offlineActions[action.entryid] == 'undefined') {
|
||||
if (offlineActions[action.entryid] === undefined) {
|
||||
offlineActions[action.entryid] = [];
|
||||
}
|
||||
offlineActions[action.entryid].push(action);
|
||||
|
@ -437,7 +437,11 @@ export class AddonModDataHelperProvider {
|
|||
return courseId;
|
||||
}
|
||||
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(dataId, 'data', siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(
|
||||
dataId,
|
||||
'data',
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
return module.course;
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ export class AddonModDataOfflineProvider {
|
|||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
timemodified = timemodified || new Date().getTime();
|
||||
entryId = typeof entryId == 'undefined' || entryId === null ? -timemodified : entryId;
|
||||
entryId = entryId === undefined || entryId === null ? -timemodified : entryId;
|
||||
|
||||
const entry: AddonModDataEntryDBRecord = {
|
||||
dataid: dataId,
|
||||
|
|
|
@ -197,7 +197,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
const offlineEntries: Record<number, AddonModDataOfflineAction[]> = {};
|
||||
|
||||
offlineActions.forEach((entry) => {
|
||||
if (typeof offlineEntries[entry.entryid] == 'undefined') {
|
||||
if (offlineEntries[entry.entryid] === undefined) {
|
||||
offlineEntries[entry.entryid] = [];
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ export class AddonModDataProvider {
|
|||
data,
|
||||
};
|
||||
|
||||
if (typeof groupId !== 'undefined') {
|
||||
if (groupId !== undefined) {
|
||||
params.groupid = groupId;
|
||||
}
|
||||
|
||||
|
@ -1004,16 +1004,16 @@ export class AddonModDataProvider {
|
|||
componentId: options.cmId,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||
};
|
||||
if (typeof options.sort != 'undefined') {
|
||||
if (options.sort !== undefined) {
|
||||
params.sort = options.sort;
|
||||
}
|
||||
if (typeof options.order !== 'undefined') {
|
||||
if (options.order !== undefined) {
|
||||
params.order = options.order;
|
||||
}
|
||||
if (typeof options.search !== 'undefined') {
|
||||
if (options.search !== undefined) {
|
||||
params.search = options.search;
|
||||
}
|
||||
if (typeof options.advSearch !== 'undefined') {
|
||||
if (options.advSearch !== undefined) {
|
||||
params.advsearch = options.advSearch;
|
||||
}
|
||||
const response = await site.read<AddonModDataSearchEntriesWSResponse>('mod_data_search_entries', params, preSets);
|
||||
|
|
|
@ -50,7 +50,7 @@ export class AddonModDataApproveLinkHandlerService extends CoreContentLinksHandl
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> {
|
||||
if (typeof params.d == 'undefined' || (typeof params.approve == 'undefined' && typeof params.disapprove == 'undefined')) {
|
||||
if (params.d === undefined || (params.approve === undefined && params.disapprove === undefined)) {
|
||||
// Required fields not defined. Cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ export class AddonModDataDeleteLinkHandlerService extends CoreContentLinksHandle
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> {
|
||||
if (typeof params.d == 'undefined' || typeof params.delete == 'undefined') {
|
||||
if (params.d === undefined || params.delete === undefined) {
|
||||
// Required fields not defined. Cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModDataModuleHandlerService } from './module';
|
||||
|
@ -44,10 +45,13 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB
|
|||
const rId = params.rid || '';
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(dataId, 'data', siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(
|
||||
dataId,
|
||||
'data',
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
const pageParams: Params = {
|
||||
module,
|
||||
courseId: module.course,
|
||||
title: module.name,
|
||||
};
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
|
@ -66,7 +70,7 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> {
|
||||
if (typeof params.d == 'undefined') {
|
||||
if (params.d === undefined) {
|
||||
// Id not defined. Cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
async invalidateModule(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
|
||||
const promises: Promise<void>[] = [];
|
||||
promises.push(AddonModData.invalidateDatabaseData(courseId));
|
||||
promises.push(AddonModData.invalidateDatabaseAccessInformationData(module.instance!));
|
||||
promises.push(AddonModData.invalidateDatabaseAccessInformationData(module.instance));
|
||||
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
});
|
||||
|
||||
// Add Basic Info to manage links.
|
||||
promises.push(CoreCourse.getModuleBasicInfoByInstance(database.id, 'data', siteId));
|
||||
promises.push(CoreCourse.getModuleBasicInfoByInstance(database.id, 'data', { siteId }));
|
||||
|
||||
// Get course data, needed to determine upload max size if it's configured to be course limit.
|
||||
promises.push(CoreUtils.ignoreErrors(CoreCourses.getCourseByField('id', courseId, siteId)));
|
||||
|
@ -279,7 +279,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
*/
|
||||
async sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModDataSyncResult> {
|
||||
const promises = [
|
||||
AddonModDataSync.syncDatabase(module.instance!, siteId),
|
||||
AddonModDataSync.syncDatabase(module.instance, siteId),
|
||||
AddonModDataSync.syncRatings(module.id, true, siteId),
|
||||
];
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModDataModuleHandlerService } from './module';
|
||||
|
@ -47,10 +48,13 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB
|
|||
const page = parseInt(params.page, 10) || false;
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(dataId, 'data', siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(
|
||||
dataId,
|
||||
'data',
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
const pageParams: Params = {
|
||||
module: module,
|
||||
courseId: module.course,
|
||||
title: module.name,
|
||||
};
|
||||
|
||||
if (group) {
|
||||
|
@ -77,12 +81,12 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> {
|
||||
if (typeof params.d == 'undefined') {
|
||||
if (params.d === undefined) {
|
||||
// Id not defined. Cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((!params.mode || params.mode != 'single') && typeof params.rid == 'undefined') {
|
||||
if ((!params.mode || params.mode != 'single') && params.rid === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
item.data = <string[]> item.data.map((dataItem) => {
|
||||
const parsed = <Record<string, string>> CoreTextUtils.parseJSON(dataItem);
|
||||
|
||||
return typeof parsed.show != 'undefined' ? parsed.show : false;
|
||||
return parsed.show !== undefined ? parsed.show : false;
|
||||
}).filter((dataItem) => dataItem); // Filter false entries.
|
||||
|
||||
case 'textfield':
|
||||
|
@ -312,7 +312,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
const parsedData = <Record<string, string | number>[]> item.data.map((dataItem) => {
|
||||
const parsed = <Record<string, string | number>> CoreTextUtils.parseJSON(dataItem);
|
||||
|
||||
return typeof parsed.answertext != 'undefined' ? parsed : false;
|
||||
return parsed.answertext !== undefined ? parsed : false;
|
||||
}).filter((dataItem) => dataItem); // Filter false entries.
|
||||
|
||||
// Format labels.
|
||||
|
@ -320,7 +320,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
dataItem.quotient = (<number> dataItem.quotient * 100).toFixed(2);
|
||||
let label = '';
|
||||
|
||||
if (typeof dataItem.value != 'undefined') {
|
||||
if (dataItem.value !== undefined) {
|
||||
label = '(' + dataItem.value + ') ';
|
||||
}
|
||||
label += dataItem.answertext;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { CoreSite } from '@classes/site';
|
||||
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
|
||||
import { CoreCourse, CoreCourseCommonModWSOptions, CoreCourseWSModule } from '@features/course/services/course';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreCourse, CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CanLeave } from '@guards/can-leave';
|
||||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
|
@ -51,7 +51,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
|
||||
@ViewChild(IonContent) content?: IonContent;
|
||||
|
||||
protected module?: CoreCourseWSModule;
|
||||
protected module?: CoreCourseModuleData;
|
||||
protected currentPage?: number;
|
||||
protected siteAfterSubmit?: string;
|
||||
protected onlineObserver: Subscription;
|
||||
|
|
|
@ -100,7 +100,7 @@ export class AddonModFeedbackNonRespondentsPage implements OnInit {
|
|||
protected async loadGroupUsers(groupId?: number): Promise<void> {
|
||||
this.loadMoreError = false;
|
||||
|
||||
if (typeof groupId == 'undefined') {
|
||||
if (groupId === undefined) {
|
||||
this.page++;
|
||||
} else {
|
||||
this.selectedGroup = groupId;
|
||||
|
|
|
@ -115,7 +115,7 @@ export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
|||
* @return Resolved with the attempts loaded.
|
||||
*/
|
||||
protected async loadGroupAttempts(groupId?: number): Promise<void> {
|
||||
if (typeof groupId == 'undefined') {
|
||||
if (groupId === undefined) {
|
||||
this.page++;
|
||||
this.loadingMore = true;
|
||||
} else {
|
||||
|
|
|
@ -176,9 +176,12 @@ export class AddonModFeedbackHelperProvider {
|
|||
const modal = await CoreDomUtils.showModalLoading();
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfo(Number(params.id), siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
Number(params.id),
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
if (typeof params.showcompleted == 'undefined') {
|
||||
if (params.showcompleted === undefined) {
|
||||
// Param showcompleted not defined. Show entry list.
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/respondents`,
|
||||
|
@ -269,7 +272,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
|
||||
if (type == MODE_COURSE || type == MODE_CATEGORY) {
|
||||
formItem.presentation = formItem.otherdata;
|
||||
formItem.value = typeof formItem.rawValue != 'undefined' ? formItem.rawValue : formItem.otherdata;
|
||||
formItem.value = formItem.rawValue !== undefined ? formItem.rawValue : formItem.otherdata;
|
||||
} else if (type == MODE_RESPONSETIME) {
|
||||
formItem.value = '__CURRENT__TIMESTAMP__';
|
||||
|
||||
|
@ -298,7 +301,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
|
||||
const formItem: AddonModFeedbackNumericItem = Object.assign(item, {
|
||||
templateName: 'numeric',
|
||||
value: typeof item.rawValue != 'undefined' ? Number(item.rawValue) : '',
|
||||
value: item.rawValue !== undefined ? Number(item.rawValue) : '',
|
||||
rangefrom: typeof rangeFrom == 'number' && !isNaN(rangeFrom) ? range[0] : '',
|
||||
rangeto: typeof rangeTo == 'number' && !isNaN(rangeTo) ? rangeTo : '',
|
||||
hasTextInput: true,
|
||||
|
@ -318,7 +321,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
return Object.assign(item, {
|
||||
templateName: 'textfield',
|
||||
length: Number(item.presentation.split(AddonModFeedbackProvider.LINE_SEP)[1]) || 255,
|
||||
value: typeof item.rawValue != 'undefined' ? item.rawValue : '',
|
||||
value: item.rawValue !== undefined ? item.rawValue : '',
|
||||
hasTextInput: true,
|
||||
});
|
||||
}
|
||||
|
@ -332,7 +335,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
protected getItemFormTextarea(item: AddonModFeedbackItem): AddonModFeedbackFormBasicItem {
|
||||
return Object.assign(item, {
|
||||
templateName: 'textarea',
|
||||
value: typeof item.rawValue != 'undefined' ? item.rawValue : '',
|
||||
value: item.rawValue !== undefined ? item.rawValue : '',
|
||||
hasTextInput: true,
|
||||
});
|
||||
}
|
||||
|
@ -373,12 +376,12 @@ export class AddonModFeedbackHelperProvider {
|
|||
|
||||
if (formItem.subtype === 'r' && formItem.options.search(AddonModFeedbackProvider.MULTICHOICE_HIDENOSELECT) == -1) {
|
||||
formItem.choices.unshift({ value: 0, label: Translate.instant('addon.mod_feedback.not_selected') });
|
||||
formItem.value = typeof formItem.rawValue != 'undefined' ? Number(formItem.rawValue) : 0;
|
||||
formItem.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : 0;
|
||||
} else if (formItem.subtype === 'd') {
|
||||
formItem.choices.unshift({ value: 0, label: '' });
|
||||
formItem.value = typeof formItem.rawValue != 'undefined' ? Number(formItem.rawValue) : 0;
|
||||
formItem.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : 0;
|
||||
} else if (formItem.subtype === 'c') {
|
||||
if (typeof formItem.rawValue != 'undefined') {
|
||||
if (formItem.rawValue !== undefined) {
|
||||
formItem.rawValue = String(formItem.rawValue);
|
||||
const values = formItem.rawValue.split(AddonModFeedbackProvider.LINE_SEP);
|
||||
formItem.choices.forEach((choice) => {
|
||||
|
@ -392,7 +395,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
formItem.value = typeof formItem.rawValue != 'undefined' ? Number(formItem.rawValue) : '';
|
||||
formItem.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : '';
|
||||
}
|
||||
|
||||
return formItem;
|
||||
|
|
|
@ -223,7 +223,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
|
|||
if (result.updated) {
|
||||
// Data has been sent to server, update data.
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(feedbackId, 'feedback', siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(feedbackId, 'feedback', { siteId });
|
||||
|
||||
await this.prefetchAfterUpdate(AddonModFeedbackPrefetchHandler.instance, module, courseId, undefined, siteId);
|
||||
} catch {
|
||||
|
|
|
@ -87,7 +87,7 @@ export class AddonModFeedbackProvider {
|
|||
let values: AddonModFeedbackResponseValue[];
|
||||
|
||||
if (subtype === 'c') {
|
||||
if (typeof item.rawValue == 'undefined') {
|
||||
if (item.rawValue === undefined) {
|
||||
values = [''];
|
||||
} else {
|
||||
item.rawValue = '' + item.rawValue;
|
||||
|
@ -146,7 +146,7 @@ export class AddonModFeedbackProvider {
|
|||
});
|
||||
|
||||
filledItems.forEach((itemData) => {
|
||||
if (itemData.hasvalue && typeof values[itemData.id] != 'undefined') {
|
||||
if (itemData.hasvalue && values[itemData.id] !== undefined) {
|
||||
itemData.rawValue = values[itemData.id];
|
||||
}
|
||||
});
|
||||
|
@ -182,7 +182,7 @@ export class AddonModFeedbackProvider {
|
|||
});
|
||||
|
||||
offlineValuesArray.forEach((value) => {
|
||||
if (typeof offlineValues[value.item] == 'undefined') {
|
||||
if (offlineValues[value.item] === undefined) {
|
||||
offlineValues[value.item] = [];
|
||||
}
|
||||
offlineValues[value.item].push(value.value);
|
||||
|
|
|
@ -43,13 +43,11 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks
|
|||
const moduleId = Number(params.id);
|
||||
|
||||
try {
|
||||
const moduleBasicInfo = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
|
||||
// Get the module.
|
||||
const module = await CoreCourse.getModule(
|
||||
moduleId,
|
||||
moduleBasicInfo.course,
|
||||
moduleBasicInfo.section,
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
false,
|
||||
siteId,
|
||||
|
@ -78,7 +76,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> {
|
||||
if (typeof params.id == 'undefined') {
|
||||
if (params.id === undefined) {
|
||||
// Cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackModuleHandlerService } from './module';
|
||||
|
@ -43,13 +44,16 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks
|
|||
const moduleId = Number(params.id);
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
moduleId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`,
|
||||
{
|
||||
params: {
|
||||
page: typeof params.gopage != 'undefined' ? Number(params.gopage) : undefined,
|
||||
page: params.gopage !== undefined ? Number(params.gopage) : undefined,
|
||||
},
|
||||
siteId,
|
||||
},
|
||||
|
@ -67,7 +71,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> {
|
||||
if (typeof params.id == 'undefined') {
|
||||
if (params.id === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
|
|||
* @inheritdoc
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModFeedbackSyncResult> {
|
||||
return AddonModFeedbackSync.syncFeedback(module.instance!, siteId);
|
||||
return AddonModFeedbackSync.syncFeedback(module.instance, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackModuleHandlerService } from './module';
|
||||
|
@ -43,7 +44,10 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan
|
|||
const moduleId = Number(params.id);
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
moduleId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`,
|
||||
|
@ -67,7 +71,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> {
|
||||
if (typeof params.id == 'undefined') {
|
||||
if (params.id === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ export class AddonModFeedbackShowEntriesLinkHandlerService extends CoreContentLi
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> {
|
||||
if (typeof params.id == 'undefined') {
|
||||
if (params.id === undefined) {
|
||||
// Cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackModuleHandlerService } from './module';
|
||||
|
@ -42,7 +43,10 @@ export class AddonModFeedbackShowNonRespondentsLinkHandlerService extends CoreCo
|
|||
const moduleId = Number(params.id);
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
moduleId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/nonrespondents`,
|
||||
|
@ -61,7 +65,7 @@ export class AddonModFeedbackShowNonRespondentsLinkHandlerService extends CoreCo
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> {
|
||||
if (typeof params.id == 'undefined') {
|
||||
if (params.id === undefined) {
|
||||
// Cannot treat the URL.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo
|
|||
await this.loadContent();
|
||||
|
||||
try {
|
||||
await AddonModFolder.logView(this.module.instance!, this.module.name);
|
||||
await AddonModFolder.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
@ -96,7 +96,7 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo
|
|||
try {
|
||||
this.folderInstance = await AddonModFolder.getFolder(this.courseId, this.module.id);
|
||||
|
||||
const contents = await CoreCourse.getModuleContents(this.module, this.courseId, undefined, false, refresh);
|
||||
const contents = await CoreCourse.getModuleContents(this.module, undefined, undefined, false, refresh);
|
||||
|
||||
this.dataRetrieved.emit(this.folderInstance || this.module);
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
||||
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFolder, AddonModFolderProvider } from '../folder';
|
||||
|
||||
|
@ -31,7 +32,7 @@ export class AddonModFolderPrefetchHandlerService extends CoreCourseResourcePref
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
const promises: Promise<unknown>[] = [];
|
||||
|
||||
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
||||
|
|
|
@ -128,7 +128,7 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource
|
|||
async loadForum(): Promise<void> {
|
||||
this.forum = await AddonModForum.getForum(this.COURSE_ID, this.CM_ID);
|
||||
|
||||
if (typeof this.forum.istracked != 'undefined') {
|
||||
if (this.forum.istracked !== undefined) {
|
||||
this.trackPosts = this.forum.istracked;
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource
|
|||
}
|
||||
|
||||
// If any discussion has unread posts, the whole forum is being tracked.
|
||||
if (typeof this.forum.istracked === 'undefined' && !this.trackPosts) {
|
||||
if (this.forum.istracked === undefined && !this.trackPosts) {
|
||||
for (const discussion of discussions) {
|
||||
if (discussion.numunread > 0) {
|
||||
this.trackPosts = true;
|
||||
|
|
|
@ -218,13 +218,13 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
) as AddonModForumDiscussion;
|
||||
|
||||
if (discussion) {
|
||||
if (typeof data.locked != 'undefined') {
|
||||
if (data.locked !== undefined) {
|
||||
discussion.locked = data.locked;
|
||||
}
|
||||
if (typeof data.pinned != 'undefined') {
|
||||
if (data.pinned !== undefined) {
|
||||
discussion.pinned = data.pinned;
|
||||
}
|
||||
if (typeof data.starred != 'undefined') {
|
||||
if (data.starred !== undefined) {
|
||||
discussion.starred = data.starred;
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
}
|
||||
}
|
||||
|
||||
if (typeof data.deleted != 'undefined' && data.deleted) {
|
||||
if (data.deleted !== undefined && data.deleted) {
|
||||
if (data.post?.parentid == 0 && CoreScreen.isTablet && !this.discussions.empty) {
|
||||
// Discussion deleted, clear details page.
|
||||
this.discussions.select(this.discussions[0]);
|
||||
|
|
|
@ -69,7 +69,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit, OnDestroy
|
|||
return;
|
||||
}
|
||||
|
||||
if (typeof this.post.capabilities.delete == 'undefined') {
|
||||
if (this.post.capabilities.delete === undefined) {
|
||||
if (this.forumId) {
|
||||
try {
|
||||
this.post =
|
||||
|
|
|
@ -254,17 +254,17 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => {
|
||||
if (discussion && this.forumId && (this.forumId === data.forumId || data.cmId === this.cmId)) {
|
||||
AddonModForum.invalidateDiscussionsList(this.forumId).finally(() => {
|
||||
if (typeof data.locked != 'undefined') {
|
||||
if (data.locked !== undefined) {
|
||||
discussion.locked = data.locked;
|
||||
}
|
||||
if (typeof data.pinned != 'undefined') {
|
||||
if (data.pinned !== undefined) {
|
||||
discussion.pinned = data.pinned;
|
||||
}
|
||||
if (typeof data.starred != 'undefined') {
|
||||
if (data.starred !== undefined) {
|
||||
discussion.starred = data.starred;
|
||||
}
|
||||
|
||||
if (typeof data.deleted != 'undefined' && data.deleted) {
|
||||
if (data.deleted !== undefined && data.deleted) {
|
||||
if (!data.post?.parentid) {
|
||||
this.goBack();
|
||||
} else {
|
||||
|
@ -469,7 +469,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
// Now try to get the forum.
|
||||
const forum = await this.fetchForum();
|
||||
// "forum.istracked" is more reliable than "trackPosts".
|
||||
if (typeof forum.istracked != 'undefined') {
|
||||
if (forum.istracked !== undefined) {
|
||||
this.trackPosts = forum.istracked;
|
||||
}
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
|
||||
// Do not sync same discussion twice.
|
||||
replies.forEach((reply) => {
|
||||
if (typeof promises[reply.discussionid] != 'undefined') {
|
||||
if (promises[reply.discussionid] !== undefined) {
|
||||
return;
|
||||
}
|
||||
promises[reply.discussionid] = this.syncDiscussionReplies(reply.discussionid, userId, siteId);
|
||||
|
|
|
@ -253,11 +253,11 @@ export class AddonModForumProvider {
|
|||
throw new Error('Invalid response calling mod_forum_can_add_discussion');
|
||||
}
|
||||
|
||||
if (typeof result.canpindiscussions == 'undefined') {
|
||||
if (result.canpindiscussions === undefined) {
|
||||
// WS doesn't support it yet, default it to false to prevent students from seeing the option.
|
||||
result.canpindiscussions = false;
|
||||
}
|
||||
if (typeof result.cancreateattachment == 'undefined') {
|
||||
if (result.cancreateattachment === undefined) {
|
||||
// WS doesn't support it yet, default it to true since usually the users will be able to create them.
|
||||
result.cancreateattachment = true;
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ export class AddonModForumProvider {
|
|||
discussions: [] as AddonModForumDiscussion[],
|
||||
error: false,
|
||||
};
|
||||
let numPages = typeof options.numPages == 'undefined' ? -1 : options.numPages;
|
||||
let numPages = options.numPages === undefined ? -1 : options.numPages;
|
||||
|
||||
if (!numPages) {
|
||||
return result;
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/
|
|||
import { CoreConstants } from '@/core/constants';
|
||||
import { AddonModForumIndexComponent } from '../../components/index';
|
||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
|
||||
/**
|
||||
* Handler to support forum modules.
|
||||
|
@ -53,7 +53,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async getData(module: CoreCourseModule, courseId: number): Promise<CoreCourseModuleHandlerData> {
|
||||
async getData(module: CoreCourseModuleData, courseId: number): Promise<CoreCourseModuleHandlerData> {
|
||||
const data = await super.getData(module, courseId);
|
||||
|
||||
if ('afterlink' in module && !!module.afterlink) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModForumModuleHandlerService } from './module';
|
||||
|
@ -53,7 +54,11 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler
|
|||
const forumId = parseInt(params.forum, 10);
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(forumId, 'forum', siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(
|
||||
forumId,
|
||||
'forum',
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${AddonModForumModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/new/0`,
|
||||
|
@ -78,7 +83,7 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler
|
|||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> {
|
||||
return typeof params.forum != 'undefined';
|
||||
return params.forum !== undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -320,8 +320,8 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
|
|||
): Promise<AddonModForumSyncResult> {
|
||||
const promises: Promise<AddonModForumSyncResult>[] = [];
|
||||
|
||||
promises.push(AddonModForumSync.syncForumDiscussions(module.instance!, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncForumReplies(module.instance!, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncForumDiscussions(module.instance, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncForumReplies(module.instance, undefined, siteId));
|
||||
promises.push(AddonModForumSync.syncRatings(module.id, undefined, true, siteId));
|
||||
|
||||
const results = await Promise.all(promises);
|
||||
|
|
|
@ -71,7 +71,7 @@ export class AddonModGlossaryHelperProvider {
|
|||
files: CoreFileEntry[],
|
||||
original?: AddonModGlossaryNewEntryWithFiles,
|
||||
): boolean {
|
||||
if (!original || typeof original.concept == 'undefined') {
|
||||
if (!original || original.concept === undefined) {
|
||||
// There is no original data.
|
||||
return !!(entry.definition || entry.concept || files.length > 0);
|
||||
}
|
||||
|
|
|
@ -583,7 +583,7 @@ export class AddonModGlossaryProvider {
|
|||
try {
|
||||
const data = await this.getStoredDataForEntry(entryId, site.getId());
|
||||
|
||||
if (typeof data.from != 'undefined') {
|
||||
if (data.from !== undefined) {
|
||||
const response = await CoreUtils.ignoreErrors(
|
||||
this.getEntryFromList(data.glossaryId, entryId, data.from, false, options),
|
||||
);
|
||||
|
|
|
@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModGlossaryModuleHandlerService } from './module';
|
||||
|
@ -44,7 +45,10 @@ export class AddonModGlossaryEditLinkHandlerService extends CoreContentLinksHand
|
|||
const cmId = Number(params.cmid);
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfo(cmId, siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
cmId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModGlossaryModuleHandlerService.PAGE_NAME + '/edit/0',
|
||||
|
@ -70,7 +74,7 @@ export class AddonModGlossaryEditLinkHandlerService extends CoreContentLinksHand
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> {
|
||||
return typeof params.cmid != 'undefined';
|
||||
return params.cmid !== undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModGlossary } from '../glossary';
|
||||
|
@ -43,12 +44,15 @@ export class AddonModGlossaryEntryLinkHandlerService extends CoreContentLinksHan
|
|||
try {
|
||||
const entryId = params.mode == 'entry' ? Number(params.hook) : Number(params.eid);
|
||||
|
||||
const response = await AddonModGlossary.getEntry(entryId, { siteId });
|
||||
const response = await AddonModGlossary.getEntry(
|
||||
entryId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(
|
||||
response.entry.glossaryid,
|
||||
'glossary',
|
||||
siteId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
|
|
|
@ -205,8 +205,8 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
|
|||
promises.push(AddonModGlossary.getAllCategories(glossary.id, options));
|
||||
|
||||
// Prefetch data for link handlers.
|
||||
promises.push(CoreCourse.getModuleBasicInfo(module.id, siteId));
|
||||
promises.push(CoreCourse.getModuleBasicInfoByInstance(glossary.id, 'glossary', siteId));
|
||||
promises.push(CoreCourse.getModuleBasicInfo(module.id, { siteId }));
|
||||
promises.push(CoreCourse.getModuleBasicInfoByInstance(glossary.id, 'glossary', { siteId }));
|
||||
|
||||
// Get course data, needed to determine upload max size if it's configured to be course limit.
|
||||
promises.push(CoreUtils.ignoreErrors(CoreCourses.getCourseByField('id', courseId, siteId)));
|
||||
|
@ -219,7 +219,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
|
|||
*/
|
||||
async sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModGlossarySyncResult> {
|
||||
const results = await Promise.all([
|
||||
AddonModGlossarySync.syncGlossaryEntries(module.instance!, undefined, siteId),
|
||||
AddonModGlossarySync.syncGlossaryEntries(module.instance, undefined, siteId),
|
||||
AddonModGlossarySync.syncRatings(module.id, undefined, siteId),
|
||||
]);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModH5PActivity } from '../h5pactivity';
|
||||
|
@ -41,54 +41,36 @@ export class AddonModH5PActivityReportLinkHandlerService extends CoreContentLink
|
|||
siteIds: string[],
|
||||
url: string,
|
||||
params: Record<string, string>,
|
||||
courseId?: number,
|
||||
): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
courseId = courseId || Number(params.courseid) || Number(params.cid);
|
||||
|
||||
return [{
|
||||
action: async (siteId) => {
|
||||
const modal = await CoreDomUtils.showModalLoading();
|
||||
|
||||
try {
|
||||
const instanceId = Number(params.a);
|
||||
|
||||
if (!courseId) {
|
||||
courseId = await this.getCourseId(instanceId, siteId);
|
||||
}
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(
|
||||
instanceId,
|
||||
'h5pactivity',
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(instanceId, 'h5pactivity', siteId);
|
||||
|
||||
if (typeof params.attemptid != 'undefined') {
|
||||
this.openAttemptResults(module.id, Number(params.attemptid), courseId, siteId);
|
||||
if (params.attemptid !== undefined) {
|
||||
this.openAttemptResults(module.id, Number(params.attemptid), module.course, siteId);
|
||||
} else {
|
||||
const userId = params.userid ? Number(params.userid) : undefined;
|
||||
|
||||
this.openUserAttempts(module.id, courseId, siteId, userId);
|
||||
this.openUserAttempts(module.id, module.course, siteId, userId);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'Error processing link.');
|
||||
} finally {
|
||||
modal.dismiss();
|
||||
}
|
||||
},
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get course Id for an activity.
|
||||
*
|
||||
* @param id Activity ID.
|
||||
* @param siteId Site ID.
|
||||
* @return Promise resolved with course ID.
|
||||
*/
|
||||
protected async getCourseId(id: number, siteId: string): Promise<number> {
|
||||
const modal = await CoreDomUtils.showModalLoading();
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(id, 'h5pactivity', siteId);
|
||||
|
||||
return module.course;
|
||||
} finally {
|
||||
modal.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
|
|
@ -53,7 +53,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom
|
|||
await this.loadContent();
|
||||
|
||||
try {
|
||||
await AddonModImscp.logView(this.module.instance!, this.module.name);
|
||||
await AddonModImscp.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
@ -84,7 +84,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom
|
|||
this.dataRetrieved.emit(imscp);
|
||||
|
||||
// Get contents. No need to refresh, it has been done in downloadResourceIfNeeded.
|
||||
const contents = await CoreCourse.getModuleContents(this.module, this.courseId);
|
||||
const contents = await CoreCourse.getModuleContents(this.module);
|
||||
|
||||
this.items = AddonModImscp.createItemList(contents);
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import {
|
|||
CoreCourse,
|
||||
CoreCourseAnyModuleData,
|
||||
CoreCourseModuleContentFile,
|
||||
CoreCourseWSModule,
|
||||
} from '@features/course/services/course';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -40,7 +40,7 @@ export class AddonModImscpPrefetchHandlerService extends CoreCourseResourcePrefe
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
const siteId = CoreSites.getCurrentSiteId();
|
||||
|
||||
const dirPath = await CoreFilepool.getPackageDirPathByUrl(siteId, module.url!);
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
|
@ -171,7 +171,7 @@ export class AddonModImscpProvider {
|
|||
* @param itemHref Href of item to get. If not defined, gets src of main item.
|
||||
* @return Promise resolved with the item src.
|
||||
*/
|
||||
async getIframeSrc(module: CoreCourseModule, itemHref?: string): Promise<string> {
|
||||
async getIframeSrc(module: CoreCourseModuleData, itemHref?: string): Promise<string> {
|
||||
const contents = await CoreCourse.getModuleContents(module);
|
||||
|
||||
if (!itemHref) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { CoreConstants } from '@/core/constants';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
|
@ -45,7 +45,7 @@ export class AddonModLabelModuleHandlerService extends CoreModuleHandlerBase imp
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async getData(module: CoreCourseModule): Promise<CoreCourseModuleHandlerData> {
|
||||
async getData(module: CoreCourseModuleData): Promise<CoreCourseModuleHandlerData> {
|
||||
// Remove the description from the module so it isn't rendered twice.
|
||||
const title = module.description || '';
|
||||
module.description = '';
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreContentLinksModuleGradeHandler } from '@features/contentlinks/class
|
|||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModLesson } from '../lesson';
|
||||
|
@ -57,8 +58,10 @@ export class AddonModLessonGradeLinkHandlerService extends CoreContentLinksModul
|
|||
const modal = await CoreDomUtils.showModalLoading();
|
||||
|
||||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
courseId = Number(module.course || courseId || params.courseid || params.cid);
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
moduleId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
// Check if the user can see the user reports in the lesson.
|
||||
const accessInfo = await AddonModLesson.getAccessInformation(module.instance, { cmId: module.id, siteId });
|
||||
|
@ -66,14 +69,14 @@ export class AddonModLessonGradeLinkHandlerService extends CoreContentLinksModul
|
|||
if (accessInfo.canviewreports) {
|
||||
// User can view reports, go to view the report.
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModLessonModuleHandlerService.PAGE_NAME + `/${courseId}/${module.id}/user-retake/${userId}`,
|
||||
AddonModLessonModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/user-retake/${userId}`,
|
||||
{
|
||||
siteId,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
// User cannot view the report, go to lesson index.
|
||||
CoreCourseHelper.navigateToModule(moduleId, siteId, courseId, module.section);
|
||||
CoreCourseHelper.navigateToModule(moduleId, siteId, module.course, module.section);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/class
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -85,14 +86,15 @@ export class AddonModLessonIndexLinkHandlerService extends CoreContentLinksModul
|
|||
|
||||
try {
|
||||
// Get the module.
|
||||
const module = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
|
||||
courseId = courseId || module.course;
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
moduleId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
|
||||
// Store the password so it's automatically used.
|
||||
await CoreUtils.ignoreErrors(AddonModLesson.storePassword(module.instance, password, siteId));
|
||||
|
||||
await CoreCourseHelper.navigateToModule(moduleId, siteId, courseId, module.section);
|
||||
await CoreCourseHelper.navigateToModule(moduleId, siteId, module.course, module.section);
|
||||
} catch {
|
||||
// Error, go to index page.
|
||||
await CoreCourseHelper.navigateToModule(moduleId, siteId, courseId);
|
||||
|
|
|
@ -537,7 +537,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
sync(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModLessonSyncResult> {
|
||||
return AddonModLessonSync.syncLesson(module.instance!, false, false, siteId);
|
||||
return AddonModLessonSync.syncLesson(module.instance, false, false, siteId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
|
|||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModLessonModuleHandlerService } from './module';
|
||||
|
@ -38,26 +39,20 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand
|
|||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @param data Extra data to handle the URL.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(
|
||||
siteIds: string[],
|
||||
url: string,
|
||||
params: Record<string, string>,
|
||||
courseId?: number,
|
||||
data?: unknown, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
courseId = Number(courseId || params.courseid || params.cid);
|
||||
|
||||
return [{
|
||||
action: (siteId) => {
|
||||
if (!params.action || params.action == 'reportoverview') {
|
||||
// Go to overview.
|
||||
this.openReportOverview(Number(params.id), courseId, Number(params.group), siteId);
|
||||
this.openReportOverview(Number(params.id), Number(params.group), siteId);
|
||||
} else if (params.action == 'reportdetail') {
|
||||
this.openUserRetake(Number(params.id), Number(params.userid), Number(params.try), siteId, courseId);
|
||||
this.openUserRetake(Number(params.id), Number(params.userid), Number(params.try), siteId);
|
||||
}
|
||||
},
|
||||
}];
|
||||
|
@ -70,11 +65,9 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand
|
|||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>, courseId?: number): Promise<boolean> {
|
||||
async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> {
|
||||
if (params.action == 'reportdetail' && !params.userid) {
|
||||
// Individual details are only available if the teacher is seeing a certain user.
|
||||
return false;
|
||||
|
@ -87,29 +80,33 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand
|
|||
* Open report overview.
|
||||
*
|
||||
* @param moduleId Module ID.
|
||||
* @param courseId Course ID.
|
||||
* @param groupId Group ID.
|
||||
* @param siteId Site ID.
|
||||
* @param navCtrl The NavController to use to navigate.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected async openReportOverview(moduleId: number, courseId?: number, groupId?: number, siteId?: string): Promise<void> {
|
||||
protected async openReportOverview(moduleId: number, groupId?: number, siteId?: string): Promise<void> {
|
||||
|
||||
const modal = await CoreDomUtils.showModalLoading();
|
||||
|
||||
try {
|
||||
// Get the module object.
|
||||
const module = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
const module = await CoreCourse.getModule(
|
||||
moduleId,
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
false,
|
||||
siteId,
|
||||
);
|
||||
|
||||
courseId = courseId || module.course;
|
||||
const params = {
|
||||
module: module,
|
||||
module,
|
||||
action: 'report',
|
||||
group: groupId === undefined || isNaN(groupId) ? null : groupId,
|
||||
};
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
`${AddonModLessonModuleHandlerService.PAGE_NAME}/${courseId}/${module.id}`,
|
||||
`${AddonModLessonModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}`,
|
||||
{ params, siteId },
|
||||
);
|
||||
} catch (error) {
|
||||
|
@ -126,7 +123,6 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand
|
|||
* @param userId User ID.
|
||||
* @param retake Retake to open.
|
||||
* @param siteId Site ID.
|
||||
* @param courseId Course ID.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected async openUserRetake(
|
||||
|
@ -134,22 +130,22 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand
|
|||
userId: number,
|
||||
retake: number,
|
||||
siteId: string,
|
||||
courseId?: number,
|
||||
): Promise<void> {
|
||||
|
||||
const modal = await CoreDomUtils.showModalLoading();
|
||||
|
||||
try {
|
||||
// Get the module object.
|
||||
const module = await CoreCourse.getModuleBasicInfo(moduleId, siteId);
|
||||
|
||||
courseId = courseId || module.course;
|
||||
const module = await CoreCourse.getModuleBasicInfo(
|
||||
moduleId,
|
||||
{ siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
|
||||
);
|
||||
const params = {
|
||||
retake: retake || 0,
|
||||
};
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModLessonModuleHandlerService.PAGE_NAME + `/${courseId}/${module.id}/user-retake/${userId}`,
|
||||
AddonModLessonModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/user-retake/${userId}`,
|
||||
{ params, siteId },
|
||||
);
|
||||
} catch (error) {
|
||||
|
|
|
@ -416,7 +416,7 @@ export class AddonModLessonHelperProvider {
|
|||
// Treat each option.
|
||||
let controlAdded = false;
|
||||
options.forEach((option) => {
|
||||
if (typeof option.value == 'undefined') {
|
||||
if (option.value === undefined) {
|
||||
// Option not valid, ignore it.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
|
|||
if (result.updated && result.courseId) {
|
||||
try {
|
||||
// Data has been sent to server, update data.
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(lessonId, 'lesson', siteId);
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(lessonId, 'lesson', { siteId });
|
||||
await this.prefetchAfterUpdate(AddonModLessonPrefetchHandler.instance, module, result.courseId, undefined, siteId);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
|
|
@ -418,11 +418,11 @@ export class AddonModLessonProvider {
|
|||
}
|
||||
|
||||
// The name was changed to "answer_editor" in 3.7. Before it was just "answer". Support both cases.
|
||||
if (typeof data['answer_editor[text]'] != 'undefined') {
|
||||
if (data['answer_editor[text]'] !== undefined) {
|
||||
studentAnswer = data['answer_editor[text]'];
|
||||
} else if (typeof data.answer_editor == 'object') {
|
||||
studentAnswer = (<{text: string}> data.answer_editor).text;
|
||||
} else if (typeof data['answer[text]'] != 'undefined') {
|
||||
} else if (data['answer[text]'] !== undefined) {
|
||||
studentAnswer = data['answer[text]'];
|
||||
} else if (typeof data.answer == 'object') {
|
||||
studentAnswer = (<{text: string}> data.answer).text;
|
||||
|
@ -505,7 +505,7 @@ export class AddonModLessonProvider {
|
|||
value = CoreTextUtils.decodeHTML(value);
|
||||
userResponse.push(value);
|
||||
|
||||
if (typeof answers[id] != 'undefined') {
|
||||
if (answers[id] !== undefined) {
|
||||
const answer = answers[id];
|
||||
|
||||
result.studentanswer += '<br />' + answer.answer + ' = ' + value;
|
||||
|
@ -606,7 +606,7 @@ export class AddonModLessonProvider {
|
|||
nHits++;
|
||||
} else {
|
||||
// Always use the first student wrong answer.
|
||||
if (typeof wrongPageId == 'undefined') {
|
||||
if (wrongPageId === undefined) {
|
||||
wrongPageId = answer.jumpto;
|
||||
}
|
||||
// Save the answer id for scoring.
|
||||
|
@ -621,7 +621,7 @@ export class AddonModLessonProvider {
|
|||
nCorrect++;
|
||||
|
||||
// Save the first jumpto.
|
||||
if (typeof correctPageId == 'undefined') {
|
||||
if (correctPageId === undefined) {
|
||||
correctPageId = answer.jumpto;
|
||||
}
|
||||
// Save the answer id for scoring.
|
||||
|
@ -644,7 +644,7 @@ export class AddonModLessonProvider {
|
|||
}
|
||||
} else {
|
||||
// Only one answer allowed.
|
||||
if (typeof data.answerid == 'undefined' || (!data.answerid && Number(data.answerid) !== 0)) {
|
||||
if (data.answerid === undefined || (!data.answerid && Number(data.answerid) !== 0)) {
|
||||
result.noanswer = true;
|
||||
|
||||
return;
|
||||
|
@ -1501,7 +1501,7 @@ export class AddonModLessonProvider {
|
|||
|
||||
const response = await site.read<AddonModLessonGetLessonWSResponse>('mod_lesson_get_lesson', params, preSets);
|
||||
|
||||
if (typeof response.lesson.ongoing == 'undefined') {
|
||||
if (response.lesson.ongoing === undefined) {
|
||||
// Basic data not received, password is wrong. Remove stored password.
|
||||
this.removeStoredPassword(lessonId, site.id);
|
||||
|
||||
|
@ -1788,7 +1788,7 @@ export class AddonModLessonProvider {
|
|||
const jumps: AddonModLessonPossibleJumps = {};
|
||||
|
||||
response.jumps.forEach((jump) => {
|
||||
if (typeof jumps[jump.pageid] == 'undefined') {
|
||||
if (jumps[jump.pageid] === undefined) {
|
||||
jumps[jump.pageid] = {};
|
||||
}
|
||||
jumps[jump.pageid][jump.jumpto] = jump;
|
||||
|
@ -2886,7 +2886,7 @@ export class AddonModLessonProvider {
|
|||
if (options.pageIndex[lastAttempt.pageid].qtype == AddonModLessonProvider.LESSON_PAGE_ESSAY) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const score: number | undefined = (<any> lastAttempt.useranswer)?.score;
|
||||
if (typeof score != 'undefined') {
|
||||
if (score !== undefined) {
|
||||
result.earned += score;
|
||||
}
|
||||
result.nmanual++;
|
||||
|
@ -2917,7 +2917,7 @@ export class AddonModLessonProvider {
|
|||
for (const answerId in answers) {
|
||||
const answer = answers[answerId];
|
||||
|
||||
if (typeof bestScores[answer.pageid] == 'undefined') {
|
||||
if (bestScores[answer.pageid] === undefined) {
|
||||
bestScores[answer.pageid] = answer.score || 0;
|
||||
} else if (bestScores[answer.pageid] < (answer.score || 0)) {
|
||||
bestScores[answer.pageid] = answer.score || 0;
|
||||
|
@ -3271,7 +3271,7 @@ export class AddonModLessonProvider {
|
|||
|
||||
if (lesson.review && !result.correctanswer && !result.isessayquestion) {
|
||||
// Calculate the number of question attempt in the page if it isn't calculated already.
|
||||
if (typeof nAttempts == 'undefined') {
|
||||
if (nAttempts === undefined) {
|
||||
const result = await this.getQuestionsAttempts(lesson.id, retake, {
|
||||
cmId: lesson.coursemodule,
|
||||
pageId: pageData.page.id,
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable, Type } from '@angular/core';
|
|||
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModLtiHelper } from '../lti-helper';
|
||||
import { AddonModLtiIndexComponent } from '../../components/index';
|
||||
|
@ -49,7 +49,7 @@ export class AddonModLtiModuleHandlerService extends CoreModuleHandlerBase imple
|
|||
* @inheritdoc
|
||||
*/
|
||||
async getData(
|
||||
module: CoreCourseModule,
|
||||
module: CoreCourseModuleData,
|
||||
courseId: number,
|
||||
sectionId?: number,
|
||||
forCoursePage?: boolean,
|
||||
|
@ -63,7 +63,7 @@ export class AddonModLtiModuleHandlerService extends CoreModuleHandlerBase imple
|
|||
data.buttons = [{
|
||||
icon: 'fas-external-link-alt',
|
||||
label: 'addon.mod_lti.launchactivity',
|
||||
action: (event: Event, module: CoreCourseModule, courseId: number): void => {
|
||||
action: (event: Event, module: CoreCourseModuleData, courseId: number): void => {
|
||||
// Launch the LTI.
|
||||
AddonModLtiHelper.getDataAndLaunch(courseId, module);
|
||||
},
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { makeSingleton, Platform } from '@singletons';
|
||||
|
@ -28,7 +28,7 @@ import { AddonModLti, AddonModLtiLti } from './lti';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonModLtiHelperProvider {
|
||||
|
||||
protected pendingCheckCompletion: {[moduleId: string]: {courseId: number; module: CoreCourseModule}} = {};
|
||||
protected pendingCheckCompletion: {[moduleId: string]: {courseId: number; module: CoreCourseModuleData}} = {};
|
||||
|
||||
constructor() {
|
||||
// Clear pending completion on logout.
|
||||
|
@ -57,7 +57,7 @@ export class AddonModLtiHelperProvider {
|
|||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
async getDataAndLaunch(courseId: number, module: CoreCourseModule, lti?: AddonModLtiLti, siteId?: string): Promise<void> {
|
||||
async getDataAndLaunch(courseId: number, module: CoreCourseModuleData, lti?: AddonModLtiLti, siteId?: string): Promise<void> {
|
||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||
|
||||
const modal = await CoreDomUtils.showModalLoading();
|
||||
|
@ -108,7 +108,7 @@ export class AddonModLtiHelperProvider {
|
|||
*/
|
||||
async logViewAndCheckCompletion(
|
||||
courseId: number,
|
||||
module: CoreCourseModule,
|
||||
module: CoreCourseModuleData,
|
||||
ltiId: number,
|
||||
name?: string,
|
||||
siteId?: string,
|
||||
|
|
|
@ -54,7 +54,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
|
|||
await this.loadContent();
|
||||
|
||||
try {
|
||||
await AddonModPage.logView(this.module.instance!, this.module.name);
|
||||
await AddonModPage.logView(this.module.instance, this.module.name);
|
||||
CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata);
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
|
@ -82,7 +82,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
|
|||
const downloadResult = await this.downloadResourceIfNeeded(refresh);
|
||||
|
||||
// Get contents. No need to refresh, it has been done in downloadResourceIfNeeded.
|
||||
const contents = await CoreCourse.getModuleContents(this.module, this.courseId);
|
||||
const contents = await CoreCourse.getModuleContents(this.module);
|
||||
|
||||
const results = await Promise.all([
|
||||
this.loadPageData(),
|
||||
|
@ -113,9 +113,9 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
|
|||
const options: Record<string, string | boolean> =
|
||||
CoreTextUtils.unserialize(this.page.displayoptions) || {};
|
||||
|
||||
this.displayDescription = typeof options.printintro == 'undefined' ||
|
||||
this.displayDescription = options.printintro === undefined ||
|
||||
CoreUtils.isTrueOrOne(options.printintro);
|
||||
this.displayTimemodified = typeof options.printlastmodified == 'undefined' ||
|
||||
this.displayTimemodified = options.printlastmodified === undefined ||
|
||||
CoreUtils.isTrueOrOne(options.printlastmodified);
|
||||
} else {
|
||||
this.displayDescription = true;
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
||||
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModPage, AddonModPageProvider } from '../page';
|
||||
|
@ -38,7 +39,7 @@ export class AddonModPagePrefetchHandlerService extends CoreCourseResourcePrefet
|
|||
* @param prefetch True to prefetch, false to download right away.
|
||||
* @return Promise resolved when all content is downloaded. Data returned is not reliable.
|
||||
*/
|
||||
async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean): Promise<void> {
|
||||
const promises: Promise<unknown>[] = [];
|
||||
|
||||
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
||||
|
|
|
@ -48,7 +48,7 @@ export class AddonModQuizAccessPasswordHandlerService implements AddonModQuizAcc
|
|||
prefetch?: boolean,
|
||||
siteId?: string,
|
||||
): Promise<void> {
|
||||
if (typeof preflightData.quizpassword != 'undefined') {
|
||||
if (preflightData.quizpassword !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ export class AddonModQuizAccessPasswordHandlerService implements AddonModQuizAcc
|
|||
siteId?: string,
|
||||
): Promise<void> {
|
||||
// The password is right, store it to use it automatically in following executions.
|
||||
if (typeof preflightData.quizpassword != 'undefined') {
|
||||
if (preflightData.quizpassword !== undefined) {
|
||||
return this.storePassword(quiz.id, preflightData.quizpassword, siteId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -615,7 +615,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
|
||||
await Promise.all(promises);
|
||||
|
||||
const grade = typeof this.gradebookData?.grade != 'undefined' ? this.gradebookData.grade : this.bestGrade?.grade;
|
||||
const grade = this.gradebookData?.grade !== undefined ? this.gradebookData.grade : this.bestGrade?.grade;
|
||||
const quizGrade = AddonModQuiz.formatGrade(grade, quiz.decimalpoints);
|
||||
|
||||
// Calculate data to construct the header of the attempts table.
|
||||
|
|
|
@ -186,7 +186,7 @@ export class AddonModQuizAttemptPage implements OnInit {
|
|||
promises.push(AddonModQuiz.invalidateQuizAccessInformation(this.quiz.id));
|
||||
promises.push(AddonModQuiz.invalidateCombinedReviewOptionsForUser(this.quiz.id));
|
||||
|
||||
if (this.attempt && typeof this.feedback != 'undefined') {
|
||||
if (this.attempt && this.feedback !== undefined) {
|
||||
promises.push(AddonModQuiz.invalidateFeedback(this.quiz.id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
|||
if (page != -1 && (this.attempt.state == AddonModQuizProvider.ATTEMPT_OVERDUE || this.attempt.finishedOffline)) {
|
||||
// We can't load a page if overdue or the local attempt is finished.
|
||||
return;
|
||||
} else if (page == this.attempt.currentpage && !this.showSummary && typeof slot != 'undefined') {
|
||||
} else if (page == this.attempt.currentpage && !this.showSummary && slot !== undefined) {
|
||||
// Navigating to a question in the current page.
|
||||
this.scrollToQuestion(slot);
|
||||
|
||||
|
@ -317,7 +317,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
|||
} finally {
|
||||
this.loaded = true;
|
||||
|
||||
if (typeof slot != 'undefined') {
|
||||
if (slot !== undefined) {
|
||||
// Scroll to the question. Give some time to the questions to render.
|
||||
setTimeout(() => {
|
||||
this.scrollToQuestion(slot);
|
||||
|
|
|
@ -116,7 +116,7 @@ export class AddonModQuizReviewPage implements OnInit {
|
|||
* @param slot Slot of the question to scroll to.
|
||||
*/
|
||||
async changePage(page: number, fromModal?: boolean, slot?: number): Promise<void> {
|
||||
if (typeof slot != 'undefined' && (this.attempt!.currentpage == -1 || page == this.currentPage)) {
|
||||
if (slot !== undefined && (this.attempt!.currentpage == -1 || page == this.currentPage)) {
|
||||
// Scrol to a certain question in the current page.
|
||||
this.scrollToQuestion(slot);
|
||||
|
||||
|
@ -136,7 +136,7 @@ export class AddonModQuizReviewPage implements OnInit {
|
|||
} finally {
|
||||
this.loaded = true;
|
||||
|
||||
if (typeof slot != 'undefined') {
|
||||
if (slot !== undefined) {
|
||||
// Scroll to the question. Give some time to the questions to render.
|
||||
setTimeout(() => {
|
||||
this.scrollToQuestion(slot);
|
||||
|
@ -286,7 +286,7 @@ export class AddonModQuizReviewPage implements OnInit {
|
|||
if (this.options!.someoptions.marks >= AddonModQuizProvider.QUESTION_OPTIONS_MARK_AND_MAX &&
|
||||
AddonModQuiz.quizHasGrades(this.quiz)) {
|
||||
|
||||
if (data.grade === null || typeof data.grade == 'undefined') {
|
||||
if (data.grade === null || data.grade === undefined) {
|
||||
this.readableGrade = AddonModQuiz.formatGrade(data.grade, this.quiz.decimalpoints);
|
||||
} else {
|
||||
// Show raw marks only if they are different from the grade (like on the entry page).
|
||||
|
|
|
@ -120,7 +120,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
}
|
||||
|
||||
const attemptGrade = AddonModQuiz.rescaleGrade(attempt.sumgrades, quiz, false);
|
||||
if (typeof attemptGrade == 'undefined') {
|
||||
if (attemptGrade === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
// Invalidate the calls required to check if a quiz is downloadable.
|
||||
await Promise.all([
|
||||
AddonModQuiz.invalidateQuizData(courseId),
|
||||
AddonModQuiz.invalidateUserAttemptsForUser(module.instance!),
|
||||
AddonModQuiz.invalidateUserAttemptsForUser(module.instance),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
if (AddonModQuiz.isAttemptFinished(attempt.state)) {
|
||||
// Attempt is finished, get feedback and review data.
|
||||
const attemptGrade = AddonModQuiz.rescaleGrade(attempt.sumgrades, quiz, false);
|
||||
if (typeof attemptGrade != 'undefined') {
|
||||
if (attemptGrade !== undefined) {
|
||||
promises.push(AddonModQuiz.getFeedbackForGrade(quiz.id, Number(attemptGrade), modOptions));
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ export class AddonModQuizPushClickHandlerService implements CorePushNotification
|
|||
return AddonModQuizHelper.handleReviewLink(
|
||||
Number(contextUrlParams.attempt),
|
||||
Number(contextUrlParams.page),
|
||||
courseId,
|
||||
Number(data.instance),
|
||||
notification.site,
|
||||
);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue