@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.cjs
CHANGED
|
@@ -21,11 +21,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AIBotService: () => AIBotService,
|
|
24
|
+
ApiErrors: () => ApiErrors,
|
|
24
25
|
CookieConsentLog: () => CookieConsentLog,
|
|
25
26
|
HighlightResultType: () => HighlightResultType,
|
|
26
27
|
HighlightService: () => HighlightService,
|
|
27
28
|
PdfGeneratorService: () => PdfGeneratorService,
|
|
28
29
|
PollyService: () => PollyService,
|
|
30
|
+
QuizService: () => QuizService,
|
|
29
31
|
SSMLSpeechSpeeds: () => SSMLSpeechSpeeds,
|
|
30
32
|
SolrProxyService: () => SolrProxyService,
|
|
31
33
|
TaggingService: () => TaggingService,
|
|
@@ -124,6 +126,16 @@ var BaseService = class {
|
|
|
124
126
|
const method = "DELETE";
|
|
125
127
|
return await this.callAsync({ url, body: null, method, headers, addAuthHeaders, timeout });
|
|
126
128
|
}
|
|
129
|
+
async patchAsync({
|
|
130
|
+
url,
|
|
131
|
+
headers,
|
|
132
|
+
addAuthHeaders = true,
|
|
133
|
+
body,
|
|
134
|
+
timeout
|
|
135
|
+
}) {
|
|
136
|
+
const method = "PATCH";
|
|
137
|
+
return await this.callAsync({ url, body, method, headers, addAuthHeaders, timeout });
|
|
138
|
+
}
|
|
127
139
|
async callAsync({
|
|
128
140
|
url,
|
|
129
141
|
body,
|
|
@@ -1062,6 +1074,279 @@ var AIBotService = class extends base_service_default {
|
|
|
1062
1074
|
}
|
|
1063
1075
|
};
|
|
1064
1076
|
|
|
1077
|
+
// src/services/quiz_service.ts
|
|
1078
|
+
var ApiErrors = /* @__PURE__ */ ((ApiErrors2) => {
|
|
1079
|
+
ApiErrors2["OVERVIEW_NOT_FOUND"] = "Quiz overview not found";
|
|
1080
|
+
ApiErrors2["NOT_FOUND"] = "Quiz not found";
|
|
1081
|
+
ApiErrors2["ARCHIVED"] = "This shared quiz session is archived";
|
|
1082
|
+
ApiErrors2["GALE_USER_DATA_CLIENT_ERROR"] = "Failed to fetch Gale user data: Client error";
|
|
1083
|
+
return ApiErrors2;
|
|
1084
|
+
})(ApiErrors || {});
|
|
1085
|
+
var QuizService = class extends base_service_default {
|
|
1086
|
+
discoverUrlPrefix() {
|
|
1087
|
+
switch (this.environment) {
|
|
1088
|
+
case "production":
|
|
1089
|
+
return "https://api.iquiz.dk/api";
|
|
1090
|
+
case "development":
|
|
1091
|
+
case "local":
|
|
1092
|
+
case "testing":
|
|
1093
|
+
return "https://galecms.test.tibalo.dk/api";
|
|
1094
|
+
case "test":
|
|
1095
|
+
return `https://localhost:3010/galeapi/api`;
|
|
1096
|
+
default:
|
|
1097
|
+
throw new Error(`Unknown environment: ${this.environment}`);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
makeHeaders(extra) {
|
|
1101
|
+
const headers = new Headers();
|
|
1102
|
+
headers.append("Content-Type", "application/json");
|
|
1103
|
+
if (extra) {
|
|
1104
|
+
for (const [key, val] of Object.entries(extra)) {
|
|
1105
|
+
headers.append(key, val);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return headers;
|
|
1109
|
+
}
|
|
1110
|
+
// ─────────────────────────────────────────────────────────────
|
|
1111
|
+
// Legacy Gale quizzes
|
|
1112
|
+
// ─────────────────────────────────────────────────────────────
|
|
1113
|
+
async checkActiveSession({
|
|
1114
|
+
isbn,
|
|
1115
|
+
quizNumber,
|
|
1116
|
+
extraHeaders,
|
|
1117
|
+
timeout = 3e3
|
|
1118
|
+
}) {
|
|
1119
|
+
const url = `${this.getUrlPrefix()}/isbn/${isbn}/quiz/${quizNumber}`;
|
|
1120
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1121
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1122
|
+
return await res.json();
|
|
1123
|
+
}
|
|
1124
|
+
async startQuiz({
|
|
1125
|
+
isbn,
|
|
1126
|
+
quiz,
|
|
1127
|
+
shared,
|
|
1128
|
+
extraHeaders,
|
|
1129
|
+
timeout = 3e3
|
|
1130
|
+
}) {
|
|
1131
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quiz}` : `${this.getUrlPrefix()}/isbn/${isbn}/quiz/${quiz}`;
|
|
1132
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1133
|
+
const res = await this.postAsync({ url, headers, body: "{}", timeout });
|
|
1134
|
+
return await res.json();
|
|
1135
|
+
}
|
|
1136
|
+
async getProblems({
|
|
1137
|
+
isbn,
|
|
1138
|
+
quizUnitId,
|
|
1139
|
+
shared,
|
|
1140
|
+
extraHeaders,
|
|
1141
|
+
timeout = 3e3
|
|
1142
|
+
}) {
|
|
1143
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}` : `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}`;
|
|
1144
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1145
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1146
|
+
return await res.json();
|
|
1147
|
+
}
|
|
1148
|
+
async resetAnswer({
|
|
1149
|
+
isbn,
|
|
1150
|
+
quizUnitId,
|
|
1151
|
+
questionID,
|
|
1152
|
+
extraHeaders,
|
|
1153
|
+
timeout = 3e3
|
|
1154
|
+
}) {
|
|
1155
|
+
const url = `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}/question/${questionID}`;
|
|
1156
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1157
|
+
const res = await this.putAsync({
|
|
1158
|
+
url,
|
|
1159
|
+
headers,
|
|
1160
|
+
body: JSON.stringify({}),
|
|
1161
|
+
timeout
|
|
1162
|
+
});
|
|
1163
|
+
return await res.json();
|
|
1164
|
+
}
|
|
1165
|
+
async saveAnswer({
|
|
1166
|
+
isbn,
|
|
1167
|
+
quizUnitId,
|
|
1168
|
+
answer,
|
|
1169
|
+
shared,
|
|
1170
|
+
extraHeaders,
|
|
1171
|
+
timeout = 3e3
|
|
1172
|
+
}) {
|
|
1173
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}` : `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}`;
|
|
1174
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1175
|
+
const res = await this.putAsync({
|
|
1176
|
+
url,
|
|
1177
|
+
headers,
|
|
1178
|
+
body: JSON.stringify(answer),
|
|
1179
|
+
timeout
|
|
1180
|
+
});
|
|
1181
|
+
return await res.json();
|
|
1182
|
+
}
|
|
1183
|
+
async finishQuiz({
|
|
1184
|
+
isbn,
|
|
1185
|
+
quizUnitId,
|
|
1186
|
+
shared,
|
|
1187
|
+
extraHeaders,
|
|
1188
|
+
timeout = 3e3
|
|
1189
|
+
}) {
|
|
1190
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}/finish` : `${this.getUrlPrefix()}/isbn/${isbn}/student/${quizUnitId}`;
|
|
1191
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1192
|
+
const res = await this.postAsync({
|
|
1193
|
+
url,
|
|
1194
|
+
headers,
|
|
1195
|
+
body: JSON.stringify({}),
|
|
1196
|
+
timeout
|
|
1197
|
+
});
|
|
1198
|
+
return await res.json();
|
|
1199
|
+
}
|
|
1200
|
+
async getResults({
|
|
1201
|
+
isbn,
|
|
1202
|
+
quizUnitId,
|
|
1203
|
+
shared,
|
|
1204
|
+
extraHeaders,
|
|
1205
|
+
timeout = 3e3
|
|
1206
|
+
}) {
|
|
1207
|
+
const url = shared ? `${this.getUrlPrefix()}/shared/student/${quizUnitId}/result` : `${this.getUrlPrefix()}/isbn/${isbn}/student/overview/${quizUnitId}`;
|
|
1208
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1209
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1210
|
+
return await res.json();
|
|
1211
|
+
}
|
|
1212
|
+
// ─────────────────────────────────────────────────────────────
|
|
1213
|
+
// Shared quizzes
|
|
1214
|
+
// ─────────────────────────────────────────────────────────────
|
|
1215
|
+
async createSharedQuiz({
|
|
1216
|
+
quizData,
|
|
1217
|
+
extraHeaders,
|
|
1218
|
+
timeout = 3e3
|
|
1219
|
+
}) {
|
|
1220
|
+
const url = `${this.getUrlPrefix()}/shared/quiz`;
|
|
1221
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1222
|
+
const res = await this.postAsync({
|
|
1223
|
+
url,
|
|
1224
|
+
headers,
|
|
1225
|
+
body: JSON.stringify(quizData),
|
|
1226
|
+
timeout
|
|
1227
|
+
});
|
|
1228
|
+
return await res.json();
|
|
1229
|
+
}
|
|
1230
|
+
async copyEditSharedQuiz({
|
|
1231
|
+
quizSessionId,
|
|
1232
|
+
quizData,
|
|
1233
|
+
action,
|
|
1234
|
+
extraHeaders,
|
|
1235
|
+
timeout = 3e3
|
|
1236
|
+
}) {
|
|
1237
|
+
const url = `${this.getUrlPrefix()}/shared/quiz/${quizSessionId}`;
|
|
1238
|
+
const method = action === "edit" ? "PUT" : "POST";
|
|
1239
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1240
|
+
const res = method === "PUT" ? await this.putAsync({
|
|
1241
|
+
url,
|
|
1242
|
+
headers,
|
|
1243
|
+
body: JSON.stringify(quizData),
|
|
1244
|
+
timeout
|
|
1245
|
+
}) : await this.postAsync({
|
|
1246
|
+
url,
|
|
1247
|
+
headers,
|
|
1248
|
+
body: JSON.stringify(quizData),
|
|
1249
|
+
timeout
|
|
1250
|
+
});
|
|
1251
|
+
return await res.json();
|
|
1252
|
+
}
|
|
1253
|
+
async getTeachersQuizProblems({
|
|
1254
|
+
quizSessionId,
|
|
1255
|
+
extraHeaders,
|
|
1256
|
+
timeout = 3e3
|
|
1257
|
+
}) {
|
|
1258
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}/problems`;
|
|
1259
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1260
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1261
|
+
return await res.json();
|
|
1262
|
+
}
|
|
1263
|
+
async getTeachersUnitOverview({
|
|
1264
|
+
quizSessionId,
|
|
1265
|
+
quizUnitId,
|
|
1266
|
+
extraHeaders,
|
|
1267
|
+
timeout = 3e3
|
|
1268
|
+
}) {
|
|
1269
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}/units/${quizUnitId}`;
|
|
1270
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1271
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1272
|
+
return await res.json();
|
|
1273
|
+
}
|
|
1274
|
+
async activateDeactivateQuestion({
|
|
1275
|
+
quizSessionId,
|
|
1276
|
+
questionId,
|
|
1277
|
+
activate,
|
|
1278
|
+
extraHeaders,
|
|
1279
|
+
timeout = 3e3
|
|
1280
|
+
}) {
|
|
1281
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quiz/${quizSessionId}/question/${questionId}`;
|
|
1282
|
+
const method = activate ? "PATCH" : "DELETE";
|
|
1283
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1284
|
+
const res = method === "PATCH" ? await this.patchAsync({
|
|
1285
|
+
url,
|
|
1286
|
+
headers,
|
|
1287
|
+
body: null,
|
|
1288
|
+
timeout
|
|
1289
|
+
}) : await this.deleteAsync({ url, headers, timeout });
|
|
1290
|
+
return await res.json();
|
|
1291
|
+
}
|
|
1292
|
+
async getTeachersQuizzes({
|
|
1293
|
+
extraHeaders,
|
|
1294
|
+
timeout = 3e3
|
|
1295
|
+
}) {
|
|
1296
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes`;
|
|
1297
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1298
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1299
|
+
return await res.json();
|
|
1300
|
+
}
|
|
1301
|
+
async getStudentsQuizzes({
|
|
1302
|
+
extraHeaders,
|
|
1303
|
+
timeout = 3e3
|
|
1304
|
+
}) {
|
|
1305
|
+
const url = `${this.getUrlPrefix()}/shared/student/quizzes`;
|
|
1306
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1307
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1308
|
+
return await res.json();
|
|
1309
|
+
}
|
|
1310
|
+
async getTeachersQuiz({
|
|
1311
|
+
quizSessionId,
|
|
1312
|
+
extraHeaders,
|
|
1313
|
+
timeout = 3e3
|
|
1314
|
+
}) {
|
|
1315
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}`;
|
|
1316
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1317
|
+
const res = await this.getAsync({ url, headers, timeout });
|
|
1318
|
+
return await res.json();
|
|
1319
|
+
}
|
|
1320
|
+
async toggleArchiveQuiz({
|
|
1321
|
+
quizSessionId,
|
|
1322
|
+
archive,
|
|
1323
|
+
extraHeaders,
|
|
1324
|
+
timeout = 3e3
|
|
1325
|
+
}) {
|
|
1326
|
+
const url = `${this.getUrlPrefix()}/shared/quiz/${quizSessionId}`;
|
|
1327
|
+
const method = archive ? "DELETE" : "PATCH";
|
|
1328
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1329
|
+
const res = method === "DELETE" ? await this.deleteAsync({ url, headers, timeout }) : await this.postAsync({
|
|
1330
|
+
url,
|
|
1331
|
+
headers,
|
|
1332
|
+
body: null,
|
|
1333
|
+
timeout
|
|
1334
|
+
});
|
|
1335
|
+
return await res.json();
|
|
1336
|
+
}
|
|
1337
|
+
async deleteSharedQuizUnit({
|
|
1338
|
+
quizSessionId,
|
|
1339
|
+
quizUnitId,
|
|
1340
|
+
extraHeaders,
|
|
1341
|
+
timeout = 3e3
|
|
1342
|
+
}) {
|
|
1343
|
+
const url = `${this.getUrlPrefix()}/shared/teacher/quizzes/${quizSessionId}/units/${quizUnitId}`;
|
|
1344
|
+
const headers = this.makeHeaders(extraHeaders);
|
|
1345
|
+
const res = await this.deleteAsync({ url, headers, timeout });
|
|
1346
|
+
return await res.json();
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1065
1350
|
// src/services/writing_task_service.ts
|
|
1066
1351
|
var WritingTaskService = class extends base_service_default {
|
|
1067
1352
|
discoverUrlPrefix() {
|
|
@@ -1100,11 +1385,13 @@ var SolrProxyService = class extends base_service_default {
|
|
|
1100
1385
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1101
1386
|
0 && (module.exports = {
|
|
1102
1387
|
AIBotService,
|
|
1388
|
+
ApiErrors,
|
|
1103
1389
|
CookieConsentLog,
|
|
1104
1390
|
HighlightResultType,
|
|
1105
1391
|
HighlightService,
|
|
1106
1392
|
PdfGeneratorService,
|
|
1107
1393
|
PollyService,
|
|
1394
|
+
QuizService,
|
|
1108
1395
|
SSMLSpeechSpeeds,
|
|
1109
1396
|
SolrProxyService,
|
|
1110
1397
|
TaggingService,
|