Skip to content

Commit

Permalink
SEBSERV-494 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Nov 29, 2023
1 parent e426a7a commit 32567a2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ default Result<Exam> releaseLock(final Exam exam, final String updateId) {
/** This checks if there are write locks that are out of date and release such. */
void releaseAgedLocks();

/** Use this to check if the exam is up to date
/** Use this to check if the exam is up-to-date
*
* @param exam the exam to check if it is in sync with the persistent or if there is a newer version
* @return Result refer to the up-to-date result or to an error if happened */
Expand All @@ -178,7 +178,7 @@ default Result<Exam> releaseLock(final Exam exam, final String updateId) {
/** Marks the specified exam as updated (sets the last modified date to now)
* to notify exam content has changed.
* This is automatically done also with normal save but not always an entire
* save is needed. In this cases this can be used to notify a exam content change.
* save is needed. In these cases this can be used to notify a exam content change.
*
* @param examId The exam identifier */
void setModified(Long examId);
Expand Down Expand Up @@ -212,7 +212,7 @@ default Result<Exam> releaseLock(final Exam exam, final String updateId) {

/** Marks the given exam by setting the last-update-time to current time.
* This provokes a cache update on distributed setup.
* Additionally this flushes the local cache immediately.
* Additionally, this flushes the local cache immediately.
*
* @param examId the Exam identifier */
@CacheEvict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl;

import static ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamRecordDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import java.util.ArrayList;
Expand All @@ -25,6 +26,7 @@
import org.mybatis.dynamic.sql.SqlCriterion;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
Expand Down Expand Up @@ -314,20 +316,17 @@ public Result<ExamRecord> updateFromQuizData(
throw new IllegalStateException("Exam is currently locked: " + examId);
}

final ExamRecord examRecord = new ExamRecord(
examId,
null, null,
quizData.id,
null, null, null, null, null, null, null, null,
updateId,
null, null,
Utils.getMillisecondsNow(),
quizData.getName(),
quizData.getStartTime(),
quizData.getEndTime(),
BooleanUtils.toIntegerObject(true));
UpdateDSL.updateWithMapper(examRecordMapper::update, examRecord)
.set(externalId).equalTo(quizData.id)
.set(lastupdate).equalTo(updateId)
.set(lastModified).equalTo(Utils.getMillisecondsNow())
.set(quizName).equalTo(quizData.getName())
.set(quizStartTime).equalTo(quizData.getStartTime())
.set(quizEndTime).equalTo(quizData.getEndTime())
.where(id, isEqualTo(oldRecord::getId))
.build()
.execute();

this.examRecordMapper.updateByPrimaryKeySelective(examRecord);
return this.examRecordMapper.selectByPrimaryKey(examId);
})
.onError(TransactionHandler::rollback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MockCourseAccessAPI(
"2019-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/"));
this.mockups.add(new QuizData(
"quiz7", institutionId, lmsSetupId, lmsType, "Demo Quiz 7 (MOCKUP)", "<p>Demo Quiz Mockup</p>",
"2018-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/"));
"2018-01-01T09:00:00Z", null, "http://lms.mockup.com/api/"));

this.mockups.add(new QuizData(
"quiz10", institutionId, lmsSetupId, lmsType, "Demo Quiz 10 (MOCKUP)",
Expand Down

0 comments on commit 32567a2

Please sign in to comment.