Skip to content

Commit 368aa1f

Browse files
committed
Add "change-keycode" feature.
Also raise version number to 0.1.2.
1 parent 1848646 commit 368aa1f

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.1
1+
0.1.2

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
abitti-ktpapi (0.1.2) stable; urgency=medium
2+
3+
* Add "change-keycode".
4+
5+
-- Puavo Org <dev@opinsys.fi> Tue, 14 Dec 2021 12:45:16 +0200
6+
17
abitti-ktpapi (0.1.1) stable; urgency=medium
28

39
* Fix service startup in USB-stick case.

doc/API.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Following commands are supported
77
* `load-exam [filename] [keycodefile]`
88
* `start-new-exam [filename] [keycodefile]`
99
* `start-loaded-exam`
10-
* `change-keycode` (unimplemented)
10+
* `change-keycode`
1111
* `get-status`
1212
* `get-exam`
1313
* `get-script-info`
@@ -69,6 +69,15 @@ Starts exam already loaded to the server
6969
```json
7070
{"error":false,"start-exam":{"startTime":"2020-11-03T12:16:53.248Z"},"cmd":"start-new-exam"}
7171
```
72+
73+
### Change-keycode
74+
75+
* Input `change-keycode`
76+
* Output: JSON `{"error":true/false, "change-keycode":{...}, "cmd":"change-keycode"}`
77+
```json
78+
{"error":false, "change-keycode":{"keyCode":"1234","confirmationCode":"xx"}, "cmd":"change-keycode"}
79+
```
80+
7281
### Get-Status
7382
Returns status of the surveillance view on the server containing current keycode and students.
7483
* Input `get-status`

src/apiwatcher

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@ execute_startnewexam() {
208208
"start-exam:${output_start}"
209209
}
210210

211+
change_keycode() {
212+
local keycode_json
213+
if keycode_json=$(
214+
curl -s \
215+
-H 'Accept: application/json, text/javascript, /; q=0.01' \
216+
--compressed \
217+
-H 'Content-Type: application/json; charset=UTF-8' \
218+
-H 'X-Requested-With: XMLHttpRequest' \
219+
--data-raw '' \
220+
'http://localhost/single-security-code'); then
221+
write_output "change-keycode:${keycode_json}"
222+
else
223+
output_error 'Error in changing exam keycode'
224+
fi
225+
}
226+
211227
get_script_info() {
212228
script_version="$(cat "$script_version_file")"
213229
write_output "$(printf 'script-version:"%s"' "$script_version")"
@@ -254,6 +270,9 @@ case "$cmd_cmd" in
254270
ping)
255271
execute_ping
256272
;;
273+
change-keycode)
274+
change_keycode
275+
;;
257276
get-script-info)
258277
get_script_info
259278
;;

0 commit comments

Comments
 (0)