Use OpenOlat endpoint to fetch exams

This commit is contained in:
Christian Schweizer 2024-04-30 10:15:08 +02:00
parent d4d12b4446
commit b1afde6755
2 changed files with 15 additions and 13 deletions

View file

@ -275,7 +275,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);
} }
@ -295,8 +295,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 - a.leadTime * 1000 * 60),
Utils.toDateTimeUTC(a.dateTo), Utils.toDateTimeUTC(a.end + a.followupTime * 1000 * 60),
examUrl(a.repositoryEntryKey), examUrl(a.repositoryEntryKey),
new HashMap<String, String>()); new HashMap<String, String>());
}) })
@ -316,7 +316,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),
@ -325,8 +325,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 - a.leadTime * 1000 * 60),
Utils.toDateTimeUTC(a.dateTo), Utils.toDateTimeUTC(a.end + a.followupTime * 1000 * 60),
examUrl(a.repositoryEntryKey), examUrl(a.repositoryEntryKey),
new HashMap<String, String>()); new HashMap<String, String>());
} }

View file

@ -20,22 +20,24 @@ 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,
* "name": "SEB test" * "name": "SEB test",
* "leadTime": 15,
* "followupTime", 5
* } * }
*/ */
public long key; public long key;
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; public long leadTime;
public long followupTime;
} }
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)