merge config keys with attached config history, minor GUI bug

This commit is contained in:
anhefti 2020-04-07 13:47:35 +02:00
parent 63f8358107
commit a8082471bc
9 changed files with 28 additions and 20 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
docs/images/lookup/list.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View file

@ -117,9 +117,6 @@ public final class Exam implements GrantEntity {
@JsonProperty(EXAM.ATTR_STATUS) @JsonProperty(EXAM.ATTR_STATUS)
public final ExamStatus status; public final ExamStatus status;
// @JsonProperty(EXAM.ATTR_LMS_SEB_RESTRICTION)
// public final Boolean lmsSebRestriction;
@JsonProperty(EXAM.ATTR_BROWSER_KEYS) @JsonProperty(EXAM.ATTR_BROWSER_KEYS)
public final String browserExamKeys; public final String browserExamKeys;
@ -145,7 +142,6 @@ public final class Exam implements GrantEntity {
@JsonProperty(EXAM.ATTR_OWNER) final String owner, @JsonProperty(EXAM.ATTR_OWNER) final String owner,
@JsonProperty(EXAM.ATTR_SUPPORTER) final Collection<String> supporter, @JsonProperty(EXAM.ATTR_SUPPORTER) final Collection<String> supporter,
@JsonProperty(EXAM.ATTR_STATUS) final ExamStatus status, @JsonProperty(EXAM.ATTR_STATUS) final ExamStatus status,
// @JsonProperty(EXAM.ATTR_LMS_SEB_RESTRICTION) final Boolean lmsSebRestriction,
@JsonProperty(EXAM.ATTR_BROWSER_KEYS) final String browserExamKeys, @JsonProperty(EXAM.ATTR_BROWSER_KEYS) final String browserExamKeys,
@JsonProperty(EXAM.ATTR_ACTIVE) final Boolean active, @JsonProperty(EXAM.ATTR_ACTIVE) final Boolean active,
@JsonProperty(EXAM.ATTR_LASTUPDATE) final String lastUpdate) { @JsonProperty(EXAM.ATTR_LASTUPDATE) final String lastUpdate) {
@ -163,7 +159,6 @@ public final class Exam implements GrantEntity {
this.quitPassword = quitPassword; this.quitPassword = quitPassword;
this.owner = owner; this.owner = owner;
this.status = (status != null) ? status : getStatusFromDate(startTime, endTime); this.status = (status != null) ? status : getStatusFromDate(startTime, endTime);
// this.lmsSebRestriction = (lmsSebRestriction != null) ? lmsSebRestriction : Boolean.FALSE;
this.browserExamKeys = browserExamKeys; this.browserExamKeys = browserExamKeys;
this.active = (active != null) ? active : Boolean.TRUE; this.active = (active != null) ? active : Boolean.TRUE;
this.lastUpdate = lastUpdate; this.lastUpdate = lastUpdate;
@ -216,7 +211,6 @@ public final class Exam implements GrantEntity {
this.quitPassword = null; this.quitPassword = null;
this.owner = null; this.owner = null;
this.status = (status != null) ? status : getStatusFromDate(this.startTime, this.endTime); this.status = (status != null) ? status : getStatusFromDate(this.startTime, this.endTime);
// this.lmsSebRestriction = null;
this.browserExamKeys = null; this.browserExamKeys = null;
this.active = null; this.active = null;
this.supporter = null; this.supporter = null;
@ -314,10 +308,6 @@ public final class Exam implements GrantEntity {
return this.status; return this.status;
} }
// public Boolean getLmsSebRestriction() {
// return this.lmsSebRestriction;
// }
public String getBrowserExamKeys() { public String getBrowserExamKeys() {
return this.browserExamKeys; return this.browserExamKeys;
} }
@ -357,8 +347,6 @@ public final class Exam implements GrantEntity {
builder.append(this.supporter); builder.append(this.supporter);
builder.append(", status="); builder.append(", status=");
builder.append(this.status); builder.append(this.status);
// builder.append(", lmsSebRestriction=");
// builder.append(this.lmsSebRestriction);
builder.append(", browserExamKeys="); builder.append(", browserExamKeys=");
builder.append(this.browserExamKeys); builder.append(this.browserExamKeys);
builder.append(", active="); builder.append(", active=");

View file

@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
import java.util.Collection; import java.util.Collection;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Group;
@ -83,6 +84,7 @@ interface CellFieldBuilderAdapter {
builder.parent, builder.parent,
new LocTextKey(ExamConfigurationService.ATTRIBUTE_LABEL_LOC_TEXT_PREFIX + attribute.name, new LocTextKey(ExamConfigurationService.ATTRIBUTE_LABEL_LOC_TEXT_PREFIX + attribute.name,
attribute.name)); attribute.name));
label.setData(RWT.MARKUP_ENABLED, true);
final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
switch (orientation.title) { switch (orientation.title) {

View file

@ -8,6 +8,7 @@
package ch.ethz.seb.sebserver.gui.service.examconfig.impl; package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@ -54,6 +55,7 @@ public class LabelBuilder implements InputFieldBuilder {
final Label label = this.widgetFactory.labelLocalized( final Label label = this.widgetFactory.labelLocalized(
parent, parent,
ExamConfigurationService.attributeNameLocKey(attribute)); ExamConfigurationService.attributeNameLocKey(attribute));
label.setData(RWT.MARKUP_ENABLED, true);
return new LabelField( return new LabelField(
attribute, attribute,

View file

@ -114,9 +114,9 @@ public final class PolyglotPageServiceImpl implements PolyglotPageService {
public void injectI18n(final Button button, final LocTextKey locTextKey, final LocTextKey locToolTipKey) { public void injectI18n(final Button button, final LocTextKey locTextKey, final LocTextKey locToolTipKey) {
final Consumer<Button> buttonFunction = b -> { final Consumer<Button> buttonFunction = b -> {
if (locTextKey != null) { if (locTextKey != null) {
b.setText(this.i18nSupport.getText(locTextKey)); b.setText(Utils.formatLineBreaks(this.i18nSupport.getText(locTextKey)));
} }
if (i18nSupport.hasText(locToolTipKey)) { if (this.i18nSupport.hasText(locToolTipKey)) {
b.setToolTipText(Utils.formatLineBreaks(this.i18nSupport.getText(locToolTipKey))); b.setToolTipText(Utils.formatLineBreaks(this.i18nSupport.getText(locToolTipKey)));
} }
}; };
@ -177,12 +177,13 @@ public final class PolyglotPageServiceImpl implements PolyglotPageService {
} }
@Override @Override
public void injectI18nTooltip(Control control, LocTextKey locTooltipKey) { public void injectI18nTooltip(final Control control, final LocTextKey locTooltipKey) {
if (locTooltipKey == null || control == null) { if (locTooltipKey == null || control == null) {
return; return;
} }
if (this.i18nSupport.hasText(locTooltipKey) && StringUtils.isNotBlank(this.i18nSupport.getText(locTooltipKey, ""))) { if (this.i18nSupport.hasText(locTooltipKey)
&& StringUtils.isNotBlank(this.i18nSupport.getText(locTooltipKey, ""))) {
control.setData(POLYGLOT_ITEM_TOOLTIP_DATA_KEY, locTooltipKey); control.setData(POLYGLOT_ITEM_TOOLTIP_DATA_KEY, locTooltipKey);
control.setToolTipText(Utils.formatLineBreaks(this.i18nSupport.getText(locTooltipKey))); control.setToolTipText(Utils.formatLineBreaks(this.i18nSupport.getText(locTooltipKey)));
} }

View file

@ -17,6 +17,8 @@ public interface SebRestrictionService {
/** Used as name prefix to store additional SEB restriction properties within AdditionalAttribute domain. */ /** Used as name prefix to store additional SEB restriction properties within AdditionalAttribute domain. */
String SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX = "sebRestrictionProp_"; String SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX = "sebRestrictionProp_";
String SEB_RESTRICTION_ADDITIONAL_PROPERTY_CONFIG_KEY = "config_key";
/** Get the SebRestriction properties for specified Exam. /** Get the SebRestriction properties for specified Exam.
* *
* @param exam the Exam * @param exam the Exam

View file

@ -11,8 +11,11 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -60,14 +63,24 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
} }
@Override @Override
@Transactional(readOnly = true) @Transactional
public Result<SebRestriction> getSebRestrictionFromExam(final Exam exam) { public Result<SebRestriction> getSebRestrictionFromExam(final Exam exam) {
return Result.tryCatch(() -> { return Result.tryCatch(() -> {
// generate the config keys from applied exam configurations // load the config keys from restriction and merge with new generated config keys
final Collection<String> configKeys = this.examConfigService final Set<String> configKeys = new HashSet<>();
final Collection<String> generatedKeys = this.examConfigService
.generateConfigKeys(exam.institutionId, exam.id) .generateConfigKeys(exam.institutionId, exam.id)
.getOrThrow(); .getOrThrow();
configKeys.addAll(generatedKeys);
if (generatedKeys != null && !generatedKeys.isEmpty()) {
configKeys.addAll(this.lmsAPIService
.getLmsAPITemplate(exam.lmsSetupId)
.flatMap(lmsTemplate -> lmsTemplate.getSebClientRestriction(exam))
.map(r -> r.configKeys)
.getOr(Collections.emptyList()));
}
// get the browser exam keys from exam record // get the browser exam keys from exam record
final Collection<String> browserExamKeys = new ArrayList<>(); final Collection<String> browserExamKeys = new ArrayList<>();
final String browserExamKeysString = exam.getBrowserExamKeys(); final String browserExamKeysString = exam.getBrowserExamKeys();
@ -137,7 +150,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
.stream() .stream()
.filter(attr -> attr.getName().startsWith(SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX)) .filter(attr -> attr.getName().startsWith(SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX))
.forEach(attr -> this.additionalAttributesDAO.delete(attr.getId())); .forEach(attr -> this.additionalAttributesDAO.delete(attr.getId()));
// create new once if needed // create new ones if needed
sebRestriction.additionalProperties sebRestriction.additionalProperties
.entrySet() .entrySet()
.stream() .stream()