Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ion-list lines="none">
<!--commented while doing course TOC-->
<!-- <ion-item (click)="close(0)">{{ 'REMOVE_FROM_DEVICE' | translate }}</ion-item> -->
<ion-item *ngIf="!isUnenrollDisabled()" (click)="unenroll()">{{ 'UNENROLL_FROM_COURSE' | translate }}</ion-item>
<ion-item (click)="unenroll()">{{ 'UNENROLL_FROM_COURSE' | translate }}</ion-item>
</ion-list>
25 changes: 0 additions & 25 deletions src/app/components/content-actions/content-actions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,31 +251,6 @@ export class ContentActionsComponent {
this.data.enrollmentType !== 'invite-only'));
}

isUnenrollDisabled() {
if (!this.batchDetails || this.isObjectEmpty(this.batchDetails)) {
return true;
}

if (!this.batchDetails.endDate) {
let progress;

if (this.data && this.data.courseProgress) {
progress = this.data.courseProgress ? Math.round(this.data.courseProgress) : 0;
}

return !(this.batchDetails.enrollmentType === 'open' && progress !== 100);
} else {
if (moment(this.batchDetails.endDate).diff(moment(new Date())) !== 0) {
let progress;

if (this.data && this.data.courseProgress) {
progress = this.data.courseProgress ? Math.round(this.data.courseProgress) : 0;
}

return !(this.batchDetails.enrollmentType === 'open' && progress !== 100);
}
}
}

private isObjectEmpty(obj) {
return Object.keys(obj).length === 0 && obj.constructor === Object;
Expand Down
6 changes: 1 addition & 5 deletions src/app/course-batches/course-batches.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
</p>
</div>
<div class="card-icon">
<!-- <ion-button size="small" slot="end" (click)="enrollIntoBatch(batch)"
[disabled]="(batch.endDate && (todayDate > batch.endDate))">
{{ 'ENROLL' | translate }}
</ion-button> -->
<button class="sb-btn sb-btn-sm sb-btn-outline-info view-all-p8" float-end
(click)="enrollIntoBatch(batch);" [disabled]="(batch.enrollmentEndDate && (todayDate > batch.enrollmentEndDate))">
{{ 'ENROLL' | translate }}</button>
Expand Down Expand Up @@ -98,7 +94,7 @@
</p>
</div>
<div class="card-icon">
<button size="small" ion-button item-end (click)="enrollIntoBatch(batch)" [disabled]="(batch.enrollmentEndDate && (todayDate > batch.enrollmentEndDate))"
<button class="sb-btn sb-btn-sm sb-btn-outline-info view-all-p8" float-end (click)="enrollIntoBatch(batch)" [disabled]="(batch.enrollmentEndDate && (todayDate > batch.enrollmentEndDate))"
[ngClass]="{'enroll-style' : (batch.enrollmentEndDate && (todayDate > batch.enrollmentEndDate))}">
{{ 'ENROLL' | translate }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<button class="enrolled-course-card-button"
(click)="navigateToBatchListPage();">{{'JOIN_TRAINING' | translate}}</button>
<ion-card-subtitle *ngIf="batchCount || enrollmentEndDate" class="font-12 margin-bottom-2">
<div *ngIf="batchCount > 1">
<div *ngIf="batchCount">
<ion-icon name="information-circle"></ion-icon> {{batchCount}}
{{'BATCHES_AVAILABLE' | translate}}
</div>
Expand All @@ -23,7 +23,7 @@
{{'LAST_DATE_TO_JOIN' | translate }} {{enrollmentEndDate | date}}
</div>
<div *ngIf="!enrollmentEndDate && batchEndDate">
{{'TRAINING_ENDS_ON' | translate}} {{batchEndDate}}
{{'TRAINING_ENDS_ON' | translate}} {{batchEndDate | date}}
</div>
</ion-card-subtitle>
</div>
Expand All @@ -38,7 +38,6 @@
<div class="sb-dt-card-actions">
<div class="wrapper sb-btn-tile-group" *ngIf="course?.progress !==100">
<div>
<!-- *ngIf="downloadIdentifiers?.length && !isDownloadStarted" -->
<button [disabled]="isDownloadStarted" *ngIf="downloadIdentifiers?.length"
(click)="showDownloadConfirmationAlert()" slot="icon-only"
class="card-button">
Expand Down Expand Up @@ -67,7 +66,7 @@
<div class="sb-course-progress-container"
*ngIf="course?.progress!==100 && !batchExp">
<p><b>{{'YOUR_PROGRESS_LABEL' | translate}}</b></p>
<p>{{course?.progress ? course?.progress : '0'}} %
<p>{{course?.progress ? course?.progress : '0'}}%
{{'COURSE_COMPLETED_LABEL' | translate}}</p>
<app-pb-horizontal [progress]="course?.progress" class="course-progress"
[ngClass]="{'blurbackground': batchExp}" isOnBoardCard="flase"
Expand Down Expand Up @@ -107,9 +106,8 @@
(click)="resumeContent(courseCardData?.lastReadContentId)"><span><img class="play-icon"
src="assets/imgs/[email protected]" alt="play-icon">{{
'CONTINUE_NOW' | translate }}</span></button>
<div *ngIf="batchDetails?.endDate" class="enrollment-end-date ion-padding-bottom">
<div *ngIf="batchDetails?.endDate && !batchExp" class="enrollment-end-date ion-padding-bottom">
<ion-icon name="information-circle"></ion-icon>
<!-- {{'COMPLETE_TRAINING_TO_EARN_CERTIFICATE'| translate :{'%s':batchDetails?.enrollmentEndDate | date} }} -->
Complete Training by {{batchDetails?.endDate | date}} to earn a certificate
</div>
</ion-card-content>
Expand Down Expand Up @@ -147,15 +145,15 @@
<div>
<div class="ion-margin-bottom">
<ion-card-title class="font-12 subtitle-color label-margin-bottom">
{{'TRAINING_IS_RELEVENT_TO_TEACHERS'| translate}}:
<b>{{'TRAINING_IS_RELEVENT_TO_TEACHERS'| translate}}</b>:
</ion-card-title>
<p *ngIf="course?.gradeLevel">{{'CLASS' | translate}} : {{course?.gradeLevel}}</p>
<p *ngIf="course?.subject">{{'SUBJECT' | translate}}: {{course?.subject}}</p>
<p *ngIf="course?.medium">{{'MEDIUM' | translate}} : {{course?.medium}}</p>
</div>
<div class="ion-margin-bottom">
<ion-card-title class="font-12 subtitle-color label-margin-bottom">
{{'TRAINING_DETAILS' | translate}}
<b>{{'TRAINING_DETAILS' | translate}}</b>
</ion-card-title>
<p *ngIf="batchEndDate">{{'TRAINING_END_DATA' | translate }} : {{ batchEndDate | date}}</p>
</div>
Expand Down Expand Up @@ -210,7 +208,7 @@
</div>
</div>
</ion-content>
<div class="loading-backdrop" *ngIf="showLoading && !isDownloadStarted" text-center>
<div class="loading-backdrop" *ngIf="showLoading" text-center>
<div class="backdrop-container">
<ion-label>{{ 'LOADING_CONTENTS' | translate: {'%s': downloadProgress ? downloadProgress : 0} }}</ion-label>
<app-pb-horizontal [progress]="downloadProgress" isOnBoardCard="false"></app-pb-horizontal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ export class EnrolledCourseDetailsPage implements OnInit {
*/
courseStartDate;
isContentPlayed;
showLoading = false;
showLoading;
showDownloadProgress: boolean;
totalDownload: number;
currentCount = 0;
isDownloadComplete = false;
queuedIdentifiers: Array<string> = [];
faultyIdentifiers: Array<any> = [];
isDownloadStarted = false;
isDownloadStarted;
batchDetails: Batch;
batchExp = false;
userId = '';
Expand All @@ -173,8 +173,8 @@ export class EnrolledCourseDetailsPage implements OnInit {
profileType = '';
objId;
objType;
batchCount = 1;
batchEndDate;
batchCount:Number;
batchEndDate:String;
objVer;
didViewLoad: boolean;
backButtonFunc = undefined;
Expand Down Expand Up @@ -264,12 +264,13 @@ export class EnrolledCourseDetailsPage implements OnInit {
this.appName = appName;
});
this.subscribeUtilityEvents();
// const self = this;
if (this.courseCardData.batchId) {
this.segmentType = 'modules';
// this.isEnrolled = true;
} else {
this.getAllBatches();
}
if (this.courseCardData.batchId){
this.getBatchDetails();
} else {
this.getAllBatches();
}
}

Expand Down Expand Up @@ -523,21 +524,21 @@ export class EnrolledCourseDetailsPage implements OnInit {
}

async showOverflowMenu(event) {
const overFlowMenuData = {
batchStatus: this.batchDetails ? this.batchDetails.status : 2,
contentStatus: this.courseCardData.status,
enrollmentType: this.batchDetails ? this.batchDetails.enrollmentType : '',
courseProgress: this.course.progress
};
const contentData = this.course;
contentData.batchId = this.courseCardData.batchId ? this.courseCardData.batchId : false;
// const overFlowMenuData = {
// batchStatus: this.batchDetails ? this.batchDetails.status : 2,
// contentStatus: this.courseCardData.status,
// enrollmentType: this.batchDetails ? this.batchDetails.enrollmentType : '',
// courseProgress: this.course.progress
// };
// const contentData = this.course;
// contentData.batchId = this.courseCardData.batchId ? this.courseCardData.batchId : false;
const popover = await this.popoverCtrl.create({
component: ContentActionsComponent,
event,
cssClass: 'content-action',
componentProps: {
overFlowMenuData,
content: contentData,
// overFlowMenuData,
content: this.course,
batchDetails: this.batchDetails,
pageName: PageId.COURSE_DETAIL
},
Expand Down Expand Up @@ -621,15 +622,15 @@ export class EnrolledCourseDetailsPage implements OnInit {
this.objId = this.course.identifier;
this.objType = this.course.contentType;
this.objVer = this.course.pkgVersion;

this.showLoading = false;
if (!this.didViewLoad) {
this.generateImpressionEvent(this.course.identifier, this.course.contentType, this.course.pkgVersion);
this.generateStartEvent(this.course.identifier, this.course.contentType, this.course.pkgVersion);
}
this.didViewLoad = true;
// if (this.course.lastReadContentId) {
// this.getLastPlayedName(this.course.lastReadContentId);
// }
if (this.courseCardData.lastReadContentId) {
this.getLastPlayedName(this.courseCardData.lastReadContentId);
}

if (this.course && this.course.isAvailableLocally) {
this.headerService.showHeaderWithBackButton();
Expand Down Expand Up @@ -677,7 +678,7 @@ export class EnrolledCourseDetailsPage implements OnInit {
if (Boolean(data.isAvailableLocally)) {
this.setChildContents();
} else {
this.showLoading = true;
// this.showLoading = true;
this.headerService.hideHeader();
this.telemetryGeneratorService.generateSpineLoadingTelemetry(data, true);
this.importContent([this.identifier], false);
Expand Down Expand Up @@ -1005,12 +1006,7 @@ export class EnrolledCourseDetailsPage implements OnInit {
});
});
}
/** Extract only numbers from an array */
getNumbersFromArray(str) {
if (str) {
return str.replace(/^\D+/g, '');
}
}

getAllBatches() {
const courseBatchesRequest: CourseBatchesRequest = {
filters: {
Expand All @@ -1022,14 +1018,14 @@ export class EnrolledCourseDetailsPage implements OnInit {
};
this.courseService.getCourseBatches(courseBatchesRequest).toPromise()
.then((data: Batch[]) => {
this.batchCount = data.length;
if (data.length > 1) {
// this.batchCount = data.length;
} else if (data.length === 1) {
// unenrolled and only one batch available
this.batches = data || [];
// this.batchCount = this.batches.length;

if ( data && data.length > 1) {
this.batchCount = data.length;
} else {
this.batchEndDate = data[0].endDate;
this.enrollmentEndDate = data[0].enrollmentEndDate ;
// this.batchDetails = data[0];
}
})
.catch((error: any) => {
Expand Down Expand Up @@ -1244,11 +1240,13 @@ export class EnrolledCourseDetailsPage implements OnInit {
* Ionic life cycle hook
*/
async ionViewWillEnter() {
this.showLoading = true;
this.identifier = this.courseCardData.contentId || this.courseCardData.identifier;
this.setContentDetails(this.identifier);
this.headerObservable = this.headerService.headerEventEmitted$.subscribe(eventName => {
this.handleHeaderEvents(eventName);
});
this.downloadSize = 0;
this.identifier = this.courseCardData.contentId || this.courseCardData.identifier;
if (!this.guestUser) {
this.updatedCourseCardData = await this.courseService.getEnrolledCourses
({userId: this.userId, returnFreshCourses: false}).toPromise().then((data) => {
Expand All @@ -1267,6 +1265,7 @@ export class EnrolledCourseDetailsPage implements OnInit {
this.courseCardData.batch = this.updatedCourseCardData.batch;
this.courseCardData.batchId = this.updatedCourseCardData.batchId;
}

}

// check if the course is already enrolled
Expand All @@ -1278,7 +1277,6 @@ export class EnrolledCourseDetailsPage implements OnInit {
if (this.courseCardData.progress && this.courseCardData.progress > 0) {
this.showResumeBtn = true;
}
this.setContentDetails(this.identifier);
this.headerService.showHeaderWithBackButton();
// If courseCardData does not have a batch id then it is not a enrolled course
this.subscribeSdkEvent();
Expand Down Expand Up @@ -1496,11 +1494,7 @@ export class EnrolledCourseDetailsPage implements OnInit {

if (this.commonUtilService.networkInfo.isNetworkAvailable) {
await loader.present();
this.courseService.getCourseBatches(courseBatchesRequest).toPromise()
.then((data: Batch[]) => {
this.zone.run(async () => {
await loader.dismiss();
this.batches = data;
if (this.batches.length) {
if (this.batches.length === 1) {
this.enrollIntoBatch(this.batches[0]);
Expand All @@ -1523,11 +1517,6 @@ export class EnrolledCourseDetailsPage implements OnInit {
} else {
this.commonUtilService.showToast('NO_BATCHES_AVAILABLE');
}
});
})
.catch(async (error: any) => {
await loader.dismiss();
});
} else {
this.commonUtilService.showToast('ERROR_NO_INTERNET_MESSAGE');
}
Expand Down
10 changes: 5 additions & 5 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@
"CONTRIBUTORS": "Contributor(s)",
"COMPLETE_TRAINING_TO_EARN_CERTIFICATE":"Complete Training by {{%s}} to earn a certificate",
"COPYRIGHT": "Copyright",
"COURSES_BNAV": "Courses",
"COURSES_BNAV": "Trainings",
"COURSES_IN_PROGRESS": "My Courses",
"COURSES_LW": "Courses",
"COURSE_ENROLLED": "Courses enroled in",
"COURSE_ENROLLED": "You have joined the training",
"COURSE_NOT_AVAILABLE": "This course is no longer active",
"COURSE_PROGRESS_COMPLETED": "Completed: {{%s}} %",
"COURSE_COMPLETED_LABEL":"completed",
"COURSE_UNENROLLED": "Unenroled from course successfully",
"COURSE_UNENROLLED": "You have been removed from the Training",
"COURSE_WILL_BE_AVAILABLE": "Course will be available from {{%s}}",
"CREATE_GROUP": "Create Group",
"CREATE_NEW_GROUP": "Create New Group",
Expand Down Expand Up @@ -181,7 +181,7 @@
"EMPTY_SEARCH_RESULTS": "No results found",
"ENDORSE": "Endorse",
"ENJOYED_THIS_CONTENT": "Enjoyed this content?",
"ENROLL": "Enrol",
"ENROLL": "Join",
"ENROLLMENT_LAST_DATE": "Last date for enrolment: ",
"ENROLL_COURSE": "ENROL IN COURSE",
"ENTER_GROUP_NAME": "Enter group name",
Expand Down Expand Up @@ -528,7 +528,7 @@
"TRY_BEFORE_RATING": "Please try the content before rating it.",
"TRY_DIFF_QR": "Try a different QR code?",
"UNABLE_TO_FETCH_CONTENT": "Unable to fetch retired content",
"UNENROLL_CONFIRMATION_MESSAGE": "Unenrol from course?",
"UNENROLL_CONFIRMATION_MESSAGE": "Would you like to leave the training?",
"UNENROLL_FROM_COURSE": "Leave Training",
"UNIT_COMING_SOON": "Coming soon!",
"UNKNOWN_QR": "You seem to have scanned an invalid QR code",
Expand Down