@gyldendalas/gyldendal-divine-api 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +287 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +455 -1
- package/dist/index.d.ts +455 -1
- package/dist/index.js +285 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -84,6 +84,16 @@ var BaseService = class {
|
|
|
84
84
|
const method = "DELETE";
|
|
85
85
|
return await this.callAsync({ url, body: null, method, headers, addAuthHeaders, timeout });
|
|
86
86
|
}
|
|
87
|
+
async patchAsync({
|
|
88
|
+
url,
|
|
89
|
+
headers,
|
|
90
|
+
addAuthHeaders = true,
|
|
91
|
+
body,
|
|
92
|
+
timeout
|
|
93
|
+
}) {
|
|
94
|
+
const method = "PATCH";
|
|
95
|
+
return await this.callAsync({ url, body, method, headers, addAuthHeaders, timeout });
|
|
96
|
+
}
|
|
87
97
|
async callAsync({
|
|
88
98
|
url,
|
|
89
99
|
body,
|
|
@@ -1022,6 +1032,279 @@ var AIBotService = class extends base_service_default {
|
|
|
1022
1032
|
}
|
|
1023
1033
|
};
|
|
1024
1034
|
|
|
1035
|
+
// src/services/quiz_service.ts
|
|
1036
|
+
var ApiErrors = /* @__PURE__ */ ((ApiErrors2) => {
|
|
1037
|
+
ApiErrors2["OVERVIEW_NOT_FOUND"] = "Quiz overview not found";
|
|
1038
|
+
ApiErrors2["NOT_FOUND"] = "Quiz not found";
|
|
1039
|
+
ApiErrors2["ARCHIVED"] = "This shared quiz session is archived";
|
|
1040
|
+
ApiErrors2["GALE_USER_DATA_CLIENT_ERROR"] = "Failed to fetch Gale user data: Client error";
|
|
1041
|
+
return ApiErrors2;
|
|
1042
|
+
})(ApiErrors || {});
|
|
1043
|
+
var QuizService = class extends base_service_default {
|
|
1044
|
+
discoverUrlPrefix() {
|
|
1045
|
+
switch (this.environment) {
|
|
1046
|
+
case "production":
|
|
1047
|
+
return "https://api.iquiz.dk/api";
|
|
1048
|
+
case "development":
|
|
1049
|
+
case "local":
|
|
1050
|
+
case "testing":
|
|
1051
|
+
return "https://galecms.test.tibalo.dk/api";
|
|
1052
|
+
case "test":
|
|
1053
|
+
return `https://localhost:3010/galeapi/api`;
|
|
1054
|
+
default:
|
|
1055
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
makeHeaders(extra) {
|
|
1059
|
+
const headers = new Headers();
|
|
1060
|
+
headers.append("Content-Type", "application/json");
|
|
1061
|
+
if (extra) {
|
|
1062
|
+
for (const [key, val] of Object.entries(extra)) {
|
|
1063
|
+
headers.append(key, val);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return headers;
|
|
1067
|
+
}
|
|
1068
|
+
// ─────────────────────────────────────────────────────────────
|
|
1069
|
+
// Legacy Gale quizzes
|
|
1070
|
+
// ─────────────────────────────────────────────────────────────
|
|
1071
|
+
async checkActiveSession({
|
|
1072
|
+
isbn,
|
|
1073
|
+
quizNumber,
|
|
1074
|
+
extraHeaders,
|
|
1075
|
+
timeout = 3e3
|
|
1076
|
+
}) {
|
|
1077
|
+
const url = `${this.getUrlPrefix()}/isbn/${isbn}/quiz/${quizNumber}`;
|
|
1078
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1079
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1080
|
+
return await res.json();
|
|
1081
|
+
}
|
|
1082
|
+
async startQuiz({
|
|
1083
|
+
isbn,
|
|
1084
|
+
quiz,
|
|
1085
|
+
shared,
|
|
1086
|
+
extraHeaders,
|
|
1087
|
+
timeout = 3e3
|
|
1088
|
+
}) {
|
|
1089
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quiz}` : `${this.getUrlPrefix()}/isbn/${isbn}/quiz/${quiz}`;
|
|
1090
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1091
|
+
const res = await this.postAsync({ url, headers, body: "{}", timeout });
|
|
1092
|
+
return await res.json();
|
|
1093
|
+
}
|
|
1094
|
+
async getProblems({
|
|
1095
|
+
isbn,
|
|
1096
|
+
quizUnitId,
|
|
1097
|
+
shared,
|
|
1098
|
+
extraHeaders,
|
|
1099
|
+
timeout = 3e3
|
|
1100
|
+
}) {
|
|
1101
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}` : `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}`;
|
|
1102
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1103
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1104
|
+
return await res.json();
|
|
1105
|
+
}
|
|
1106
|
+
async resetAnswer({
|
|
1107
|
+
isbn,
|
|
1108
|
+
quizUnitId,
|
|
1109
|
+
questionID,
|
|
1110
|
+
extraHeaders,
|
|
1111
|
+
timeout = 3e3
|
|
1112
|
+
}) {
|
|
1113
|
+
const url = `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}/question/${questionID}`;
|
|
1114
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1115
|
+
const res = await this.putAsync({
|
|
1116
|
+
url,
|
|
1117
|
+
headers,
|
|
1118
|
+
body: JSON.stringify({}),
|
|
1119
|
+
timeout
|
|
1120
|
+
});
|
|
1121
|
+
return await res.json();
|
|
1122
|
+
}
|
|
1123
|
+
async saveAnswer({
|
|
1124
|
+
isbn,
|
|
1125
|
+
quizUnitId,
|
|
1126
|
+
answer,
|
|
1127
|
+
shared,
|
|
1128
|
+
extraHeaders,
|
|
1129
|
+
timeout = 3e3
|
|
1130
|
+
}) {
|
|
1131
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}` : `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}`;
|
|
1132
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1133
|
+
const res = await this.putAsync({
|
|
1134
|
+
url,
|
|
1135
|
+
headers,
|
|
1136
|
+
body: JSON.stringify(answer),
|
|
1137
|
+
timeout
|
|
1138
|
+
});
|
|
1139
|
+
return await res.json();
|
|
1140
|
+
}
|
|
1141
|
+
async finishQuiz({
|
|
1142
|
+
isbn,
|
|
1143
|
+
quizUnitId,
|
|
1144
|
+
shared,
|
|
1145
|
+
extraHeaders,
|
|
1146
|
+
timeout = 3e3
|
|
1147
|
+
}) {
|
|
1148
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}/finish` : `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}`;
|
|
1149
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1150
|
+
const res = await this.postAsync({
|
|
1151
|
+
url,
|
|
1152
|
+
headers,
|
|
1153
|
+
body: JSON.stringify({}),
|
|
1154
|
+
timeout
|
|
1155
|
+
});
|
|
1156
|
+
return await res.json();
|
|
1157
|
+
}
|
|
1158
|
+
async getResults({
|
|
1159
|
+
isbn,
|
|
1160
|
+
quizUnitId,
|
|
1161
|
+
shared,
|
|
1162
|
+
extraHeaders,
|
|
1163
|
+
timeout = 3e3
|
|
1164
|
+
}) {
|
|
1165
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}/result` : `${this.getUrlPrefix()}/isbn/${isbn}/student/overview/${quizUnitId}`;
|
|
1166
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1167
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1168
|
+
return await res.json();
|
|
1169
|
+
}
|
|
1170
|
+
// ─────────────────────────────────────────────────────────────
|
|
1171
|
+
// Shared quizzes
|
|
1172
|
+
// ─────────────────────────────────────────────────────────────
|
|
1173
|
+
async createSharedQuiz({
|
|
1174
|
+
quizData,
|
|
1175
|
+
extraHeaders,
|
|
1176
|
+
timeout = 3e3
|
|
1177
|
+
}) {
|
|
1178
|
+
const url = `${this.getUrlPrefix()}/shared/quiz`;
|
|
1179
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1180
|
+
const res = await this.postAsync({
|
|
1181
|
+
url,
|
|
1182
|
+
headers,
|
|
1183
|
+
body: JSON.stringify(quizData),
|
|
1184
|
+
timeout
|
|
1185
|
+
});
|
|
1186
|
+
return await res.json();
|
|
1187
|
+
}
|
|
1188
|
+
async copyEditSharedQuiz({
|
|
1189
|
+
quizSessionId,
|
|
1190
|
+
quizData,
|
|
1191
|
+
action,
|
|
1192
|
+
extraHeaders,
|
|
1193
|
+
timeout = 3e3
|
|
1194
|
+
}) {
|
|
1195
|
+
const url = `${this.getUrlPrefix()}/shared/quiz/${quizSessionId}`;
|
|
1196
|
+
const method = action === "edit" ? "PUT" : "POST";
|
|
1197
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1198
|
+
const res = method === "PUT" ? await this.putAsync({
|
|
1199
|
+
url,
|
|
1200
|
+
headers,
|
|
1201
|
+
body: JSON.stringify(quizData),
|
|
1202
|
+
timeout
|
|
1203
|
+
}) : await this.postAsync({
|
|
1204
|
+
url,
|
|
1205
|
+
headers,
|
|
1206
|
+
body: JSON.stringify(quizData),
|
|
1207
|
+
timeout
|
|
1208
|
+
});
|
|
1209
|
+
return await res.json();
|
|
1210
|
+
}
|
|
1211
|
+
async getTeachersQuizProblems({
|
|
1212
|
+
quizSessionId,
|
|
1213
|
+
extraHeaders,
|
|
1214
|
+
timeout = 3e3
|
|
1215
|
+
}) {
|
|
1216
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}/problems`;
|
|
1217
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1218
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1219
|
+
return await res.json();
|
|
1220
|
+
}
|
|
1221
|
+
async getTeachersUnitOverview({
|
|
1222
|
+
quizSessionId,
|
|
1223
|
+
quizUnitId,
|
|
1224
|
+
extraHeaders,
|
|
1225
|
+
timeout = 3e3
|
|
1226
|
+
}) {
|
|
1227
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}/units/${quizUnitId}`;
|
|
1228
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1229
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1230
|
+
return await res.json();
|
|
1231
|
+
}
|
|
1232
|
+
async activateDeactivateQuestion({
|
|
1233
|
+
quizSessionId,
|
|
1234
|
+
questionId,
|
|
1235
|
+
activate,
|
|
1236
|
+
extraHeaders,
|
|
1237
|
+
timeout = 3e3
|
|
1238
|
+
}) {
|
|
1239
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quiz/${quizSessionId}/question/${questionId}`;
|
|
1240
|
+
const method = activate ? "PATCH" : "DELETE";
|
|
1241
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1242
|
+
const res = method === "PATCH" ? await this.patchAsync({
|
|
1243
|
+
url,
|
|
1244
|
+
headers,
|
|
1245
|
+
body: null,
|
|
1246
|
+
timeout
|
|
1247
|
+
}) : await this.deleteAsync({ url, headers, timeout });
|
|
1248
|
+
return await res.json();
|
|
1249
|
+
}
|
|
1250
|
+
async getTeachersQuizzes({
|
|
1251
|
+
extraHeaders,
|
|
1252
|
+
timeout = 3e3
|
|
1253
|
+
}) {
|
|
1254
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes`;
|
|
1255
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1256
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1257
|
+
return await res.json();
|
|
1258
|
+
}
|
|
1259
|
+
async getStudentsQuizzes({
|
|
1260
|
+
extraHeaders,
|
|
1261
|
+
timeout = 3e3
|
|
1262
|
+
}) {
|
|
1263
|
+
const url = `${this.getUrlPrefix()}/shared/student/quizzes`;
|
|
1264
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1265
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1266
|
+
return await res.json();
|
|
1267
|
+
}
|
|
1268
|
+
async getTeachersQuiz({
|
|
1269
|
+
quizSessionId,
|
|
1270
|
+
extraHeaders,
|
|
1271
|
+
timeout = 3e3
|
|
1272
|
+
}) {
|
|
1273
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}`;
|
|
1274
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1275
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1276
|
+
return await res.json();
|
|
1277
|
+
}
|
|
1278
|
+
async toggleArchiveQuiz({
|
|
1279
|
+
quizSessionId,
|
|
1280
|
+
archive,
|
|
1281
|
+
extraHeaders,
|
|
1282
|
+
timeout = 3e3
|
|
1283
|
+
}) {
|
|
1284
|
+
const url = `${this.getUrlPrefix()}/shared/quiz/${quizSessionId}`;
|
|
1285
|
+
const method = archive ? "DELETE" : "PATCH";
|
|
1286
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1287
|
+
const res = method === "DELETE" ? await this.deleteAsync({ url, headers, timeout }) : await this.postAsync({
|
|
1288
|
+
url,
|
|
1289
|
+
headers,
|
|
1290
|
+
body: null,
|
|
1291
|
+
timeout
|
|
1292
|
+
});
|
|
1293
|
+
return await res.json();
|
|
1294
|
+
}
|
|
1295
|
+
async deleteSharedQuizUnit({
|
|
1296
|
+
quizSessionId,
|
|
1297
|
+
quizUnitId,
|
|
1298
|
+
extraHeaders,
|
|
1299
|
+
timeout = 3e3
|
|
1300
|
+
}) {
|
|
1301
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}/units/${quizUnitId}`;
|
|
1302
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1303
|
+
const res = await this.deleteAsync({ url, headers, timeout });
|
|
1304
|
+
return await res.json();
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1025
1308
|
// src/services/writing_task_service.ts
|
|
1026
1309
|
var WritingTaskService = class extends base_service_default {
|
|
1027
1310
|
discoverUrlPrefix() {
|
|
@@ -1059,11 +1342,13 @@ var SolrProxyService = class extends base_service_default {
|
|
|
1059
1342
|
};
|
|
1060
1343
|
export {
|
|
1061
1344
|
AIBotService,
|
|
1345
|
+
ApiErrors,
|
|
1062
1346
|
CookieConsentLog,
|
|
1063
1347
|
HighlightResultType,
|
|
1064
1348
|
HighlightService,
|
|
1065
1349
|
PdfGeneratorService,
|
|
1066
1350
|
PollyService,
|
|
1351
|
+
QuizService,
|
|
1067
1352
|
SSMLSpeechSpeeds,
|
|
1068
1353
|
SolrProxyService,
|
|
1069
1354
|
TaggingService,
|