WEB API
The API_ROOT is “/api”. See structures.go for the most relevant information.
API_ROOT/test
GET Requests
- Get a test according to a particular blueprint
URL Parameters
- questions : the number of questions specified for this test. The default value is 20.
- blueprint : the category indices from which to pull questions. These indices match the indices
received from
API_ROOT/questions/categories.
Returns
- Returns a JSON-encoded string of an array comprised of
Record:
type Record struct {
Question string
Reference string
Answer string
Category int
ID int
}
POST Requests
- Post the results of a test
- Accepts the JSON-encoded string of the ClientTest struct:
type ClientTest struct {
Records []ClientRecord
Score float32
Username string
}
type ClientRecord struct {
Record // ClientRecord is composed of Record
ClientAnswer string
AnsweredCorrectly bool
}
type Record struct {
Question string
Reference string
Answer string
Category int
ID int
}
API_ROOT/test/score
GET Requests
Returns the test scores for the specified user.
URL Parameters
- username : the username for which to request the test scores
Returns
- A JSON formatted string of the array of structs of
ClientTestitems:
type ClientTest struct {
Records []ClientRecord
Score float32
Username string
}
type ClientRecord struct {
Record // ClientRecord is composed of Record
ClientAnswer string
AnsweredCorrectly bool
}
type Record struct {
Question string
Reference string
Answer string
Category int
ID int
}
See structures.go for the most relevant structures.
Example response (5 questions, user scored 40%):
[{"Records":[{"Question":"windows releases: NT 6.0 = Windows Server [?]","Reference":"","Answer":"2008","Category":19,"ID":0,"ClientAnswer":"","AnsweredCorrectly":false},{"Question":"ether[0:?] what value will result in an ld1 bpf compiled filter","Reference":"","Answer":"1","Category":15,"ID":0,"ClientAnswer":"","AnsweredCorrectly":false},{"Question":"which flag produces slightly more verbose output: tcpdump -[?]","Reference":"","Answer":"v","Category":15,"ID":0,"ClientAnswer":"","AnsweredCorrectly":true},{"Question":"which flag specifies the size of the ICMP packets: (unix) ping -[?] 100","Reference":"","Answer":"s","Category":17,"ID":0,"ClientAnswer":"","AnsweredCorrectly":true},{"Question":"linux init: runlevel for extended multi user mode (networking and services started)","Reference":"","Answer":"3","Category":7,"ID":0,"ClientAnswer":"","AnsweredCorrectly":false}],"Score":40,"Username":"anon"}]
Formatted:
[
{
"Records": [
{
"Answer": "2008",
"AnsweredCorrectly": false,
"Category": 19,
"ClientAnswer": "",
"ID": 0,
"Question": "windows releases: NT 6.0 = Windows Server [?]",
"Reference": ""
},
{
"Answer": "1",
"AnsweredCorrectly": false,
"Category": 15,
"ClientAnswer": "",
"ID": 0,
"Question": "ether[0:?] what value will result in an ld1 bpf compiled filter",
"Reference": ""
},
{
"Answer": "v",
"AnsweredCorrectly": true,
"Category": 15,
"ClientAnswer": "",
"ID": 0,
"Question": "which flag produces slightly more verbose output: tcpdump -[?]",
"Reference": ""
},
{
"Answer": "s",
"AnsweredCorrectly": true,
"Category": 17,
"ClientAnswer": "",
"ID": 0,
"Question": "which flag specifies the size of the ICMP packets: (unix) ping -[?] 100",
"Reference": ""
},
{
"Answer": "3",
"AnsweredCorrectly": false,
"Category": 7,
"ClientAnswer": "",
"ID": 0,
"Question": "linux init: runlevel for extended multi user mode (networking and services started)",
"Reference": ""
}
],
"Score": 40,
"Username": "anon"
}
]
POST Requests
- No result
API_ROOT/questions/categories
GET Requests
- Returns the array of all categories known by the server
The array is of Category (found in structures.go).
POST Requests
- No result