From 41f0fe0f2b20bd6391f221d09d0bf7109703c6ee Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 23 Mar 2022 08:31:00 +0100 Subject: [PATCH] apply patch (from Carol Alexandru ) --- .../lms/impl/ans/AnsLmsAPITemplate.java | 22 +++++++------- .../servicelayer/lms/impl/ans/AnsLmsData.java | 29 +++++++++---------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java index 078227ac..721a2c18 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java @@ -59,7 +59,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.APITemplateDataSupplier import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPITemplate; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.AbstractCachedCourseAccess; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.AccessibilitySettingsData; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.SEBServerData; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.AssignmentData; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.UserData; @@ -252,10 +252,10 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms } private List getAssignments(final RestTemplate restTemplate) { - // NOTE: at the moment, seb_server_enabled cannot be set inside the Ans GUI, + // NOTE: at the moment, seb server cannot be enabled inside the Ans GUI, // only via the API, so we need to list all assignments. Maybe in the future, // we can only list those for which seb server has been enabled in Ans (like in OLAT): - //final String url = "/api/v2/search/assignments?query=seb_server_enabled:true"; + //final String url = "/api/v2/search/assignments?query=integrations.safe_exam_browser_server.enabled:true"; final String url = "/api/v2/search/assignments"; return this.apiGetList(restTemplate, url, new ParameterizedTypeReference>() { }); @@ -346,7 +346,7 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms private SEBRestriction getRestrictionForAssignmentId(final RestTemplate restTemplate, final String id) { final String url = String.format("/api/v2/assignments/%s", id); final AssignmentData assignment = this.apiGet(restTemplate, url, AssignmentData.class); - final AccessibilitySettingsData ts = assignment.accessibility_settings; + final SEBServerData ts = assignment.integrations.safe_exam_browser_server; return new SEBRestriction(Long.valueOf(id), ts.config_keys, null, new HashMap()); } @@ -354,24 +354,24 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms final SEBRestriction restriction) { final String url = String.format("/api/v2/assignments/%s", id); final AssignmentData assignment = getAssignmentById(restTemplate, id); - assignment.accessibility_settings.config_keys = new ArrayList<>(restriction.configKeys); - assignment.accessibility_settings.seb_server_enabled = true; + assignment.integrations.safe_exam_browser_server.config_keys = new ArrayList<>(restriction.configKeys); + assignment.integrations.safe_exam_browser_server.enabled = true; @SuppressWarnings("unused") final AssignmentData r = this.apiPatch(restTemplate, url, assignment, AssignmentData.class, AssignmentData.class); - final AccessibilitySettingsData ts = assignment.accessibility_settings; + final SEBServerData ts = assignment.integrations.safe_exam_browser_server; return new SEBRestriction(Long.valueOf(id), ts.config_keys, null, new HashMap()); } private SEBRestriction deleteRestrictionForAssignmentId(final RestTemplate restTemplate, final String id) { final String url = String.format("/api/v2/assignments/%s", id); final AssignmentData assignment = getAssignmentById(restTemplate, id); - assignment.accessibility_settings.config_keys = null; - assignment.accessibility_settings.seb_server_enabled = false; + assignment.integrations.safe_exam_browser_server.config_keys = null; + assignment.integrations.safe_exam_browser_server.enabled = false; @SuppressWarnings("unused") final AssignmentData r = this.apiPatch(restTemplate, url, assignment, AssignmentData.class, AssignmentData.class); - final AccessibilitySettingsData ts = assignment.accessibility_settings; + final SEBServerData ts = assignment.integrations.safe_exam_browser_server; return new SEBRestriction(Long.valueOf(id), ts.config_keys, null, new HashMap()); } @@ -406,7 +406,7 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms private List parseLinks(final String header) { // Extracts the individual links from a header that looks like this: - // ; rel="first",; rel="last" + // ; rel="first",; rel="last" final Stream links = Arrays.stream(header.split(",")); return links .map(s -> { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsData.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsData.java index b0a17dce..7645dcdd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsData.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsData.java @@ -15,12 +15,18 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; public final class AnsLmsData { @JsonIgnoreProperties(ignoreUnknown = true) - static final class AccessibilitySettingsData { + static final class SEBServerData { /* Ans API example: see nested in AssignmentData */ - public boolean seb_server_enabled; + public boolean enabled; public List config_keys; } + @JsonIgnoreProperties(ignoreUnknown = true) + static final class IntegrationsData { + /* Ans API example: see nested in AssignmentData */ + public SEBServerData safe_exam_browser_server; + } + @JsonIgnoreProperties(ignoreUnknown = true) static final class AssignmentData { /* @@ -37,19 +43,10 @@ public final class AnsLmsData { * "updated_at": "2021-08-17T03:41:56.747+02:00", * "trashed": false, * "start_url": "https://staging.ans.app/digital_test/assignments/78805/results/new", - * "accessibility_settings": { - * "attempts": 1, - * "restricted_access_to_other_pages": false, - * "notes": false, - * "spellchecker": false, - * "feedback": false, - * "forced_test_navigation": false, - * "cannot_reopen_question_groups": false, - * "seb_server_enabled": true, - * "config_keys": [ - * "9dd14ac828617116a1230c71b9a1aa9e06f43b32d9fa7db67f4fa113a6896e83e" - * ] - * }, + * "integrations": { + * "safe_exam_browser_server": { + * "enabled": false, + * "config_keys": [ "123" ] } } * "grades_settings": { * "grade_calculation": "formula", * "grade_formula": "1 + 9 * points / total", @@ -70,7 +67,7 @@ public final class AnsLmsData { public String start_at; public String end_at; public String start_url; - public AccessibilitySettingsData accessibility_settings; + public IntegrationsData integrations; } @JsonIgnoreProperties(ignoreUnknown = true)