Skip to content

Commit

Permalink
SEBSERV-560 SEBSERV-563 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Jul 16, 2024
1 parent 303b3ac commit e70a209
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ public interface ScreenProctoringGroupDAO {
Result<Collection<EntityKey>> deleteGroups(Long examId);

void updateGroupSize(String groupUUID, Integer activeCount, Integer totalCount);

void resetAllForExam(Long examId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ public void updateGroupSize(

try {

UpdateDSL.updateWithMapper(
UpdateDSL
.updateWithMapper(
this.screenProctoringGroopRecordMapper::update,
ScreenProctoringGroopRecordDynamicSqlSupport.screenProctoringGroopRecord)
.set(ScreenProctoringGroopRecordDynamicSqlSupport.size)
Expand All @@ -259,6 +260,26 @@ public void updateGroupSize(

}

@Override
@Transactional
public void resetAllForExam(final Long examId) {
try {

UpdateDSL
.updateWithMapper(
this.screenProctoringGroopRecordMapper::update,
ScreenProctoringGroopRecordDynamicSqlSupport.screenProctoringGroopRecord)
.set(ScreenProctoringGroopRecordDynamicSqlSupport.size)
.equalTo(0)
.where(ScreenProctoringGroopRecordDynamicSqlSupport.examId, isEqualTo(examId))
.build()
.execute();

} catch (final Exception e) {
log.warn("Failed to reset SPS groups size: {}", e.getMessage());
}
}

private ScreenProctoringGroup toDomainModel(final ScreenProctoringGroopRecord record) {
return new ScreenProctoringGroup(
record.getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public void notifyExamFinished(final ExamFinishedEvent event) {

if (event.exam.status != Exam.ExamStatus.UP_COMING) {
this.screenProctoringAPIBinding.deactivateScreenProctoring(event.exam);
this.screenProctoringGroupDAO.resetAllForExam(event.exam.id);
}
}

Expand Down

0 comments on commit e70a209

Please sign in to comment.