Skip to content

Commit

Permalink
Merge pull request #570 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

add support to negative score and bonus in hybrid mode
  • Loading branch information
barais authored Oct 23, 2024
2 parents 8681033 + d2b7c79 commit 35f907d
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 13 deletions.
6 changes: 6 additions & 0 deletions src/main/webapp/app/entities/question/question.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export interface IQuestion {
examId?: number;
zoneDTO?: Zone;
randomHorizontalCorrection?: boolean;
canExceedTheMax?: boolean;
canBeNegative?: boolean;
mustBeIgnoreInGlobalScale?: boolean;
}

export interface IQuestionMark {
Expand All @@ -45,6 +48,9 @@ export class Question implements IQuestion {
public examId?: number,
public zoneDTO?: Zone,
public randomHorizontalCorrection?: boolean,
public canExceedTheMax?: boolean,
public canBeNegative?: boolean,
public mustBeIgnoreInGlobalScale?: boolean,
) {}
}
export function getQuestionIdentifier(question: IQuestion): number | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ export class EventHandlerService {
q.point = pref.point;
q.step = pref.step;
q.gradeType = pref.gradeType;
q.canBeNegative = false;
q.canExceedTheMax = false;
q.mustBeIgnoreInGlobalScale = false;
this.questionService.create(q).subscribe(() => {
this.selectedTool = DrawingTools.SELECT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ export class FabricCanvasComponent implements OnInit, OnDestroy {
q.point = pref.point;
q.step = pref.step;
q.gradeType = pref.gradeType;
q.canBeNegative = false;
q.canExceedTheMax = false;
q.mustBeIgnoreInGlobalScale = false;

if (subq.t === 'qcm') {
q.typeId = 3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,51 @@
>
</p-checkbox>
</div>

<div *ngIf="editForm.get(['typeId'])!.value !== qcmid && editForm.get(['gradeType'])!.value === hybrid" class="row">
<label class="form-label" jhiTranslate="scanexam.canexceedthemax" for="field_canexceedthemax"></label>

<p-inputSwitch
[disabled]="disableCanExceed"
formControlName="canExceedTheMax"
[pTooltip]="'scanexam.canexceedthemaxtooltip' | translate"
[tooltipPosition]="'right'"
(onChange)="contentChange()"
/>
</div>
<div *ngIf="editForm.get(['typeId'])!.value !== qcmid && editForm.get(['gradeType'])!.value === hybrid" class="row">
<label class="form-label" jhiTranslate="scanexam.canbenegative" for="field_canbenegative"></label>

<p-inputSwitch
[disabled]="disableMin0"
formControlName="canBeNegative"
[pTooltip]="'scanexam.canbenegativetooltip' | translate"
[tooltipPosition]="'right'"
(onChange)="contentChange()"
/>
</div>

<div
*ngIf="
editForm.get(['typeId'])!.value !== qcmid &&
editForm.get(['gradeType'])!.value === hybrid &&
(editForm.get(['canBeNegative'])!.value || editForm.get(['canExceedTheMax'])!.value)
"
class="row"
>
<label class="form-label" jhiTranslate="scanexam.mustbeignoreinglobalscale" for="field_mustbeignoreinglobalscale"></label>

<p-inputSwitch
[disabled]="disableIgnoreBareme"
formControlName="mustBeIgnoreInGlobalScale"
[pTooltip]="'scanexam.mustbeignoreinglobalscaletooltip' | translate"
[tooltipPosition]="'right'"
(onChange)="contentChange()"
/>
</div>
</div>
</form>

<div *ngIf="disableGradeType" class="row">
<label class="form-label" jhiTranslate="scanexam.forceedit" for="field_forceedit"></label>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ describe('QuestionpropertiesviewComponent', () => {
typeId: 2,
defaultpoint: undefined,
randomHorizontalCorrection: false,
canBeNegative: false,
canExceedTheMax: false,
mustBeIgnoreInGlobalScale: false,
}));
mockPrefService.savePref4Question = jest.fn();

Expand Down Expand Up @@ -145,6 +148,9 @@ describe('QuestionpropertiesviewComponent', () => {
zoneId: 100,
defaultpoint: undefined,
randomHorizontalCorrection: false,
canBeNegative: false,
canExceedTheMax: false,
mustBeIgnoreInGlobalScale: false,
};

otherQ = {
Expand All @@ -160,6 +166,9 @@ describe('QuestionpropertiesviewComponent', () => {
zoneId: 1002,
defaultpoint: undefined,
randomHorizontalCorrection: false,
canBeNegative: false,
canExceedTheMax: false,
mustBeIgnoreInGlobalScale: false,
};

jest.spyOn(component.editForm, 'patchValue');
Expand All @@ -184,6 +193,9 @@ describe('QuestionpropertiesviewComponent', () => {
gradeType: selectedQ.gradeType,
typeId: selectedQ.typeId,
randomHorizontalCorrection: false,
canBeNegative: false,
canExceedTheMax: false,
mustBeIgnoreInGlobalScale: false,
},
{ emitEvent: false },
);
Expand Down Expand Up @@ -252,6 +264,9 @@ describe('QuestionpropertiesviewComponent', () => {
zoneId: 1001,
typeId: 2,
randomHorizontalCorrection: false,
canBeNegative: false,
canExceedTheMax: false,
mustBeIgnoreInGlobalScale: false,
},
{
id: 12,
Expand All @@ -265,6 +280,9 @@ describe('QuestionpropertiesviewComponent', () => {
zoneId: 1002,
typeId: 2,
randomHorizontalCorrection: false,
canBeNegative: false,
canExceedTheMax: false,
mustBeIgnoreInGlobalScale: false,
},
];

Expand All @@ -289,6 +307,9 @@ describe('QuestionpropertiesviewComponent', () => {
gradeType: qs[0].gradeType,
typeId: qs[0].typeId,
randomHorizontalCorrection: false,
canBeNegative: false,
canExceedTheMax: false,
mustBeIgnoreInGlobalScale: false,
},
{ emitEvent: false },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
public disableNumero: boolean | null = false;
public disablePoint: boolean | null = false;
public disableStep: boolean | null = false;
public disableCanExceed: boolean = false;
public disableMin0: boolean = false;
public disableIgnoreBareme: boolean = false;

public forceEdit: boolean = false;

public isSaving = false;
Expand Down Expand Up @@ -202,6 +206,9 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
examId: [],
defaultpoint: [pref.defaultpoint],
randomHorizontalCorrection: [false],
canBeNegative: [false],
canExceedTheMax: [false],
mustBeIgnoreInGlobalScale: [false],
});

this.questionTypeService.query().subscribe((res: HttpResponse<IQuestionType[]>) => {
Expand All @@ -220,6 +227,10 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
this.disableNumero = null;
this.disablePoint = null;
this.disableStep = null;
this.disableCanExceed = false;
this.disableMin0 = false;
this.disableIgnoreBareme = false;

this.forceEdit = false;

if (selectedQ === undefined) {
Expand Down Expand Up @@ -261,10 +272,17 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
if (count.body! > 0 && !this.forceEdit) {
this.disableGradeType = true;
this.disableNumero = true;

if (question.typeId !== this.qcmid) {
this.disableStep = true;

if (question.gradeType === GradeType.DIRECT) {
this.disablePoint = true;
} else if (question.gradeType === GradeType.HYBRID) {
this.disablePoint = true;
this.disableCanExceed = true;
this.disableMin0 = true;
this.disableIgnoreBareme = true;
} else {
this.disablePoint = true;
}
Expand All @@ -276,6 +294,9 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
this.disableNumero = false;
this.disableStep = false;
this.disablePoint = false;
this.disableCanExceed = false;
this.disableMin0 = false;
this.disableIgnoreBareme = false;
}
});
}
Expand All @@ -291,6 +312,9 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
typeId: question.typeId,
defaultpoint: question.defaultpoint,
randomHorizontalCorrection: question.randomHorizontalCorrection,
canExceedTheMax: question.canExceedTheMax,
canBeNegative: question.canBeNegative,
mustBeIgnoreInGlobalScale: question.mustBeIgnoreInGlobalScale,
},
{
emitEvent: false,
Expand All @@ -313,6 +337,9 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
q.typeId = this.editForm.get(['typeId'])!.value;
q.defaultpoint = this.editForm.get(['defaultpoint'])?.value;
q.randomHorizontalCorrection = this.editForm.get(['randomHorizontalCorrection'])?.value;
q.canExceedTheMax = this.editForm.get(['canExceedTheMax'])?.value;
q.canBeNegative = this.editForm.get(['canBeNegative'])?.value;
q.mustBeIgnoreInGlobalScale = this.editForm.get(['mustBeIgnoreInGlobalScale'])?.value;
});

// Saving the current preferences
Expand Down Expand Up @@ -406,6 +433,10 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
this.questions[0].libelle = this.questions[1].libelle;
this.questions[0].defaultpoint = this.questions[1].defaultpoint!;
this.questions[0].randomHorizontalCorrection = this.questions[1].randomHorizontalCorrection!;
this.questions[0].canBeNegative = this.questions[1].canBeNegative!;
this.questions[0].canExceedTheMax = this.questions[1].canExceedTheMax!;
this.questions[0].mustBeIgnoreInGlobalScale = this.questions[1].mustBeIgnoreInGlobalScale!;

return firstValueFrom(this.questionService.update(this.questions[0]));
}
return Promise.resolve(new HttpResponse<IQuestion>());
Expand Down Expand Up @@ -496,6 +527,9 @@ export class QuestionpropertiesviewComponent implements OnInit, OnDestroy {
this.disableNumero = false;
this.disablePoint = false;
this.disableStep = false;
this.disableCanExceed = false;
this.disableMin0 = false;
this.disableIgnoreBareme = false;
} else {
this.updateForm();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ <h3 jhiTranslate="scanexam.resumebareme">Résumé du sujet</h3>
<div *ngIf="isFollowingQuestion(i, q); then follow; else nofollow"></div>
<ng-template #follow>( <span jhiTranslate="scanexam.suite"></span> )</ng-template>
<ng-template #nofollow
>- {{ q.point }} <span jhiTranslate="scanexam.pointincr">points, incr. de </span>{{ 1 / (q.step ?? 1) }}</ng-template
>- {{ q.point }} <span jhiTranslate="scanexam.pointincr">points, incr. de </span>{{ 1 / (q.step ?? 1) }}
<span *ngIf="q.mustBeIgnoreInGlobalScale"> (ignore)</span></ng-template
>
</div>
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class SummaryTemplateComponent {
public sumPoints(): number {
return this.getSortedQuestions()
.filter((q, i) => !this.isFollowingQuestion(i, q))
.filter(q => !q.mustBeIgnoreInGlobalScale)
.map(q => q.point ?? 0)
.reduce((a, b) => a + b, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1452,9 +1452,9 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
});
currentNote = (currentQ.point! * pourcentage) / 100.0 + absoluteNote2Add;
if (currentNote > currentQ.point!) {
if (currentNote > currentQ.point! && !currentQ.canExceedTheMax) {
currentNote = currentQ.point!;
} else if (currentNote < 0) {
} else if (currentNote < 0 && !currentQ.canBeNegative) {
currentNote = 0;
}
if (resp) {
Expand Down
25 changes: 17 additions & 8 deletions src/main/webapp/app/scanexam/statsexam/statsexam.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,10 @@ export class StatsExamComponent implements OnInit {
}

public getBaremeExam(): number {
return this.sum([...this.baremes.values()]);
const numeros = [...new Set(this.infosQuestions.map(e => e.numero))];
const qs: IQuestion[] = [];
numeros.forEach(n => qs.push(this.infosQuestions.find(ind => n === ind.numero)!));
return this.sum(qs.filter(q => !q.mustBeIgnoreInGlobalScale).map(q => q.point ?? 0));
}

private getNotes(etudiant: StudentRes): Map<number, number> {
Expand Down Expand Up @@ -594,7 +597,7 @@ export class StatsExamComponent implements OnInit {
}

private radarMoy(): IRadarDataset {
return this.basicDataset(this.translateService.instant('scanexam.avergetMoyeage'), BLEU_AERO, TRANSPARENT, [
return this.basicDataset(this.translateService.instant('scanexam.average'), BLEU_AERO, TRANSPARENT, [
...this.getMoyennesQuestions().values(),
]);
}
Expand Down Expand Up @@ -626,12 +629,18 @@ export class StatsExamComponent implements OnInit {
}

private radarStudent(etudiant: StudentRes): IRadarDataset {
return this.basicDataset(
this.translateService.instant('scanexam.notes'),
VIOLET,
VIOLET_LEGER,
Array.from(this.getNotes(etudiant).values()),
);
console.error(this.questionNumeros, this.getNotes(etudiant));
const notes: number[] = [];
const notesetu = this.getNotes(etudiant);
this.questionNumeros.forEach(n => {
if (notesetu.has(n - 1)) {
notes.push(notesetu.get(n - 1)!);
} else {
notes.push(0);
}
});

return this.basicDataset(this.translateService.instant('scanexam.notes'), VIOLET, VIOLET_LEGER, notes);
}

private basicDataset(label: string, couleurForte: string, couleurLegere: string, data: number[]): IRadarDataset {
Expand Down
8 changes: 7 additions & 1 deletion src/main/webapp/i18n/en/scanexammodule.json
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@
"gotonextstudent": "In vertical correction, switches to the first question for the next exam sheet (student)",
"gotopreviousquestion": "In horizontal correction, switches to the last exam sheet for the previous question",
"gotopreviousstudent": "In vertical correction, switches to the last question for the previous exam sheet (student)",
"startcorrect": "Let's go"
"startcorrect": "Let's go",
"canbenegative": "Permits a negative mark for this question",
"canbenegativetooltip": "If all the comments selected lead to a score of less than zero, this question may reduce the overall exam score for this exam sheet.",
"mustbeignoreinglobalscale": "Ignore this question in the global scale",
"mustbeignoreinglobalscaletooltip": "This allows the points awarded for this question to be ignored for the overall scale. For example, if you create a question to manage absences from class, this 3-point question can be used to deduct up to three points from the copy, but the grade remains 20, for example.)",
"canexceedthemaxtooltip": "If all the comments selected lead to a mark higher than the maximum score for this question, this question may increase the overall exam score for this exam sheet.",
"canexceedthemax": "Permits a mark above the scale for this question"
}
}
8 changes: 7 additions & 1 deletion src/main/webapp/i18n/fr/scanexammodule.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@
"gotonextstudent": "En correction verticale, permet de basculer à la première question pour la prochaine copie (étudiant)",
"gotopreviousquestion": "En correction horizontale, permet de basculer à la dernière copie pour la question précédente",
"gotopreviousstudent": "En correction verticale, permet de basculer à la dernière question pour la copie précédente (étudiant)",
"startcorrect": "Débuter"
"startcorrect": "Débuter",
"canbenegative": "Autorise une note négative pour cette question",
"canbenegativetooltip": "Si l'ensemble des commentaires sélectionnés amène à une note inférieure à zéro, cette question peut baisser la note globale de l'examen pour cette copie",
"mustbeignoreinglobalscale": "Ignorer cette question dans le barème global",
"mustbeignoreinglobalscaletooltip": "Cela permet d'ignorer le nombre de points de cette question pour le barème global. Par exemple, on crée une question permettant de gérer les absences en cours, cette question sur 3 points permet de retirer jusqu'à trois points à la copie, mais le barème reste sur 20 par exemple)",
"canexceedthemaxtooltip": "Si l'ensemble des commentaires sélectionnés amène à une note supérieure à la note maximale de cette question, cette question peut augmenter la note globale de l'examen pour cette copie",
"canexceedthemax": "Autorise une note supérieure au barème de cette question"
}
}

0 comments on commit 35f907d

Please sign in to comment.