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. */ /** This checks if there are write locks that are out of date and release such. */
void releaseAgedLocks(); 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 * @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 */ * @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) /** Marks the specified exam as updated (sets the last modified date to now)
* to notify exam content has changed. * to notify exam content has changed.
* This is automatically done also with normal save but not always an entire * 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 */ * @param examId The exam identifier */
void setModified(Long examId); 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. /** Marks the given exam by setting the last-update-time to current time.
* This provokes a cache update on distributed setup. * 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 */ * @param examId the Exam identifier */
@CacheEvict( @CacheEvict(

View file

@ -8,6 +8,7 @@
package ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl; 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 static org.mybatis.dynamic.sql.SqlBuilder.*;
import java.util.ArrayList; 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.SqlCriterion;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter; import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL; import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@ -314,20 +316,17 @@ public class ExamRecordDAO {
throw new IllegalStateException("Exam is currently locked: " + examId); throw new IllegalStateException("Exam is currently locked: " + examId);
} }
final ExamRecord examRecord = new ExamRecord( UpdateDSL.updateWithMapper(examRecordMapper::update, examRecord)
examId, .set(externalId).equalTo(quizData.id)
null, null, .set(lastupdate).equalTo(updateId)
quizData.id, .set(lastModified).equalTo(Utils.getMillisecondsNow())
null, null, null, null, null, null, null, null, .set(quizName).equalTo(quizData.getName())
updateId, .set(quizStartTime).equalTo(quizData.getStartTime())
null, null, .set(quizEndTime).equalTo(quizData.getEndTime())
Utils.getMillisecondsNow(), .where(id, isEqualTo(oldRecord::getId))
quizData.getName(), .build()
quizData.getStartTime(), .execute();
quizData.getEndTime(),
BooleanUtils.toIntegerObject(true));
this.examRecordMapper.updateByPrimaryKeySelective(examRecord);
return this.examRecordMapper.selectByPrimaryKey(examId); return this.examRecordMapper.selectByPrimaryKey(examId);
}) })
.onError(TransactionHandler::rollback); .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/")); "2019-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/"));
this.mockups.add(new QuizData( this.mockups.add(new QuizData(
"quiz7", institutionId, lmsSetupId, lmsType, "Demo Quiz 7 (MOCKUP)", "<p>Demo Quiz Mockup</p>", "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( this.mockups.add(new QuizData(
"quiz10", institutionId, lmsSetupId, lmsType, "Demo Quiz 10 (MOCKUP)", "quiz10", institutionId, lmsSetupId, lmsType, "Demo Quiz 10 (MOCKUP)",