MOBILE-2149 course: Show section completion on the section selector
parent
d0b801dff2
commit
3f7dde49d0
|
@ -7,15 +7,6 @@
|
|||
|
||||
<!-- Default course format. -->
|
||||
<core-dynamic-component [component]="courseFormatComponent" [data]="data">
|
||||
<!-- Course summary. By default we only display the course progress. -->
|
||||
<core-dynamic-component [component]="courseSummaryComponent" [data]="data">
|
||||
<ion-list no-lines *ngIf="selectedSection && selectedSection.id == allSectionsId && course.progress != null && course.progress >= 0" class="core-format-progress-list">
|
||||
<ion-item class="core-course-progress">
|
||||
<core-progress-bar [progress]="course.progress"></core-progress-bar>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</core-dynamic-component>
|
||||
|
||||
<core-loading [hideUntil]="loaded">
|
||||
<!-- Section selector. -->
|
||||
<core-dynamic-component [component]="sectionSelectorComponent" [data]="data">
|
||||
|
@ -30,6 +21,15 @@
|
|||
</div>
|
||||
</core-dynamic-component>
|
||||
|
||||
<!-- Course summary. By default we only display the course progress. -->
|
||||
<core-dynamic-component [component]="courseSummaryComponent" [data]="data">
|
||||
<ion-list no-lines *ngIf="selectedSection && selectedSection.id == allSectionsId && course.progress != null && course.progress >= 0" class="core-format-progress-list">
|
||||
<ion-item class="core-course-progress">
|
||||
<core-progress-bar [progress]="course.progress"></core-progress-bar>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</core-dynamic-component>
|
||||
|
||||
<!-- Single section. -->
|
||||
<div *ngIf="selectedSection && selectedSection.id != allSectionsId">
|
||||
<core-dynamic-component [component]="singleSectionComponent" [data]="data">
|
||||
|
|
|
@ -95,22 +95,28 @@ export class CoreCourseModuleCompletionComponent implements OnChanges {
|
|||
let langKey,
|
||||
image;
|
||||
|
||||
if (this.completion.tracking === 1 && this.completion.state === 0) {
|
||||
if (this.completion.tracking === CoreCourseProvider.COMPLETION_TRACKING_MANUAL &&
|
||||
this.completion.state === CoreCourseProvider.COMPLETION_INCOMPLETE) {
|
||||
image = 'completion-manual-n';
|
||||
langKey = 'core.completion-alt-manual-n';
|
||||
} else if (this.completion.tracking === 1 && this.completion.state === 1) {
|
||||
} else if (this.completion.tracking === CoreCourseProvider.COMPLETION_TRACKING_MANUAL &&
|
||||
this.completion.state === CoreCourseProvider.COMPLETION_COMPLETE) {
|
||||
image = 'completion-manual-y';
|
||||
langKey = 'core.completion-alt-manual-y';
|
||||
} else if (this.completion.tracking === 2 && this.completion.state === 0) {
|
||||
} else if (this.completion.tracking === CoreCourseProvider.COMPLETION_TRACKING_AUTOMATIC &&
|
||||
this.completion.state === CoreCourseProvider.COMPLETION_INCOMPLETE) {
|
||||
image = 'completion-auto-n';
|
||||
langKey = 'core.completion-alt-auto-n';
|
||||
} else if (this.completion.tracking === 2 && this.completion.state === 1) {
|
||||
} else if (this.completion.tracking === CoreCourseProvider.COMPLETION_TRACKING_AUTOMATIC &&
|
||||
this.completion.state === CoreCourseProvider.COMPLETION_COMPLETE) {
|
||||
image = 'completion-auto-y';
|
||||
langKey = 'core.completion-alt-auto-y';
|
||||
} else if (this.completion.tracking === 2 && this.completion.state === 2) {
|
||||
} else if (this.completion.tracking === CoreCourseProvider.COMPLETION_TRACKING_AUTOMATIC &&
|
||||
this.completion.state === CoreCourseProvider.COMPLETION_COMPLETE_PASS) {
|
||||
image = 'completion-auto-pass';
|
||||
langKey = 'core.completion-alt-auto-pass';
|
||||
} else if (this.completion.tracking === 2 && this.completion.state === 3) {
|
||||
} else if (this.completion.tracking === CoreCourseProvider.COMPLETION_TRACKING_AUTOMATIC &&
|
||||
this.completion.state === CoreCourseProvider.COMPLETION_COMPLETE_FAIL) {
|
||||
image = 'completion-auto-fail';
|
||||
langKey = 'core.completion-alt-auto-fail';
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<a ion-item *ngIf="!section.hiddenbynumsections && section.id != stealthModulesSectionId" text-wrap (click)="selectSection(section)" [class.core-primary-selected-item]="selected.id == section.id" [class.item-dimmed]="section.visible === 0 || section.uservisible === false" detail-none>
|
||||
<core-icon name="fa-folder" item-start></core-icon>
|
||||
<h2><core-format-text [text]="section.formattedName || section.name"></core-format-text></h2>
|
||||
<core-progress-bar *ngIf="section.progress" [progress]="section.progress"></core-progress-bar>
|
||||
<ion-badge color="secondary" *ngIf="section.visible === 0 && section.uservisible !== false">{{ 'core.course.hiddenfromstudents' | translate }}</ion-badge>
|
||||
<ion-badge color="secondary" *ngIf="section.availabilityinfo"><core-format-text [text]=" section.availabilityinfo"></core-format-text></ion-badge>
|
||||
</a>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
ion-app.app-root page-core-course-section-selector {
|
||||
core-progress-bar {
|
||||
.core-progress-text {
|
||||
line-height: 24px;
|
||||
@include position(-8px, 10px, null, null);
|
||||
}
|
||||
progress {
|
||||
margin: 8px 0 4px 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,6 +34,24 @@ export class CoreCourseSectionSelectorPage {
|
|||
constructor(navParams: NavParams, courseHelper: CoreCourseHelperProvider, private viewCtrl: ViewController) {
|
||||
this.sections = navParams.get('sections');
|
||||
this.selected = navParams.get('selected');
|
||||
this.sections.forEach((section) => {
|
||||
let complete = 0,
|
||||
total = 0;
|
||||
section.modules && section.modules.forEach((module) => {
|
||||
if (typeof module.completiondata != 'undefined' &&
|
||||
module.completiondata.tracking > CoreCourseProvider.COMPLETION_TRACKING_NONE) {
|
||||
total++;
|
||||
if (module.completiondata.state == CoreCourseProvider.COMPLETION_COMPLETE ||
|
||||
module.completiondata.state == CoreCourseProvider.COMPLETION_COMPLETE_PASS) {
|
||||
complete++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (total > 0) {
|
||||
section.progress = complete / total * 100;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,6 +34,15 @@ export class CoreCourseProvider {
|
|||
static ACCESS_GUEST = 'courses_access_guest';
|
||||
static ACCESS_DEFAULT = 'courses_access_default';
|
||||
|
||||
static COMPLETION_TRACKING_NONE = 0;
|
||||
static COMPLETION_TRACKING_MANUAL = 1;
|
||||
static COMPLETION_TRACKING_AUTOMATIC = 2;
|
||||
|
||||
static COMPLETION_INCOMPLETE = 0;
|
||||
static COMPLETION_COMPLETE = 1;
|
||||
static COMPLETION_COMPLETE_PASS = 2;
|
||||
static COMPLETION_COMPLETE_FAIL = 3;
|
||||
|
||||
protected ROOT_CACHE_KEY = 'mmCourse:';
|
||||
|
||||
// Variables for database.
|
||||
|
|
Loading…
Reference in New Issue