MOBILE-3833 chore: Reduce typeof undefined usage
parent
9b19735e51
commit
7d7f738d05
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 [];
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,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 +309,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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +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.isEditing = this.entryId !== undefined && this.entryId > 0;
|
||||
|
||||
this.title = this.module.name;
|
||||
|
||||
|
|
|
@ -98,7 +98,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;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,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 +313,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 +329,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) {
|
||||
|
|
|
@ -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] = {};
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,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;
|
||||
}
|
||||
|
|
|
@ -77,12 +77,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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -178,7 +178,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
try {
|
||||
const module = await CoreCourse.getModuleBasicInfo(Number(params.id), siteId);
|
||||
|
||||
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 +269,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 +298,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 +318,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 +332,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 +373,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 +392,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
formItem.value = typeof formItem.rawValue != 'undefined' ? Number(formItem.rawValue) : '';
|
||||
formItem.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : '';
|
||||
}
|
||||
|
||||
return formItem;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -78,7 +78,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;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks
|
|||
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 +67,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,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;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -78,7 +78,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
);
|
||||
|
|
|
@ -70,7 +70,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export class AddonModH5PActivityReportLinkHandlerService extends CoreContentLink
|
|||
|
||||
const module = await CoreCourse.getModuleBasicInfoByInstance(instanceId, 'h5pactivity', siteId);
|
||||
|
||||
if (typeof params.attemptid != 'undefined') {
|
||||
if (params.attemptid !== undefined) {
|
||||
this.openAttemptResults(module.id, Number(params.attemptid), courseId, siteId);
|
||||
} else {
|
||||
const userId = params.userid ? Number(params.userid) : undefined;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ export class AddonModQuizProvider {
|
|||
attemptId: number,
|
||||
options: AddonModQuizGetAttemptReviewOptions = {},
|
||||
): Promise<AddonModQuizGetAttemptReviewResponse> {
|
||||
const page = typeof options.page == 'undefined' ? -1 : options.page;
|
||||
const page = options.page === undefined ? -1 : options.page;
|
||||
|
||||
const site = await CoreSites.getSite(options.siteId);
|
||||
|
||||
|
@ -620,7 +620,7 @@ export class AddonModQuizProvider {
|
|||
* @return Number of decimals.
|
||||
*/
|
||||
getGradeDecimals(quiz: AddonModQuizQuizWSData): number {
|
||||
if (typeof quiz.questiondecimalpoints == 'undefined') {
|
||||
if (quiz.questiondecimalpoints === undefined) {
|
||||
quiz.questiondecimalpoints = -1;
|
||||
}
|
||||
|
||||
|
@ -1029,7 +1029,7 @@ export class AddonModQuizProvider {
|
|||
): Promise<AddonModQuizAttemptWSData[]> {
|
||||
|
||||
const status = options.status || 'all';
|
||||
const includePreviews = typeof options.includePreviews == 'undefined' ? true : options.includePreviews;
|
||||
const includePreviews = options.includePreviews === undefined ? true : options.includePreviews;
|
||||
|
||||
const site = await CoreSites.getSite(options.siteId);
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
|||
resource.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {};
|
||||
|
||||
try {
|
||||
this.displayDescription = typeof options.printintro == 'undefined' || !!options.printintro;
|
||||
this.displayDescription = options.printintro === undefined || !!options.printintro;
|
||||
this.dataRetrieved.emit(resource);
|
||||
|
||||
if (AddonModResourceHelper.isDisplayedInIframe(this.module)) {
|
||||
|
|
|
@ -203,7 +203,7 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
this.accessInfo = accessInfo;
|
||||
|
||||
// Check whether to launch the SCORM immediately.
|
||||
if (typeof this.skip == 'undefined') {
|
||||
if (this.skip === undefined) {
|
||||
this.skip = !this.hasOffline && !this.errorMessage &&
|
||||
(!this.scorm.lastattemptlock || this.attemptsLeft > 0) &&
|
||||
this.accessInfo.canskipview && !this.accessInfo.canviewreport &&
|
||||
|
|
|
@ -682,7 +682,7 @@ export class AddonModScormOfflineProvider {
|
|||
scoid: scoId,
|
||||
attempt,
|
||||
element: element,
|
||||
value: typeof value == 'undefined' ? null : JSON.stringify(value),
|
||||
value: value === undefined ? null : JSON.stringify(value),
|
||||
timemodified: CoreTimeUtils.timestamp(),
|
||||
synced: 0,
|
||||
};
|
||||
|
@ -937,7 +937,7 @@ export class AddonModScormOfflineProvider {
|
|||
param: string,
|
||||
ifEmpty: AddonModScormDataValue = '',
|
||||
): AddonModScormDataValue {
|
||||
if (typeof userData[param] != 'undefined') {
|
||||
if (userData[param] !== undefined) {
|
||||
return userData[param];
|
||||
}
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
await this.syncScorm(scorm, siteId) :
|
||||
await this.syncScormIfNeeded(scorm, siteId);
|
||||
|
||||
if (typeof data != 'undefined') {
|
||||
if (data !== undefined) {
|
||||
// We tried to sync. Send event.
|
||||
CoreEvents.trigger(AddonModScormSyncProvider.AUTO_SYNCED, {
|
||||
scormId: scorm.id,
|
||||
|
|
|
@ -331,7 +331,7 @@ export class AddonModScormProvider {
|
|||
set.forEach((setElement) => {
|
||||
setElement = setElement.trim();
|
||||
|
||||
if (typeof trackData[setElement] != 'undefined' &&
|
||||
if (trackData[setElement] !== undefined &&
|
||||
(trackData[setElement].status == 'completed' || trackData[setElement].status == 'passed')) {
|
||||
count++;
|
||||
}
|
||||
|
@ -350,11 +350,11 @@ export class AddonModScormProvider {
|
|||
matches = element.match(reOther)!;
|
||||
element = matches[1].trim();
|
||||
|
||||
if (typeof trackData[element] != 'undefined') {
|
||||
if (trackData[element] !== undefined) {
|
||||
let value = matches[3].trim().replace(/('|")/gi, '');
|
||||
let oper: string;
|
||||
|
||||
if (typeof STATUSES[value] != 'undefined') {
|
||||
if (STATUSES[value] !== undefined) {
|
||||
value = STATUSES[value];
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ export class AddonModScormProvider {
|
|||
}
|
||||
} else {
|
||||
// Everything else must be an element defined like S45 ...
|
||||
if (typeof trackData[element] != 'undefined' &&
|
||||
if (trackData[element] !== undefined &&
|
||||
(trackData[element].status == 'completed' || trackData[element].status == 'passed')) {
|
||||
element = 'true';
|
||||
} else {
|
||||
|
@ -395,7 +395,7 @@ export class AddonModScormProvider {
|
|||
* @return Grade to display.
|
||||
*/
|
||||
formatGrade(scorm: AddonModScormScorm, grade: number): string {
|
||||
if (typeof grade == 'undefined' || grade == -1) {
|
||||
if (grade === undefined || grade == -1) {
|
||||
return Translate.instant('core.none');
|
||||
}
|
||||
|
||||
|
@ -607,8 +607,8 @@ export class AddonModScormProvider {
|
|||
attemptScore.scos++;
|
||||
}
|
||||
|
||||
if (userData.score_raw || (typeof scorm.scormtype != 'undefined' &&
|
||||
scorm.scormtype == 'sco' && typeof userData.score_raw != 'undefined')) {
|
||||
if (userData.score_raw || (scorm.scormtype !== undefined &&
|
||||
scorm.scormtype == 'sco' && userData.score_raw !== undefined)) {
|
||||
|
||||
const scoreRaw = parseFloat(<string> userData.score_raw);
|
||||
attemptScore.values++;
|
||||
|
@ -912,14 +912,14 @@ export class AddonModScormProvider {
|
|||
}
|
||||
|
||||
// Check isvisible attribute.
|
||||
sco.isvisible = typeof scoData.isvisible == 'undefined' || (!!scoData.isvisible && scoData.isvisible !== 'false');
|
||||
sco.isvisible = scoData.isvisible === undefined || (!!scoData.isvisible && scoData.isvisible !== 'false');
|
||||
// Check pre-requisites status.
|
||||
sco.prereq = typeof scoData.prerequisites == 'undefined' ||
|
||||
sco.prereq = scoData.prerequisites === undefined ||
|
||||
this.evalPrerequisites(<string> scoData.prerequisites, trackDataBySCO);
|
||||
// Add status.
|
||||
sco.status = (typeof scoData.status == 'undefined' || scoData.status === '') ? 'notattempted' : <string> scoData.status;
|
||||
sco.status = (scoData.status === undefined || scoData.status === '') ? 'notattempted' : <string> scoData.status;
|
||||
// Exit var.
|
||||
sco.exitvar = typeof scoData.exitvar == 'undefined' ? 'cmi.core.exit' : <string> scoData.exitvar;
|
||||
sco.exitvar = scoData.exitvar === undefined ? 'cmi.core.exit' : <string> scoData.exitvar;
|
||||
sco.exitvalue = <string> scoData[sco.exitvar];
|
||||
// Copy score.
|
||||
sco.scoreraw = scoData.score_raw;
|
||||
|
@ -1109,7 +1109,7 @@ export class AddonModScormProvider {
|
|||
}
|
||||
|
||||
// If the SCORM isn't available the WS returns a warning and it doesn't return timeopen and timeclosed.
|
||||
if (typeof currentScorm.timeopen == 'undefined') {
|
||||
if (currentScorm.timeopen === undefined) {
|
||||
const warning = response.warnings?.find(warning => warning.itemid === currentScorm.id);
|
||||
currentScorm.warningMessage = warning?.message;
|
||||
}
|
||||
|
@ -1339,7 +1339,7 @@ export class AddonModScormProvider {
|
|||
* @return Whether the SCORM is downloadable.
|
||||
*/
|
||||
isScormDownloadable(scorm: AddonModScormScorm): boolean {
|
||||
return typeof scorm.protectpackagedownloads != 'undefined' && scorm.protectpackagedownloads === false;
|
||||
return scorm.protectpackagedownloads !== undefined && scorm.protectpackagedownloads === false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1635,7 +1635,7 @@ export class AddonModScormProvider {
|
|||
|
||||
const component = AddonModScormProvider.COMPONENT;
|
||||
|
||||
if (typeof isOutdated == 'undefined') {
|
||||
if (isOutdated === undefined) {
|
||||
// Calculate if it's outdated.
|
||||
const data = await CoreUtils.ignoreErrors(CoreFilepool.getPackageData(siteId, component, scorm.coursemodule));
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
|||
|
||||
if (url.displayoptions) {
|
||||
const unserialized = CoreTextUtils.unserialize<AddonModUrlDisplayOptions>(url.displayoptions);
|
||||
this.displayDescription = typeof unserialized.printintro == 'undefined' || !!unserialized.printintro;
|
||||
this.displayDescription = unserialized.printintro === undefined || !!unserialized.printintro;
|
||||
}
|
||||
|
||||
// Try to get module contents, it's needed to get the URL with parameters.
|
||||
|
|
|
@ -959,28 +959,28 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
candidateSubwikiId = subwiki.id;
|
||||
}
|
||||
|
||||
if (typeof candidateSubwikiId != 'undefined') {
|
||||
if (candidateSubwikiId !== undefined) {
|
||||
if (candidateSubwikiId > 0) {
|
||||
// Subwiki found and created, no need to keep looking.
|
||||
candidateFirstPage = Number(i);
|
||||
break;
|
||||
} else if (typeof candidateNoFirstPage == 'undefined') {
|
||||
} else if (candidateNoFirstPage === undefined) {
|
||||
candidateNoFirstPage = Number(i);
|
||||
}
|
||||
} else if (typeof firstCanEdit == 'undefined') {
|
||||
} else if (firstCanEdit === undefined) {
|
||||
firstCanEdit = Number(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let subWikiToTake: number;
|
||||
if (typeof candidateFirstPage != 'undefined') {
|
||||
if (candidateFirstPage !== undefined) {
|
||||
// Take the candidate that already has the first page created.
|
||||
subWikiToTake = candidateFirstPage;
|
||||
} else if (typeof candidateNoFirstPage != 'undefined') {
|
||||
} else if (candidateNoFirstPage !== undefined) {
|
||||
// No first page created, take the first candidate.
|
||||
subWikiToTake = candidateNoFirstPage;
|
||||
} else if (typeof firstCanEdit != 'undefined') {
|
||||
} else if (firstCanEdit !== undefined) {
|
||||
// None selected, take the first the user can edit.
|
||||
subWikiToTake = firstCanEdit;
|
||||
} else {
|
||||
|
@ -989,7 +989,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
}
|
||||
|
||||
const subwiki = subwikiList[subWikiToTake];
|
||||
if (typeof subwiki != 'undefined') {
|
||||
if (subwiki !== undefined) {
|
||||
this.setSelectedWiki(subwiki.id, subwiki.userid, subwiki.groupid);
|
||||
}
|
||||
}
|
||||
|
@ -1022,7 +1022,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
// As we loop over each subwiki, add it to the current group
|
||||
subwikiList.forEach((subwiki) => {
|
||||
// Add the subwiki to the currently active grouping.
|
||||
if (typeof subwiki.canedit == 'undefined') {
|
||||
if (subwiki.canedit === undefined) {
|
||||
noGrouping.subwikis.push(subwiki);
|
||||
} else if (subwiki.canedit) {
|
||||
myGroupsGrouping.subwikis.push(subwiki);
|
||||
|
|
|
@ -54,7 +54,7 @@ export class AddonModWikiEditLinkHandlerService extends CoreContentLinksHandlerB
|
|||
const module = await CoreCourse.getModuleBasicInfoByInstance(pageContents.wikiid, 'wiki', siteId);
|
||||
|
||||
let section = '';
|
||||
if (typeof params.section != 'undefined') {
|
||||
if (params.section !== undefined) {
|
||||
section = params.section.replace(/\+/g, ' ');
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ export class AddonModWikiPageOrMapLinkHandlerService extends CoreContentLinksHan
|
|||
if (params.id && !isMap) {
|
||||
// ID param is more prioritary than pageid in index page, it's a index URL.
|
||||
return false;
|
||||
} else if (isMap && typeof params.option != 'undefined' && params.option != '5') {
|
||||
} else if (isMap && params.option !== undefined && params.option != '5') {
|
||||
// Map link but the option isn't "Page list", not supported.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export class AddonModWikiProvider {
|
|||
* @param wikiId wiki Id, if not provided all will be cleared.
|
||||
*/
|
||||
clearSubwikiList(wikiId?: number): void {
|
||||
if (typeof wikiId == 'undefined') {
|
||||
if (wikiId === undefined) {
|
||||
this.subwikiListsCache = {};
|
||||
} else {
|
||||
delete this.subwikiListsCache[wikiId];
|
||||
|
|
|
@ -322,7 +322,7 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
|
|||
|
||||
const offlineData = await AddonModWorkshopHelper.applyOfflineData(submission, this.offlineSubmissions);
|
||||
|
||||
if (typeof offlineData != 'undefined') {
|
||||
if (offlineData !== undefined) {
|
||||
this.grades!.push(offlineData);
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -160,7 +160,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
|
|||
return {
|
||||
workshop,
|
||||
groups,
|
||||
files: files.filter((file) => typeof file !== 'undefined'),
|
||||
files: files.filter((file) => file !== undefined),
|
||||
};
|
||||
} catch (error) {
|
||||
if (options.omitFail) {
|
||||
|
@ -168,7 +168,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
|
|||
return {
|
||||
workshop,
|
||||
groups,
|
||||
files: files.filter((file) => typeof file !== 'undefined'),
|
||||
files: files.filter((file) => file !== undefined),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ export class AddonModWorkshopHelperProvider {
|
|||
return submission;
|
||||
}
|
||||
|
||||
if (typeof submission == 'undefined') {
|
||||
if (submission === undefined) {
|
||||
submission = {
|
||||
id: 0,
|
||||
workshopid: 0,
|
||||
|
@ -559,7 +559,7 @@ export class AddonModWorkshopHelperProvider {
|
|||
return value;
|
||||
}
|
||||
|
||||
if (value == null || typeof value == 'undefined') {
|
||||
if (value == null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ export class AddonModWorkshopHelperProvider {
|
|||
* @return If grade should be shown or not.
|
||||
*/
|
||||
showGrade(grade?: number|string): boolean {
|
||||
return typeof grade !== 'undefined' && grade !== null;
|
||||
return grade !== undefined && grade !== null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -263,8 +263,8 @@ export class AddonModWorkshopProvider {
|
|||
}
|
||||
|
||||
// Set submission types for Moodle 3.5.
|
||||
if (typeof workshop.submissiontypetext == 'undefined') {
|
||||
if (typeof workshop.nattachments != 'undefined' && workshop.nattachments > 0) {
|
||||
if (workshop.submissiontypetext === undefined) {
|
||||
if (workshop.nattachments !== undefined && workshop.nattachments > 0) {
|
||||
workshop.submissiontypetext = AddonModWorkshopSubmissionType.SUBMISSION_TYPE_AVAILABLE;
|
||||
workshop.submissiontypefile = AddonModWorkshopSubmissionType.SUBMISSION_TYPE_AVAILABLE;
|
||||
} else {
|
||||
|
|
|
@ -195,7 +195,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
|
|||
},
|
||||
});
|
||||
|
||||
if (typeof modalData != 'undefined') {
|
||||
if (modalData !== undefined) {
|
||||
|
||||
if (modalData.sent && modalData.type) {
|
||||
if (modalData.type != this.type) {
|
||||
|
|
|
@ -52,7 +52,7 @@ export class AddonNotesCourseOptionHandlerService implements CoreCourseOptionsHa
|
|||
return false; // Not enabled for guests.
|
||||
}
|
||||
|
||||
if (navOptions && typeof navOptions.notes != 'undefined') {
|
||||
if (navOptions && navOptions.notes !== undefined) {
|
||||
return navOptions.notes;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
|
|||
? this.syncNotes(courseId, siteId)
|
||||
: this.syncNotesIfNeeded(courseId, siteId));
|
||||
|
||||
if (typeof result != 'undefined') {
|
||||
if (result !== undefined) {
|
||||
// Sync successful, send event.
|
||||
CoreEvents.trigger(AddonNotesSyncProvider.AUTO_SYNCED, {
|
||||
courseId,
|
||||
|
|
|
@ -59,7 +59,7 @@ export class AddonQtypeDdImageOrTextComponent extends CoreQuestionBaseComponent
|
|||
const ddArea = element.querySelector('.ddarea');
|
||||
|
||||
this.ddQuestion.text = CoreDomUtils.getContentsOfElement(element, '.qtext');
|
||||
if (!ddArea || typeof this.ddQuestion.text == 'undefined') {
|
||||
if (!ddArea || this.ddQuestion.text === undefined) {
|
||||
this.logger.warn('Aborting because of an error parsing question.', this.ddQuestion.slot);
|
||||
|
||||
return CoreQuestionHelper.showComponentError(this.onAbort);
|
||||
|
@ -71,18 +71,18 @@ export class AddonQtypeDdImageOrTextComponent extends CoreQuestionBaseComponent
|
|||
|
||||
if (this.ddQuestion.initObjects) {
|
||||
// Moodle version = 3.5.
|
||||
if (typeof this.ddQuestion.initObjects.drops != 'undefined') {
|
||||
if (this.ddQuestion.initObjects.drops !== undefined) {
|
||||
this.drops = <unknown[]> this.ddQuestion.initObjects.drops;
|
||||
}
|
||||
if (typeof this.ddQuestion.initObjects.readonly != 'undefined') {
|
||||
if (this.ddQuestion.initObjects.readonly !== undefined) {
|
||||
this.ddQuestion.readOnly = !!this.ddQuestion.initObjects.readonly;
|
||||
}
|
||||
} else if (this.ddQuestion.amdArgs) {
|
||||
// Moodle version >= 3.6.
|
||||
if (typeof this.ddQuestion.amdArgs[1] != 'undefined') {
|
||||
if (this.ddQuestion.amdArgs[1] !== undefined) {
|
||||
this.ddQuestion.readOnly = !!this.ddQuestion.amdArgs[1];
|
||||
}
|
||||
if (typeof this.ddQuestion.amdArgs[2] != 'undefined') {
|
||||
if (this.ddQuestion.amdArgs[2] !== undefined) {
|
||||
this.drops = <unknown[]> this.ddQuestion.amdArgs[2];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -499,7 +499,7 @@ export class AddonQtypeDdMarkerQuestion {
|
|||
const dragging = !!this.doc.dragItemBeingDragged(choiceNo);
|
||||
const coords: number[][] = [];
|
||||
|
||||
if (fv !== '' && typeof fv != 'undefined' && fv !== null) {
|
||||
if (fv !== '' && fv !== undefined && fv !== null) {
|
||||
// Get all the coordinates in the input and add them to the coords list.
|
||||
const coordsStrings = fv.split(';');
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ export class AddonQtypeDdMarkerComponent extends CoreQuestionBaseComponent imple
|
|||
const ddForm = element.querySelector('.ddform');
|
||||
|
||||
this.ddQuestion.text = CoreDomUtils.getContentsOfElement(element, '.qtext');
|
||||
if (!ddArea || !ddForm || typeof this.ddQuestion.text == 'undefined') {
|
||||
if (!ddArea || !ddForm || this.ddQuestion.text === undefined) {
|
||||
this.logger.warn('Aborting because of an error parsing question.', this.ddQuestion.slot);
|
||||
|
||||
return CoreQuestionHelper.showComponentError(this.onAbort);
|
||||
|
@ -82,10 +82,10 @@ export class AddonQtypeDdMarkerComponent extends CoreQuestionBaseComponent imple
|
|||
|
||||
if (this.ddQuestion.initObjects) {
|
||||
// Moodle version = 3.5.
|
||||
if (typeof this.ddQuestion.initObjects.dropzones != 'undefined') {
|
||||
if (this.ddQuestion.initObjects.dropzones !== undefined) {
|
||||
this.dropZones = <unknown[]> this.ddQuestion.initObjects.dropzones;
|
||||
}
|
||||
if (typeof this.ddQuestion.initObjects.readonly != 'undefined') {
|
||||
if (this.ddQuestion.initObjects.readonly !== undefined) {
|
||||
this.ddQuestion.readOnly = !!this.ddQuestion.initObjects.readonly;
|
||||
}
|
||||
} else if (this.ddQuestion.amdArgs) {
|
||||
|
@ -97,12 +97,12 @@ export class AddonQtypeDdMarkerComponent extends CoreQuestionBaseComponent imple
|
|||
nextIndex++;
|
||||
}
|
||||
|
||||
if (typeof this.ddQuestion.amdArgs[nextIndex] != 'undefined') {
|
||||
if (this.ddQuestion.amdArgs[nextIndex] !== undefined) {
|
||||
this.ddQuestion.readOnly = !!this.ddQuestion.amdArgs[nextIndex];
|
||||
}
|
||||
nextIndex++;
|
||||
|
||||
if (typeof this.ddQuestion.amdArgs[nextIndex] != 'undefined') {
|
||||
if (this.ddQuestion.amdArgs[nextIndex] !== undefined) {
|
||||
this.dropZones = <unknown[]> this.ddQuestion.amdArgs[nextIndex];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ export class AddonQtypeDdwtosComponent extends CoreQuestionBaseComponent impleme
|
|||
this.ddQuestion.answers = answerContainer.outerHTML;
|
||||
|
||||
this.ddQuestion.text = CoreDomUtils.getContentsOfElement(element, '.qtext');
|
||||
if (typeof this.ddQuestion.text == 'undefined') {
|
||||
if (this.ddQuestion.text === undefined) {
|
||||
this.logger.warn('Aborting because of an error parsing question.', this.ddQuestion.slot);
|
||||
|
||||
return CoreQuestionHelper.showComponentError(this.onAbort);
|
||||
|
|
|
@ -45,7 +45,7 @@ export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent implemen
|
|||
* Component being initialized.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.uploadFilesSupported = typeof this.question?.responsefileareas != 'undefined';
|
||||
this.uploadFilesSupported = this.question?.responsefileareas !== undefined;
|
||||
this.initEssayComponent(this.review);
|
||||
this.essayQuestion = this.question;
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
*/
|
||||
getPreventSubmitMessage(question: CoreQuestionQuestionParsed): string | undefined {
|
||||
const element = CoreDomUtils.convertToElement(question.html);
|
||||
const uploadFilesSupported = typeof question.responsefileareas != 'undefined';
|
||||
const uploadFilesSupported = question.responsefileareas !== undefined;
|
||||
|
||||
if (!uploadFilesSupported && element.querySelector('div[id*=filemanager]')) {
|
||||
// The question allows attachments. Since the app cannot attach files yet we will prevent submitting the question.
|
||||
|
@ -229,7 +229,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
): number {
|
||||
|
||||
const hasTextAnswer = !!answers.answer;
|
||||
const uploadFilesSupported = typeof question.responsefileareas != 'undefined';
|
||||
const uploadFilesSupported = question.responsefileareas !== undefined;
|
||||
const allowedOptions = this.getAllowedOptions(question);
|
||||
|
||||
if (hasTextAnswer && this.checkInputWordCount(question, <string> answers.answer, undefined)) {
|
||||
|
@ -281,7 +281,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
component: string,
|
||||
componentId: string | number,
|
||||
): number {
|
||||
if (typeof question.responsefileareas == 'undefined') {
|
||||
if (question.responsefileareas === undefined) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
component: string,
|
||||
componentId: string | number,
|
||||
): boolean {
|
||||
const uploadFilesSupported = typeof question.responsefileareas != 'undefined';
|
||||
const uploadFilesSupported = question.responsefileareas !== undefined;
|
||||
const allowedOptions = this.getAllowedOptions(question);
|
||||
|
||||
// First check the inline text.
|
||||
|
@ -355,7 +355,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
// Search the textarea to get its name.
|
||||
const textarea = <HTMLTextAreaElement> element.querySelector('textarea[name*=_answer]');
|
||||
|
||||
if (textarea && typeof answers[textarea.name] != 'undefined') {
|
||||
if (textarea && answers[textarea.name] !== undefined) {
|
||||
await this.prepareTextAnswer(question, answers, textarea, siteId);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ export class AddonUserProfileFieldCheckboxHandlerService implements CoreUserProf
|
|||
): Promise<CoreUserProfileFieldHandlerData | undefined> {
|
||||
const name = 'profile_field_' + field.shortname;
|
||||
|
||||
if (typeof formValues[name] != 'undefined') {
|
||||
if (formValues[name] !== undefined) {
|
||||
return {
|
||||
type: 'checkbox',
|
||||
name: name,
|
||||
|
|
|
@ -244,7 +244,7 @@ export class CoreSyncBaseProvider<T = void> {
|
|||
* @return Promise resolved when the time is set.
|
||||
*/
|
||||
async setSyncTime(id: string | number, siteId?: string, time?: number): Promise<void> {
|
||||
time = typeof time != 'undefined' ? time : Date.now();
|
||||
time = time !== undefined ? time : Date.now();
|
||||
|
||||
await CoreSync.insertOrUpdateSyncRecord(this.component, id, { time: time }, siteId);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export class CoreCache {
|
|||
getValue<T = unknown>(id: string, name: string, ignoreInvalidate = false): T | undefined {
|
||||
const entry = this.getEntry(id);
|
||||
|
||||
if (entry[name] && typeof entry[name].value != 'undefined') {
|
||||
if (entry[name] && entry[name].value !== undefined) {
|
||||
const now = Date.now();
|
||||
// Invalidate after 5 minutes.
|
||||
if (ignoreInvalidate || entry[name].timemodified + 300000 >= now) {
|
||||
|
|
|
@ -199,7 +199,7 @@ export class CoreDelegate<HandlerType extends CoreDelegateHandler> {
|
|||
* @return If the handler is registered or not.
|
||||
*/
|
||||
hasHandler(name: string, enabled: boolean = false): boolean {
|
||||
return enabled ? typeof this.enabledHandlers[name] !== 'undefined' : typeof this.handlers[name] !== 'undefined';
|
||||
return enabled ? this.enabledHandlers[name] !== undefined : this.handlers[name] !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +226,7 @@ export class CoreDelegate<HandlerType extends CoreDelegateHandler> {
|
|||
registerHandler(handler: HandlerType): boolean {
|
||||
const key = handler[this.handlerNameProperty] || handler.name;
|
||||
|
||||
if (typeof this.handlers[key] !== 'undefined') {
|
||||
if (this.handlers[key] !== undefined) {
|
||||
this.logger.log(`Handler '${handler[this.handlerNameProperty]}' already registered`);
|
||||
|
||||
return false;
|
||||
|
@ -293,7 +293,7 @@ export class CoreDelegate<HandlerType extends CoreDelegateHandler> {
|
|||
* @return Whether is enabled or disabled in site.
|
||||
*/
|
||||
protected isFeatureDisabled(handler: HandlerType, site: CoreSite): boolean {
|
||||
return typeof this.featurePrefix != 'undefined' && site.isFeatureDisabled(this.featurePrefix + handler.name);
|
||||
return this.featurePrefix !== undefined && site.isFeatureDisabled(this.featurePrefix + handler.name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,7 @@ export class CoreAjaxWSError extends CoreError {
|
|||
this.backtrace = error.backtrace;
|
||||
|
||||
this.available = available;
|
||||
if (typeof this.available == 'undefined') {
|
||||
if (this.available === undefined) {
|
||||
if (this.errorcode) {
|
||||
this.available = this.errorcode == 'invalidrecord' ? -1 : 1;
|
||||
} else {
|
||||
|
|
|
@ -53,7 +53,7 @@ export class CoreInterceptor implements HttpInterceptor {
|
|||
innerObj[fullSubName] = subValue;
|
||||
query += this.serialize(innerObj) + '&';
|
||||
}
|
||||
} else if (addNull || (typeof value != 'undefined' && value !== null)) {
|
||||
} else if (addNull || (value !== undefined && value !== null)) {
|
||||
query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -355,7 +355,7 @@ export class CoreSite {
|
|||
* @return Whether the user authenticated in the site using an OAuth method.
|
||||
*/
|
||||
isOAuth(): boolean {
|
||||
return this.oauthId != null && typeof this.oauthId != 'undefined';
|
||||
return this.oauthId != null && this.oauthId !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -366,7 +366,7 @@ export class CoreSite {
|
|||
canAccessMyFiles(): boolean {
|
||||
const info = this.getInfo();
|
||||
|
||||
return !!(info && (typeof info.usercanmanageownfiles === 'undefined' || info.usercanmanageownfiles));
|
||||
return !!(info && (info.usercanmanageownfiles === undefined || info.usercanmanageownfiles));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,7 +390,7 @@ export class CoreSite {
|
|||
canUseAdvancedFeature(featureName: string, whenUndefined: boolean = true): boolean {
|
||||
const info = this.getInfo();
|
||||
|
||||
if (typeof info?.advancedfeatures === 'undefined') {
|
||||
if (info?.advancedfeatures === undefined) {
|
||||
return whenUndefined;
|
||||
}
|
||||
|
||||
|
@ -444,13 +444,13 @@ export class CoreSite {
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
read<T = unknown>(method: string, data: any, preSets?: CoreSiteWSPreSets): Promise<T> {
|
||||
preSets = preSets || {};
|
||||
if (typeof preSets.getFromCache == 'undefined') {
|
||||
if (preSets.getFromCache === undefined) {
|
||||
preSets.getFromCache = true;
|
||||
}
|
||||
if (typeof preSets.saveToCache == 'undefined') {
|
||||
if (preSets.saveToCache === undefined) {
|
||||
preSets.saveToCache = true;
|
||||
}
|
||||
if (typeof preSets.reusePending == 'undefined') {
|
||||
if (preSets.reusePending === undefined) {
|
||||
preSets.reusePending = true;
|
||||
}
|
||||
|
||||
|
@ -468,13 +468,13 @@ export class CoreSite {
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
write<T = unknown>(method: string, data: any, preSets?: CoreSiteWSPreSets): Promise<T> {
|
||||
preSets = preSets || {};
|
||||
if (typeof preSets.getFromCache == 'undefined') {
|
||||
if (preSets.getFromCache === undefined) {
|
||||
preSets.getFromCache = false;
|
||||
}
|
||||
if (typeof preSets.saveToCache == 'undefined') {
|
||||
if (preSets.saveToCache === undefined) {
|
||||
preSets.saveToCache = false;
|
||||
}
|
||||
if (typeof preSets.emergencyCache == 'undefined') {
|
||||
if (preSets.emergencyCache === undefined) {
|
||||
preSets.emergencyCache = false;
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,7 @@ export class CoreSite {
|
|||
this.saveToCache(method, data, error, preSets);
|
||||
|
||||
throw new CoreWSError(error);
|
||||
} else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) {
|
||||
} else if (preSets.emergencyCache !== undefined && !preSets.emergencyCache) {
|
||||
this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`);
|
||||
|
||||
throw new CoreWSError(error);
|
||||
|
@ -681,7 +681,7 @@ export class CoreSite {
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
}).then((response: any) => {
|
||||
// Check if the response is an error, this happens if the error was stored in the cache.
|
||||
if (response && (typeof response.exception != 'undefined' || typeof response.errorcode != 'undefined')) {
|
||||
if (response && (response.exception !== undefined || response.errorcode !== undefined)) {
|
||||
throw new CoreWSError(response);
|
||||
}
|
||||
|
||||
|
@ -857,7 +857,7 @@ export class CoreSite {
|
|||
} else {
|
||||
let responseData = response.data ? CoreTextUtils.parseJSON(response.data) : {};
|
||||
// Match the behaviour of CoreWSProvider.call when no response is expected.
|
||||
const responseExpected = typeof wsPresets.responseExpected == 'undefined' || wsPresets.responseExpected;
|
||||
const responseExpected = wsPresets.responseExpected === undefined || wsPresets.responseExpected;
|
||||
if (!responseExpected && (responseData == null || responseData === '')) {
|
||||
responseData = {};
|
||||
}
|
||||
|
@ -938,7 +938,7 @@ export class CoreSite {
|
|||
entry = await db.getRecord(CoreSite.WS_CACHE_TABLE, { id });
|
||||
}
|
||||
|
||||
if (typeof entry == 'undefined') {
|
||||
if (entry === undefined) {
|
||||
throw new CoreError('Cache entry not valid.');
|
||||
}
|
||||
|
||||
|
@ -957,7 +957,7 @@ export class CoreSite {
|
|||
}
|
||||
}
|
||||
|
||||
if (typeof entry.data != 'undefined') {
|
||||
if (entry.data !== undefined) {
|
||||
if (!expirationTime) {
|
||||
this.logger.info(`Cached element found, id: ${id}. Expiration time ignored.`);
|
||||
} else {
|
||||
|
@ -1206,7 +1206,7 @@ export class CoreSite {
|
|||
* @return Fixed URL.
|
||||
*/
|
||||
fixPluginfileURL(url: string): string {
|
||||
const accessKey = this.tokenPluginFileWorks || typeof this.tokenPluginFileWorks == 'undefined' ?
|
||||
const accessKey = this.tokenPluginFileWorks || this.tokenPluginFileWorks === undefined ?
|
||||
this.infos && this.infos.userprivateaccesskey : undefined;
|
||||
|
||||
return CoreUrlUtils.fixPluginfileURL(url, this.token || '', this.siteUrl, accessKey);
|
||||
|
@ -1829,7 +1829,7 @@ export class CoreSite {
|
|||
|
||||
return <T> entry.value;
|
||||
} catch (error) {
|
||||
if (typeof defaultValue != 'undefined') {
|
||||
if (defaultValue !== undefined) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
@ -1876,7 +1876,7 @@ export class CoreSite {
|
|||
if (!CoreUrlUtils.canUseTokenPluginFile(url, this.siteUrl, this.infos && this.infos.userprivateaccesskey)) {
|
||||
// Cannot use tokenpluginfile.
|
||||
return Promise.resolve(false);
|
||||
} else if (typeof this.tokenPluginFileWorks != 'undefined') {
|
||||
} else if (this.tokenPluginFileWorks !== undefined) {
|
||||
// Already checked.
|
||||
return Promise.resolve(this.tokenPluginFileWorks);
|
||||
} else if (this.tokenPluginFileWorksPromise) {
|
||||
|
|
|
@ -221,7 +221,7 @@ export class SQLiteDB {
|
|||
columnSql += ` CHECK (${column.check})`;
|
||||
}
|
||||
|
||||
if (typeof column.default != 'undefined') {
|
||||
if (column.default !== undefined) {
|
||||
columnSql += ` DEFAULT ${column.default}`;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ export class SQLiteDB {
|
|||
* @return Promise resolved with the number of affected rows.
|
||||
*/
|
||||
async deleteRecords(table: string, conditions?: SQLiteDBRecordValues): Promise<number> {
|
||||
if (conditions === null || typeof conditions == 'undefined') {
|
||||
if (conditions === null || conditions === undefined) {
|
||||
// No conditions, delete the whole table.
|
||||
const result = await this.execute(`DELETE FROM ${table}`);
|
||||
|
||||
|
@ -485,7 +485,7 @@ export class SQLiteDB {
|
|||
|
||||
// Remove undefined entries and convert null to "NULL".
|
||||
for (const name in data) {
|
||||
if (typeof data[name] == 'undefined') {
|
||||
if (data[name] === undefined) {
|
||||
delete data[name];
|
||||
}
|
||||
}
|
||||
|
@ -581,13 +581,13 @@ export class SQLiteDB {
|
|||
let params: SQLiteDBRecordValue[];
|
||||
|
||||
// Default behavior, return empty data on empty array.
|
||||
if (Array.isArray(items) && !items.length && typeof onEmptyItems == 'undefined') {
|
||||
if (Array.isArray(items) && !items.length && onEmptyItems === undefined) {
|
||||
return { sql: '', params: [] };
|
||||
}
|
||||
|
||||
// Handle onEmptyItems on empty array of items.
|
||||
if (Array.isArray(items) && !items.length) {
|
||||
if (onEmptyItems === null || typeof onEmptyItems === 'undefined') { // Special case, NULL value.
|
||||
if (onEmptyItems === null || onEmptyItems === undefined) { // Special case, NULL value.
|
||||
sql = equal ? ' IS NULL' : ' IS NOT NULL';
|
||||
|
||||
return { sql, params: [] };
|
||||
|
@ -1091,7 +1091,7 @@ export class SQLiteDB {
|
|||
for (const key in conditions) {
|
||||
const value = conditions[key];
|
||||
|
||||
if (typeof value == 'undefined' || value === null) {
|
||||
if (value === undefined || value === null) {
|
||||
where.push(key + ' IS NULL');
|
||||
} else {
|
||||
where.push(key + ' = ?');
|
||||
|
@ -1124,7 +1124,7 @@ export class SQLiteDB {
|
|||
let sql = '';
|
||||
|
||||
values.forEach((value) => {
|
||||
if (typeof value == 'undefined' || value === null) {
|
||||
if (value === undefined || value === null) {
|
||||
sql = field + ' IS NULL';
|
||||
} else {
|
||||
params.push(value);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue