Skip to content

Commit

Permalink
Implementing progress bar in my course-details (#1266)
Browse files Browse the repository at this point in the history
* added progress bar to my courses

* fix counter issue

* add a progress bars to every category in the course details

* making adjustments to the progress bar

* add some changes

* remove the bar from my-courses and display the progress  in the course-detail only + add an alert in points-dialog

* remove unecessary event

* fix lint

* add new progress design concept

* calculate progress stats

* fix bar

* add calculations and badget

* adjust design

* fix passed condition

* add info for no requirements

* Remove unused code

* Update course detail component and translations

---------

Co-authored-by: Medienkunzt <[email protected]>
Co-authored-by: Johannes Kunz <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2024
1 parent 0d395cc commit 3b0b51f
Show file tree
Hide file tree
Showing 9 changed files with 541 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class TaskPointsDialogComponent implements OnInit {
private snackbar: MatSnackBar,
public dialogRef: MatDialogRef<TaskPointsDialogComponent>
) {}

beforeUnloadTimeout: any;
tasks: Task[];
allRequirements: Requirement[];
selected: Requirement;
Expand Down Expand Up @@ -128,6 +128,18 @@ export class TaskPointsDialogComponent implements OnInit {
}

save() {
/*window.addEventListener('beforeunload', handleBeforeUnload);
function handleBeforeUnload(e) {
e.preventDefault();
e.returnValue = '';
}
clearTimeout(this.beforeUnloadTimeout); // Clear any existing timeout
this.beforeUnloadTimeout = setTimeout(() => {
window.removeEventListener('beforeunload', handleBeforeUnload);
}, 1500);*/
let checked = true;
const newReq = [];
const oldReq = [];
Expand Down
1 change: 1 addition & 0 deletions modules/fbs-core/web/src/app/model/UserTaskResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export interface UserTaskResult {
maxPoints: number;
passed: boolean;
submission: boolean;
isPrivate: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,107 @@
</button>
</div>

<!-- Johannes approach for progres bar -->
<mat-card class="progress-card">
<mat-card-content>
<div class="title">
<h2>{{ "course.progress-title" | i18nextEager }}</h2>
<!-- if coursePassed show badge -->
<mat-chip-list *ngIf="(requirements | async).length === 0">
<mat-chip class="badget-chip">
<mat-icon
matTooltip="{{ 'course.progress-no-conditions' | i18nextEager }}"
>
question_mark
</mat-icon>
</mat-chip>
</mat-chip-list>
<mat-chip-list *ngIf="(requirements | async).length > 0">
<mat-chip class="badget-chip">
<mat-icon
[ngClass]="{
'badget-icon-passed': coursePassed,
'badget-icon-gray': !coursePassed
}"
[matTooltip]="
coursePassed
? ('course.progress-complete' | i18nextEager)
: ('course.progress-no-complete' | i18nextEager)
"
>
military_tech
</mat-icon>
</mat-chip>

<mat-chip class="badget-chip">
<mat-icon
[ngClass]="{
'badget-icon-passed': calculatedBonusPoints > 0,
'badget-icon-gray': calculatedBonusPoints <= 0
}"
[matTooltip]="
calculatedBonusPoints > 0
? ('course.progress-bonus-pre' | i18nextEager) +
calculatedBonusPoints +
('course.progress-bonus-seq' | i18nextEager)
: ('course.progress-no-bonus' | i18nextEager)
"
>
stars
</mat-icon>
</mat-chip>
</mat-chip-list>
</div>

<!-- little widgets -->
<!-- Bearbeitete Pflichtaufgaben / Bearbeitetet Bonusaufgaben / Bearbeitete Übungsaufgaben -->
<div class="progress-widget">
<div class="progress-widget-item">
<mat-icon>priority_high</mat-icon>
<span>{{ courseProgressBar.mandatory.done }}</span>
<span>/</span>
<span>{{ courseProgressBar.mandatory.sum }}</span>
</div>
<div class="progress-widget-item">
<mat-icon>star</mat-icon>
&nbsp;
<span>{{ courseProgressBar.optional.done }}</span>
<span>/</span>
<span>{{ courseProgressBar.optional.sum }}</span>
<!-- <span>&nbsp;&nbsp;Bonuspunkte: {{ calculatedBonusPoints }}</span> -->
</div>
<div class="progress-widget-item">
<mat-icon>school</mat-icon>
&nbsp;&nbsp;
<span>{{ courseProgressBar.practice.done }}</span>
<span>/</span>
<span>{{ courseProgressBar.practice.sum }}</span>
</div>
</div>

<section class="progress-section">
<mat-progress-bar
mode="buffer"
[value]="courseProgressBar.mandatory.done_percent"
[bufferValue]="courseProgressBar.mandatory.failed_percent"
>
</mat-progress-bar>
<mat-progress-bar
mode="buffer"
[value]="courseProgressBar.optional.done_percent"
[bufferValue]="courseProgressBar.optional.failed_percent"
>
</mat-progress-bar>
<mat-progress-bar
mode="buffer"
[value]="courseProgressBar.practice.done_percent"
[bufferValue]="courseProgressBar.practice.failed_percent"
>
</mat-progress-bar>
</section>
</mat-card-content>
</mat-card>

<!-- <markdown ngPreserveWhitespaces [data]="courseDetail?.course_description"></markdown>-->
<div class="task-list">
<div *ngFor="let task of tasks">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
@import "src/colors";

/*.task-container {
cursor: pointer;
margin-top: 12px;
display: flex;
justify-content: space-between;
.meta {
> * {
margin-left: 8px;
}
> .tiny {
font-size: small;
}
.state {
text-align: center;
line-height: 30px;
}
}
span {
display: flex;
align-items: center;
}
}
.task-container:hover {
background: #d4dadd;
}*/

.container {
display: block;
margin-top: 16px;
Expand Down Expand Up @@ -127,3 +100,163 @@
justify-content: center;
}
}

