Skip to content

Commit

Permalink
Display achieved percentage in table
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-glombik committed Sep 17, 2023
1 parent 2ee4c99 commit 139cb49
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ArtemisServerDateService } from 'app/shared/server-date.service';
import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service';
import { GradeType } from 'app/entities/grading-scale.model';
import { faAward, faClipboard } from '@fortawesome/free-solid-svg-icons';
import { StudentExamWithGradeDTO } from 'app/exam/exam-scores/exam-score-dtos.model';
import { ExerciseResult, StudentExamWithGradeDTO } from 'app/exam/exam-scores/exam-score-dtos.model';
import { BonusStrategy } from 'app/entities/bonus.model';

@Component({
Expand Down Expand Up @@ -82,6 +82,7 @@ export class ExamPointsSummaryComponent implements OnInit {
}

getAchievedPointsSum() {
console.log('studentExamWithGrade', this.studentExamWithGrade);
return this.studentExamWithGrade?.studentResult.overallPointsAchieved ?? 0;
}

Expand All @@ -92,7 +93,7 @@ export class ExamPointsSummaryComponent implements OnInit {
return this.studentExamWithGrade?.maxPoints ?? 0;
}

getAchievedPointsPercentageSum() {
getAchievedScoreSum() {
return 10;
}

Expand All @@ -114,6 +115,24 @@ export class ExamPointsSummaryComponent implements OnInit {
return this.getMaxNormalPointsSum() + this.getMaxBonusPointsSum();
}

getExerciseResultByExerciseId(exerciseId?: number): ExerciseResult | undefined {
if (exerciseId === undefined) {
return undefined;
}

const exerciseGroupResultMapping = this.studentExamWithGrade?.studentResult?.exerciseGroupIdToExerciseResult;
let exerciseResult = undefined;

for (const key in exerciseGroupResultMapping) {
if (key in exerciseGroupResultMapping && exerciseGroupResultMapping[key].exerciseId === exerciseId) {
exerciseResult = exerciseGroupResultMapping[key];
break;
}
}

return exerciseResult;
}

private hasAtLeastOneResult(): boolean {
const exercises = this.studentExamWithGrade?.studentExam?.exercises;
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ <h3>
}}</span>
</td>
<td>
<!-- TODO adjust calculation-->
<span *ngIf="exercise.maxPoints != undefined">{{
exercise.includedInOverallScore === IncludedInOverallScore.INCLUDED_AS_BONUS ? 0 : exercise.maxPoints
}}</span>
<span *ngIf="exercise.maxPoints != undefined"> {{ getExerciseResultByExerciseId(exercise.id)?.achievedScore }}% </span>
</td>
<td *ngIf="getMaxBonusPointsSum() != 0">
<span *ngIf="exercise.bonusPoints != undefined">{{
Expand All @@ -61,7 +58,12 @@ <h3>
{{ getMaxNormalPointsSum() }}
</th>
<th>
{{ getAchievedPointsPercentageSum() }}
<span *ngIf="studentExamWithGrade.studentResult.overallScoreAchieved !== undefined; else totalScoreNotDefinedPlaceholder">
{{ studentExamWithGrade.studentResult.overallScoreAchieved }}%
</span>
<ng-template #totalScoreNotDefinedPlaceholder>
<span>-</span>
</ng-template>
</th>
<th *ngIf="getMaxBonusPointsSum() != 0">
{{ getMaxBonusPointsSum() }}
Expand Down

0 comments on commit 139cb49

Please sign in to comment.