MOBILE-2354 workshop: PR fixes

main
Albert Gasset 2018-06-14 11:12:17 +02:00
parent 71a5999c60
commit 973f1cdc72
5 changed files with 9 additions and 15 deletions

View File

@ -6,7 +6,6 @@
<core-dynamic-component [component]="componentClass" [data]="data"></core-dynamic-component> <core-dynamic-component [component]="componentClass" [data]="data"></core-dynamic-component>
</ng-container> </ng-container>
<!-- This content will be replaced by the directive if any is applied. -->
<div class="core-info-card" *ngIf="notSupported"> <div class="core-info-card" *ngIf="notSupported">
{{ 'addon.mod_workshop.assessmentstrategynotsupported' | translate:{$a: strategy} }} {{ 'addon.mod_workshop.assessmentstrategynotsupported' | translate:{$a: strategy} }}
</div> </div>

View File

@ -263,7 +263,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit {
/** /**
* Save the assessment. * Save the assessment.
* *
* @return {Promise<any>} Promise resolved when done. * @return {Promise<any>} Promise resolved when done, rejected if assessment could not be saved.
*/ */
saveAssessment(): Promise<any> { saveAssessment(): Promise<any> {
const files = this.fileSessionProvider.getFiles(AddonModWorkshopProvider.COMPONENT, const files = this.fileSessionProvider.getFiles(AddonModWorkshopProvider.COMPONENT,

View File

@ -88,10 +88,7 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
// Since most actions will take the user out of the app, we should refresh the view when the app is resumed. // Since most actions will take the user out of the app, we should refresh the view when the app is resumed.
this.appResumeSubscription = platform.resume.subscribe(() => { this.appResumeSubscription = platform.resume.subscribe(() => {
this.content && this.content.scrollToTop(); this.showLoadingAndRefresh(true);
this.loaded = false;
this.refreshContent(true, false);
}); });
// Refresh workshop on sync. // Refresh workshop on sync.
@ -114,6 +111,8 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
this.workshopProvider.logView(this.workshop.id).then(() => { this.workshopProvider.logView(this.workshop.id).then(() => {
this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus); this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus);
}).catch((error) => {
// Ignore errors.
}); });
}); });
} }
@ -125,10 +124,8 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
*/ */
protected eventReceived(data: any): void { protected eventReceived(data: any): void {
if ((this.workshop && this.workshop.id === data.workshopId) || data.cmId === this.module.id) { if ((this.workshop && this.workshop.id === data.workshopId) || data.cmId === this.module.id) {
this.content && this.content.scrollToTop(); this.showLoadingAndRefresh(true);
this.loaded = false;
this.refreshContent(true, false);
// Check completion since it could be configured to complete once the user adds a new discussion or replies. // Check completion since it could be configured to complete once the user adds a new discussion or replies.
this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus); this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus);
} }
@ -223,8 +220,6 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
} }
}); });
} }
return Promise.resolve();
}).then(() => { }).then(() => {
return this.workshopProvider.getUserPlanPhases(this.workshop.id); return this.workshopProvider.getUserPlanPhases(this.workshop.id);
}).then((phases) => { }).then((phases) => {

View File

@ -154,14 +154,14 @@ export class AddonModWorkshopPrefetchHandler extends CoreCourseModulePrefetchHan
groups: groups, groups: groups,
files: files.filter((file) => typeof file !== 'undefined') files: files.filter((file) => typeof file !== 'undefined')
}; };
}).catch((message) => { }).catch((message): any => {
if (omitFail) { if (omitFail) {
// Any error, return the info we have. // Any error, return the info we have.
return Promise.resolve({ return {
workshop: workshop, workshop: workshop,
groups: groups, groups: groups,
files: files.filter((file) => typeof file !== 'undefined') files: files.filter((file) => typeof file !== 'undefined')
}); };
} }
return Promise.reject(message); return Promise.reject(message);

View File

@ -1060,7 +1060,7 @@ export class AddonModWorkshopProvider {
* @param {string} [siteId] Site ID. If not defined, current site. * @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved when the data is invalidated. * @return {Promise<any>} Promise resolved when the data is invalidated.
*/ */
invalidateAssessmentFormData(workshopId: number, assessmentId: number, mode: string = 'assesssment', siteId?: string): invalidateAssessmentFormData(workshopId: number, assessmentId: number, mode: string = 'assessment', siteId?: string):
Promise<any> { Promise<any> {
return this.sitesProvider.getSite(siteId).then((site) => { return this.sitesProvider.getSite(siteId).then((site) => {
return site.invalidateWsCacheForKey(this.getAssessmentFormDataCacheKey(workshopId, assessmentId, mode)); return site.invalidateWsCacheForKey(this.getAssessmentFormDataCacheKey(workshopId, assessmentId, mode));