Skip to content

Commit

Permalink
SEBSERV-585 fixed by saving BEK separately
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Sep 25, 2024
1 parent 2c36033 commit e4c24e8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ public void compose(final PageContext pageContext) {
.onError(error -> pageContext.notifyLoadError(EntityType.EXAM, error))
.getOrThrow();



// new PageContext with actual EntityKey
final EntityKey entityKey = (readonly || !newExamNoLMS) ? pageContext.getEntityKey() : null;
final PageContext formContext = pageContext.withEntityKey(exam.getEntityKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,6 @@ default Result<Exam> releaseLock(final Exam exam, final String updateId) {
void markLMSAvailability(final String externalQuizId, final boolean available, final String updateId);

void updateQuitPassword(Exam exam, String quitPassword);


void saveBrowserExamKeys(Long examId, String bek);
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ public void updateQuitPassword(final Exam exam, final String quitPassword) {
.onError(err -> log.error("Failed to update quit password on exam: {}", exam, err));
}

@Override
public void saveBrowserExamKeys(final Long examId, final String bek) {
this.examRecordDAO
.saveBrowserExamKeys(examId, bek)
.onError(err -> log.error("Failed to update Browser Exam Keys on exam: {}", examId, err));
}

@Override
public Result<Exam> setSEBRestriction(final Long examId, final boolean sebRestriction) {
return this.examRecordDAO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,22 @@ public Result<Collection<ExamRecord>> allOf(final Set<Long> pks) {
});
}

@Transactional
public Result<ExamRecord> saveBrowserExamKeys(final Long examId, final String bek) {
return Result.tryCatch(() -> {

UpdateDSL.updateWithMapper(examRecordMapper::update, ExamRecordDynamicSqlSupport.examRecord)
.set(browserKeys).equalTo(bek)
.set(lastModified).equalTo(Utils.getMillisecondsNow())
.where(id, isEqualTo(examId))
.build()
.execute();

return this.examRecordMapper.selectByPrimaryKey(examId);
})
.onError(TransactionHandler::rollback);
}

private String getEncryptedQuitPassword(final String pwd) {
return (StringUtils.isNotBlank(pwd))
? this.cryptor
Expand All @@ -609,3 +625,4 @@ private String getEncryptedQuitPassword(final String pwd) {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,11 @@ public Result<Exam> saveSEBRestrictionToExam(final Exam exam, final SEBRestricti
return Result.tryCatch(() -> {
// save Browser Exam Keys
final Collection<String> browserExamKeys = sebRestriction.getBrowserExamKeys();
final Exam newExam = new Exam(
exam.id,
null, null, null, null, null, null, null, null, null,
exam.supporter,
exam.status,
null,
null,
this.examDAO.saveBrowserExamKeys(
exam.id,
(browserExamKeys != null && !browserExamKeys.isEmpty())
? StringUtils.join(browserExamKeys, Constants.LIST_SEPARATOR_CHAR)
: StringUtils.EMPTY,
null, null, null, null, null);

this.examDAO.save(newExam)
.getOrThrow();
: StringUtils.EMPTY);

// save additional restriction properties
// remove old ones first by collecting its id's and then delete by id's
Expand Down

0 comments on commit e4c24e8

Please sign in to comment.