.mat-progress-bar {
height: 15px;
border-radius: 5px;
}

:host ::ng-deep .mat-progress-bar-fill::after {
background-color: $green;
}

::ng-deep .mat-progress-bar-buffer {
background: $red;
}

// ::ng-deep .mat-progress-bar {
// margin: auto;
// border-radius: 2px;
// height: 20px;
// }

// ::ng-deep .mat-progress-bar-background {
// background: #1e457c;
// animation: none !important;
// fill: #1e457c;
// }

//animation none and color gray
::ng-deep .mat-progress-bar-background {
background: #cccccc;
animation: none !important;
fill: #cccccc;
}

.flex-container {
padding: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
}
.legend-color {
height: 1rem;
width: 1rem;
position: absolute;
}
.legend-text {
position: relative;
left: 1rem;
padding-left: 0.5rem;
height: 1.25rem;
line-height: 1.25rem;
font-size: 0.9rem;
}
.flex-container > div {
background-color: #f1f1f1;
margin: 10px;
padding: 20px;
font-size: 30px;
}
.progress-value {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 16px;
font-weight: bold;
}
.example-section {
display: flex;
align-content: center;
align-items: center;
height: 60px;
bottom: 15px;
right: 10px;
}
#num {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: rgb(255, 255, 255);
font-size: 32px;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);

padding: 8px 16px;
}

.progress-card {
.title {
margin-top: -15px;
display: flex;
align-items: center;
justify-content: space-between;

.badget-icon-passed {
width: auto;
height: auto;
font-size: 30px;
color: orange;
}

.badget-icon-gray {
color: lightslategrey;
}

.badget-chip {
display: flex;
align-items: center;
justify-content: center;
background-color: ghostwhite;
}

.mat-standard-chip {
height: auto !important;
}
}

.progress-widget {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
height: 100%;

margin-bottom: 10px;

.progress-widget-item {
margin: 0px 10px;
display: flex;
align-items: center;
justify-content: center;

// first item color
&:nth-child(1) {
mat-icon {
color: $red;
}
}
// second item color
&:nth-child(2) {
mat-icon {
color: $orange;
}
}
// third item color
&:nth-child(3) {
mat-icon {
color: $green;
}
}
}
}

.progress-section {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 20px;

// round progress bar
}
}
Loading

0 comments on commit 3b0b51f

Please sign in to comment.