Skip to content

Commit

Permalink
Merge branch 'dev' into CSCEXAM-1998
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari authored Jan 24, 2025
2 parents 65b3b7c + 1be5dbc commit 2d9ea97
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/models/enrolment/ExamEnrolment.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Entity
public class ExamEnrolment extends GeneratedIdentityModel implements Comparable<ExamEnrolment> {

private static final int DELAY_MAX = 30;
private static final int DELAY_MAX = 30 * 1000;

@ManyToOne
@JsonManagedReference
Expand Down
13 changes: 4 additions & 9 deletions app/repository/EnrolmentRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,6 @@ private void handleUpcomingEnrolment(
if (
enrolment.getExam() != null && enrolment.getExam().getImplementation() == Exam.Implementation.AQUARIUM
) {
// If user is on a correct aquarium machine then always set a header
headers.put(
"x-exam-aquarium-login",
String.format("%s:::%d", getExamHash(enrolment), enrolment.getId())
);
// Aquarium exam, don't set headers unless it starts in 5 minutes
DateTime threshold = DateTime.now().plusMinutes(5);
DateTime start = dateTimeHandler.normalize(
Expand Down Expand Up @@ -327,22 +322,22 @@ private boolean isInsideBounds(ExamEnrolment ee, int minutesToFuture) {
int delay = ee.getDelay();
return (
(reservation != null &&
reservation.getStartAt().plusSeconds(delay).isBefore(latest) &&
reservation.getStartAt().plusMillis(delay).isBefore(latest) &&
reservation.getEndAt().isAfter(earliest)) ||
(event != null &&
event.getStart().plusSeconds(delay).isBefore(latest) &&
event.getStart().plusMillis(delay).isBefore(latest) &&
event.getStart().plusMinutes(ee.getExam().getDuration()).isAfter(earliest))
);
}

private DateTime getStartTime(ExamEnrolment enrolment) {
return enrolment.getReservation() != null
? enrolment.getReservation().getStartAt().plusSeconds(enrolment.getDelay())
? enrolment.getReservation().getStartAt().plusMillis(enrolment.getDelay())
: enrolment
.getExaminationEventConfiguration()
.getExaminationEvent()
.getStart()
.plusSeconds(enrolment.getDelay());
.plusMillis(enrolment.getDelay());
}

private Optional<ExamEnrolment> getNextEnrolment(Long userId, int minutesToFuture) {
Expand Down
9 changes: 9 additions & 0 deletions conf/evolutions/default/136.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- SPDX-FileCopyrightText: 2024 The members of the EXAM Consortium
--
-- SPDX-License-Identifier: EUPL-1.2

# --- !Ups
UPDATE exam_enrolment SET delay = delay * 1000;

# --- !Downs
UPDATE exam_enrolment SET delay = delay / 1000;
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class WaitingRoomComponent implements OnInit, OnDestroy {
private startScheduled = () => {
window.clearTimeout(this.startTimerId);
const offset = Math.ceil(
DateTime.fromJSDate(this.getStart()).plus({ seconds: this.enrolment.delay }).toSeconds() -
DateTime.fromJSDate(this.getStart()).plus({ milliseconds: this.enrolment.delay }).toSeconds() -
DateTime.now().toSeconds(),
);
this.delayTimerId = window.setTimeout(this.Session.checkSession, Math.max(0, offset * 1000));
Expand Down

0 comments on commit 2d9ea97

Please sign in to comment.