SEBSERV-435 fix monitoring update, fix group release when assign failed
This commit is contained in:
parent
aff3544802
commit
0e1ee3330a
6 changed files with 42 additions and 6 deletions
|
@ -59,6 +59,8 @@ public interface ScreenProctoringGroupDAO {
|
|||
* @throws If the Result contains a AllGroupsFullException, there must be created a new Group first */
|
||||
Result<ScreenProctoringGroup> reservePlaceInCollectingGroup(Long examId, int maxSize);
|
||||
|
||||
Result<ScreenProctoringGroup> releasePlaceInCollectingGroup(Long examId, Long groupId);
|
||||
|
||||
/** This creates a new ScreenProctoringGroup with the given group data.
|
||||
* Note that examId and uuid and name are mandatory. The size is ignored and initially set to 0
|
||||
*
|
||||
|
|
|
@ -151,6 +151,28 @@ public class ScreenProctoringGroupDAOImpl implements ScreenProctoringGroupDAO {
|
|||
.onError(TransactionHandler::rollback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result<ScreenProctoringGroup> releasePlaceInCollectingGroup(final Long examId, final Long groupId) {
|
||||
return Result.tryCatch(() -> {
|
||||
final ScreenProctoringGroopRecord record =
|
||||
this.screenProctoringGroopRecordMapper.selectByPrimaryKey(groupId);
|
||||
|
||||
UpdateDSL.updateWithMapper(
|
||||
this.screenProctoringGroopRecordMapper::update,
|
||||
ScreenProctoringGroopRecordDynamicSqlSupport.screenProctoringGroopRecord)
|
||||
.set(ScreenProctoringGroopRecordDynamicSqlSupport.size)
|
||||
.equalTo(record.getSize() - 1)
|
||||
.where(ScreenProctoringGroopRecordDynamicSqlSupport.id, isEqualTo(groupId))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
return this.screenProctoringGroopRecordMapper.selectByPrimaryKey(groupId);
|
||||
})
|
||||
.map(this::toDomainModel)
|
||||
.onError(TransactionHandler::rollback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result<ScreenProctoringGroup> createNewGroup(final ScreenProctoringGroup group) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import ch.ethz.seb.sebserver.gbl.model.exam.ClientGroupData.ClientOS;
|
|||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.ProctoringServiceSettings;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.ScreenProctoringSettings;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.RemoteProctoringService;
|
||||
|
@ -115,10 +116,10 @@ public interface ExamAdminService {
|
|||
|
||||
if (exam.additionalAttributesIncluded()) {
|
||||
return BooleanUtils.toBoolean(
|
||||
exam.getAdditionalAttribute(ProctoringServiceSettings.ATTR_ENABLE_PROCTORING));
|
||||
exam.getAdditionalAttribute(ScreenProctoringSettings.ATTR_ENABLE_SCREEN_PROCTORING));
|
||||
}
|
||||
|
||||
return isProctoringEnabled(exam.id).getOr(false);
|
||||
return isScreenProctoringEnabled(exam.id).getOr(false);
|
||||
}
|
||||
|
||||
/** Updates needed additional attributes from assigned exam configuration for the exam
|
||||
|
|
|
@ -487,7 +487,6 @@ class ScreenProctoringAPIBinding {
|
|||
|
||||
final String token = clientConnection.getConnectionToken();
|
||||
final ScreenProctoringServiceOAuthTemplate apiTemplate = this.getAPITemplate(examId);
|
||||
|
||||
final String uri = UriComponentsBuilder
|
||||
.fromUriString(this.apiTemplate.screenProctoringSettings.spsServiceURL)
|
||||
.path(SPS_API.SESSION_ENDPOINT)
|
||||
|
|
|
@ -297,6 +297,8 @@ public class ScreenProctoringServiceImpl implements ScreenProctoringService {
|
|||
|
||||
private void applyScreenProctoringSession(final ClientConnectionRecord ccRecord) {
|
||||
|
||||
Long placeReservedInGroup = null;
|
||||
|
||||
try {
|
||||
final Long examId = ccRecord.getExamId();
|
||||
final Exam runningExam = this.examSessionCacheService.getRunningExam(examId);
|
||||
|
@ -305,6 +307,7 @@ public class ScreenProctoringServiceImpl implements ScreenProctoringService {
|
|||
final ScreenProctoringGroup group = applySEBConnectionToGroup(
|
||||
ccRecord,
|
||||
runningExam);
|
||||
placeReservedInGroup = group.id;
|
||||
|
||||
// create screen proctoring session for SEB connection on SPS service
|
||||
final String spsSessionToken = this.screenProctoringAPIBinding
|
||||
|
@ -315,6 +318,15 @@ public class ScreenProctoringServiceImpl implements ScreenProctoringService {
|
|||
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to apply screen proctoring session to SEB with connection: ", ccRecord, e);
|
||||
|
||||
// if (placeReservedInGroup != null) {
|
||||
// // release reserved place in group
|
||||
// this.screenProctoringGroupDAO.releasePlaceInCollectingGroup(
|
||||
// ccRecord.getExamId(),
|
||||
// placeReservedInGroup)
|
||||
// .onError(
|
||||
// error -> log.warn("Failed to release reserved place in group: {}", error.getMessage()));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,7 +360,7 @@ public class ScreenProctoringServiceImpl implements ScreenProctoringService {
|
|||
final ClientConnectionRecord ccRecord,
|
||||
final Exam exam) {
|
||||
|
||||
final ScreenProctoringGroup screenProctoringGroup = getProctoringGroup(exam);
|
||||
final ScreenProctoringGroup screenProctoringGroup = reservePlaceOnProctoringGroup(exam);
|
||||
this.clientConnectionDAO.assignToScreenProctoringGroup(
|
||||
exam.id,
|
||||
ccRecord.getConnectionToken(),
|
||||
|
@ -358,7 +370,7 @@ public class ScreenProctoringServiceImpl implements ScreenProctoringService {
|
|||
return screenProctoringGroup;
|
||||
}
|
||||
|
||||
private ScreenProctoringGroup getProctoringGroup(final Exam exam) {
|
||||
private ScreenProctoringGroup reservePlaceOnProctoringGroup(final Exam exam) {
|
||||
|
||||
int collectingGroupSize = 0;
|
||||
if (exam.additionalAttributes.containsKey(ScreenProctoringSettings.ATTR_COLLECTING_GROUP_SIZE)) {
|
||||
|
|
|
@ -25,7 +25,7 @@ sebserver.webservice.clean-db-on-startup=false
|
|||
|
||||
# webservice configuration
|
||||
sebserver.init.adminaccount.gen-on-init=false
|
||||
sebserver.webservice.distributed=false
|
||||
sebserver.webservice.distributed=true
|
||||
#sebserver.webservice.master.delay.threshold=10000
|
||||
sebserver.webservice.http.external.scheme=http
|
||||
sebserver.webservice.http.external.servername=localhost
|
||||
|
|
Loading…
Reference in a new issue