SEBSERV-449 fixes

This commit is contained in:
anhefti 2023-06-08 15:05:41 +02:00
parent 0d650f9fb6
commit b2f7337019
8 changed files with 51 additions and 31 deletions

View file

@ -451,7 +451,7 @@ public class QuizLookupList implements TemplateComposer {
} }
} }
private boolean showingFetchNote = false; private Composite warningPanel = null;
private void handelPageReload( private void handelPageReload(
final Composite notePanel, final Composite notePanel,
@ -459,29 +459,28 @@ public class QuizLookupList implements TemplateComposer {
if (table.isComplete()) { if (table.isComplete()) {
PageService.clearComposite(notePanel); PageService.clearComposite(notePanel);
this.showingFetchNote = false; if (this.warningPanel != null) {
} else { this.warningPanel.dispose();
if (!this.showingFetchNote) {
final Composite warningPanel = this.widgetFactory.createWarningPanel(notePanel, 15, true);
GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, true);
gridData.heightHint = 28;
gridData.widthHint = 25;
gridData.verticalIndent = 5;
this.widgetFactory.imageButton(
ImageIcon.SWITCH,
warningPanel,
TEXT_FETCH_NOTE_TOOLTIP,
event -> table.applyFilter());
final Label text = new Label(warningPanel, SWT.NONE);
text.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
text.setText(this.pageService.getI18nSupport().getText(TEXT_FETCH_NOTE));
gridData = new GridData(SWT.LEFT, SWT.FILL, true, true);
gridData.heightHint = 16;
text.setLayoutData(gridData);
this.showingFetchNote = true;
} }
this.warningPanel = null;
} else {
if (this.warningPanel != null && !this.warningPanel.isDisposed()) {
this.warningPanel.dispose();
}
this.warningPanel = this.widgetFactory.createWarningPanel(notePanel, 15, true);
this.widgetFactory.imageButton(
ImageIcon.SWITCH,
this.warningPanel,
TEXT_FETCH_NOTE_TOOLTIP,
event -> table.applyFilter());
final Label text = new Label(this.warningPanel, SWT.NONE);
text.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
text.setText(this.pageService.getI18nSupport().getText(TEXT_FETCH_NOTE));
final GridData gridData = new GridData(SWT.LEFT, SWT.FILL, true, true);
gridData.heightHint = 28;
text.setLayoutData(gridData);
} }
notePanel.getParent().layout(true, true); notePanel.getParent().layout(true, true);
} }

View file

@ -154,7 +154,7 @@ public class MonitoringRunningExam implements TemplateComposer {
pageContext.getParent(), pageContext.getParent(),
new LocTextKey( new LocTextKey(
"sebserver.monitoring.exam", "sebserver.monitoring.exam",
StringEscapeUtils.escapeHtml4(exam.name))); StringEscapeUtils.escapeXml11(exam.name)));
final Composite tablePane = new Composite(content, SWT.NONE); final Composite tablePane = new Composite(content, SWT.NONE);
tablePane.setLayout(new GridLayout()); tablePane.setLayout(new GridLayout());

View file

