From d4e20084373462333f9f3022c1e075a94c8745a1 Mon Sep 17 00:00:00 2001 From: Leander Date: Thu, 27 Apr 2017 18:58:39 +0200 Subject: [PATCH] new files added --- api.html | 259 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ login.php | 0 2 files changed, 259 insertions(+) create mode 100644 api.html create mode 100644 login.php diff --git a/api.html b/api.html new file mode 100644 index 0000000..3b4b96d --- /dev/null +++ b/api.html @@ -0,0 +1,259 @@ +

PHP Application Programming Interface

+

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: {
+		
+	}
+}
+

User Management

+

Registration

+

Base URI: /register.php

+

Parameters

+
- `name`
+	- Unique user name chosen by user
+	- Must match regex ^[a-zA-Z0-9 ]{6,20}$
+
+

Response

+
Errors
+ + + + + + + + + + + + + +
HTTP status codesMeta status codeMeta message
+
Success data object
+
{
+	name: "User chosen name",
+	uid: "fsdff3q4fFWEFFDSFfewf3rwSDF"
+}
+

User name changing

+

Base URI: /rename.php

+

Parameters

+
- `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
+
+

Response

+
Errors
+ + + + + + + + + + + + + +
HTTP status codesMeta status codeMeta message
+
Success data object
+
{
+	name: "User chosen name",
+	uid: "fsdff3q4fFWEFFDSFfewf3rwSDF"
+}
+

Data listing

+

List categories

+

Base URI: /categories.php

+

Parameters

+
- `uid`
+	- User identifier string given within the registration proccess
+
+

Response

+
Errors
+ + + + + + + + + + + + + +
HTTP status codesMeta status codeMeta message
+
Success data object
+
{
+	categories: [
+		{
+			id: 1,
+			name: "BWL"
+		},
+		{
+			id: 2,
+			name: "Mathematik"
+		},
+		...
+	]
+}
+

Show highscores

+

Base URI: /highscores.php

+

Parameters

+

This request has no parameters.

+

Response

+
Errors
+ + + + + + + + + + + + + +
HTTP status codesMeta status codeMeta message
+
Success data object
+
{
+	score: 3253,
+	place: 122,
+	all: 321,
+	categories: [
+		{
+			id: 1,
+			name: "BWL",
+			score: 321,
+			place: 123
+		},
+		{
+			id: 2,
+			name: "Mathematik",
+			score: 1454,
+			place: 1
+		},
+		...
+	]
+}
+

Game methods

+

Start game

+

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

+

Parameters

+
- `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)
+
+

Response

+
Errors
+ + + + + + + + + + + + + +
HTTP status codesMeta status codeMeta message
+
Success data object
+
{
+	next: {
+		categoryID: 1,
+		categoryName: "BWL",
+		question: "What is the day after yesterday?",
+		anwsers: [
+			"yesterday",
+			"today",
+			"tommorrow",
+			"next week"
+		]
+	}
+}
+

Answer a question

+

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

+

Parameters

+
- `uid`
+	- User identifier string given within the registration proccess
+- `answer`
+	- Selected answer index
+- `time`
+	- Time needed to answer the last question
+
+

Response

+
Errors
+ + + + + + + + + + + + + +
HTTP status codesMeta status codeMeta message
+
Success data object
+

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
+	}
+}
\ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..e69de29