diff --git a/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.html b/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.html
index 5fe8c6ba..dac0142e 100644
--- a/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.html
+++ b/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.html
@@ -33,7 +33,7 @@
-
+
Layout options
-
+
{{ comment.text }}
@@ -661,7 +666,7 @@ {{ comment.text }}
@@ -685,14 +690,14 @@ {{ comment.text }}
Ajouter
Retirer
@@ -794,7 +799,12 @@ {{ comment.text }}
-
+
{{ comment.text }}
@@ -813,7 +823,7 @@ {{ comment.text }}
@@ -833,7 +843,11 @@ {{ comment.text }}
/>
-
+
Note associée à ce commentaire :
@@ -857,14 +871,14 @@
{{ comment.text }}
Ajouter
Retirer
@@ -880,7 +894,7 @@ {{ comment.text }}
{{ comment.text }} ({{ comment.shortcut }})
-
+
{{ comment.text }}
-
+
{{ comment.text }}
@@ -991,7 +1010,7 @@ {{ comment.text }}
@@ -1010,7 +1029,11 @@ {{ comment.text }}
-
+
0"> +
{{ comment.grade }} pt %
@@ -1058,7 +1081,11 @@ {{ comment.text }}
-
+
Nombre de pas:
{{ comment.step }}
@@ -1139,7 +1166,8 @@ {{ comment.text }}
*ngIf="
(!minimizeComment ||
((currentGradedComment4Question === undefined || currentGradedComment4Question?.length === 0) &&
- (currentTextComment4Question === undefined || currentTextComment4Question?.length === 0))) &&
+ (currentTextComment4Question === undefined || currentTextComment4Question?.length === 0) &&
+ (currentHybridGradedComment4Question === undefined || currentHybridGradedComment4Question?.length === 0))) &&
currentQuestion &&
currentQuestion?.typeAlgoName !== 'QCM'
"
diff --git a/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.ts b/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.ts
index e70e2466..c0a49cb2 100644
--- a/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.ts
+++ b/src/main/webapp/app/scanexam/corrigequestion/corrigequestion.component.ts
@@ -17,6 +17,10 @@ import {
HostListener,
ViewChild,
NgZone,
+ Signal,
+ signal,
+ WritableSignal,
+ effect,
} from '@angular/core';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { CourseService } from 'app/entities/course/service/course.service';
@@ -66,6 +70,8 @@ import { Inplace } from 'primeng/inplace';
import { IExamSheet } from 'app/entities/exam-sheet/exam-sheet.model';
import { OrderList } from 'primeng/orderlist';
import { Title } from '@angular/platform-browser';
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+import { PromisePool } from '@supercharge/promise-pool';
enum ScalePolicy {
FitWidth = 1,
@@ -73,6 +79,15 @@ enum ScalePolicy {
Original = 3,
}
+interface CommentAction {
+ f:
+ | ((comment: ITextComment, self: CorrigequestionComponent) => Promise)
+ | ((comment: IGradedComment, self: CorrigequestionComponent) => Promise)
+ | ((comment: IHybridGradedComment, self: CorrigequestionComponent) => Promise);
+ c: ITextComment | IGradedComment | IHybridGradedComment;
+ self: CorrigequestionComponent;
+}
+
@Component({
selector: 'jhi-corrigequestion',
templateUrl: './corrigequestion.component.html',
@@ -136,9 +151,9 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
noalign = false;
factor = 1;
scale = 1;
- currentTextComment4Question: ITextComment[] | undefined;
- currentGradedComment4Question: IGradedComment[] | undefined;
- currentHybridGradedComment4Question: IHybridGradedComment[] | undefined;
+ currentTextComment4Question: Signal[] | undefined;
+ currentGradedComment4Question: Signal[] | undefined;
+ currentHybridGradedComment4Question: Signal[] | undefined;
windowWidth = 0;
currentZoneCorrectionHandler: Map = new Map(); // | undefined;
@@ -156,7 +171,8 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
@ViewChild(KeyboardShortcutsComponent)
private keyboard: KeyboardShortcutsComponent | undefined;
@ViewChild('input') input: ElementRef | undefined;
- testdisableAndEnableKeyBoardShortCut = false;
+ testdisableAndEnableKeyBoardShortCut: WritableSignal = signal(false);
+ testdisableAndEnableKeyBoardShortCutSignal = false;
activeIndex = 1;
responsiveOptions2: any[] = [
{
@@ -191,6 +207,8 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
step = 1;
answer2HybridGradedCommentMap: Map = new Map();
+ queriesPool: Array = [];
+
constructor(
public examService: ExamService,
public courseService: CourseService,
@@ -216,7 +234,11 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
private keyboardShortcutService: KeyboardShortcutService,
private applicationConfigService: ApplicationConfigService,
private titleService: Title,
- ) {}
+ ) {
+ effect(() => {
+ this.testdisableAndEnableKeyBoardShortCutSignal = this.testdisableAndEnableKeyBoardShortCut();
+ });
+ }
ngOnInit(): void {
this.windowWidth = window.innerWidth;
@@ -230,7 +252,7 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
async manageParam(params: ParamMap) {
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.init = true;
// let forceRefreshStudent = false;
@@ -309,29 +331,47 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
if (questions![0].gradeType === GradeType.DIRECT && questions![0].typeAlgoName !== 'QCM') {
const com = await firstValueFrom(this.textCommentService.query({ questionId: questions![0].id }));
- this.currentTextComment4Question = com.body!;
+ /* this.currentTextComment4Question = com.body!;
this.currentTextComment4Question.forEach(com1 => {
this.active.set(com1.id!, false);
+ });*/
+ this.currentTextComment4Question = [];
+ com.body!.forEach(comment => {
+ this.currentTextComment4Question?.push(signal(comment));
+ });
+ this.currentTextComment4Question.forEach(com1 => {
+ this.active.set(com1().id!, signal(false));
});
} else if (questions![0].gradeType === GradeType.HYBRID && questions![0].typeAlgoName !== 'QCM') {
const com = await firstValueFrom(this.hybridGradedCommentService.query({ questionId: questions![0].id }));
- this.currentHybridGradedComment4Question = com.body!;
+ /* this.currentHybridGradedComment4Question = com.body!;
this.currentHybridGradedComment4Question.forEach(com1 => {
this.active.set(com1.id!, false);
+ });*/
+ this.currentHybridGradedComment4Question = [];
+ com.body!.forEach(comment => {
+ this.currentHybridGradedComment4Question?.push(signal(comment));
+ });
+
+ this.currentHybridGradedComment4Question.forEach(com1 => {
+ this.active.set(com1().id!, signal(false));
});
} else {
const com = await firstValueFrom(this.gradedCommentService.query({ questionId: questions![0].id }));
- this.currentGradedComment4Question = com.body!;
+ this.currentGradedComment4Question = [];
+ com.body!.forEach(comment => {
+ this.currentGradedComment4Question?.push(signal(comment));
+ });
+ // this.currentGradedComment4Question = com.body!;
this.currentGradedComment4Question.forEach(com1 => {
- this.active.set(com1.id!, false);
+ this.active.set(com1().id!, signal(false));
});
}
}
}
-
- this.currentGradedComment4Question?.forEach(com2 => ((com2 as any).checked = false));
- this.currentTextComment4Question?.forEach(com2 => ((com2 as any).checked = false));
- this.currentHybridGradedComment4Question?.forEach(com2 => ((com2 as any).checked = false));
+ this.currentGradedComment4Question?.forEach(com2 => ((com2() as any).checked = false));
+ this.currentTextComment4Question?.forEach(com2 => ((com2() as any).checked = false));
+ this.currentHybridGradedComment4Question?.forEach(com2 => ((com2() as any).checked = false));
// this.currentHybridGradedComment4Question?.forEach(com2 => ());
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -361,29 +401,29 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
await this.computeNote(false, this.resp!, this.currentQuestion!);
if (questions![0].gradeType === GradeType.DIRECT && questions![0].typeAlgoName !== 'QCM') {
this.resp.textcomments!.forEach(com1 => {
- const elt = this.currentTextComment4Question?.find(com2 => com2.id === com1.id);
+ const elt = this.currentTextComment4Question?.find(com2 => com2().id === com1.id);
if (elt !== undefined) {
- (elt as any).checked = true;
+ (elt as any)().checked = true;
} else {
- (elt as any).checked = false;
+ (elt as any)().checked = false;
}
});
} else if (questions![0].gradeType === GradeType.HYBRID && questions![0].typeAlgoName !== 'QCM') {
this.answer2HybridGradedCommentMap.forEach((com1v, com1k) => {
- const elt = this.currentHybridGradedComment4Question?.find(com2 => com2.id === com1k);
+ const elt = this.currentHybridGradedComment4Question?.find(com2 => com2().id === com1k);
if (elt !== undefined && com1v > 0) {
- (elt as any).checked = true;
+ (elt as any)().checked = true;
} else {
- (elt as any).checked = false;
+ (elt as any)().checked = false;
}
});
} else {
this.resp.gradedcomments!.forEach(com1 => {
- const elt = this.currentGradedComment4Question?.find(com2 => com2.id === com1.id);
+ const elt = this.currentGradedComment4Question?.find(com2 => com2().id === com1.id);
if (elt !== undefined) {
- (elt as any).checked = true;
+ (elt as any)().checked = true;
} else {
- (elt as any).checked = false;
+ (elt as any)().checked = false;
}
});
}
@@ -418,7 +458,7 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
const c = this.currentStudent + 1;
this.router.navigateByUrl('/answer/' + this.examId! + '/' + (this.questionindex! + 1) + '/' + c);
}
- this.testdisableAndEnableKeyBoardShortCut = true;
+ this.testdisableAndEnableKeyBoardShortCut.set(true);
}
}
@@ -507,20 +547,20 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
}
- active: Map = new Map();
+ active: Map> = new Map();
populateDefaultShortCut(): void {
const toRemove: number[] = [];
const comments: (IGradedComment | ITextComment | IHybridGradedComment)[] = [];
if (this.currentGradedComment4Question && this.currentGradedComment4Question.length > 0) {
- comments.push(...this.currentGradedComment4Question);
+ comments.push(...this.currentGradedComment4Question.map(e => e()));
}
if (this.currentTextComment4Question && this.currentTextComment4Question.length > 0) {
- comments.push(...this.currentTextComment4Question);
+ comments.push(...this.currentTextComment4Question.map(e => e()));
}
if (this.currentHybridGradedComment4Question && this.currentHybridGradedComment4Question.length > 0) {
- comments.push(...this.currentHybridGradedComment4Question);
+ comments.push(...this.currentHybridGradedComment4Question.map(e => e()));
}
if (this.keyboardShortcutService.getShortCutPreference().shortcuts.has(this.examId + '_' + this.questionindex)) {
@@ -554,22 +594,29 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
- editComment(comment: any) {
- this.active.set(comment.id, true);
+ editComment(l: any) {
+ if (this.active.has(l.id!)) {
+ this.active.get(l.id!)!.set(true);
+ } else {
+ this.active.set(l.id!, signal(true));
+ }
this.minimizeComment = false;
}
resetAllShortCut() {
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.shortCut4Comment = false;
this.keyboardShortcutService.clearToDefault();
this.populateDefaultShortCut();
- setTimeout(() => (this.testdisableAndEnableKeyBoardShortCut = true), 30);
+ // this.testdisableAndEnableKeyBoardShortCut.set(true)
+
+ setTimeout(() => this.testdisableAndEnableKeyBoardShortCut.set(true), 30);
}
saveShortCut() {
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
+ // this.testdisableAndEnableKeyBoardShortCut = false;
this.shortCut4Comment = false;
const shorts = this.keyboardShortcutService.getShortCutPreference();
if (shorts.shortcuts.has(this.examId! + '_' + this.questionindex)) {
@@ -622,18 +669,23 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
]);
}
this.keyboardShortcutService.save(shorts);
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.populateDefaultShortCut();
this.commentShortcut = null;
this.currentKeyBoardShorcut = '';
+ // this.testdisableAndEnableKeyBoardShortCut.set(true);
+
setTimeout(() => {
- this.testdisableAndEnableKeyBoardShortCut = true;
+ this.testdisableAndEnableKeyBoardShortCut.set(true);
}, 30);
}
cleanShortCut() {
this.commentShortcut = null;
this.currentKeyBoardShorcut = '';
- this.testdisableAndEnableKeyBoardShortCut = true;
+ this.testdisableAndEnableKeyBoardShortCut.set(true);
+
+ // this.testdisableAndEnableKeyBoardShortCut = true;
}
reloadImageGrowFactor(event: any): void {
@@ -785,9 +837,9 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
if (this.currentGradedComment4Question === undefined) {
this.currentGradedComment4Question = [];
}
- validToCreate = validExp!.filter(c => !this.currentGradedComment4Question?.map(v => v.text).includes(c));
+ validToCreate = validExp!.filter(c => !this.currentGradedComment4Question?.map(v => v().text).includes(c));
invalidToCreate = invalidExp!.filter(
- c => !this.currentGradedComment4Question?.map(v => v.text).includes(c) && !validExp!.includes(c!) && c !== '',
+ c => !this.currentGradedComment4Question?.map(v => v().text).includes(c) && !validExp!.includes(c!) && c !== '',
);
invalidToCreate = [...new Set(invalidToCreate)];
@@ -800,7 +852,7 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
studentResponses: [],
};
const c1 = await this.createGradedComment(comment);
- this.currentGradedComment4Question!.push(c1);
+ this.currentGradedComment4Question!.push(signal(c1));
}
for (const gcv of invalidToCreate) {
const comment: IGradedComment = {
@@ -814,7 +866,7 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
studentResponses: [],
};
const c1 = await this.createGradedComment(comment);
- this.currentGradedComment4Question!.push(c1);
+ this.currentGradedComment4Question!.push(signal(c1));
}
// UpdateStudentResponse
for (const solution of solutions!) {
@@ -830,16 +882,16 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
);
resp.gradedcomments?.forEach(gc => {
- (gc as any).checked = false;
+ (gc as any)().checked = false;
});
resp!.gradedcomments = [];
// Check if gradedcomment with good parameters exists
- const gcs = this.currentGradedComment4Question?.filter(c => c.text === e.solution);
+ const gcs = this.currentGradedComment4Question?.filter(c => c().text === e.solution);
// Comment already exists
if (gcs !== undefined && gcs.length > 0) {
- resp.gradedcomments.push(gcs[0]);
- await this.updateStudentResponsAndComputeNote4QCM(resp, e.numero!, gcs[0]);
+ resp.gradedcomments.push(gcs[0]());
+ await this.updateStudentResponsAndComputeNote4QCM(resp, e.numero!, gcs[0]());
// gcs[0].studentResponses?.push(resp!);
}
}
@@ -849,10 +901,12 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
return new Promise((resolve, reject) => {
this.gradedCommentService.create(comment).subscribe(e1 => {
if (e1.body !== null) {
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.populateDefaultShortCut();
+ // this.testdisableAndEnableKeyBoardShortCut.set(true);
+
setTimeout(() => {
- (this.testdisableAndEnableKeyBoardShortCut = true), 300;
+ this.testdisableAndEnableKeyBoardShortCut.set(true), 300;
});
resolve(e1.body!);
} else {
@@ -866,7 +920,7 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
return new Promise(resolve => {
this.updateResponseRequest(resp).subscribe(resp1 => {
if (this.currentStudent === numero) {
- (comment as any).checked = true;
+ (comment as any)().checked = true;
}
this.computeNote(true, resp1.body!, this.currentQuestion!).then(value => {
resolve(value);
@@ -966,60 +1020,46 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
}
- async ajouterTComment(comment: ITextComment) {
- if (!this.blocked) {
- this.blocked = true;
- if (!this.resp!.id) {
- const ret = await this.updateResponseRequest(this.resp!).toPromise();
- this.resp = ret!.body!;
- }
-
- this.resp?.textcomments?.push(comment);
- this.updateResponseRequest(this.resp!).subscribe(resp1 => {
- this.resp = resp1.body!;
- (comment as any).checked = true;
- this.blocked = false;
- });
+ private async ajouterTComment(comment: ITextComment, self: CorrigequestionComponent) {
+ if (!self.resp!.id) {
+ const ret = await firstValueFrom(self.updateResponseRequest(self.resp!));
+ self.resp = ret!.body!;
}
+
+ self.resp?.textcomments?.push(comment);
+ const resp1 = await firstValueFrom(self.updateResponseRequest(self.resp!));
+ self.resp = resp1.body!;
}
- async ajouterGComment(comment: IGradedComment) {
- if (!this.blocked) {
- this.blocked = true;
- if (!this.resp!.id) {
- const ret = await this.updateResponseRequest(this.resp!).toPromise();
- this.resp = ret!.body!;
- }
- this.resp?.gradedcomments?.push(comment);
- this.updateResponseRequest(this.resp!).subscribe(resp1 => {
- this.resp = resp1.body!;
- (comment as any).checked = true;
- this.computeNote(true, this.resp!, this.currentQuestion!).then(() => (this.blocked = false));
- });
+
+ private async retirerTComment(comment: ITextComment, self: CorrigequestionComponent) {
+ if (!self.resp!.id) {
+ const ret = await firstValueFrom(self.updateResponseRequest(self.resp!));
+ self.resp = ret!.body!;
}
+ self.resp!.textcomments = self.resp?.textcomments!.filter(e => e.id !== comment.id);
+ const resp1 = await firstValueFrom(self.updateResponseRequest(self.resp!));
+ self.resp = resp1.body!;
+ (comment as any).checked = false;
}
- async incrementHComment(comment: IHybridGradedComment) {
- if (!this.blocked) {
- this.blocked = true;
- await this.incrementHCommentInternal(comment);
- this.blocked = false;
- }
+ incrementHComment(comment: IHybridGradedComment) {
+ this.fillorcreateQueryPool(this.incrementHCommentInternal, comment);
}
- async incrementHCommentInternal(comment: IHybridGradedComment) {
- if (!this.resp!.id) {
- const ret = await firstValueFrom(this.updateResponseRequest(this.resp!));
- this.resp = ret!.body!;
+ private async incrementHCommentInternal(comment: IHybridGradedComment, self: CorrigequestionComponent): Promise {
+ if (!self.resp!.id) {
+ const ret = await firstValueFrom(self.updateResponseRequest(self.resp!));
+ self.resp = ret!.body!;
}
- const ah = await firstValueFrom(this.answer2HybridGradedCommentService.updateAnswer2Hybrid(this.resp?.id, comment.id));
+ const ah = await firstValueFrom(self.answer2HybridGradedCommentService.updateAnswer2Hybrid(self.resp?.id, comment.id));
if (ah.body?.hybridcommentsId) {
// this.answer2HybridGradedCommentMap.set(ah.body.hybridcommentsId!, ah.body.stepValue!);
if (comment.step !== undefined && comment.step !== null && comment.step > 2) {
setTimeout(() => {
- this.answer2HybridGradedCommentMap.set(ah.body!.hybridcommentsId!, ah.body!.stepValue!);
+ self.answer2HybridGradedCommentMap.set(ah.body!.hybridcommentsId!, ah.body!.stepValue!);
}, 3);
}
- this.answer2HybridGradedCommentMap.set(ah.body!.hybridcommentsId!, ah.body!.stepValue!);
+ self.answer2HybridGradedCommentMap.set(ah.body!.hybridcommentsId!, ah.body!.stepValue!);
if (ah.body.stepValue !== null && ah.body.stepValue !== undefined && ah.body.stepValue > 0) {
(comment as any).checked = true;
@@ -1027,90 +1067,135 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
(comment as any).checked = false;
}
- await this.computeNote(true, this.resp!, this.currentQuestion!);
+ await self.computeNote(true, self.resp!, self.currentQuestion!);
}
}
- async retirerTComment(comment: ITextComment) {
- if (!this.blocked) {
- this.blocked = true;
- if (!this.resp!.id) {
- const ret = await this.updateResponseRequest(this.resp!).toPromise();
- this.resp = ret!.body!;
- }
+ toggleTCommentById(commentId: any) {
+ const res = this.currentTextComment4Question?.filter(c => c().id === commentId);
+ if (res !== undefined && res.length > 0) {
+ this.toggleTComment(res[0]());
+ }
+ }
- this.resp!.textcomments = this.resp?.textcomments!.filter(e => e.id !== comment.id);
- this.blocked = true;
- this.updateResponseRequest(this.resp!).subscribe(resp1 => {
- this.resp = resp1.body!;
+ isResolved = true;
+ queryPoolPromise: any;
+
+ fillorcreateQueryPool(
+ f:
+ | ((comment: ITextComment, self: CorrigequestionComponent) => Promise)
+ | ((comment: IGradedComment, self: CorrigequestionComponent) => Promise)
+ | ((comment: IHybridGradedComment, self: CorrigequestionComponent) => Promise),
+ c: ITextComment | IGradedComment | IHybridGradedComment,
+ ) {
+ if (!this.isResolved) {
+ this.queriesPool.push({ f, c, self: this });
+ } else {
+ this.isResolved = false;
+ this.queryPoolPromise = this.createQueryPool(f, c);
+ this.queryPoolPromise.then(() => {
this.blocked = false;
- (comment as any).checked = false;
+ this.queriesPool = [];
+ this.isResolved = true;
});
}
}
- toggleTCommentById(commentId: any) {
- if (!this.blocked) {
- const res = this.currentTextComment4Question?.filter(c => c.id === commentId);
- if (res !== undefined && res.length > 0) {
- this.toggleTComment(res[0]);
- }
- }
+ async createQueryPool(
+ f:
+ | ((comment: ITextComment, self: CorrigequestionComponent) => Promise)
+ | ((comment: IGradedComment, self: CorrigequestionComponent) => Promise)
+ | ((comment: IHybridGradedComment, self: CorrigequestionComponent) => Promise),
+ c: ITextComment | IGradedComment | IHybridGradedComment,
+ ): Promise {
+ this.isResolved = false;
+ this.queriesPool = [];
+ this.blocked = true;
+
+ this.queriesPool.push({
+ f,
+ c,
+ self: this,
+ });
+ await PromisePool.withConcurrency(1)
+ .for(this.queriesPool)
+ .process(async prom => {
+ await prom.f(prom.c as any, prom.self);
+ /* await new Promise((resolve)=> {
+ setTimeout(()=> resolve(undefined),100)
+ })*/
+ });
+ return true;
}
+
toggleGCommentById(commentId: any) {
- if (!this.blocked) {
- const res = this.currentGradedComment4Question?.filter(c => c.id === commentId);
- if (res !== undefined && res.length > 0) {
- this.toggleGComment(res[0]);
- }
+ const res = this.currentGradedComment4Question?.filter(c => c().id === commentId);
+ if (res !== undefined && res.length > 0) {
+ this.toggleGComment(res[0]());
}
}
toggleHCommentById(commentId: any) {
- if (!this.blocked) {
- const res = this.currentHybridGradedComment4Question?.filter(c => c.id === commentId);
- if (res !== undefined && res.length > 0) {
- this.incrementHComment(res[0]);
- }
+ const res = this.currentHybridGradedComment4Question?.filter(c => c().id === commentId);
+ if (res !== undefined && res.length > 0) {
+ this.incrementHComment(res[0]());
}
}
toggleGComment(comment: IGradedComment) {
- if (!this.blocked) {
- if (!this.checked(comment)) {
- this.ajouterGComment(comment);
- } else {
- this.retirerGComment(comment);
- }
+ if (!this.checked(comment)) {
+ (comment as any).checked = true;
+ setTimeout(() => {
+ (comment as any).checked = true;
+ }, 30);
+ this.fillorcreateQueryPool(this.ajouterGComment, comment);
+ } else {
+ (comment as any).checked = false;
+ setTimeout(() => {
+ // this.active.set(comment.id!, false);
+ (comment as any).checked = false;
+ }, 30);
+ this.fillorcreateQueryPool(this.retirerGComment, comment);
}
}
+
toggleTComment(comment: ITextComment) {
- if (!this.blocked) {
- if (!this.checked(comment)) {
- this.ajouterTComment(comment);
- } else {
- this.retirerTComment(comment);
- }
+ if (!this.checked(comment)) {
+ (comment as any).checked = true;
+ this.fillorcreateQueryPool(this.ajouterTComment, comment);
+ } else {
+ (comment as any).checked = false;
+ this.fillorcreateQueryPool(this.retirerTComment, comment);
}
}
- async retirerGComment(comment: IGradedComment) {
- if (!this.blocked) {
- this.blocked = true;
- if (!this.resp!.id) {
- const ret = await this.updateResponseRequest(this.resp!).toPromise();
- this.resp = ret!.body!;
- }
- this.resp!.gradedcomments = this.resp?.gradedcomments!.filter(e => e.id !== comment.id);
- this.blocked = true;
- this.updateResponseRequest(this.resp!).subscribe(resp1 => {
- this.resp = resp1.body!;
+ private async ajouterGComment(comment: IGradedComment, self: CorrigequestionComponent) {
+ if (!self.resp!.id) {
+ const ret = await firstValueFrom(self.updateResponseRequest(self.resp!));
+ self.resp = ret!.body!;
+ }
- (comment as any).checked = false;
- this.computeNote(true, this.resp!, this.currentQuestion!).then(() => (this.blocked = false));
- });
+ self.resp?.gradedcomments?.push(comment);
+
+ const resp1 = await firstValueFrom(self.updateResponseRequest(self.resp!)); // .subscribe(resp1 => {
+ self.resp = resp1.body!;
+ await self.computeNote(true, self.resp!, self.currentQuestion!);
+ // });
+ }
+
+ private async retirerGComment(comment: IGradedComment, self: CorrigequestionComponent) {
+ self.blocked = true;
+ if (!self.resp!.id) {
+ const ret = await firstValueFrom(self.updateResponseRequest(self.resp!));
+ self.resp = ret!.body!;
}
+ self.resp!.gradedcomments = self.resp?.gradedcomments!.filter(e => e.id !== comment.id);
+ self.blocked = true;
+ const resp1 = await firstValueFrom(self.updateResponseRequest(self.resp!)); // .subscribe(resp1 => {
+ self.resp = resp1.body!;
+ await self.computeNote(true, self.resp!, self.currentQuestion!);
}
+
updateNote4updateQuestion(update: boolean, resp: IStudentResponse, currentQ: IQuestion[]): Promise {
this.updateQuestion(currentQ);
return this.computeNote(update, resp, currentQ[0]);
@@ -1169,13 +1254,13 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
let absoluteNote2Add = 0;
let pourcentage = currentQ.defaultpoint ? currentQ.defaultpoint : 0;
this.currentHybridGradedComment4Question?.forEach(g => {
- if (this.answer2HybridGradedCommentMap.has(g.id)) {
- const stepValue = this.answer2HybridGradedCommentMap.get(g.id);
+ if (this.answer2HybridGradedCommentMap.has(g().id)) {
+ const stepValue = this.answer2HybridGradedCommentMap.get(g().id);
if (stepValue! > 0) {
- if (g.relative) {
- pourcentage = pourcentage + (stepValue! / g.step!) * g.grade!;
+ if (g().relative) {
+ pourcentage = pourcentage + (stepValue! / g().step!) * g().grade!;
} else {
- absoluteNote2Add = absoluteNote2Add + (stepValue! / g.step!) * g.grade!;
+ absoluteNote2Add = absoluteNote2Add + (stepValue! / g().step!) * g().grade!;
}
}
}
@@ -1270,11 +1355,12 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
this.updateResponseRequest(this.resp!).subscribe(resp1 => {
this.resp = resp1.body!;
(currentComment as any).checked = true;
- this.currentTextComment4Question?.push(currentComment);
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.currentTextComment4Question?.push(signal(currentComment));
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.populateDefaultShortCut();
+ // this.testdisableAndEnableKeyBoardShortCut.set(true);
setTimeout(() => {
- (this.testdisableAndEnableKeyBoardShortCut = true), 300;
+ this.testdisableAndEnableKeyBoardShortCut.set(true), 300;
});
this.titreCommentaire = '';
@@ -1302,11 +1388,13 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
this.resp = resp1.body!;
(currentComment as any).checked = true;
- this.currentGradedComment4Question?.push(currentComment);
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.currentGradedComment4Question?.push(signal(currentComment));
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.populateDefaultShortCut();
+ // this.testdisableAndEnableKeyBoardShortCut.set(true);
+
setTimeout(() => {
- (this.testdisableAndEnableKeyBoardShortCut = true), 300;
+ this.testdisableAndEnableKeyBoardShortCut.set(true), 300;
});
this.computeNote(false, this.resp!, this.currentQuestion!);
@@ -1330,13 +1418,17 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
this.blocked = true;
this.hybridGradedCommentService.create(t).subscribe(e => {
const currentComment = e.body!;
- this.currentHybridGradedComment4Question?.push(currentComment);
+ this.currentHybridGradedComment4Question?.push(signal(currentComment));
+
+ this.incrementHCommentInternal(currentComment, this).then(() => {
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
- this.incrementHCommentInternal(currentComment).then(() => {
this.populateDefaultShortCut();
+ // this.testdisableAndEnableKeyBoardShortCut.set(true);
+
setTimeout(() => {
- this.testdisableAndEnableKeyBoardShortCut = true;
- }, 30);
+ this.testdisableAndEnableKeyBoardShortCut.set(true);
+ }, 300);
this.titreCommentaire = '';
this.descCommentaire = '';
this.noteCommentaire = 0;
@@ -1360,7 +1452,11 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
}
- previousStudent() {
+ async previousStudent() {
+ if (this.queryPoolPromise) {
+ await this.queryPoolPromise;
+ }
+
if (!this.blocked) {
this.cleanCanvassCache();
const c = this.currentStudent;
@@ -1375,7 +1471,10 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
}
- nextStudent() {
+ async nextStudent() {
+ if (this.queryPoolPromise) {
+ await this.queryPoolPromise;
+ }
if (!this.blocked) {
this.cleanCanvassCache();
@@ -1389,7 +1488,11 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
}
}
- previousQuestion(): void {
+ async previousQuestion(): Promise {
+ if (this.queryPoolPromise) {
+ await this.queryPoolPromise;
+ }
+
if (!this.blocked) {
this.cleanCanvassCache();
@@ -1403,7 +1506,11 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
}
- nextQuestion(): void {
+ async nextQuestion(): Promise {
+ if (this.queryPoolPromise) {
+ await this.queryPoolPromise;
+ }
+
if (!this.blocked) {
this.cleanCanvassCache();
const c = this.currentStudent + 1;
@@ -1795,7 +1902,11 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
updateComment($event: any, l: IGradedComment | ITextComment | IHybridGradedComment, graded: boolean, hybrid: boolean): any {
if (l.id) {
setTimeout(() => {
- this.active.set(l.id!, false);
+ if (this.active.has(l.id!)) {
+ this.active.get(l.id!)!.set(false);
+ } else {
+ this.active.set(l.id!, signal(false));
+ }
}, 30);
}
@@ -1821,11 +1932,11 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
(l as IHybridGradedComment).relative = true;
}
this.hybridGradedCommentService.update(l as IHybridGradedComment).subscribe(() => {
- const coms = this.currentHybridGradedComment4Question?.filter(c => c.id === l.id!);
+ const coms = this.currentHybridGradedComment4Question?.filter(c => c().id === l.id!);
if (coms !== undefined && coms.length > 0) {
- coms[0].grade = (l as any).grade;
- coms[0].step = (l as any).step;
- coms[0].relative = (l as any).relative;
+ coms[0]().grade = (l as any).grade;
+ coms[0]().step = (l as any).step;
+ coms[0]().relative = (l as any).relative;
this.computeNote(true, this.resp!, this.currentQuestion!);
}
});
@@ -1836,7 +1947,11 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
closeEditComment(l: IGradedComment | ITextComment | IHybridGradedComment) {
if (l.id) {
- this.active.set(l.id, false);
+ if (this.active.has(l.id!)) {
+ this.active.get(l.id!)!.set(false);
+ } else {
+ this.active.set(l.id!, signal(false));
+ }
}
}
@@ -1902,8 +2017,8 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
this.confirmationService.confirm({
message: this.translateService.instant('scanexam.removetextcommentconfirmation', { c1 }),
accept: () => {
- this.retirerTComment(comment).then(() => {
- this.currentTextComment4Question = this.currentTextComment4Question!.filter(e => e.id !== comment.id);
+ this.retirerTComment(comment, this).then(() => {
+ this.currentTextComment4Question = this.currentTextComment4Question!.filter(e => e().id !== comment.id);
this.textCommentService.delete(comment!.id!).subscribe(() => {
const m = this.preferenceService.getCommentSort4Question(this.examId + '_' + this.currentQuestion!.id!);
if (m.has(comment!.id!)) {
@@ -1931,8 +2046,8 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
this.confirmationService.confirm({
message: this.translateService.instant('scanexam.removegradedcommentconfirmation', { c1 }),
accept: () => {
- this.retirerGComment(comment).then(() => {
- this.currentGradedComment4Question = this.currentGradedComment4Question!.filter(e => e.id !== comment.id);
+ this.retirerGComment(comment, this).then(() => {
+ this.currentGradedComment4Question = this.currentGradedComment4Question!.filter(e => e().id !== comment.id);
this.gradedCommentService.delete(comment!.id!).subscribe(() => {
const m = this.preferenceService.getCommentSort4Question(this.examId + '_' + this.currentQuestion!.id!);
if (m.has(comment!.id!)) {
@@ -1967,7 +2082,7 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
this.confirmationService.confirm({
message: this.translateService.instant('scanexam.removehybridcommentconfirmation', { c1 }),
accept: () => {
- this.currentHybridGradedComment4Question = this.currentHybridGradedComment4Question!.filter(e => e.id !== comment.id);
+ this.currentHybridGradedComment4Question = this.currentHybridGradedComment4Question!.filter(e => e().id !== comment.id);
setTimeout(() => {
this.answer2HybridGradedCommentMap.delete(comment.id);
this.computeNote(true, this.resp!, this.currentQuestion!);
@@ -2285,73 +2400,77 @@ export class CorrigequestionComponent implements OnInit, AfterViewInit {
}
addTextComment($event: ITextComment): void {
- this.currentTextComment4Question?.push($event);
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.currentTextComment4Question?.push(signal($event));
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
+
this.populateDefaultShortCut();
+ // this.testdisableAndEnableKeyBoardShortCut.set(false);
+
setTimeout(() => {
- this.testdisableAndEnableKeyBoardShortCut = true;
+ this.testdisableAndEnableKeyBoardShortCut.set(true);
}, 30);
}
updateTextComment($event: ITextComment): void {
- const c1 = this.currentTextComment4Question?.find(c => (c.id = $event.id));
+ const c1 = this.currentTextComment4Question?.find(c => (c().id = $event.id));
if (c1) {
- if (c1.description !== $event.description) {
- c1.description = $event.description;
+ if (c1().description !== $event.description) {
+ c1().description = $event.description;
}
- if (c1.text !== $event.text) {
- c1.text = $event.text;
+ if (c1().text !== $event.text) {
+ c1().text = $event.text;
}
}
}
addGradedComment($event: IGradedComment): void {
- this.currentGradedComment4Question?.push($event);
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.currentGradedComment4Question?.push(signal($event));
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.populateDefaultShortCut();
- setTimeout(() => (this.testdisableAndEnableKeyBoardShortCut = true), 30);
+ // this.testdisableAndEnableKeyBoardShortCut.set(true);
+ setTimeout(() => this.testdisableAndEnableKeyBoardShortCut.set(true), 30);
}
updateGradedComment($event: IGradedComment): void {
- const c1 = this.currentGradedComment4Question?.find(c => (c.id = $event.id));
+ const c1 = this.currentGradedComment4Question?.find(c => (c().id = $event.id));
if (c1) {
- if (c1.description !== $event.description) {
- c1.description = $event.description;
+ if (c1().description !== $event.description) {
+ c1().description = $event.description;
}
- if (c1.text !== $event.text) {
- c1.text = $event.text;
+ if (c1().text !== $event.text) {
+ c1().text = $event.text;
}
- if (c1.grade !== $event.grade) {
- c1.grade = $event.grade;
+ if (c1().grade !== $event.grade) {
+ c1().grade = $event.grade;
}
}
}
addHybridComment($event: IHybridGradedComment): void {
- this.currentHybridGradedComment4Question?.push($event);
- this.testdisableAndEnableKeyBoardShortCut = false;
+ this.currentHybridGradedComment4Question?.push(signal($event));
+ this.testdisableAndEnableKeyBoardShortCut.set(false);
this.populateDefaultShortCut();
- setTimeout(() => (this.testdisableAndEnableKeyBoardShortCut = true), 30);
+ setTimeout(() => this.testdisableAndEnableKeyBoardShortCut.set(true), 300);
}
updateHybridComment($event: IHybridGradedComment): void {
- const c1 = this.currentHybridGradedComment4Question?.find(c => (c.id = $event.id));
+ const c1 = this.currentHybridGradedComment4Question?.find(c => (c().id = $event.id));
if (c1) {
let computen = false;
- if (c1.description !== $event.description) {
- c1.description = $event.description;
+ if (c1().description !== $event.description) {
+ c1().description = $event.description;
}
- if (c1.text !== $event.text) {
- c1.text = $event.text;
+ if (c1().text !== $event.text) {
+ c1().text = $event.text;
}
- if (c1.grade !== $event.grade) {
- c1.grade = $event.grade;
+ if (c1().grade !== $event.grade) {
+ c1().grade = $event.grade;
computen = true;
}
- if (c1.relative !== $event.relative) {
- c1.relative = $event.relative;
+ if (c1().relative !== $event.relative) {
+ c1().relative = $event.relative;
computen = true;
}
- if (c1.step !== $event.step) {
- c1.step = $event.step;
+ if (c1().step !== $event.step) {
+ c1().step = $event.step;
computen = true;
}
if (computen && this.resp !== undefined && this.currentQuestion !== undefined) {
diff --git a/src/main/webapp/app/scanexam/corrigequestion/keyboardshortcut/keyboardshortcut.component.ts b/src/main/webapp/app/scanexam/corrigequestion/keyboardshortcut/keyboardshortcut.component.ts
index 2f2323c1..eec11adf 100644
--- a/src/main/webapp/app/scanexam/corrigequestion/keyboardshortcut/keyboardshortcut.component.ts
+++ b/src/main/webapp/app/scanexam/corrigequestion/keyboardshortcut/keyboardshortcut.component.ts
@@ -3,7 +3,7 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @angular-eslint/no-empty-lifecycle-method */
-import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
+import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, Signal, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { IKeyBoardShortCutPreferenceEntry, KeyboardShortcutService } from 'app/scanexam/preference-page/keyboardshortcut.service';
@@ -27,12 +27,12 @@ export class KeyboardshortcutComponent implements AfterViewInit {
questionindex = 0;
@Input()
- textcomments?: ITextComment[];
+ textcomments?: Signal[];
@Input()
- gradedcomments?: IGradedComment[];
+ gradedcomments?: Signal[];
@Input()
- hybridgradedcomments?: IHybridGradedComment[];
+ hybridgradedcomments?: Signal[];
@Output()
toggleTCommentById: EventEmitter = new EventEmitter();
@@ -59,13 +59,13 @@ export class KeyboardshortcutComponent implements AfterViewInit {
const toRemove: number[] = [];
const comments: (IGradedComment | ITextComment | IHybridGradedComment)[] = [];
if (this.gradedcomments) {
- comments.push(...this.gradedcomments);
+ comments.push(...this.gradedcomments.map(e => e()));
}
if (this.textcomments) {
- comments.push(...this.textcomments);
+ comments.push(...this.textcomments.map(e => e()));
}
if (this.hybridgradedcomments) {
- comments.push(...this.hybridgradedcomments);
+ comments.push(...this.hybridgradedcomments.map(e => e()));
}
if (this.keyboardShortcutService.getShortCutPreference().shortcuts.has(this.examId + '_' + this.questionindex)) {
diff --git a/src/main/webapp/app/scanexam/sortComment.ts b/src/main/webapp/app/scanexam/sortComment.ts
index 60e82e65..ad4b007c 100644
--- a/src/main/webapp/app/scanexam/sortComment.ts
+++ b/src/main/webapp/app/scanexam/sortComment.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
-import { Pipe, PipeTransform } from '@angular/core';
+import { Pipe, PipeTransform, Signal } from '@angular/core';
import { IGradedComment } from 'app/entities/graded-comment/graded-comment.model';
import { ITextComment } from 'app/entities/text-comment/text-comment.model';
import { PreferenceService } from './preference-page/preference.service';
@@ -12,7 +12,11 @@ import { IHybridGradedComment } from 'app/entities/hybrid-graded-comment/hybrid-
export class CommentSortPipe implements PipeTransform {
constructor(public preferenceService: PreferenceService) {}
- transform(array: (IHybridGradedComment | ITextComment | IGradedComment)[] | undefined, examId: string, qId: number): any[] {
+ transform(
+ array: (Signal | Signal | Signal)[] | undefined,
+ examId: string,
+ qId: number,
+ ): any[] {
const examId_qId = examId + '_' + qId;
if (array === undefined || !Array.isArray(array) || array.length === 0) {
return [];
@@ -21,12 +25,15 @@ export class CommentSortPipe implements PipeTransform {
if (m.size > 0) {
// eslint-disable-next-line arrow-body-style
const r = array.sort(
- (a: IHybridGradedComment | ITextComment | IGradedComment, b: IHybridGradedComment | ITextComment | IGradedComment) => {
- if (m.has(a.id!) && m.has(b.id!)) {
- return m.get(a.id!)! - m.get(b.id!)!;
- } else if (m.has(a.id!)) {
+ (
+ a: Signal | Signal | Signal,
+ b: Signal | Signal | Signal,
+ ) => {
+ if (m.has(a().id!) && m.has(b().id!)) {
+ return m.get(a().id!)! - m.get(b().id!)!;
+ } else if (m.has(a().id!)) {
return -1;
- } else if (m.has(b.id!)) {
+ } else if (m.has(b().id!)) {
return 1;
} else {
return 0;
@@ -35,19 +42,19 @@ export class CommentSortPipe implements PipeTransform {
);
if (m.size < array.length) {
for (let i = m.size; i < array.length; i++) {
- m.set(array[i].id!, i);
+ m.set(array[i]().id!, i);
}
this.preferenceService.saveCommentSort4Question(examId_qId, m);
} else if (m.size > array.length) {
this.preferenceService.saveCommentSort4Question(examId_qId, new Map());
}
- return r;
+ return r.map(e => e());
} else {
array.forEach((e, index) => {
- m.set(e.id!, index);
+ m.set(e().id!, index);
});
this.preferenceService.saveCommentSort4Question(examId_qId, m);
- return array;
+ return array.map(e => e());
}
}
}