Merge branch 'dev-lms-ans' into dev-1.3
This commit is contained in:
commit
a7b587a8f2
2 changed files with 24 additions and 27 deletions
|
@ -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.LmsAPIService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPITemplate;
|
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.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.AssignmentData;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.UserData;
|
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<AssignmentData> getAssignments(final RestTemplate restTemplate) {
|
private List<AssignmentData> 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,
|
// 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):
|
// 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";
|
final String url = "/api/v2/search/assignments";
|
||||||
return this.apiGetList(restTemplate, url, new ParameterizedTypeReference<List<AssignmentData>>() {
|
return this.apiGetList(restTemplate, url, new ParameterizedTypeReference<List<AssignmentData>>() {
|
||||||
});
|
});
|
||||||
|
@ -346,7 +346,7 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms
|
||||||
private SEBRestriction getRestrictionForAssignmentId(final RestTemplate restTemplate, final String id) {
|
private SEBRestriction getRestrictionForAssignmentId(final RestTemplate restTemplate, final String id) {
|
||||||
final String url = String.format("/api/v2/assignments/%s", id);
|
final String url = String.format("/api/v2/assignments/%s", id);
|
||||||
final AssignmentData assignment = this.apiGet(restTemplate, url, AssignmentData.class);
|
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<String, String>());
|
return new SEBRestriction(Long.valueOf(id), ts.config_keys, null, new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,24 +354,24 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms
|
||||||
final SEBRestriction restriction) {
|
final SEBRestriction restriction) {
|
||||||
final String url = String.format("/api/v2/assignments/%s", id);
|
final String url = String.format("/api/v2/assignments/%s", id);
|
||||||
final AssignmentData assignment = getAssignmentById(restTemplate, id);
|
final AssignmentData assignment = getAssignmentById(restTemplate, id);
|
||||||
assignment.accessibility_settings.config_keys = new ArrayList<>(restriction.configKeys);
|
assignment.integrations.safe_exam_browser_server.config_keys = new ArrayList<>(restriction.configKeys);
|
||||||
assignment.accessibility_settings.seb_server_enabled = true;
|
assignment.integrations.safe_exam_browser_server.enabled = true;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
final AssignmentData r =
|
final AssignmentData r =
|
||||||
this.apiPatch(restTemplate, url, assignment, AssignmentData.class, AssignmentData.class);
|
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<String, String>());
|
return new SEBRestriction(Long.valueOf(id), ts.config_keys, null, new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private SEBRestriction deleteRestrictionForAssignmentId(final RestTemplate restTemplate, final String id) {
|
private SEBRestriction deleteRestrictionForAssignmentId(final RestTemplate restTemplate, final String id) {
|
||||||
final String url = String.format("/api/v2/assignments/%s", id);
|
final String url = String.format("/api/v2/assignments/%s", id);
|
||||||
final AssignmentData assignment = getAssignmentById(restTemplate, id);
|
final AssignmentData assignment = getAssignmentById(restTemplate, id);
|
||||||
assignment.accessibility_settings.config_keys = null;
|
assignment.integrations.safe_exam_browser_server.config_keys = null;
|
||||||
assignment.accessibility_settings.seb_server_enabled = false;
|
assignment.integrations.safe_exam_browser_server.enabled = false;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
final AssignmentData r =
|
final AssignmentData r =
|
||||||
this.apiPatch(restTemplate, url, assignment, AssignmentData.class, AssignmentData.class);
|
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<String, String>());
|
return new SEBRestriction(Long.valueOf(id), ts.config_keys, null, new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms
|
||||||
|
|
||||||
private List<PageLink> parseLinks(final String header) {
|
private List<PageLink> parseLinks(final String header) {
|
||||||
// Extracts the individual links from a header that looks like this:
|
// Extracts the individual links from a header that looks like this:
|
||||||
// <https://staging.ans.app/api/v2/search/assignments?query=seb_server_enabled%3Atrue&page=1&items=20>; rel="first",<https://staging.ans.app/api/v2/search/assignments?query=seb_server_enabled%3Atrue&page=1&items=20>; rel="last"
|
// <https://staging.ans.app/api/v2/search/assignments?page=1&items=20>; rel="first",<https://staging.ans.app/api/v2/search/assignments?page=1&items=20>; rel="last"
|
||||||
final Stream<String> links = Arrays.stream(header.split(","));
|
final Stream<String> links = Arrays.stream(header.split(","));
|
||||||
return links
|
return links
|
||||||
.map(s -> {
|
.map(s -> {
|
||||||
|
|
|
@ -15,12 +15,18 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
public final class AnsLmsData {
|
public final class AnsLmsData {
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
static final class AccessibilitySettingsData {
|
static final class SEBServerData {
|
||||||
/* Ans API example: see nested in AssignmentData */
|
/* Ans API example: see nested in AssignmentData */
|
||||||
public boolean seb_server_enabled;
|
public boolean enabled;
|
||||||
public List<String> config_keys;
|
public List<String> 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)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
static final class AssignmentData {
|
static final class AssignmentData {
|
||||||
/*
|
/*
|
||||||
|
@ -37,19 +43,10 @@ public final class AnsLmsData {
|
||||||
* "updated_at": "2021-08-17T03:41:56.747+02:00",
|
* "updated_at": "2021-08-17T03:41:56.747+02:00",
|
||||||
* "trashed": false,
|
* "trashed": false,
|
||||||
* "start_url": "https://staging.ans.app/digital_test/assignments/78805/results/new",
|
* "start_url": "https://staging.ans.app/digital_test/assignments/78805/results/new",
|
||||||
* "accessibility_settings": {
|
* "integrations": {
|
||||||
* "attempts": 1,
|
* "safe_exam_browser_server": {
|
||||||
* "restricted_access_to_other_pages": false,
|
* "enabled": false,
|
||||||
* "notes": false,
|
* "config_keys": [ "123" ] } }
|
||||||
* "spellchecker": false,
|
|
||||||
* "feedback": false,
|
|
||||||
* "forced_test_navigation": false,
|
|
||||||
* "cannot_reopen_question_groups": false,
|
|
||||||
* "seb_server_enabled": true,
|
|
||||||
* "config_keys": [
|
|
||||||
* "9dd14ac828617116a1230c71b9a1aa9e06f43b32d9fa7db67f4fa113a6896e83e"
|
|
||||||
* ]
|
|
||||||
* },
|
|
||||||
* "grades_settings": {
|
* "grades_settings": {
|
||||||
* "grade_calculation": "formula",
|
* "grade_calculation": "formula",
|
||||||
* "grade_formula": "1 + 9 * points / total",
|
* "grade_formula": "1 + 9 * points / total",
|
||||||
|
@ -70,7 +67,7 @@ public final class AnsLmsData {
|
||||||
public String start_at;
|
public String start_at;
|
||||||
public String end_at;
|
public String end_at;
|
||||||
public String start_url;
|
public String start_url;
|
||||||
public AccessibilitySettingsData accessibility_settings;
|
public IntegrationsData integrations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
|
Loading…
Reference in a new issue