@ -270,7 +270,16 @@ public final class PolyglotPageServiceImpl implements PolyglotPageService {
return label -> { return label -> {
if (locTextKey != null) { if (locTextKey != null) {
label.setText(i18nSupport.getText(locTextKey)); try {
label.setText(i18nSupport.getText(locTextKey));
} catch (final Exception e) {
label.setData(RWT.MARKUP_ENABLED, false);
try {
label.setText(i18nSupport.getText(locTextKey));
} catch (final Exception ee) {
label.setText(locTextKey.name);
}
}
} }
if (i18nSupport.hasText(locToolTipKey)) { if (i18nSupport.hasText(locToolTipKey)) {
label.setToolTipText(Utils.formatLineBreaks(i18nSupport.getText(locToolTipKey))); label.setToolTipText(Utils.formatLineBreaks(i18nSupport.getText(locToolTipKey)));

View file

@ -63,7 +63,8 @@ public class MockCourseAccessAPI implements CourseAccessAPI {
"quiz1", institutionId, lmsSetupId, lmsType, "Demo Quiz 1 (MOCKUP)", "<p>Demo Quiz Mockup</p>", "quiz1", institutionId, lmsSetupId, lmsType, "Demo Quiz 1 (MOCKUP)", "<p>Demo Quiz Mockup</p>",
"2020-01-01T09:00:00Z", null, "http://lms.mockup.com/api/")); "2020-01-01T09:00:00Z", null, "http://lms.mockup.com/api/"));
this.mockups.add(new QuizData( this.mockups.add(new QuizData(
"quiz2", institutionId, lmsSetupId, lmsType, "Demo Quiz 2 (MOCKUP)", "<p>Demo Quiz Mockup</p>", "quiz2", institutionId, lmsSetupId, lmsType, "Demo Quiz 2 (MOCKUP) äöüèÜÄÖ ?< ",
"<p>Demo Quiz Mockup</p>",
"2020-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); "2020-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/"));
this.mockups.add(new QuizData( this.mockups.add(new QuizData(
"quiz3", institutionId, lmsSetupId, lmsType, "Demo Quiz 3 (MOCKUP)", "<p>Demo Quiz Mockup</p>", "quiz3", institutionId, lmsSetupId, lmsType, "Demo Quiz 3 (MOCKUP)", "<p>Demo Quiz Mockup</p>",

View file

@ -93,6 +93,7 @@ public class MoodlePluginCourseAccess extends AbstractCachedCourseAccess impleme
private final int pageSize; private final int pageSize;
private final int maxSize; private final int maxSize;
private final int cutoffTimeOffset; private final int cutoffTimeOffset;
private final boolean applyNameCriteria;
private MoodleAPIRestTemplate restTemplate; private MoodleAPIRestTemplate restTemplate;
@ -101,11 +102,13 @@ public class MoodlePluginCourseAccess extends AbstractCachedCourseAccess impleme
final AsyncService asyncService, final AsyncService asyncService,
final MoodleRestTemplateFactory restTemplateFactory, final MoodleRestTemplateFactory restTemplateFactory,
final CacheManager cacheManager, final CacheManager cacheManager,
final Environment environment) { final Environment environment,
final boolean applyNameCriteria) {
super(cacheManager); super(cacheManager);
this.jsonMapper = jsonMapper; this.jsonMapper = jsonMapper;
this.restTemplateFactory = restTemplateFactory; this.restTemplateFactory = restTemplateFactory;
this.applyNameCriteria = applyNameCriteria;
this.prependShortCourseName = BooleanUtils.toBoolean(environment.getProperty( this.prependShortCourseName = BooleanUtils.toBoolean(environment.getProperty(
"sebserver.webservice.lms.moodle.prependShortCourseName", "sebserver.webservice.lms.moodle.prependShortCourseName",
@ -433,7 +436,9 @@ public class MoodlePluginCourseAccess extends AbstractCachedCourseAccess impleme
final String fromElement = String.valueOf(page * size); final String fromElement = String.valueOf(page * size);
final LinkedMultiValueMap<String, String> attributes = new LinkedMultiValueMap<>(); final LinkedMultiValueMap<String, String> attributes = new LinkedMultiValueMap<>();
if (StringUtils.isNotBlank(nameCondition)) { // 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 (m.name LIKE '" +
Utils.toSQLWildcard(nameCondition) + Utils.toSQLWildcard(nameCondition) +
"')"; "')";

View file

@ -46,6 +46,7 @@ public class MooldePluginLmsAPITemplateFactory implements LmsAPITemplateFactory
private final ExamConfigurationValueService examConfigurationValueService; private final ExamConfigurationValueService examConfigurationValueService;
private final ClientHttpRequestFactoryService clientHttpRequestFactoryService; private final ClientHttpRequestFactoryService clientHttpRequestFactoryService;
private final String[] alternativeTokenRequestPaths; private final String[] alternativeTokenRequestPaths;
private final boolean applyNameCriteria;
protected MooldePluginLmsAPITemplateFactory( protected MooldePluginLmsAPITemplateFactory(
final JSONMapper jsonMapper, final JSONMapper jsonMapper,
@ -55,7 +56,8 @@ public class MooldePluginLmsAPITemplateFactory implements LmsAPITemplateFactory
final ClientCredentialService clientCredentialService, final ClientCredentialService clientCredentialService,
final ExamConfigurationValueService examConfigurationValueService, final ExamConfigurationValueService examConfigurationValueService,
final ClientHttpRequestFactoryService clientHttpRequestFactoryService, final ClientHttpRequestFactoryService clientHttpRequestFactoryService,
@Value("${sebserver.webservice.lms.moodle.api.token.request.paths:}") final String alternativeTokenRequestPaths) { @Value("${sebserver.webservice.lms.moodle.api.token.request.paths:}") final String alternativeTokenRequestPaths,
@Value("${sebserver.webservice.lms.moodle.fetch.applyNameCriteria:false}") final boolean applyNameCriteria) {
this.jsonMapper = jsonMapper; this.jsonMapper = jsonMapper;
this.cacheManager = cacheManager; this.cacheManager = cacheManager;
@ -67,6 +69,7 @@ public class MooldePluginLmsAPITemplateFactory implements LmsAPITemplateFactory
this.alternativeTokenRequestPaths = (alternativeTokenRequestPaths != null) this.alternativeTokenRequestPaths = (alternativeTokenRequestPaths != null)
? StringUtils.split(alternativeTokenRequestPaths, Constants.LIST_SEPARATOR) ? StringUtils.split(alternativeTokenRequestPaths, Constants.LIST_SEPARATOR)
: null; : null;
this.applyNameCriteria = applyNameCriteria;
} }
@Override @Override
@ -90,7 +93,8 @@ public class MooldePluginLmsAPITemplateFactory implements LmsAPITemplateFactory
this.asyncService, this.asyncService,
moodleRestTemplateFactory, moodleRestTemplateFactory,
this.cacheManager, this.cacheManager,
this.environment); this.environment,
this.applyNameCriteria);
final MoodlePluginCourseRestriction moodlePluginCourseRestriction = new MoodlePluginCourseRestriction( final MoodlePluginCourseRestriction moodlePluginCourseRestriction = new MoodlePluginCourseRestriction(
this.jsonMapper, this.jsonMapper,

View file

@ -81,6 +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.api.token.request.paths=/login/token.php
sebserver.webservice.lms.moodle.prependShortCourseName=true sebserver.webservice.lms.moodle.prependShortCourseName=true
sebserver.webservice.lms.moodle.fetch.cutoffdate.yearsBeforeNow=2 sebserver.webservice.lms.moodle.fetch.cutoffdate.yearsBeforeNow=2
sebserver.webservice.lms.moodle.fetch.applyNameCriteria=false
sebserver.webservice.lms.olat.sendAdditionalAttributesWithRestriction=false sebserver.webservice.lms.olat.sendAdditionalAttributesWithRestriction=false
sebserver.webservice.lms.address.alias= sebserver.webservice.lms.address.alias=
sebserver.webservice.lms.datafetch.validity.seconds=600 sebserver.webservice.lms.datafetch.validity.seconds=600

View file

@ -324,7 +324,8 @@ public class MoodlePluginCourseAccessTest {
asyncService, asyncService,
moodleMockupRestTemplateFactory, moodleMockupRestTemplateFactory,
new NoOpCacheManager(), new NoOpCacheManager(),
mockEnvironment); mockEnvironment,
false);
} }
} }