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.
|
/** Gets invoked after an exam has been changed and saved.
|
||||||
*
|
*
|
||||||
* @param exam the exam that 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) {
|
static void newExamFieldValidation(final POSTMapper postParams) {
|
||||||
noLMSFieldValidation(new Exam(postParams));
|
noLMSFieldValidation(new Exam(postParams));
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
||||||
private final boolean appSignatureKeyEnabled;
|
private final boolean appSignatureKeyEnabled;
|
||||||
private final int defaultNumericalTrustThreshold;
|
private final int defaultNumericalTrustThreshold;
|
||||||
private final ExamConfigurationValueService examConfigurationValueService;
|
private final ExamConfigurationValueService examConfigurationValueService;
|
||||||
|
private final SEBRestrictionService sebRestrictionService;
|
||||||
|
|
||||||
protected ExamAdminServiceImpl(
|
protected ExamAdminServiceImpl(
|
||||||
final ExamDAO examDAO,
|
final ExamDAO examDAO,
|
||||||
|
@ -78,6 +79,7 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
||||||
final ExamConfigurationMapDAO examConfigurationMapDAO,
|
final ExamConfigurationMapDAO examConfigurationMapDAO,
|
||||||
final LmsAPIService lmsAPIService,
|
final LmsAPIService lmsAPIService,
|
||||||
final ExamConfigurationValueService examConfigurationValueService,
|
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.enabled:false}") boolean appSignatureKeyEnabled,
|
||||||
final @Value("${sebserver.webservice.api.admin.exam.app.signature.key.numerical.threshold:2}") int defaultNumericalTrustThreshold) {
|
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.examConfigurationValueService = examConfigurationValueService;
|
||||||
this.appSignatureKeyEnabled = appSignatureKeyEnabled;
|
this.appSignatureKeyEnabled = appSignatureKeyEnabled;
|
||||||
this.defaultNumericalTrustThreshold = defaultNumericalTrustThreshold;
|
this.defaultNumericalTrustThreshold = defaultNumericalTrustThreshold;
|
||||||
|
this.sebRestrictionService = sebRestrictionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -323,16 +326,21 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyExamSaved(final Exam exam) {
|
public Result<Exam> notifyExamSaved(final Exam exam) {
|
||||||
updateAdditionalExamConfigAttributes(exam.id);
|
return Result.tryCatch(() -> {
|
||||||
this.proctoringAdminService.notifyExamSaved(exam);
|
updateAdditionalExamConfigAttributes(exam.id);
|
||||||
|
this.proctoringAdminService.notifyExamSaved(exam);
|
||||||
|
return exam;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyQuitPassword(final Exam exam) {
|
public Result<Exam> applyQuitPassword(final Exam exam) {
|
||||||
this.examConfigurationValueService
|
return this.examConfigurationValueService
|
||||||
.applyQuitPasswordToConfigs(exam.id, exam.quitPassword)
|
.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) {
|
private Result<Exam> initAdditionalAttributesForMoodleExams(final Exam exam) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.stream.Collectors;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Cryptor;
|
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 ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSEBRestrictionException;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -669,12 +668,9 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Result<Exam> notifySaved(final Exam entity) {
|
protected Result<Exam> notifySaved(final Exam entity) {
|
||||||
return Result.tryCatch(() -> {
|
return this.examAdminService.notifyExamSaved(entity)
|
||||||
this.examAdminService.notifyExamSaved(entity);
|
.flatMap(this.examAdminService::applyQuitPassword)
|
||||||
this.examAdminService.applyQuitPassword(entity);
|
.flatMap(this.examSessionService::flushCache);
|
||||||
this.examSessionService.flushCache(entity);
|
|
||||||
return entity;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue