diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamDeletePopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamDeletePopup.java index 5ec0af5d..c039a91d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamDeletePopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamDeletePopup.java @@ -16,6 +16,7 @@ import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; +import org.apache.commons.text.StringEscapeUtils; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; @@ -161,7 +162,7 @@ public class ExamDeletePopup { new ActionEvent(action), action.pageContext()); - final String examName = examToDelete.toName().name; + final String examName = StringEscapeUtils.escapeXml11(examToDelete.toName().name); final List dependencies = report.results.stream() .filter(key -> !key.equals(entityKey)) .collect(Collectors.toList()); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java index a980c810..fcac8ab8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/LmsSetupForm.java @@ -15,7 +15,6 @@ import java.util.function.BooleanSupplier; import java.util.function.Function; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.text.StringEscapeUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; @@ -482,7 +481,7 @@ public class LmsSetupForm implements TemplateComposer { case TOKEN_REQUEST: { throw new PageMessageException(new LocTextKey( "sebserver.lmssetup.action.test.tokenRequestError", - Utils.formatHTMLLinesForceEscaped(StringEscapeUtils.escapeHtml4(error.message)))); + Utils.formatHTMLLinesForceEscaped(Utils.escapeHTML_XML_EcmaScript(error.message)))); } case QUIZ_ACCESS_API_REQUEST: { if (error.message.contains("quizaccess_sebserver_get_exams")) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java index 9913deec..4ad20c14 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/Message.java @@ -46,7 +46,7 @@ public final class Message extends MessageBox { super.prepareOpen(); } catch (final IllegalArgumentException e) { // fallback on markup text error - super.setMessage(StringEscapeUtils.escapeHtml4(super.getMessage())); + super.setMessage(StringEscapeUtils.escapeXml11(super.getMessage())); super.prepareOpen(); } final GridLayout layout = (GridLayout) super.shell.getLayout(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java index 3bb589f0..458242bc 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java @@ -63,7 +63,7 @@ public class MockCourseAccessAPI implements CourseAccessAPI { "quiz1", institutionId, lmsSetupId, lmsType, "Demo Quiz 1 (MOCKUP)", "

Demo Quiz Mockup

", "2020-01-01T09:00:00Z", null, "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( - "quiz2", institutionId, lmsSetupId, lmsType, "Demo Quiz 2 (MOCKUP) äöüèÜÄÖ ?< ", + "quiz2 äöüèÜÄÖ ?<", institutionId, lmsSetupId, lmsType, "Demo Quiz 2 (MOCKUP) äöüèÜÄÖ ?< ", "

Demo Quiz Mockup

", "2020-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java index 76e24d79..d1028a6b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java @@ -431,10 +431,10 @@ public class MoodlePluginCourseAccess extends AbstractCachedCourseAccess impleme final String fromElement = String.valueOf(page * size); final LinkedMultiValueMap attributes = new LinkedMultiValueMap<>(); - // TODO clarify with Amr and Luca if this is OK - // and if it is possible to apply the nameCondition also the the course name (shortname) if (this.applyNameCriteria && StringUtils.isNotBlank(nameCondition)) { - sqlCondition = sqlCondition + " AND (m.name LIKE '" + + sqlCondition = sqlCondition + " AND (name LIKE '" + + Utils.toSQLWildcard(nameCondition) + + "' OR shortname LIKE '" + Utils.toSQLWildcard(nameCondition) + "')"; } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MooldePluginLmsAPITemplateFactory.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MooldePluginLmsAPITemplateFactory.java index 7b027a1e..f83dbecf 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MooldePluginLmsAPITemplateFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MooldePluginLmsAPITemplateFactory.java @@ -57,7 +57,7 @@ public class MooldePluginLmsAPITemplateFactory implements LmsAPITemplateFactory final ExamConfigurationValueService examConfigurationValueService, final ClientHttpRequestFactoryService clientHttpRequestFactoryService, @Value("${sebserver.webservice.lms.moodle.api.token.request.paths:}") final String alternativeTokenRequestPaths, - @Value("${sebserver.webservice.lms.moodle.fetch.applyNameCriteria:false}") final boolean applyNameCriteria) { + @Value("${sebserver.webservice.lms.moodle.fetch.applyNameCriteria:true}") final boolean applyNameCriteria) { this.jsonMapper = jsonMapper; this.cacheManager = cacheManager; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index 77baf353..f84127e7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -267,8 +267,7 @@ public class ExamSessionServiceImpl implements ExamSessionService { filterMap .putIfAbsent(Exam.FILTER_ATTR_ACTIVE, Constants.TRUE_STRING) - .putIfAbsent(Exam.FILTER_ATTR_STATUS, ExamStatus.RUNNING.name()) - .putIfAbsent(Exam.FILTER_ATTR_HIDE_MISSING, Constants.TRUE_STRING); + .putIfAbsent(Exam.FILTER_ATTR_STATUS, ExamStatus.RUNNING.name()); return this.examDAO.allMatching(filterMap, predicate) .map(col -> col.stream() diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java index 665e9400..033e7e5f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java @@ -410,11 +410,14 @@ class ExamUpdateHandler { .getLmsAPITemplate(lmsSetupId) .getOrThrow(); + final Exam exam = exams.get(quizId); if (!lmsTemplate.getType().features.contains(Features.COURSE_RECOVERY)) { + if (exam.lmsAvailable == null || exam.isLmsAvailable()) { + this.examDAO.markLMSAvailability(quizId, false, updateId); + } throw new UnsupportedOperationException("No Course Recovery"); } - final Exam exam = exams.get(quizId); final int attempts = Integer.parseInt(this.additionalAttributesDAO.getAdditionalAttribute( EntityType.EXAM, exam.id, diff --git a/src/main/resources/config/application-ws.properties b/src/main/resources/config/application-ws.properties index 5f0ced33..ef44f5c5 100644 --- a/src/main/resources/config/application-ws.properties +++ b/src/main/resources/config/application-ws.properties @@ -81,7 +81,7 @@ sebserver.webservice.lms.openedx.api.token.request.paths=/oauth2/access_token sebserver.webservice.lms.moodle.api.token.request.paths=/login/token.php sebserver.webservice.lms.moodle.prependShortCourseName=true sebserver.webservice.lms.moodle.fetch.cutoffdate.yearsBeforeNow=2 -sebserver.webservice.lms.moodle.fetch.applyNameCriteria=false +sebserver.webservice.lms.moodle.fetch.applyNameCriteria=true sebserver.webservice.lms.olat.sendAdditionalAttributesWithRestriction=false sebserver.webservice.lms.address.alias= sebserver.webservice.lms.datafetch.validity.seconds=600 diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java index 3076b492..5bd8c9b1 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java @@ -36,12 +36,12 @@ public class ExamAPITest extends AdministrationAPIIntegrationTester { sebAdminAccess, sebAdminAccess, "LmsSetupMock", - "quiz2", + "quiz2 äöüèÜÄÖ ?<", ExamType.MANAGED, "user5"); assertNotNull(exam); - assertEquals("quiz2", exam.getExternalId()); + assertEquals("quiz2 äöüèÜÄÖ ?<", exam.getExternalId()); // Note cannot set right collation on h2 assertEquals(ExamType.MANAGED, exam.getType()); assertFalse(exam.getSupporter().isEmpty());