Use OpenOlat endpoint to fetch exams

This commit is contained in:
Christian Schweizer 2024-04-29 15:03:34 +02:00
parent c0919ce0cf
commit fe31c129c0
2 changed files with 11 additions and 12 deletions

View file

@ -276,7 +276,7 @@ public class OlatLmsAPITemplate extends AbstractCachedCourseAccess implements Lm
final DateTime quizFromTime = (filterMap != null) ? filterMap.getQuizFromTime() : null; final DateTime quizFromTime = (filterMap != null) ? filterMap.getQuizFromTime() : null;
final long fromCutTime = (quizFromTime != null) ? Utils.toUnixTimeInSeconds(quizFromTime) : -1; final long fromCutTime = (quizFromTime != null) ? Utils.toUnixTimeInSeconds(quizFromTime) : -1;
String url = "/restapi/assessment_modes/seb?"; String url = "/restapi/repo/assessmentmodes?";
if (fromCutTime != -1) { if (fromCutTime != -1) {
url = String.format("%sdateFrom=%s&", url, fromCutTime); url = String.format("%sdateFrom=%s&", url, fromCutTime);
} }
@ -296,8 +296,8 @@ public class OlatLmsAPITemplate extends AbstractCachedCourseAccess implements Lm
lmsSetup.getLmsType(), lmsSetup.getLmsType(),
a.name, a.name,
a.description, a.description,
Utils.toDateTimeUTC(a.dateFrom), Utils.toDateTimeUTC(a.begin),
Utils.toDateTimeUTC(a.dateTo), Utils.toDateTimeUTC(a.end),
examUrl(a.repositoryEntryKey), examUrl(a.repositoryEntryKey),
new HashMap<String, String>()); new HashMap<String, String>());
}) })
@ -317,7 +317,7 @@ public class OlatLmsAPITemplate extends AbstractCachedCourseAccess implements Lm
private QuizData quizById(final OlatLmsRestTemplate restTemplate, final String id) { private QuizData quizById(final OlatLmsRestTemplate restTemplate, final String id) {
final LmsSetup lmsSetup = this.apiTemplateDataSupplier.getLmsSetup(); final LmsSetup lmsSetup = this.apiTemplateDataSupplier.getLmsSetup();
final String url = String.format("/restapi/assessment_modes/%s", id); final String url = String.format("/restapi/repo/assessmentmodes/%s", id);
final AssessmentData a = this.apiGet(restTemplate, url, AssessmentData.class); final AssessmentData a = this.apiGet(restTemplate, url, AssessmentData.class);
return new QuizData( return new QuizData(
String.format("%d", a.key), String.format("%d", a.key),
@ -326,8 +326,8 @@ public class OlatLmsAPITemplate extends AbstractCachedCourseAccess implements Lm
lmsSetup.getLmsType(), lmsSetup.getLmsType(),
a.name, a.name,
a.description, a.description,
Utils.toDateTimeUTC(a.dateFrom), Utils.toDateTimeUTC(a.begin),
Utils.toDateTimeUTC(a.dateTo), Utils.toDateTimeUTC(a.end),
examUrl(a.repositoryEntryKey), examUrl(a.repositoryEntryKey),
new HashMap<String, String>()); new HashMap<String, String>());
} }

View file

@ -8,6 +8,7 @@
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.olat; package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.olat;
import java.util.Date;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@ -20,9 +21,8 @@ public final class OlatLmsData {
/* /*
* OLAT API example: * OLAT API example:
* { * {
* "courseName": "course 1", * "begin": 1624420800000,
* "dateFrom": 1624420800000, * "end": 1624658400000,
* "dateTo": 1624658400000,
* "description": "", * "description": "",
* "key": 6356992, * "key": 6356992,
* repositoryEntryKey: 462324, * repositoryEntryKey: 462324,
@ -33,9 +33,8 @@ public final class OlatLmsData {
public long repositoryEntryKey; public long repositoryEntryKey;
public String name; public String name;
public String description; public String description;
public String courseName; public Long begin;
public long dateFrom; public Long end;
public long dateTo;
} }
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)