Merge pull request #1393 from dpalou/MOBILE-2462

Mobile 2462
main
Juan Leyva 2018-07-04 15:05:41 +02:00 committed by GitHub
commit 4f636824e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 4 deletions

View File

@ -23,7 +23,7 @@
<div *ngIf="scorm && loaded && !scorm.warningMessage"> <div *ngIf="scorm && loaded && !scorm.warningMessage">
<!-- Attempts status. --> <!-- Attempts status. -->
<ion-card *ngIf="scorm.displayattemptstatus || Object.keys(scorm.offlineAttempts).length"> <ion-card *ngIf="scorm.displayattemptstatus || (scorm.offlineAttempts && scorm.offlineAttempts.length)">
<ion-card-header text-wrap> <ion-card-header text-wrap>
<h2>{{ 'addon.mod_scorm.attempts' | translate }}</h2> <h2>{{ 'addon.mod_scorm.attempts' | translate }}</h2>
</ion-card-header> </ion-card-header>

View File

@ -113,4 +113,15 @@ export class CoreCourseFormatSingleActivityHandler implements CoreCourseFormatHa
getCourseFormatComponent(injector: Injector, course: any): any | Promise<any> { getCourseFormatComponent(injector: Injector, course: any): any | Promise<any> {
return CoreCourseFormatSingleActivityComponent; return CoreCourseFormatSingleActivityComponent;
} }
/**
* Whether the view should be refreshed when completion changes. If your course format doesn't display
* activity completion then you should return false.
*
* @param {any} course The course.
* @return {boolean|Promise<boolean>} Whether course view should be refreshed when an activity completion changes.
*/
shouldRefreshWhenCompletionChanges(course: any): boolean | Promise<boolean> {
return false;
}
} }

View File

@ -80,11 +80,16 @@ export class CoreCourseSectionPage implements OnDestroy {
this.displayEnableDownload = courseFormatDelegate.displayEnableDownload(this.course); this.displayEnableDownload = courseFormatDelegate.displayEnableDownload(this.course);
this.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite(); this.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite();
// Check if the course format requires the view to be refreshed when completion changes.
courseFormatDelegate.shouldRefreshWhenCompletionChanges(this.course).then((shouldRefresh) => {
if (shouldRefresh) {
this.completionObserver = eventsProvider.on(CoreEventsProvider.COMPLETION_MODULE_VIEWED, (data) => { this.completionObserver = eventsProvider.on(CoreEventsProvider.COMPLETION_MODULE_VIEWED, (data) => {
if (data && data.courseId == this.course.id) { if (data && data.courseId == this.course.id) {
this.refreshAfterCompletionChange(); this.refreshAfterCompletionChange();
} }
}); });
}
});
if (this.downloadCourseEnabled) { if (this.downloadCourseEnabled) {
// Listen for changes in course status. // Listen for changes in course status.

View File

@ -157,4 +157,15 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
openCourse(navCtrl: NavController, course: any): Promise<any> { openCourse(navCtrl: NavController, course: any): Promise<any> {
return navCtrl.push('CoreCourseSectionPage', { course: course }); return navCtrl.push('CoreCourseSectionPage', { course: course });
} }
/**
* Whether the view should be refreshed when completion changes. If your course format doesn't display
* activity completion then you should return false.
*
* @param {any} course The course.
* @return {boolean|Promise<boolean>} Whether course view should be refreshed when an activity completion changes.
*/
shouldRefreshWhenCompletionChanges(course: any): boolean | Promise<boolean> {
return true;
}
} }

View File

@ -158,6 +158,15 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler {
* @return {Promise<any>} Promise resolved when the data is invalidated. * @return {Promise<any>} Promise resolved when the data is invalidated.
*/ */
invalidateData?(course: any, sections: any[]): Promise<any>; invalidateData?(course: any, sections: any[]): Promise<any>;
/**
* Whether the view should be refreshed when completion changes. If your course format doesn't display
* activity completion then you should return false.
*
* @param {any} course The course.
* @return {boolean|Promise<boolean>} Whether course view should be refreshed when an activity completion changes.
*/
shouldRefreshWhenCompletionChanges?(course: any): boolean | Promise<boolean>;
} }
/** /**
@ -337,4 +346,15 @@ export class CoreCourseFormatDelegate extends CoreDelegate {
openCourse(navCtrl: NavController, course: any): Promise<any> { openCourse(navCtrl: NavController, course: any): Promise<any> {
return this.executeFunctionOnEnabled(course.format, 'openCourse', [navCtrl, course]); return this.executeFunctionOnEnabled(course.format, 'openCourse', [navCtrl, course]);
} }
/**
* Whether the view should be refreshed when completion changes. If your course format doesn't display
* activity completion then you should return false.
*
* @param {any} course The course.
* @return {Promise<boolean>} Whether course view should be refreshed when an activity completion changes.
*/
shouldRefreshWhenCompletionChanges(course: any): Promise<boolean> {
return Promise.resolve(this.executeFunctionOnEnabled(course.format, 'shouldRefreshWhenCompletionChanges', [course]));
}
} }

View File

@ -297,6 +297,8 @@ export class CoreQuestionBaseComponent {
this.question.input.correctClass = 'core-question-correct'; this.question.input.correctClass = 'core-question-correct';
} else if (input.classList.contains('partiallycorrect')) { } else if (input.classList.contains('partiallycorrect')) {
this.question.input.correctClass = 'core-question-partiallycorrect'; this.question.input.correctClass = 'core-question-partiallycorrect';
} else {
this.question.input.correctClass = '';
} }
} }