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.profile.WebServiceProfile;
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.AdditionalAttributeRecordMapper;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.AdditionalAttributeRecord;
@ -124,7 +125,7 @@ public class AdditionalAttributesDAOImpl implements AdditionalAttributesDAO {
type.name(),
entityId,
name,
value);
Utils.truncateText(value, 4000));
this.additionalAttributeRecordMapper
.updateByPrimaryKeySelective(rec);
@ -136,7 +137,7 @@ public class AdditionalAttributesDAOImpl implements AdditionalAttributesDAO {
type.name(),
entityId,
name,
value);
Utils.truncateText(value, 4000));
this.additionalAttributeRecordMapper
.insert(rec);

View file

@ -170,19 +170,21 @@ public class ExamSessionControlTask implements DisposableBean {
});
// update per LMS Setup
examToLMSMapping.entrySet().stream().forEach(updateEntry -> {
final Result<Set<String>> updateExamFromLMS = this.examUpdateHandler
.updateExamFromLMS(updateEntry.getKey(), updateEntry.getValue());
examToLMSMapping.entrySet()
.stream()
.forEach(updateEntry -> {
final Result<Set<String>> updateExamFromLMS = this.examUpdateHandler
.updateExamFromLMS(updateEntry.getKey(), updateEntry.getValue());
if (updateExamFromLMS.hasError()) {
log.error("Failed to update exams from LMS: ", updateExamFromLMS.getError());
} else {
final Set<String> failedExams = updateExamFromLMS.get();
if (!failedExams.isEmpty()) {
log.warn("Failed to update following exams from LMS: {}", failedExams);
}
}
});
if (updateExamFromLMS.hasError()) {
log.error("Failed to update exams from LMS: ", updateExamFromLMS.getError());
} else {
final Set<String> failedExams = updateExamFromLMS.get();
if (!failedExams.isEmpty()) {
log.warn("Failed to update following exams from LMS: {}", failedExams);
}
}
});
} catch (final Exception e) {
log.error("Unexpected error while update exams from LMS: ", e);

View file

@ -24,6 +24,7 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Lazy;
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.ExamStatus;
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);
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);
@ -282,7 +284,7 @@ class ExamUpdateHandler {
}
}
if (exam.isLmsAvailable()) {
if (exam.lmsAvailable == null || exam.isLmsAvailable()) {
this.examDAO.markLMSAvailability(quizId, false, updateId);
}
throw new RuntimeException("Not Available");