Skip to content

Commit

Permalink
Merge pull request #126 from correctexam/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
barais authored Feb 12, 2024
2 parents 75fd304 + 03340a4 commit 79f944b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/fr/istic/web/rest/ExtendedAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,28 @@ public Response deleteAllAnswerAndComment(@PathParam("examId") long examId, @Con
return response.build();
}

@GET
@Path("/getExamStatusFinish/{examId}")
@RolesAllowed({ AuthoritiesConstants.USER, AuthoritiesConstants.ADMIN })
public Response getExamStatusFinish(@PathParam("examId") final long examId, @Context final UriInfo uriInfo,
@Context final SecurityContext ctx) {

if (!securityService.canAccess(ctx, examId, Exam.class)) {
return Response.status(403, "Current user cannot access this ressource").build();
}

final List<StudentResponse> stdResponses = StudentResponse.getAll4ExamId(examId).list();
final Map<Long, List<StudentResponse>> byQuestion = stdResponses.stream()
.collect(Collectors.groupingBy(StudentResponse::getQuestionNumero));

var nbreSheet = ExamSheet.getAll4ExamId(examId).count();
var res = byQuestion.keySet().stream().allMatch(e-> byQuestion.get(e).size()==nbreSheet);
if (nbreSheet ==0){
res = false;
}
return Response.ok(res).build();
}

/**
* Provides summary data of a given exam.
*
Expand Down

0 comments on commit 79f944b

Please sign in to comment.