Fixed Exam update task to not brake on single exam update error
This commit is contained in:
parent
291a0e3532
commit
c3eda2b81d
3 changed files with 12 additions and 15 deletions
|
@ -390,7 +390,7 @@ public class ExamForm implements TemplateComposer {
|
||||||
.withExec(this.examCreateClientConfigPopup.exportFunction(
|
.withExec(this.examCreateClientConfigPopup.exportFunction(
|
||||||
exam.institutionId,
|
exam.institutionId,
|
||||||
exam.getName()))
|
exam.getName()))
|
||||||
.publishIf(() -> modifyGrant && readonly)
|
.publishIf(() -> editable && readonly)
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)
|
.newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
|
@ -416,13 +416,13 @@ public class ExamForm implements TemplateComposer {
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(this.examProctoringSettings.settingsFunction(this.pageService, modifyGrant))
|
.withExec(this.examProctoringSettings.settingsFunction(this.pageService, modifyGrant))
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(() -> proctoringEnabled && readonly)
|
.publishIf(() -> editable && proctoringEnabled && readonly)
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_PROCTORING_OFF)
|
.newAction(ActionDefinition.EXAM_PROCTORING_OFF)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(this.examProctoringSettings.settingsFunction(this.pageService, modifyGrant))
|
.withExec(this.examProctoringSettings.settingsFunction(this.pageService, modifyGrant))
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(() -> !proctoringEnabled && readonly)
|
.publishIf(() -> editable && !proctoringEnabled && readonly)
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_DELETE)
|
.newAction(ActionDefinition.EXAM_DELETE)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
|
|
|
@ -133,7 +133,7 @@ class ExamSessionControlTask implements DisposableBean {
|
||||||
.getOrThrow()
|
.getOrThrow()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(exam -> exam.startTime.minus(this.examTimePrefix).isBefore(now))
|
.filter(exam -> exam.startTime.minus(this.examTimePrefix).isBefore(now))
|
||||||
.map(exam -> this.examUpdateHandler.setRunning(exam, updateId))
|
.flatMap(exam -> Result.skipOnError(this.examUpdateHandler.setRunning(exam, updateId)))
|
||||||
.collect(Collectors.toMap(Exam::getId, Exam::getName));
|
.collect(Collectors.toMap(Exam::getId, Exam::getName));
|
||||||
|
|
||||||
if (!updated.isEmpty()) {
|
if (!updated.isEmpty()) {
|
||||||
|
@ -158,10 +158,8 @@ class ExamSessionControlTask implements DisposableBean {
|
||||||
.getOrThrow()
|
.getOrThrow()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(exam -> exam.endTime != null && exam.endTime.plus(this.examTimeSuffix).isBefore(now))
|
.filter(exam -> exam.endTime != null && exam.endTime.plus(this.examTimeSuffix).isBefore(now))
|
||||||
.map(exam -> this.examUpdateHandler.setFinished(exam, updateId))
|
.flatMap(exam -> Result.skipOnError(this.examUpdateHandler.setFinished(exam, updateId)))
|
||||||
.map(this.examProcotringRoomService::disposeRoomsForExam)
|
.flatMap(exam -> Result.skipOnError(this.examProcotringRoomService.disposeRoomsForExam(exam)))
|
||||||
.filter(result -> !result.hasError())
|
|
||||||
.map(Result::get)
|
|
||||||
.collect(Collectors.toMap(Exam::getId, Exam::getName));
|
.collect(Collectors.toMap(Exam::getId, Exam::getName));
|
||||||
|
|
||||||
if (!updated.isEmpty()) {
|
if (!updated.isEmpty()) {
|
||||||
|
|
|
@ -64,14 +64,15 @@ class ExamUpdateHandler {
|
||||||
final DateTime now = DateTime.now(DateTimeZone.UTC);
|
final DateTime now = DateTime.now(DateTimeZone.UTC);
|
||||||
if (exam.getStatus() == ExamStatus.UP_COMING
|
if (exam.getStatus() == ExamStatus.UP_COMING
|
||||||
&& exam.endTime.plus(this.examTimeSuffix).isBefore(now)) {
|
&& exam.endTime.plus(this.examTimeSuffix).isBefore(now)) {
|
||||||
return setRunning(exam, this.createUpdateId());
|
return setRunning(exam, this.createUpdateId())
|
||||||
|
.getOr(exam);
|
||||||
} else {
|
} else {
|
||||||
return exam;
|
return exam;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Exam setRunning(final Exam exam, final String updateId) {
|
Result<Exam> setRunning(final Exam exam, final String updateId) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Update exam as running: {}", exam);
|
log.debug("Update exam as running: {}", exam);
|
||||||
}
|
}
|
||||||
|
@ -85,11 +86,10 @@ class ExamUpdateHandler {
|
||||||
.flatMap(this.sebRestrictionService::applySEBClientRestriction)
|
.flatMap(this.sebRestrictionService::applySEBClientRestriction)
|
||||||
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
||||||
.onError(error -> this.examDAO.forceUnlock(exam.id)
|
.onError(error -> this.examDAO.forceUnlock(exam.id)
|
||||||
.onError(unlockError -> log.error("Failed to force unlock update look for exam: {}", exam.id)))
|
.onError(unlockError -> log.error("Failed to force unlock update look for exam: {}", exam.id)));
|
||||||
.getOrThrow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Exam setFinished(final Exam exam, final String updateId) {
|
Result<Exam> setFinished(final Exam exam, final String updateId) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Update exam as finished: {}", exam);
|
log.debug("Update exam as finished: {}", exam);
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,7 @@ class ExamUpdateHandler {
|
||||||
updateId))
|
updateId))
|
||||||
.flatMap(this.sebRestrictionService::releaseSEBClientRestriction)
|
.flatMap(this.sebRestrictionService::releaseSEBClientRestriction)
|
||||||
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
||||||
.onError(error -> this.examDAO.forceUnlock(exam.id))
|
.onError(error -> this.examDAO.forceUnlock(exam.id));
|
||||||
.getOrThrow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue