Merge pull request #2809 from NoelDeMartin/MOBILE-3320

MOBILE-3320: Tweaks
main
Dani Palou 2021-06-04 08:37:54 +02:00 committed by GitHub
commit 530ac1a109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 275 additions and 187 deletions

View File

@ -24,12 +24,20 @@ jobs:
git clone --branch MOBILE-3738 --depth 1 git://github.com/NoelDeMartin/moodle-docker $GITHUB_WORKSPACE/moodle-docker
- name: Setup docker machine
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
export MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE
cp $GITHUB_WORKSPACE/moodle-docker/config.docker-template.php $GITHUB_WORKSPACE/moodle/config.php
MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose pull
MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose up -d
MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-db
MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-app
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose pull
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose up -d
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-db
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-app
- name: Init behat
run: MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/init.php"
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
export MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/init.php"
- name: Run tests
run: MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --tags="@app" --auto-rerun"
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
export MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --tags="@app" --auto-rerun"

View File

@ -37,16 +37,18 @@ import { IonRefresher } from '@ionic/angular';
})
export class AddonMessagesContactsPage implements OnInit, OnDestroy {
selected = 'confirmed';
selected: 'confirmed' | 'requests' = 'confirmed';
requestsBadge = '';
selectedUserId?: number; // User id of the conversation opened in the split view.
confirmedLoaded = false;
confirmedInitialising = false;
confirmedCanLoadMore = false;
confirmedLoadMoreError = false;
confirmedContacts: AddonMessagesConversationMember[] = [];
requestsLoaded = false;
requestsInitialising = false;
requestsCanLoadMore = false;
requestsLoadMoreError = false;
requests: AddonMessagesConversationMember[] = [];
@ -83,7 +85,7 @@ export class AddonMessagesContactsPage implements OnInit, OnDestroy {
this.confirmedContacts.splice(index, 1);
}
} else if (data.contactRequestConfirmed) {
this.refreshData();
this.confirmedFetchData(true);
}
if (data.contactRequestConfirmed || data.contactRequestDeclined) {
@ -104,25 +106,52 @@ export class AddonMessagesContactsPage implements OnInit, OnDestroy {
async ngOnInit(): Promise<void> {
AddonMessages.getContactRequestsCount(this.siteId); // Badge already updated by the observer.
if (this.selected == 'confirmed') {
try {
this.selected === 'confirmed'
? await this.initConfirmed()
: await this.initRequests();
}
await this.confirmedFetchData();
if (this.confirmedContacts.length && CoreScreen.isTablet) {
this.selectUser(this.confirmedContacts[0].id, true);
}
} finally {
this.confirmedLoaded = true;
/**
* Initialise confirmed contacts.
*/
async initConfirmed(): Promise<void> {
if (this.confirmedInitialising) {
return;
}
try {
this.confirmedInitialising = true;
await this.confirmedFetchData();
if (this.confirmedContacts.length && CoreScreen.isTablet) {
this.selectUser(this.confirmedContacts[0].id, true);
}
} else {
try {
await this.requestsFetchData();
if (this.requests.length && CoreScreen.isTablet) {
this.selectUser(this.requests[0].id, true);
}
} finally {
this.requestsLoaded = true;
} finally {
this.confirmedInitialising = false;
this.confirmedLoaded = true;
}
}
/**
* Initialise contact requests.
*/
async initRequests(): Promise<void> {
if (this.requestsInitialising) {
return;
}
try {
this.requestsInitialising = true;
await this.requestsFetchData();
if (this.requests.length && CoreScreen.isTablet) {
this.selectUser(this.requests[0].id, true);
}
} finally {
this.requestsInitialising = false;
this.requestsLoaded = true;
}
}
@ -228,10 +257,18 @@ export class AddonMessagesContactsPage implements OnInit, OnDestroy {
}
selectTab(selected: string): void {
if (selected !== 'confirmed' && selected !== 'requests') {
return;
}
this.selected = selected;
if ((this.selected == 'confirmed' && !this.confirmedLoaded) || (this.selected != 'confirmed' && !this.requestsLoaded)) {
this.ngOnInit();
if (this.selected == 'confirmed' && !this.confirmedLoaded) {
this.initConfirmed();
}
if (this.selected == 'requests' && !this.requestsLoaded) {
this.initRequests();
}
}

View File

@ -288,7 +288,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
this.conversationImage = this.otherMember.profileimageurl;
this.title = this.otherMember.fullname;
}
this.blockIcon = this.otherMember.isblocked ? 'fas-user-lock' : 'fas-user-check';
this.blockIcon = this.otherMember.isblocked ? 'fas-user-check' : 'fas-user-lock';
return;
}));
@ -317,7 +317,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
};
this.otherMember.isblocked = await AddonMessages.isBlocked(this.userId!);
this.otherMember.iscontact = await AddonMessages.isContact(this.userId!);
this.blockIcon = this.otherMember.isblocked ? 'fas-user-lock' : 'fas-user-check';
this.blockIcon = this.otherMember.isblocked ? 'fas-user-check' : 'fas-user-lock';
return;
}));
@ -1466,7 +1466,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'core.error', true);
} finally {
this.blockIcon = this.otherMember.isblocked ? 'fas-user-lock' : 'fas-user-check';
this.blockIcon = this.otherMember.isblocked ? 'fas-user-check' : 'fas-user-lock';
}
} catch {
// User cancelled.
@ -1548,7 +1548,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'core.error', true);
} finally {
this.blockIcon = this.otherMember.isblocked ? 'fas-user-lock' : 'fas-user-check';
this.blockIcon = this.otherMember.isblocked ? 'fas-user-check' : 'fas-user-lock';
}
} catch {
// User cancelled.

View File

@ -138,7 +138,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
isBlind: this.isBlind,
cmId: this.assign.cmid,
filter: false,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
};
let submissionStatus: AddonModAssignGetSubmissionStatusWSResponse;
@ -149,7 +149,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
} catch (error) {
// Cannot connect. Get cached data.
options.filter = true;
options.readingStrategy = CoreSitesReadingStrategy.PreferCache;
options.readingStrategy = CoreSitesReadingStrategy.PREFER_CACHE;
submissionStatus = await AddonModAssign.getSubmissionStatus(this.assign.id, options);
this.userSubmission =

View File

@ -313,7 +313,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
const options: AddonModAssignSubmissionStatusOptions = {
userId,
cmId: assign.cmid,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -427,7 +427,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
const options: AddonModAssignSubmissionStatusOptions = {
userId,
cmId: assign.cmid,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};

View File

@ -576,7 +576,7 @@ export class AddonModAssignProvider {
// Try again, ignoring cache.
const newOptions = {
...options,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
};
try {

View File

@ -234,7 +234,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
const siteId = CoreSites.getCurrentSiteId();
const options: CoreSitesCommonWSOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -287,7 +287,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
): Promise<void> {
const modOptions: CoreCourseCommonModWSOptions = {
cmId: moduleId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -313,7 +313,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
moduleId,
{
userId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
},
true,
@ -334,7 +334,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
): Promise<void> {
const options: CoreSitesCommonWSOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -364,7 +364,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
userId: submission.submitid,
groupId: group.id,
isBlind: !!submission.blindid,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -381,7 +381,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
const submissionOptions = {
userId,
groupId: group.id,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};

View File

@ -201,7 +201,7 @@ export class AddonModChatProvider {
*/
async getChatUsers(sessionId: string, options: CoreCourseCommonModWSOptions = {}): Promise<AddonModChatGetChatUsersWSResponse> {
// By default, always try to get the latest data.
options.readingStrategy = options.readingStrategy || CoreSitesReadingStrategy.PreferNetwork;
options.readingStrategy = options.readingStrategy || CoreSitesReadingStrategy.PREFER_NETWORK;
const site = await CoreSites.getSite(options.siteId);

View File

@ -78,7 +78,7 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet
protected async prefetchChat(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
const options = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {

View File

@ -60,7 +60,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
siteId = siteId || CoreSites.getCurrentSiteId();
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {

View File

@ -157,9 +157,9 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
protected getGeolocationErrorMessage(error: CoreGeolocationError): string {
// tslint:disable-next-line: switch-default
switch (error.reason) {
case CoreGeolocationErrorReason.PermissionDenied:
case CoreGeolocationErrorReason.PERMISSION_DENIED:
return 'addon.mod_data.locationpermissiondenied';
case CoreGeolocationErrorReason.LocationNotEnabled:
case CoreGeolocationErrorReason.LOCATION_NOT_ENABLED:
return 'addon.mod_data.locationnotenabled';
}
}

View File

@ -281,7 +281,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
const options: CoreCourseCommonModWSOptions = {
cmId: database.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};

View File

@ -1003,7 +1003,7 @@ export class AddonModDataProvider {
options.order || options.order || 'DESC';
options.page = options.page || 0;
options.perPage = options.perPage || AddonModDataProvider.PER_PAGE;
options.readingStrategy = options.readingStrategy || CoreSitesReadingStrategy.PreferNetwork;
options.readingStrategy = options.readingStrategy || CoreSitesReadingStrategy.PREFER_NETWORK;
const params: AddonModDataSearchEntriesWSParams = {
databaseid: dataId,

View File

@ -182,7 +182,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
*/
async isDownloadable(module: CoreCourseAnyModuleData, courseId: number): Promise<boolean> {
const database = await AddonModData.getDatabase(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
});
const accessData = await AddonModData.getDatabaseAccessInformation(database.id, { cmId: module.id });
@ -229,7 +229,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
const options = {
cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};

View File

@ -153,7 +153,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
this.offline = !CoreApp.isOnline();
const options = {
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
siteId: this.currentSite.getId(),
};
@ -198,7 +198,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
// If it fails, go offline.
this.offline = true;
options.readingStrategy = CoreSitesReadingStrategy.PreferCache;
options.readingStrategy = CoreSitesReadingStrategy.PREFER_CACHE;
this.access = await AddonModFeedback.getFeedbackAccessInformation(this.feedback!.id, options);
}
@ -221,7 +221,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
// Go offline.
this.offline = true;
options.readingStrategy = CoreSitesReadingStrategy.PreferCache;
options.readingStrategy = CoreSitesReadingStrategy.PREFER_CACHE;
return AddonModFeedback.getResumePage(this.feedback!.id, options);
}
@ -256,7 +256,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
protected async fetchPageItems(page: number): Promise<AddonModFeedbackPageItems> {
const options = {
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
siteId: this.currentSite.getId(),
};
@ -284,7 +284,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
// Go offline.
this.offline = true;
options.readingStrategy = CoreSitesReadingStrategy.PreferCache;
options.readingStrategy = CoreSitesReadingStrategy.PREFER_CACHE;
response = await AddonModFeedback.getPageItemsWithValues(this.feedback!.id, page, options);
}
@ -344,7 +344,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
await this.fetchAccessData({
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
siteId: this.currentSite.getId(),
});
} else if (typeof response.jumpto != 'number' || response.jumpto == this.currentPage) {

View File

@ -190,7 +190,7 @@ export class AddonModFeedbackHelperProvider {
const attempt = await AddonModFeedback.getAttempt(module.instance, Number(params.showcompleted), {
cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});

View File

@ -205,7 +205,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
}
const timemodified = await AddonModFeedback.getCurrentCompletedTimeModified(feedbackId, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
// Sort by page.

View File

@ -823,7 +823,7 @@ export class AddonModFeedbackProvider {
const response = await this.getPageItemsWithValues(feedbackId, page, {
cmId: options.cmId,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId,
});
@ -1173,7 +1173,7 @@ export class AddonModFeedbackProvider {
const pageItems = await this.getPageItemsWithValues(feedbackId, page, {
cmId: options.cmId,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId,
});

View File

@ -94,7 +94,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
*/
async isDownloadable(module: CoreCourseAnyModuleData, courseId: number): Promise<boolean> {
const feedback = await AddonModFeedback.getFeedback(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
});
const now = CoreTimeUtils.timestamp();
@ -136,7 +136,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
protected async prefetchFeedback(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {

View File

@ -75,7 +75,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit, OnDestroy
this.post =
await AddonModForum.getDiscussionPost(this.forumId, this.post.discussionid, this.post.id, {
cmId: this.cmId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
});
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'Error getting discussion post.');

View File

@ -778,7 +778,7 @@ export class AddonModForumProvider {
sortby: 'timemodified',
sortdirection: 'DESC',
};
Object.assign(preSets, CoreSites.getReadingStrategyPreSets(CoreSitesReadingStrategy.PreferCache));
Object.assign(preSets, CoreSites.getReadingStrategyPreSets(CoreSitesReadingStrategy.PREFER_CACHE));
response = await site.read<AddonModForumGetForumDiscussionsPaginatedWSResponse>(
'mod_forum_get_forum_discussions_paginated',
@ -889,7 +889,7 @@ export class AddonModForumProvider {
.getDiscussionsInPages(forum.id, {
cmId: forum.cmid,
sortOrder: sortOrder.value,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
})
.then((response) => {
// Now invalidate the WS calls.

View File

@ -199,7 +199,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
siteId: string,
): Promise<void> {
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {

View File

@ -644,7 +644,7 @@ export class AddonModGlossaryProvider {
// Get the entries from this "page" and check if the entry we're looking for is in it.
const result = await this.getEntriesByLetter(glossaryId, 'ALL', {
from: from,
readingStrategy: CoreSitesReadingStrategy.OnlyCache,
readingStrategy: CoreSitesReadingStrategy.ONLY_CACHE,
cmId: options.cmId,
siteId: options.siteId,
});
@ -763,7 +763,7 @@ export class AddonModGlossaryProvider {
if (!onlyEntriesList) {
promises.push(this.fetchAllEntries(this.getEntriesByLetter.bind(this, glossary.id, 'ALL'), {
cmId: glossary.coursemodule,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
}).then((entries) => this.invalidateEntries(entries, siteId)));
}
@ -995,7 +995,7 @@ export class AddonModGlossaryProvider {
// Get entries from the cache.
const entries = await this.fetchAllEntries(this.getEntriesByLetter.bind(glossaryId, 'ALL'), {
cmId: options.cmId,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId,
});

View File

@ -114,7 +114,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
const options = {
cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};

View File

@ -239,7 +239,7 @@ export class AddonModH5PActivityProvider {
// Check if the full list of results is cached. If so, get the results from there.
const cacheOptions: AddonModH5PActivityGetAttemptResultsOptions = {
...options, // Include all the original options.
readingStrategy: CoreSitesReadingStrategy.OnlyCache,
readingStrategy: CoreSitesReadingStrategy.ONLY_CACHE,
};
const attemptsResults = await AddonModH5PActivity.getAllAttemptsResults(id, cacheOptions);

View File

@ -96,7 +96,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
siteId = siteId || CoreSites.getCurrentSiteId();
const h5pActivity = await AddonModH5PActivity.getH5PActivity(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
@ -145,7 +145,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
const accessInfo = await AddonModH5PActivity.getAccessInformation(h5pActivity.id, {
cmId: h5pActivity.coursemodule,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
});
@ -155,7 +155,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
const options = {
cmId: h5pActivity.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId: siteId,
};

View File

@ -48,7 +48,7 @@ export class AddonModImscpPrefetchHandlerService extends CoreCourseResourcePrefe
promises.push(super.downloadOrPrefetch(module, courseId, prefetch, dirPath));
promises.push(AddonModImscp.getImscp(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
}));

View File

@ -41,7 +41,7 @@ export class AddonModLabelPrefetchHandlerService extends CoreCourseResourcePrefe
if (AddonModLabel.isGetLabelAvailableForSite()) {
label = await AddonModLabel.getLabel(courseId, module.id, {
readingStrategy: ignoreCache ? CoreSitesReadingStrategy.OnlyNetwork : undefined,
readingStrategy: ignoreCache ? CoreSitesReadingStrategy.ONLY_NETWORK : undefined,
});
}

View File

@ -215,11 +215,11 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
// Get the possible jumps now.
this.jumps = await AddonModLesson.getPagesPossibleJumps(this.lesson!.id, {
cmId: this.cmId,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
});
// Call the function again with offline mode and the new jumps.
options.readingStrategy = CoreSitesReadingStrategy.PreferCache;
options.readingStrategy = CoreSitesReadingStrategy.PREFER_CACHE;
options.jumps = this.jumps;
options.offline = true;
@ -280,7 +280,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
const options = {
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
};
this.accessInfo = await this.callFunction<AddonModLessonGetAccessInformationWSResponse>(
AddonModLesson.getAccessInformation.bind(AddonModLesson.instance, this.lesson.id, options),
@ -311,7 +311,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
const options = {
password: this.password,
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
};
promises.push(this.callFunction<AddonModLessonLessonWSData>(
AddonModLesson.getLessonWithPassword.bind(AddonModLesson.instance, this.lesson.id, options),
@ -327,7 +327,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
// Offline mode, get the list of possible jumps to allow navigation.
promises.push(AddonModLesson.getPagesPossibleJumps(this.lesson.id, {
cmId: this.cmId,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
}).then((jumpList) => {
this.jumps = jumpList;
@ -490,7 +490,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
// Get the last lesson timer.
const timers = await AddonModLesson.getTimers(this.lesson!.id, {
cmId: this.cmId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
});
this.endTime = timers[timers.length - 1].starttime + this.lesson!.timelimit;
@ -515,7 +515,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
const options = {
password: this.password,
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
};
const pages = await this.callFunction<AddonModLessonGetPagesPageWSData[]>(
@ -548,7 +548,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
review: this.review,
includeContents: true,
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
accessInfo: this.accessInfo,
jumps: this.jumps,
includeOfflineData: true,
@ -643,7 +643,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
const retake = this.accessInfo!.attemptscount;
const options = {
cmId: this.cmId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
};
// Update in background the list of content pages viewed or question attempts.

View File

@ -81,7 +81,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
// Get the lesson password if it's needed.
const passwordData = await this.getLessonPassword(lesson.id, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
askPassword: single,
siteId,
});
@ -188,7 +188,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
const siteId = CoreSites.getCurrentSiteId();
const lesson = await AddonModLesson.getLesson(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
});
@ -257,7 +257,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId();
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {
@ -269,7 +269,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
// Get the lesson password if it's needed.
const passwordData = await this.getLessonPassword(lesson.id, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
askPassword: single,
siteId,
});

View File

@ -287,7 +287,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
const lesson = await AddonModLesson.getLessonById(result.courseId, lessonId, { siteId });
const passwordData = await AddonModLessonPrefetchHandler.getLessonPassword(lessonId, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
askPassword,
siteId,
});
@ -431,7 +431,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
// Retrieve the needed data.
const lesson = await AddonModLesson.getLessonById(result.courseId!, lessonId, { siteId });
passwordData = await AddonModLessonPrefetchHandler.getLessonPassword(lessonId, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
askPassword,
siteId,
});

View File

@ -292,7 +292,7 @@ export class AddonModLessonProvider {
const pages = await this.getPages(lessonId, {
cmId: options.cmId,
password: options.password,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId,
});
@ -1600,7 +1600,7 @@ export class AddonModLessonProvider {
const data = await this.getPageData(lesson, pageId, {
includeContents: true,
...options, // Include all options.
readingStrategy: options.readingStrategy || CoreSitesReadingStrategy.PreferCache,
readingStrategy: options.readingStrategy || CoreSitesReadingStrategy.PREFER_CACHE,
includeOfflineData: false,
});
@ -2854,7 +2854,7 @@ export class AddonModLessonProvider {
const pages = await this.getPages(lesson.id, {
password: options.password,
cmId: lesson.coursemodule,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId,
});
@ -3038,7 +3038,7 @@ export class AddonModLessonProvider {
const pages = await this.getPages(lesson.id, {
cmId: lesson.coursemodule,
password: options.password,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId,
});

View File

@ -349,13 +349,13 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
// Get access information for the quiz.
this.quizAccessInfo = await AddonModQuiz.getQuizAccessInformation(this.quiz.id, {
cmId: this.quiz.coursemodule,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
});
// Get user attempts to determine last attempt.
const attempts = await AddonModQuiz.getUserAttempts(this.quiz.id, {
cmId: this.quiz.coursemodule,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
});
if (!attempts.length) {
@ -428,7 +428,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
// Get current page data again to get the latest sequencechecks.
const data = await AddonModQuiz.getAttemptData(this.attempt!.id, this.attempt!.currentpage!, this.preflightData, {
cmId: this.quiz!.coursemodule,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
});
const newSequenceChecks: Record<number, { name: string; value: string }> = {};
@ -486,7 +486,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
protected async loadPage(page: number): Promise<void> {
const data = await AddonModQuiz.getAttemptData(this.attempt!.id, page, this.preflightData, {
cmId: this.quiz!.coursemodule,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
});
// Update attempt, status could change during the execution.
@ -531,7 +531,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
this.summaryQuestions = await AddonModQuiz.getAttemptSummary(this.attempt!.id, this.preflightData, {
cmId: this.quiz!.coursemodule,
loadLocal: this.offline,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
});
this.showSummary = true;
@ -556,7 +556,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
this.navigation = await AddonModQuiz.getAttemptSummary(this.attempt!.id, this.preflightData, {
cmId: this.quiz!.coursemodule,
loadLocal: this.offline,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
});
this.navigation.forEach((question) => {
@ -737,7 +737,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
// Re-fetch attempt access information with the right attempt (might have changed because a new attempt was created).
this.attemptAccessInfo = await AddonModQuiz.getAttemptAccessInformation(this.quiz!.id, attempt.id, {
cmId: this.quiz!.coursemodule,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
});
this.attempt = attempt;

View File

@ -85,7 +85,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
const attempts = await AddonModQuiz.getUserAttempts(quiz.id, {
cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
});
const attemptFiles = await this.getAttemptsFeedbackFiles(quiz, attempts);
@ -126,7 +126,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
const feedback = await AddonModQuiz.getFeedbackForGrade(quiz.id, Number(attemptGrade), {
cmId: quiz.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
@ -305,7 +305,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
canStart: boolean,
): Promise<void> {
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {
@ -417,7 +417,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
const modOptions: CoreCourseCommonModWSOptions = {
cmId: quiz.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -546,7 +546,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
const modOptions = {
cmId: quiz.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -575,7 +575,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
await this.setStatusAfterPrefetch(quiz, {
cmId: quiz.coursemodule,
attempts,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
});
}

View File

@ -349,7 +349,7 @@ export class AddonModQuizHelperProvider {
const rules = accessInfo.activerulenames;
const modOptions = {
cmId: quiz.coursemodule,
readingStrategy: offline ? CoreSitesReadingStrategy.PreferCache : CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};

View File

@ -169,7 +169,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
// Prefetch finished or not needed, set the right status.
await AddonModQuizPrefetchHandler.setStatusAfterPrefetch(quiz, {
cmId: module.id,
readingStrategy: shouldDownload ? CoreSitesReadingStrategy.PreferCache : undefined,
readingStrategy: shouldDownload ? CoreSitesReadingStrategy.PREFER_CACHE : undefined,
siteId,
});
}
@ -293,7 +293,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
const courseId = quiz.course;
const modOptions = {
cmId: quiz.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
@ -368,7 +368,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
// Now get the online questions data.
const onlineQuestions = await AddonModQuiz.getAllQuestionsData(quiz, onlineAttempt, preflightData, {
pages: AddonModQuiz.getPagesFromLayoutAndQuestions(onlineAttempt.layout || '', offlineQuestions),
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});

View File

@ -1265,7 +1265,7 @@ export class AddonModQuizProvider {
// Get required data to call the invalidate functions.
const quiz = await this.getQuiz(courseId, moduleId, {
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
});
@ -1753,7 +1753,7 @@ export class AddonModQuizProvider {
const questionsArray = await this.getAttemptSummary(attempt.id, preflightData, {
cmId: quiz.coursemodule,
loadLocal: true,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
});

View File

@ -131,7 +131,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
// Get the SCORM instance.
this.scorm = await AddonModScorm.getScorm(this.courseId, this.cmId, {
moduleUrl: this.moduleUrl,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
});
// Block the SCORM so it cannot be synchronized.
@ -248,7 +248,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
// Last attempt was online, verify that we can create a new online attempt. We ignore cache.
await AddonModScorm.getScormUserData(this.scorm.id, result.attempt, {
cmId: this.cmId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
});
} catch {
// Cannot communicate with the server, create an offline attempt.
@ -529,7 +529,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
// New online attempt created, update cached data about online attempts.
await CoreUtils.ignoreErrors(AddonModScorm.getAttemptCount(this.scorm.id, {
cmId: this.cmId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
}));
}

View File

@ -212,7 +212,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
const modOptions: CoreCourseCommonModWSOptions = {
cmId: scorm.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};

View File

@ -125,7 +125,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
const siteData = await AddonModScorm.getScormUserData(scormId, attempt, {
cmId,
readingStrategy: refresh ? CoreSitesReadingStrategy.OnlyNetwork : undefined,
readingStrategy: refresh ? CoreSitesReadingStrategy.ONLY_NETWORK : undefined,
siteId,
});
@ -222,7 +222,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
// Last online attempt wasn't finished, let's check if it is now.
const incomplete = await AddonModScorm.isAttemptIncomplete(scorm.id, lastOnline, {
cmId: scorm.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
@ -365,7 +365,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
try {
userData = await AddonModScorm.getScormUserData(scormId, attempt, {
cmId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
} catch {
@ -616,7 +616,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
// Get attempts data. We ignore cache for online attempts, so this call will fail if offline or server down.
const attemptsData = await AddonModScorm.getAttemptCount(scorm.id, {
cmId: scorm.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
@ -641,7 +641,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
false :
await AddonModScorm.isAttemptIncomplete(scorm.id, lastOnline, {
cmId: scorm.coursemodule,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
@ -799,7 +799,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
const userData = await AddonModScorm.getScormUserData(scormId, attempt, {
cmId,
readingStrategy: refresh ? CoreSitesReadingStrategy.OnlyNetwork : undefined,
readingStrategy: refresh ? CoreSitesReadingStrategy.ONLY_NETWORK : undefined,
siteId,
});

View File

@ -1699,7 +1699,7 @@ export class AddonModScormProvider {
await this.getScormUserDataOnline(scormId, attempt, {
cmId: options.cmId,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId: options.siteId,
});
}

View File

@ -81,7 +81,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref
*/
protected async prefetchSurvey(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const survey = await AddonModSurvey.getSurvey(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
});
@ -95,7 +95,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref
if (!survey.surveydone) {
promises.push(AddonModSurvey.getQuestions(survey.id, {
cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
}));
}

View File

@ -60,7 +60,7 @@ export class AddonModWikiCreateLinkHandlerService extends CoreContentLinksHandle
const options = {
cmId: params.cmId,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
};

View File

@ -73,7 +73,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
CorePluginFileDelegate.getFilesDownloadSize(files)));
promises.push(this.getAllPages(module, courseId, {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
}).then((pages) => {
let size = 0;
@ -161,7 +161,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
const userId = CoreSites.getCurrentSiteUserId();
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {

View File

@ -683,7 +683,7 @@ export class AddonModWikiProvider {
// We have wiki ID, check if there's already an online page with this title and subwiki.
const used = await CoreUtils.ignoreErrors(this.isTitleUsed(options.wikiId, options.subwikiId, title, {
cmId: options.cmId,
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId,
}));

View File

@ -191,7 +191,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
*/
async isDownloadable(module: CoreCourseAnyModuleData, courseId: number): Promise<boolean> {
const workshop = await AddonModWorkshop.getWorkshop(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
});
const accessData = await AddonModWorkshop.getWorkshopAccessInformation(workshop.id, { cmId: module.id });
@ -263,7 +263,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
const userIds: number[] = [];
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.OnlyNetwork,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,
};
const modOptions = {

View File

@ -1419,7 +1419,7 @@ export class AddonModWorkshopProvider {
siteId = siteId || CoreSites.getCurrentSiteId();
const workshop = await this.getWorkshop(courseId, moduleId, {
readingStrategy: CoreSitesReadingStrategy.PreferCache,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId,
});

View File

@ -16,10 +16,10 @@ import { Component, Input } from '@angular/core';
import { Platform } from '@singletons';
const enum ScrollPosition {
Start = 'start',
End = 'end',
Middle = 'middle',
Hidden = 'hidden',
START = 'start',
END = 'end',
MIDDLE = 'middle',
HIDDEN = 'hidden',
}
@Component({
@ -32,7 +32,7 @@ export class CoreHorizontalScrollControlsComponent {
// eslint-disable-next-line @angular-eslint/no-input-rename
@Input('aria-controls') targetId?: string;
scrollPosition: ScrollPosition = ScrollPosition.Hidden;
scrollPosition: ScrollPosition = ScrollPosition.HIDDEN;
/**
* Get target element.
@ -85,22 +85,22 @@ export class CoreHorizontalScrollControlsComponent {
scrollLeft = scrollLeft ?? this.target?.scrollLeft ?? 0;
if (!this.target || this.target.scrollWidth <= this.target.clientWidth) {
return ScrollPosition.Hidden;
return ScrollPosition.HIDDEN;
}
if (scrollLeft === 0) {
return Platform.isRTL ? ScrollPosition.End : ScrollPosition.Start;
return Platform.isRTL ? ScrollPosition.END : ScrollPosition.START;
}
if (!Platform.isRTL && this.target.scrollWidth - scrollLeft === this.target.clientWidth) {
return ScrollPosition.End;
return ScrollPosition.END;
}
if (Platform.isRTL && this.target.scrollWidth + scrollLeft === this.target.clientWidth) {
return ScrollPosition.Start;
return ScrollPosition.START;
}
return ScrollPosition.Middle;
return ScrollPosition.MIDDLE;
}
}

View File

@ -1,6 +1,7 @@
<form #messageForm>
<textarea
class="core-send-message-input"
[attr.aria-label]="placeholder"
[core-auto-focus]="showKeyboard"
[placeholder]="placeholder"
rows="1"

View File

@ -19,9 +19,9 @@ import { CoreScreen } from '@services/screen';
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
export enum CoreSplitViewMode {
MenuOnly = 'menu-only', // Hides content.
ContentOnly = 'content-only', // Hides menu.
MenuAndContent = 'menu-and-content', // Shows both menu and content.
MENU_ONLY = 'menu-only', // Hides content.
CONTENT_ONLY = 'content-only', // Hides menu.
MENU_AND_CONTENT = 'menu-and-content', // Shows both menu and content.
}
const disabledScrollClass = 'disable-scroll-y';
@ -118,16 +118,16 @@ export class CoreSplitViewComponent implements AfterViewInit, OnDestroy {
}
if (this.isNested) {
return CoreSplitViewMode.MenuOnly;
return CoreSplitViewMode.MENU_ONLY;
}
if (CoreScreen.isMobile) {
return this.contentOutlet.isActivated
? CoreSplitViewMode.ContentOnly
: CoreSplitViewMode.MenuOnly;
? CoreSplitViewMode.CONTENT_ONLY
: CoreSplitViewMode.MENU_ONLY;
}
return CoreSplitViewMode.MenuAndContent;
return CoreSplitViewMode.MENU_AND_CONTENT;
}
/**

View File

@ -191,8 +191,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
this.displaySectionSelector = CoreCourseFormatDelegate.displaySectionSelector(this.course);
this.displayBlocks = CoreCourseFormatDelegate.displayBlocks(this.course);
this.progress = 'progress' in this.course && typeof this.course.progress == 'number' &&
this.course.progress >= 0 && this.course.completionusertracked !== false ? this.course.progress : undefined;
this.updateProgress();
if ('overviewfiles' in this.course) {
this.imageThumb = this.course.overviewfiles?.[0]?.fileurl;
}
@ -414,6 +414,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
CoreCourse.logView(this.course!.id, newSection.section, undefined, this.course!.fullname),
);
}
this.invalidateSectionButtons();
}
/**
@ -506,6 +508,25 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
done?.();
}
/**
* Invalidate section buttons so that they are rendered again. This is necessary in order to update
* some attributes that are not reactive, for example aria-label.
*
* @see https://github.com/ionic-team/ionic-framework/issues/21534
*/
protected async invalidateSectionButtons(): Promise<void> {
const previousSection = this.previousSection;
const nextSection = this.nextSection;
this.previousSection = undefined;
this.nextSection = undefined;
await CoreUtils.nextTick();
this.previousSection = previousSection;
this.nextSection = nextSection;
}
/**
* Show more activities (only used when showing all the sections at the same time).
*
@ -620,6 +641,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
} else {
this.course.progress = Math.max(0, this.course.progress - moduleProgressPercent);
}
this.updateProgress();
}
/**
@ -633,4 +656,23 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
CoreCourseHelper.calculateSectionsStatus(this.sections, this.course.id, false, false);
}
/**
* Update course progress.
*/
protected updateProgress(): void {
if (
!this.course ||
!('progress' in this.course) ||
typeof this.course.progress !== 'number' ||
this.course.progress < 0 ||
this.course.completionusertracked === false
) {
this.progress = undefined;
return;
}
this.progress = this.course.progress;
}
}

View File

@ -51,7 +51,7 @@ export class CoreGradesCoursePage implements AfterViewInit, OnDestroy {
const useSplitView = route.snapshot.data.useSplitView ?? true;
const outsideGradesTab = route.snapshot.data.outsideGradesTab ?? false;
this.splitViewMode = useSplitView ? undefined : CoreSplitViewMode.MenuOnly;
this.splitViewMode = useSplitView ? undefined : CoreSplitViewMode.MENU_ONLY;
this.grades = new CoreGradesCourseManager(CoreGradesCoursePage, courseId, userId, outsideGradesTab);
}

View File

@ -221,7 +221,7 @@ export class CoreGradesHelperProvider {
let coursesWereMissing = false;
try {
const courses = await CoreCourses.getUserCourses(undefined, undefined, CoreSitesReadingStrategy.OnlyCache);
const courses = await CoreCourses.getUserCourses(undefined, undefined, CoreSitesReadingStrategy.ONLY_CACHE);
const coursesMap = CoreUtils.arrayToObject(courses, 'id');
coursesWereMissing = this.addCourseData(grades, coursesMap);
@ -233,7 +233,7 @@ export class CoreGradesHelperProvider {
if (coursesWereMissing) {
const coursesPromise = CoreCourses.isGetCoursesByFieldAvailable()
? CoreCourses.getCoursesByField('ids', grades.map((grade) => grade.courseid).join(','))
: CoreCourses.getUserCourses(undefined, undefined, CoreSitesReadingStrategy.PreferNetwork);
: CoreCourses.getUserCourses(undefined, undefined, CoreSitesReadingStrategy.PREFER_NETWORK);
const courses = await coursesPromise;
const coursesMap =

View File

@ -41,7 +41,7 @@ export class CoreGeolocationProvider {
return result.coords;
} catch (error) {
if (this.isCordovaPermissionDeniedError(error)) {
throw new CoreGeolocationError(CoreGeolocationErrorReason.PermissionDenied);
throw new CoreGeolocationError(CoreGeolocationErrorReason.PERMISSION_DENIED);
}
throw error;
@ -78,7 +78,7 @@ export class CoreGeolocationProvider {
}
if (!locationEnabled) {
throw new CoreGeolocationError(CoreGeolocationErrorReason.LocationNotEnabled);
throw new CoreGeolocationError(CoreGeolocationErrorReason.LOCATION_NOT_ENABLED);
}
}
@ -93,7 +93,7 @@ export class CoreGeolocationProvider {
switch (authorizationStatus) {
case Diagnostic.permissionStatus.DENIED_ONCE:
if (failOnDeniedOnce) {
throw new CoreGeolocationError(CoreGeolocationErrorReason.PermissionDenied);
throw new CoreGeolocationError(CoreGeolocationErrorReason.PERMISSION_DENIED);
}
// Fall through.
case Diagnostic.permissionStatus.NOT_REQUESTED:
@ -107,7 +107,7 @@ export class CoreGeolocationProvider {
// Location is authorized.
return;
default:
throw new CoreGeolocationError(CoreGeolocationErrorReason.PermissionDenied);
throw new CoreGeolocationError(CoreGeolocationErrorReason.PERMISSION_DENIED);
}
}
@ -138,8 +138,8 @@ export class CoreGeolocationProvider {
export const CoreGeolocation = makeSingleton(CoreGeolocationProvider);
export enum CoreGeolocationErrorReason {
PermissionDenied = 'permission-denied',
LocationNotEnabled = 'location-not-enabled',
PERMISSION_DENIED = 'permission-denied',
LOCATION_NOT_ENABLED = 'location-not-enabled',
}
export class CoreGeolocationError extends CoreError {

View File

@ -24,28 +24,28 @@ import { makeSingleton } from '@singletons';
* @see https://ionicframework.com/docs/layout/grid#default-breakpoints
*/
enum Breakpoint {
ExtraSmall = 'xs',
Small = 'sm',
Medium = 'md',
Large = 'lg',
ExtraLarge = 'xl',
EXTRA_SMALL = 'xs',
SMALL = 'sm',
MEDIUM = 'md',
LARGE = 'lg',
EXTRA_LARGE = 'xl',
}
const BREAKPOINT_NAMES = Object.values(Breakpoint);
const BREAKPOINT_WIDTHS: Record<Breakpoint, number> = {
[Breakpoint.ExtraSmall]: 0,
[Breakpoint.Small]: 576,
[Breakpoint.Medium]: 768,
[Breakpoint.Large]: 992,
[Breakpoint.ExtraLarge]: 1200,
[Breakpoint.EXTRA_SMALL]: 0,
[Breakpoint.SMALL]: 576,
[Breakpoint.MEDIUM]: 768,
[Breakpoint.LARGE]: 992,
[Breakpoint.EXTRA_LARGE]: 1200,
};
/**
* Screen layouts.
*/
export enum CoreScreenLayout {
Mobile = 'mobile',
Tablet = 'tablet',
MOBILE = 'mobile',
TABLET = 'tablet',
}
/**
@ -86,11 +86,11 @@ export class CoreScreenService {
}
get isMobile(): boolean {
return this.layout === CoreScreenLayout.Mobile;
return this.layout === CoreScreenLayout.MOBILE;
}
get isTablet(): boolean {
return this.layout === CoreScreenLayout.Tablet;
return this.layout === CoreScreenLayout.TABLET;
}
/**
@ -131,11 +131,11 @@ export class CoreScreenService {
* @return Active layout.
*/
protected calculateLayout(breakpoints: Record<Breakpoint, boolean>): CoreScreenLayout {
if (breakpoints[Breakpoint.Large]) {
return CoreScreenLayout.Tablet;
if (breakpoints[Breakpoint.LARGE]) {
return CoreScreenLayout.TABLET;
}
return CoreScreenLayout.Mobile;
return CoreScreenLayout.MOBILE;
}
}

View File

@ -1675,20 +1675,20 @@ export class CoreSitesProvider {
*/
getReadingStrategyPreSets(strategy?: CoreSitesReadingStrategy): CoreSiteWSPreSets {
switch (strategy) {
case CoreSitesReadingStrategy.PreferCache:
case CoreSitesReadingStrategy.PREFER_CACHE:
return {
omitExpires: true,
};
case CoreSitesReadingStrategy.OnlyCache:
case CoreSitesReadingStrategy.ONLY_CACHE:
return {
omitExpires: true,
forceOffline: true,
};
case CoreSitesReadingStrategy.PreferNetwork:
case CoreSitesReadingStrategy.PREFER_NETWORK:
return {
getFromCache: false,
};
case CoreSitesReadingStrategy.OnlyNetwork:
case CoreSitesReadingStrategy.ONLY_NETWORK:
return {
getFromCache: false,
emergencyCache: false,
@ -1889,10 +1889,10 @@ export type CoreRegisteredSiteSchema = CoreSiteSchema & {
* Possible reading strategies (for cache).
*/
export const enum CoreSitesReadingStrategy {
OnlyCache,
PreferCache,
OnlyNetwork,
PreferNetwork,
ONLY_CACHE,
PREFER_CACHE,
ONLY_NETWORK,
PREFER_NETWORK,
}
/**