fixed quiz password update from Exam on LMS
This commit is contained in:
parent
25e9b9be1e
commit
675d2aad19
3 changed files with 19 additions and 15 deletions
|
@ -161,9 +161,9 @@ public interface ExamAdminService {
|
|||
/** Gets invoked after an exam has been changed and saved.
|
||||
*
|
||||
* @param exam the exam that has been changed and saved */
|
||||
void notifyExamSaved(Exam exam);
|
||||
Result<Exam> notifyExamSaved(Exam exam);
|
||||
|
||||
void applyQuitPassword(Exam entity);
|
||||
Result<Exam> applyQuitPassword(Exam exam);
|
||||
|
||||
static void newExamFieldValidation(final POSTMapper postParams) {
|
||||
noLMSFieldValidation(new Exam(postParams));
|
||||
|
|
|
@ -69,6 +69,7 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
|||
private final boolean appSignatureKeyEnabled;
|
||||
private final int defaultNumericalTrustThreshold;
|
||||
private final ExamConfigurationValueService examConfigurationValueService;
|
||||
private final SEBRestrictionService sebRestrictionService;
|
||||
|
||||
protected ExamAdminServiceImpl(
|
||||
final ExamDAO examDAO,
|
||||
|
@ -78,6 +79,7 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
|||
final ExamConfigurationMapDAO examConfigurationMapDAO,
|
||||
final LmsAPIService lmsAPIService,
|
||||
final ExamConfigurationValueService examConfigurationValueService,
|
||||
final SEBRestrictionService sebRestrictionService,
|
||||
final @Value("${sebserver.webservice.api.admin.exam.app.signature.key.enabled:false}") boolean appSignatureKeyEnabled,
|
||||
final @Value("${sebserver.webservice.api.admin.exam.app.signature.key.numerical.threshold:2}") int defaultNumericalTrustThreshold) {
|
||||
|
||||
|
@ -90,6 +92,7 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
|||
this.examConfigurationValueService = examConfigurationValueService;
|
||||
this.appSignatureKeyEnabled = appSignatureKeyEnabled;
|
||||
this.defaultNumericalTrustThreshold = defaultNumericalTrustThreshold;
|
||||
this.sebRestrictionService = sebRestrictionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -323,16 +326,21 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void notifyExamSaved(final Exam exam) {
|
||||
updateAdditionalExamConfigAttributes(exam.id);
|
||||
this.proctoringAdminService.notifyExamSaved(exam);
|
||||
public Result<Exam> notifyExamSaved(final Exam exam) {
|
||||
return Result.tryCatch(() -> {
|
||||
updateAdditionalExamConfigAttributes(exam.id);
|
||||
this.proctoringAdminService.notifyExamSaved(exam);
|
||||
return exam;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyQuitPassword(final Exam exam) {
|
||||
this.examConfigurationValueService
|
||||
public Result<Exam> applyQuitPassword(final Exam exam) {
|
||||
return this.examConfigurationValueService
|
||||
.applyQuitPasswordToConfigs(exam.id, exam.quitPassword)
|
||||
.getOrThrow();
|
||||
.flatMap(id -> this.sebRestrictionService.applySEBClientRestriction(exam))
|
||||
.flatMap(e -> this.examDAO.setSEBRestriction(e.id, true))
|
||||
.onError(t -> log.error("Failed to update SEB Client restriction for Exam: {}", exam, t));
|
||||
}
|
||||
|
||||
private Result<Exam> initAdditionalAttributesForMoodleExams(final Exam exam) {
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.util.stream.Collectors;
|
|||
import javax.validation.Valid;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.util.Cryptor;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamConfigurationValueService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSEBRestrictionException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -669,12 +668,9 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
|||
|
||||
@Override
|
||||
protected Result<Exam> notifySaved(final Exam entity) {
|
||||
return Result.tryCatch(() -> {
|
||||
this.examAdminService.notifyExamSaved(entity);
|
||||
this.examAdminService.applyQuitPassword(entity);
|
||||
this.examSessionService.flushCache(entity);
|
||||
return entity;
|
||||
});
|
||||
return this.examAdminService.notifyExamSaved(entity)
|
||||
.flatMap(this.examAdminService::applyQuitPassword)
|
||||
.flatMap(this.examSessionService::flushCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue