Skip to content

Commit

Permalink
Task #58265: start-again enhancement for course & program
Browse files Browse the repository at this point in the history
  • Loading branch information
christyfernandes committed May 24, 2022
1 parent c8c83ed commit 1435c3f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ <h2 class="mat-subheading-2 flex-1 min-w-0 margin-remove-bottom" i18n>Reason</h2
</ul>
</div>
<!-- <div class="flex"> -->
<div>
<div *ngIf="widgetData?.content?.batch?.endDate">
<p>Deadline - {{widgetData.content.batch?.endDate | date: "d MMM yyyy"}}</p>
</div>
<div class="tags" *ngIf="widgetData.content.keywords && widgetData.content.keywords.length > 0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export class ContentStripMultipleComponent extends WidgetBaseComponent

// To sort in descending order of the enrolled date
if (content && content.length) {
contentNew = content.sort((a: any, b: any) => {
contentNew = (content || []).sort((a: any, b: any) => {
const dateA: any = new Date(a.enrolledDate || 0)
const dateB: any = new Date(b.enrolledDate || 0)
return dateB - dateA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ export class AppTocBannerComponent implements OnInit, OnChanges, OnDestroy {
this.getLearningUrls()
}
if (this.resumeData && this.content) {
const resumeDataV2 = this.getResumeDataFromList()
let resumeDataV2: any
if (this.content.completionPercentage === 100) {
resumeDataV2 = this.getResumeDataFromList('start')
} else {
resumeDataV2 = this.getResumeDataFromList()
}
if (!resumeDataV2.mimeType) {
resumeDataV2.mimeType = this.getMimeType(this.content, resumeDataV2.identifier)
}
Expand Down Expand Up @@ -370,12 +375,19 @@ export class AppTocBannerComponent implements OnInit, OnChanges, OnDestroy {
}
}

private getResumeDataFromList() {
const lastItem = this.resumeData && this.resumeData.pop()
private getResumeDataFromList(type?: string) {
if (!type) {
console.log('getResumeDataFromList: type', type)
const lastItem = this.resumeData && this.resumeData.pop()
return {
identifier: lastItem.contentId,
mimeType: lastItem.progressdetails && lastItem.progressdetails.mimeType,
}
}
const firstItem = this.resumeData && this.resumeData.length && this.resumeData[0]
return {
identifier: lastItem.contentId,
mimeType: lastItem.progressdetails && lastItem.progressdetails.mimeType,

identifier: firstItem.contentId,
mimeType: firstItem.progressdetails && firstItem.progressdetails.mimeType,
}
}
private modifySensibleContentRating() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,13 @@
[routerLink]="resumeData ? resumeDataLink?.url : firstResourceLink?.url"
[queryParams]="resumeData ? generateQuery('RESUME') : generateQuery('START')"
class="mat-button mat-button-base resumeButton custom-button width-1-1 text-white">
<ng-container *ngIf="!forPreview || isInIFrame; else authView" i18n>
{{resumeData? "Resume" : "Start"}}
<ng-container *ngIf="content.completionPercentage < 100">
<ng-container *ngIf="!forPreview || isInIFrame; else authView" i18n>
{{resumeData? "Resume" : "Start"}}
</ng-container>
</ng-container>
<ng-container *ngIf="content.completionPercentage === 100">
{{resumeData? "Start again" : "Start"}}
</ng-container>
</a>
<a *ngIf="isPostAssessment && showTakeAssessment?.post_assessment" [routerLink]="firstResourceLink?.url"
Expand Down Expand Up @@ -172,8 +177,16 @@
[routerLink]="resumeData ? resumeDataLink?.url : firstResourceLink?.url"
[queryParams]="resumeData ? generateQuery('RESUME') : generateQuery('START')"
class="mat-button mat-button-base resumeButton custom-button width-1-1 text-white">
<ng-container *ngIf="!forPreview || isInIFrame; else authView" i18n>
<!-- <ng-container *ngIf="!forPreview || isInIFrame; else authView" i18n>
{{resumeData? "Resume" : "Start"}}
</ng-container> -->
<ng-container *ngIf="content.completionPercentage < 100">
<ng-container *ngIf="!forPreview || isInIFrame; else authView" i18n>
{{resumeData? "Resume" : "Start"}}
</ng-container>
</ng-container>
<ng-container *ngIf="content.completionPercentage === 100">
{{resumeData? "Start again" : "Start"}}
</ng-container>
</a>
<a *ngIf="isPostAssessment && showTakeAssessment?.post_assessment" [routerLink]="firstResourceLink?.url"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class MandatoryCourseComponent implements OnInit, OnDestroy, OnChanges {
// }

// To sort in descending order of the enrolled date
contentNew = content.sort((a: any, b: any) => {
contentNew = (content || []).sort((a: any, b: any) => {
const dateA: any = new Date(a.enrolledDate || 0)
const dateB: any = new Date(b.enrolledDate || 0)
return dateB - dateA
Expand Down

0 comments on commit 1435c3f

Please sign in to comment.