From 76ff4bbce7933e8ba2d6a162d4a84f69c96d014c Mon Sep 17 00:00:00 2001 From: Aurora Virmasalo Date: Wed, 11 Sep 2024 14:16:35 +0300 Subject: [PATCH] CSCEXAM-1300 Fix resolution between collab exams and none one --- app/controllers/ReviewController.java | 17 +++++++---------- conf/routes | 2 +- .../app/review/listing/review-list.component.ts | 4 +++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/controllers/ReviewController.java b/app/controllers/ReviewController.java index 7237c653f..974bd6125 100644 --- a/app/controllers/ReviewController.java +++ b/app/controllers/ReviewController.java @@ -437,8 +437,8 @@ public Result sendInspectionMessage(Long eid, Http.Request request) { @Authenticated @Restrict({ @Group("TEACHER"), @Group("ADMIN") }) @Anonymous(filteredProperties = { "user" }) - public Result listNoShows(Long eid, Http.Request request) { - List enrolments = DB + public Result listNoShows(Long eid, Optional collaborative, Http.Request request) { + ExpressionList el = DB .find(ExamEnrolment.class) .fetch("exam", "id, name, state, gradedTime, customCredit, trialCount, anonymous") .fetch("collaborativeExam") @@ -449,14 +449,11 @@ public Result listNoShows(Long eid, Http.Request request) { .fetch("exam.course", "code, credits") .fetch("exam.grade", "id, name") .where() - .or() - .eq("exam.id", eid) - .eq("exam.parent.id", eid) - .eq("collaborativeExam.id", eid) - .endOr() - .eq("noShow", true) - .orderBy("reservation.endAt") - .findList(); + .eq("noShow", true); + var query = collaborative.orElse(false) + ? el.eq("collaborativeExam.id", eid) + : el.or().eq("exam.id", eid).eq("exam.parent.id", eid).endOr(); + var enrolments = query.findList(); final Result result = ok(enrolments); Set anonIds = enrolments .stream() diff --git a/conf/routes b/conf/routes index c814b1994..012460a7c 100644 --- a/conf/routes +++ b/conf/routes @@ -145,7 +145,7 @@ PUT /app/review/examquestion/:id/score controlle PUT /app/review/examquestion/:id/score/force controllers.ReviewController.forceScoreExamQuestion(id: Long, request: Request) PUT /app/review/:eid/comment controllers.ReviewController.updateComment(eid: Long, request: Request) PUT /app/review/:eid/comment/:cid/feedbackstatus controllers.ReviewController.setCommentStatusRead(eid: Long, cid: Long, request: Request) -GET /app/noshows/:eid controllers.ReviewController.listNoShows(eid: Long, request: Request) +GET /app/noshows/:eid controllers.ReviewController.listNoShows(eid: Long, collaborative: java.util.Optional[java.lang.Boolean], request: Request) PUT /app/reviews/archive controllers.ReviewController.archiveExams(request: Request) GET /app/review/:eid controllers.ReviewController.getExamReview(eid: Long, request: Request) GET /app/review/:id/locked controllers.ReviewController.hasLockedAssessments(id: Long) diff --git a/ui/src/app/review/listing/review-list.component.ts b/ui/src/app/review/listing/review-list.component.ts index d6d6f4d3e..06acab545 100644 --- a/ui/src/app/review/listing/review-list.component.ts +++ b/ui/src/app/review/listing/review-list.component.ts @@ -77,7 +77,9 @@ export class ReviewListComponent implements OnInit, OnChanges { this.exam = this.Tabs.getExam(); this.collaborative = this.Tabs.isCollaborative(); this.refreshLists(); - this.http.get(`/app/noshows/${this.exam.id}`).subscribe((resp) => (this.noShows = resp)); + this.http + .get(`/app/noshows/${this.exam.id}`, { params: { collaborative: this.collaborative } }) + .subscribe((resp) => (this.noShows = resp)); this.Tabs.notifyTabChange(5); }); }