Skip to content

Commit

Permalink
Merge pull request #569 from correctexam/563-migrate-to-the-last-angu…
Browse files Browse the repository at this point in the history
…lar-182-to-support-isolated-module

563 migrate to the last angular 182 to support isolated module
  • Loading branch information
barais authored Oct 23, 2024
2 parents 6eedc71 + 9ac050c commit 8681033
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ <h5 class="card-title">{{ comment.text }}</h5>
</ng-template>
<ng-template pTemplate="content">
<p-selectButton
[required]="true"
[allowEmpty]="false"
[unselectable]="false"
[options]="relativeOptions"
[(ngModel)]="comment.relative"
optionLabel="label"
optionValue="value"
(onChange)="updateRelative($event, comment)"
></p-selectButton>
<label class="form-label" jhiTranslate="scanexam.hybridcommentGrade" for="field_defaultpoint">Point par défault</label>
<p-knob
Expand Down Expand Up @@ -259,11 +263,15 @@ <h5 class="card-title" jhiTranslate="scanexam.newcomment">Nouveau commentaire</h
>

<p-selectButton
[required]="true"
[allowEmpty]="false"
[unselectable]="false"
*ngIf="_q && _q?.gradeType === 'HYBRID'"
[options]="relativeOptions"
[(ngModel)]="relative"
optionLabel="label"
optionValue="value"
(onChange)="updateNewRelative($event)"
></p-selectButton>
<label
class="form-label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,32 @@ export class CreateCommentsComponent implements OnInit {
}
}

updateNewRelative($event: any): void {
if ($event.value) {
this.grade = (this.grade! * 100) / this.question!.point!;
} else {
this.grade = (this.question!.point! * this.grade!) / 100;
}
}

updateRelative($event: any, l: IHybridGradedComment): void {
if ($event.value) {
l.grade = (l.grade! * 100) / this.question!.point!;
} else {
l.grade = (this.question!.point! * l.grade!) / 100;
}

this.hybridGradedCommentService.update(l).subscribe(() => {
this.updateHybridGradedComment.emit(l);
const coms = this.currentHybridGradedComment4Question?.filter(c => c.id === l.id!);
if (coms !== undefined && coms.length > 0) {
coms[0].grade = l.grade;
coms[0].step = l.step;
coms[0].relative = l.relative;
}
});
}

updateComment($event: any, l: IGradedComment | ITextComment | IHybridGradedComment, graded: boolean, hybrid: boolean): any {
if (graded && !hybrid) {
if ((l as IGradedComment).grade === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ <h2>
[tooltipPosition]="'top'"
id="knobquest{{ note.key }}"
>
<h6>Question {{ this.q_notees[note.key].numero }}</h6>
<h6>Question {{ note.key + 1 }}</h6>
<p-knob
[ngModel]="this.knobsCourants.get(note.key)"
[max]="getBaremes(this.q_notees)[note.key]"
[max]="baremes.get(note.key)"
[size]="70"
[readonly]="true"
valueColor="{{ COLOR_KNOBS }}"
Expand Down Expand Up @@ -226,8 +226,8 @@ <h6>Question {{ this.q_notees[note.key].numero }}</h6>
<div *ngIf="etudiantSelec !== null && etudiantSelec !== undefined" class="progbar">
<div class="avancement-progbar" [ngStyle]="{ width: ((this.getNoteSelect() * 100) / this.getBaremeExam()).toString() + '%' }">
<div class="progbar-grade">
<b>{{ this.getNoteSelect() }}</b
>/{{ this.getBaremeExam() }}
<b>{{ getNoteSelect() }}</b
>/{{ getBaremeExam() }}
</div>
</div>
</div>
Expand Down
34 changes: 25 additions & 9 deletions src/main/webapp/app/scanexam/statsexam/statsexam.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class StatsExamComponent implements OnInit {
];
protected mobileSortChoice: ISortMobile = this.mobileSortChoices[2];
protected knobsCourants: Map<number, string> = new Map();
protected baremes: Map<number, number> = new Map();
protected COLOR_KNOBS = BLEU_AERO_TIEDE;
protected idQuestionSelected = 0;
protected questionSelectionnee = false;
Expand Down Expand Up @@ -426,12 +427,17 @@ export class StatsExamComponent implements OnInit {
}

/** @return The notation for each question */
public getBaremes(stats: ReadonlyArray<QuestionNotee>): number[] {
return stats.map(s => s.bareme);
public updateBaremes(stats: ReadonlyArray<QuestionNotee>): Map<number, number> {
const notes: Map<number, number> = new Map();
for (const t of stats) {
notes.set(t.numero - 1, t.bareme);
}
this.baremes = notes;
return this.baremes; // stats.map(s => s.bareme);
}

public getBaremeExam(): number {
return this.sum(this.getBaremes(this.q_notees));
return this.sum([...this.baremes.values()]);
}

private getNotes(etudiant: StudentRes): Map<number, number> {
Expand All @@ -450,12 +456,19 @@ export class StatsExamComponent implements OnInit {
}

public getNoteSelect(): number {
return this.sum(Array.from(this.getNotesSelect().values()));
return +this.sum(Array.from(this.getNotesSelect().values())).toFixed(2);
}

/** @return Average mark for all the questions (ordered) */
private getMoyennesQuestions(): number[] {
return this.q_notees.map(ns => this.mean(ns.notesAssociees));
private getMoyennesQuestions(): Map<number, number> {
const notes: Map<number, number> = new Map();

for (const key of this.q_notees) {
notes.set(key.numero - 1, this.s2f('' + this.mean(key.notesAssociees)));
}
return notes;

// return this.q_notees.map(ns => this.mean(ns.notesAssociees));
}

private updateKnobs(): void {
Expand Down Expand Up @@ -555,12 +568,13 @@ export class StatsExamComponent implements OnInit {

/** Initialises radar data to display **/
private initGlobalRadarData(stats: ReadonlyArray<QuestionNotee>, pourcents = false): IRadar {
this.updateBaremes(stats);
const labels = stats.map(e => e.label);
const datasets = [this.radarMoy(), this.radarMed(), this.radarMaxNote(), this.radarMinNote()];

if (pourcents) {
datasets.forEach((ds, indice) => {
datasets[indice].data = this.normaliseNotes(ds.data, this.getBaremes(stats));
datasets[indice].data = this.normaliseNotes(ds.data, [...this.baremes.values()]);
});
}
const vue = pourcents ? this.translateService.instant('scanexam.pourcents') : this.translateService.instant('scanexam.brut');
Expand All @@ -572,15 +586,17 @@ export class StatsExamComponent implements OnInit {
const datasets = [this.radarStudent(etudiant), this.radarMoy(), this.radarMed()];
if (pourcents) {
datasets.forEach((ds, indice) => {
datasets[indice].data = this.normaliseNotes(ds.data, this.getBaremes(this.q_notees));
datasets[indice].data = this.normaliseNotes(ds.data, [...this.baremes.values()]);
});
}
const vue = pourcents ? this.translateService.instant('scanexam.pourcents') : this.translateService.instant('scanexam.brut');
return { labels, datasets, vue };
}

private radarMoy(): IRadarDataset {
return this.basicDataset(this.translateService.instant('scanexam.average'), BLEU_AERO, TRANSPARENT, this.getMoyennesQuestions());
return this.basicDataset(this.translateService.instant('scanexam.avergetMoyeage'), BLEU_AERO, TRANSPARENT, [
...this.getMoyennesQuestions().values(),
]);
}

private radarMed(): IRadarDataset {
Expand Down

0 comments on commit 8681033

Please sign in to comment.