From c863fd0f03c0e49477d7aa24031f7748a958f040 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 4 Jan 2022 10:15:01 +0100 Subject: [PATCH] fixed proctoring room update in connection setup --- .../servicelayer/dao/ClientConnectionDAO.java | 4 +--- .../dao/impl/ClientConnectionDAOImpl.java | 10 -------- .../lms/impl/mockup/MockupLmsAPITemplate.java | 10 ++++---- .../impl/SEBClientConnectionServiceImpl.java | 23 +++++++++++++++++++ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientConnectionDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientConnectionDAO.java index 8090c27f..200f641f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientConnectionDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientConnectionDAO.java @@ -90,9 +90,6 @@ public interface ClientConnectionDAO extends * @return Result refer to a collection of all ClientConnection records for update or to an error when happened */ Result> getAllConnectionIdsForRoomUpdateInactive(); - /** Used to re-mark a client connection record for room update in error case. */ - void setNeedsRoomUpdate(Long connectionId); - /** Get all ClientConnection that are assigned to a defined proctoring collecting room. * * @param roomId The proctoring room identifier @@ -132,6 +129,7 @@ public interface ClientConnectionDAO extends key = "#connectionToken") Result removeFromProctoringRoom(Long connectionId, String connectionToken); + /** Used to re-mark a client connection record for room update in error case. */ Result markForProctoringUpdate(Long id); /** Deletes the given ClientConnection data. diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java index 64dc7760..5f6b5c7b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java @@ -285,16 +285,6 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { .onError(TransactionHandler::rollback); } - @Override - @Transactional - public void setNeedsRoomUpdate(final Long connectionId) { - final ClientConnectionRecord updateRecord = new ClientConnectionRecord( - connectionId, null, null, null, null, null, - null, null, null, null, null, null, null, - 1); - this.clientConnectionRecordMapper.updateByPrimaryKeySelective(updateRecord); - } - @Override @Transactional(readOnly = true) public Result> getRoomConnections(final Long roomId) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java index 35e67a9f..fd039f43 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java @@ -66,22 +66,22 @@ public class MockupLmsAPITemplate implements LmsAPITemplate { "2020-01-01T09:00:00Z", null, "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz2", institutionId, lmsSetupId, lmsType, "Demo Quiz 2 (MOCKUP)", "

Demo Quiz Mockup

", - "2020-01-01T09:00:00Z", "2022-01-01T09:00:00Z", "http://lms.mockup.com/api/")); + "2020-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz3", institutionId, lmsSetupId, lmsType, "Demo Quiz 3 (MOCKUP)", "

Demo Quiz Mockup

", "2018-07-30T09:00:00Z", "2018-08-01T00:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz4", institutionId, lmsSetupId, lmsType, "Demo Quiz 4 (MOCKUP)", "

Demo Quiz Mockup

", - "2018-01-01T00:00:00Z", "2019-01-01T00:00:00Z", "http://lms.mockup.com/api/")); + "2018-01-01T00:00:00Z", "2025-01-01T00:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz5", institutionId, lmsSetupId, lmsType, "Demo Quiz 5 (MOCKUP)", "

Demo Quiz Mockup

", - "2018-01-01T09:00:00Z", "2022-01-01T09:00:00Z", "http://lms.mockup.com/api/")); + "2018-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz6", institutionId, lmsSetupId, lmsType, "Demo Quiz 6 (MOCKUP)", "

Demo Quiz Mockup

", - "2019-01-01T09:00:00Z", "2022-01-01T09:00:00Z", "http://lms.mockup.com/api/")); + "2019-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz7", institutionId, lmsSetupId, lmsType, "Demo Quiz 7 (MOCKUP)", "

Demo Quiz Mockup

", - "2018-01-01T09:00:00Z", "2022-01-01T09:00:00Z", "http://lms.mockup.com/api/")); + "2018-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz10", institutionId, lmsSetupId, lmsType, "Demo Quiz 10 (MOCKUP)", diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java index f52a11ab..957a8bc0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java @@ -392,8 +392,15 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic .save(connectionToSave) .getOrThrow(); + // check exam integrity for established connection checkExamIntegrity(establishedClientConnection.examId); + // if proctoring is enabled for exam, mark for room update + if (proctoringEnabled) { + this.clientConnectionDAO.markForProctoringUpdate(updatedClientConnection.id); + } + + // flush and reload caches to work with actual connection data final ClientConnectionDataInternal activeClientConnection = reloadConnectionCache(connectionToken); @@ -493,6 +500,14 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic updatedClientConnection = clientConnection; } + // if proctoring is enabled for exam, mark for room update + final Boolean proctoringEnabled = this.examAdminService + .isProctoringEnabled(clientConnection.examId) + .getOr(false); + if (proctoringEnabled) { + this.clientConnectionDAO.markForProctoringUpdate(updatedClientConnection.id); + } + // delete stored ping if this is a distributed setup if (this.isDistributedSetup) { this.distributedPingCache @@ -547,6 +562,14 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic updatedClientConnection = clientConnection; } + // if proctoring is enabled for exam, mark for room update + final Boolean proctoringEnabled = this.examAdminService + .isProctoringEnabled(clientConnection.examId) + .getOr(false); + if (proctoringEnabled) { + this.clientConnectionDAO.markForProctoringUpdate(updatedClientConnection.id); + } + // delete stored ping if this is a distributed setup if (this.isDistributedSetup) { this.distributedPingCache