MOBILE-2994 lesson: Teachers can prefetch all lessons
parent
ec6332583c
commit
1710791114
|
@ -211,12 +211,12 @@ export class AddonModLessonPrefetchHandler extends CoreCourseActivityPrefetchHan
|
||||||
const siteId = this.sitesProvider.getCurrentSiteId();
|
const siteId = this.sitesProvider.getCurrentSiteId();
|
||||||
|
|
||||||
return this.lessonProvider.getLesson(courseId, module.id, false, false, siteId).then((lesson) => {
|
return this.lessonProvider.getLesson(courseId, module.id, false, false, siteId).then((lesson) => {
|
||||||
if (!this.lessonProvider.isLessonOffline(lesson)) {
|
// Check if there is any prevent access reason.
|
||||||
|
return this.lessonProvider.getAccessInformation(lesson.id, false, false, siteId).then((info) => {
|
||||||
|
if (!info.canviewreports && !this.lessonProvider.isLessonOffline(lesson)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is any prevent access reason.
|
|
||||||
return this.lessonProvider.getAccessInformation(lesson.id, false, false, siteId).then((info) => {
|
|
||||||
// It's downloadable if there are no prevent access reasons or there is just 1 and it's password.
|
// It's downloadable if there are no prevent access reasons or there is just 1 and it's password.
|
||||||
return !info.preventaccessreasons || !info.preventaccessreasons.length ||
|
return !info.preventaccessreasons || !info.preventaccessreasons.length ||
|
||||||
(info.preventaccessreasons.length == 1 && this.lessonProvider.isPasswordProtected(info));
|
(info.preventaccessreasons.length == 1 && this.lessonProvider.isPasswordProtected(info));
|
||||||
|
@ -270,7 +270,7 @@ export class AddonModLessonPrefetchHandler extends CoreCourseActivityPrefetchHan
|
||||||
lesson = data.lesson || lesson;
|
lesson = data.lesson || lesson;
|
||||||
accessInfo = data.accessInfo;
|
accessInfo = data.accessInfo;
|
||||||
|
|
||||||
if (!this.lessonProvider.leftDuringTimed(accessInfo)) {
|
if (this.lessonProvider.isLessonOffline(lesson) && !this.lessonProvider.leftDuringTimed(accessInfo)) {
|
||||||
// The user didn't left during a timed session. Call launch retake to make sure there is a started retake.
|
// The user didn't left during a timed session. Call launch retake to make sure there is a started retake.
|
||||||
return this.lessonProvider.launchRetake(lesson.id, password, undefined, false, siteId).then(() => {
|
return this.lessonProvider.launchRetake(lesson.id, password, undefined, false, siteId).then(() => {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
@ -298,6 +298,7 @@ export class AddonModLessonPrefetchHandler extends CoreCourseActivityPrefetchHan
|
||||||
promises.push(this.filepoolProvider.addFilesToQueue(siteId, files, this.component, module.id));
|
promises.push(this.filepoolProvider.addFilesToQueue(siteId, files, this.component, module.id));
|
||||||
|
|
||||||
// Get the list of pages.
|
// Get the list of pages.
|
||||||
|
if (this.lessonProvider.isLessonOffline(lesson)) {
|
||||||
promises.push(this.lessonProvider.getPages(lesson.id, password, false, true, siteId).then((pages) => {
|
promises.push(this.lessonProvider.getPages(lesson.id, password, false, true, siteId).then((pages) => {
|
||||||
const subPromises = [];
|
const subPromises = [];
|
||||||
let hasRandomBranch = false;
|
let hasRandomBranch = false;
|
||||||
|
@ -356,7 +357,9 @@ export class AddonModLessonPrefetchHandler extends CoreCourseActivityPrefetchHan
|
||||||
promises.push(this.lessonProvider.getContentPagesViewedOnline(lesson.id, retake, false, true, siteId));
|
promises.push(this.lessonProvider.getContentPagesViewedOnline(lesson.id, retake, false, true, siteId));
|
||||||
|
|
||||||
// Prefetch question attempts in last retake for offline calculations.
|
// Prefetch question attempts in last retake for offline calculations.
|
||||||
promises.push(this.lessonProvider.getQuestionsAttemptsOnline(lesson.id, retake, false, undefined, false, true, siteId));
|
promises.push(this.lessonProvider.getQuestionsAttemptsOnline(lesson.id, retake, false, undefined, false, true,
|
||||||
|
siteId));
|
||||||
|
}
|
||||||
|
|
||||||
if (accessInfo.canviewreports) {
|
if (accessInfo.canviewreports) {
|
||||||
// Prefetch reports data.
|
// Prefetch reports data.
|
||||||
|
|
Loading…
Reference in New Issue