diff --git a/api.html b/api.html new file mode 100644 index 0000000..3b4b96d --- /dev/null +++ b/api.html @@ -0,0 +1,259 @@ +
All value and foreign checks are done on server side. On error the response javascript must match the following structure. The HTTP status code should match the standards.
+{
+ meta: {
+ status: 125462,
+ message: "Error message here."
+ },
+ data: {
+
+ }
+}The basic stucture of an successful request contains the status code 0 and the success message "Success". The HTTP status code must be 200 OK.
{
+ meta: {
+ status: 0,
+ message: "Success"
+ },
+ data: {
+
+ }
+}Base URI: /register.php
- `name`
+ - Unique user name chosen by user
+ - Must match regex ^[a-zA-Z0-9 ]{6,20}$
+
+| HTTP status codes | +Meta status code | +Meta message | +
|---|---|---|
| + | + | + |
{
+ name: "User chosen name",
+ uid: "fsdff3q4fFWEFFDSFfewf3rwSDF"
+}Base URI: /rename.php
- `name`
+ - New unique user name chosen by user
+ - Must match regex ^[a-zA-Z0-9 ]{6,20}$
+- `uid`
+ - User identifier string given within the registration proccess
+
+| HTTP status codes | +Meta status code | +Meta message | +
|---|---|---|
| + | + | + |
{
+ name: "User chosen name",
+ uid: "fsdff3q4fFWEFFDSFfewf3rwSDF"
+}Base URI: /categories.php
- `uid`
+ - User identifier string given within the registration proccess
+
+| HTTP status codes | +Meta status code | +Meta message | +
|---|---|---|
| + | + | + |
{
+ categories: [
+ {
+ id: 1,
+ name: "BWL"
+ },
+ {
+ id: 2,
+ name: "Mathematik"
+ },
+ ...
+ ]
+}Base URI: /highscores.php
This request has no parameters.
+| HTTP status codes | +Meta status code | +Meta message | +
|---|---|---|
| + | + | + |
{
+ score: 3253,
+ place: 122,
+ all: 321,
+ categories: [
+ {
+ id: 1,
+ name: "BWL",
+ score: 321,
+ place: 123
+ },
+ {
+ id: 2,
+ name: "Mathematik",
+ score: 1454,
+ place: 1
+ },
+ ...
+ ]
+}If no game has started yet, a new game will start. If a game already started, it will be resetted and restarted.
+Base URI: /start.php
- `uid`
+ - User identifier string given within the registration proccess
+- `length`
+ - *Optional*
+ - Amount of questions of the test
+ - If no value given, a default value will be used (one question per category)
+
+| HTTP status codes | +Meta status code | +Meta message | +
|---|---|---|
| + | + | + |
{
+ next: {
+ categoryID: 1,
+ categoryName: "BWL",
+ question: "What is the day after yesterday?",
+ anwsers: [
+ "yesterday",
+ "today",
+ "tommorrow",
+ "next week"
+ ]
+ }
+}Answer to the last question given by last /start.php or /answer.php reqest. The response contains the score you got with your answer in a score object. If the test contains a next question´, it is store in the next object. Else an end object contains your test results.
Base URI: /answer.php
- `uid`
+ - User identifier string given within the registration proccess
+- `answer`
+ - Selected answer index
+- `time`
+ - Time needed to answer the last question
+
+| HTTP status codes | +Meta status code | +Meta message | +
|---|---|---|
| + | + | + |
If there is a next question:
+{
+ results: {
+ correct: true,
+ score: 19,
+ correctPos: 3
+ }
+ next: {
+ categoryID: 1,
+ categoryName: "BWL",
+ question: "What is the day after yesterday?",
+ anwsers: [
+ "yesterday",
+ "today",
+ "tommorrow",
+ "next week"
+ ]
+ }
+}If it was the last test question:
+{
+ results: {
+ correct: true,
+ score: 19,
+ correctPos: 3
+ }
+ end: {
+ score: 2523,
+ time: 6535952
+ }
+}