SEBSERV-494 fixed

This commit is contained in:
anhefti 2023-11-29 19:33:24 +01:00
parent e426a7a6e2
commit 32567a220a
3 changed files with 16 additions and 17 deletions

View file

@ -169,7 +169,7 @@ public interface ExamDAO extends ActivatableEntityDAO<Exam, Exam>, BulkActionSup
/** 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 */
@ -178,7 +178,7 @@ public interface ExamDAO extends ActivatableEntityDAO<Exam, Exam>, BulkActionSup
/** 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);
@ -212,7 +212,7 @@ public interface ExamDAO extends ActivatableEntityDAO<Exam, Exam>, BulkActionSup
/** 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(

View file

@ -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;
@ -25,6 +26,7 @@ import org.mybatis.dynamic.sql.SqlBuilder;
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;
@ -314,20 +316,17 @@ public class ExamRecordDAO {
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);

View file

@ -85,7 +85,7 @@ public class MockCourseAccessAPI implements CourseAccessAPI {
"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)",