Newer
Older
export async function sendTestEntryTaskQcmAPI(
fetch: fetchType,
code: string,
rid: string | null,
user_id: number | null,
test_id: number,
study_id: number,
test_group_id: number,
test_question_id: number,
response_time: number,
selected_id: number
) {
const response = await fetch(`/api/tests/entries`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code,
rid,
user_id,
test_id,
study_id,
entry_task: {
test_group_id,
test_question_id,
response_time,
entry_task_qcm: {
selected_id
}
}
})
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
export async function sendTestEntryTaskGapfillAPI(
fetch: fetchType,
code: string,
rid: string | null,
user_id: number | null,
test_id: number,
test_group_id: number,
study_id: number,
test_question_id: number,
response_time: number,
text: string
) {
const response = await fetch(`/api/tests/entries`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code,
rid,
user_id,
test_id,
study_id,
entry_task: {
test_group_id,
test_question_id,
response_time,
entry_task_gapfill: {
text
}
}
})
});
return response.ok;
}
export async function sendTestEntryTypingAPI(
fetch: fetchType,
code: string,
rid: string | null,
user_id: number | null,
test_id: number,
study_id: number,
position: number,
downtime: number,
uptime: number,
key_code: number,
key_value: string
) {
const response = await fetch(`/api/tests/entries`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code,
rid,
user_id,
test_id,
study_id,
entry_typing: {
position,
downtime,
uptime,
key_code,
key_value
}
})
});
return response.ok;
}
export async function getTestEntriesScoreAPI(
fetch: fetchType,
rid: string
): Promise<number | null> {
const response = await fetch(`/api/tests/entries/score/${rid}`);
if (!response.ok) return null;
const scoreText = await response.text();
const score = parseFloat(scoreText);
if (isNaN(score)) return null;
return score;
}
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
export async function createTestTypingAPI(
fetch: fetchType,
title: string,
explanation: string,
text: string,
repeat: number,
duration: number
) {
const response = await fetch(`/api/tests`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title,
test_typing: {
explanations: explanation,
text,
repeat,
duration
}
})
});
if (!response.ok) return null;
const test = await response.json();
return test.id;
}
export async function updateTestTypingAPI(
fetch: fetchType,
id: number,
title: string,
explanation: string,
text: string,
repeat: number,
duration: number
): Promise<boolean> {
const response = await fetch(`/api/tests/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title,
test_typing: {
explanations: explanation,
text,
repeat,
duration
}
})
});
return response.ok;
}
export async function deleteTestAPI(fetch: fetchType, id: number): Promise<boolean> {
const response = await fetch(`/api/tests/${id}`, {
method: 'DELETE'
});
if (!response.ok) return false;
return true;
}
export async function getTestAPI(fetch: fetchType, id: number): Promise<any> {
const response = await fetch(`/api/tests/${id}`);
if (!response.ok) return null;
const test = await response.json();
return test;
}
export async function getTestGroupsAPI(fetch: fetchType): Promise<any> {
const response = await fetch(`/api/tests/groups`);
if (!response.ok) return null;
const groups = await response.json();
return groups;
}
export async function getTestTaskGroupAPI(fetch: fetchType, id: number): Promise<any> {
const response = await fetch(`/api/tests/groups/${id}`);
if (!response.ok) return null;
const group = await response.json();
return group;
}
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
export async function getTestQuestionsAPI(fetch: fetchType): Promise<any> {
const response = await fetch(`/api/tests/questions`);
if (!response.ok) return null;
const questions = await response.json();
return questions;
}
export async function createTestTaskAPI(
fetch: fetchType,
title: string,
groups: number[]
): Promise<number | null> {
const response = await fetch(`/api/tests`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title,
test_task: {
groups
}
})
});
if (!response.ok) return null;
const test = await response.json();
return test.id;
}
export async function updateTestTaskAPI(
fetch: fetchType,
id: number,
title: string,
groups: number[]
): Promise<boolean> {
const response = await fetch(`/api/tests/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title,
test_task: {
groups
}
})
});
return response.ok;
}
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
export async function createTestTaskGroupAPI(
fetch: fetchType,
title: string,
demo: boolean,
randomize: boolean,
questions: number[]
): Promise<number | null> {
const response = await fetch(`/api/tests/groups`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title,
demo,
randomize,
questions
})
});
if (!response.ok) return null;
const group = await response.json();
return group.id;
}
export async function updateTestTaskGroupAPI(
fetch: fetchType,
id: number,
title: string,
demo: boolean,
randomize: boolean,
questions: number[]
): Promise<boolean> {
const response = await fetch(`/api/tests/groups/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title,
demo,
randomize,
questions
})
});
return response.ok;
}