Moodle quiz recovery | additional attributes value size check

This commit is contained in:
anhefti 2022-05-25 10:11:49 +02:00
parent 7b582f95dc
commit b60d5ebf61
3 changed files with 21 additions and 16 deletions

View file

@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.api.EntityType;
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.gbl.util.Utils;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.AdditionalAttributeRecordDynamicSqlSupport; import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.AdditionalAttributeRecordDynamicSqlSupport;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.AdditionalAttributeRecordMapper; import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.AdditionalAttributeRecordMapper;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.AdditionalAttributeRecord; import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.AdditionalAttributeRecord;
@ -124,7 +125,7 @@ public class AdditionalAttributesDAOImpl implements AdditionalAttributesDAO {
type.name(), type.name(),
entityId, entityId,
name, name,
value); Utils.truncateText(value, 4000));
this.additionalAttributeRecordMapper this.additionalAttributeRecordMapper
.updateByPrimaryKeySelective(rec); .updateByPrimaryKeySelective(rec);
@ -136,7 +137,7 @@ public class AdditionalAttributesDAOImpl implements AdditionalAttributesDAO {
type.name(), type.name(),
entityId, entityId,
name, name,
value); Utils.truncateText(value, 4000));
this.additionalAttributeRecordMapper this.additionalAttributeRecordMapper
.insert(rec); .insert(rec);

View file

@ -170,7 +170,9 @@ public class ExamSessionControlTask implements DisposableBean {
}); });
// update per LMS Setup // update per LMS Setup
examToLMSMapping.entrySet().stream().forEach(updateEntry -> { examToLMSMapping.entrySet()
.stream()
.forEach(updateEntry -> {
final Result<Set<String>> updateExamFromLMS = this.examUpdateHandler final Result<Set<String>> updateExamFromLMS = this.examUpdateHandler
.updateExamFromLMS(updateEntry.getKey(), updateEntry.getValue()); .updateExamFromLMS(updateEntry.getKey(), updateEntry.getValue());

View file

@ -24,6 +24,7 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus; import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus;
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
@ -243,7 +244,8 @@ class ExamUpdateHandler {
log.info("Try to recover quiz data for Moodle quiz with internal identifier: {}", quizId); log.info("Try to recover quiz data for Moodle quiz with internal identifier: {}", quizId);
if (exam != null && exam.name != null) { if (exam != null && exam.name != null
&& !exam.name.startsWith(Constants.SQUARE_BRACE_OPEN.toString())) {
log.debug("Found formerName quiz name: {}", exam.name); log.debug("Found formerName quiz name: {}", exam.name);
@ -282,7 +284,7 @@ class ExamUpdateHandler {
} }
} }
if (exam.isLmsAvailable()) { if (exam.lmsAvailable == null || exam.isLmsAvailable()) {
this.examDAO.markLMSAvailability(quizId, false, updateId); this.examDAO.markLMSAvailability(quizId, false, updateId);
} }
throw new RuntimeException("Not Available"); throw new RuntimeException("Not Available");