diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..14604be --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,11 @@ + + + + + postgresql + true + org.postgresql.Driver + jdbc:postgresql://lamp.wlan.hwr-berlin.de:5432/CSDB + + + \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 0000000..1962b9b --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Question.php b/Question.php index 4678270..1b9e7aa 100644 --- a/Question.php +++ b/Question.php @@ -35,6 +35,14 @@ class Question $this->category = $c; } + public static function get_next_question($db, $uid) { + $qid = $db->query('SELECT "Questions_ID" FROM "GamesQuestions" WHERE "Games_ID" = $1 LIMIT 1', array($uid))['data'][0]['ID']; + $question = new Question($db, $qid); + $db->query('DELETE FROM "GamesQuestions" WHERE "Games_ID" = $1 AND "Questions_ID" = $2', array($uid, $qid)); + $question_object = $question->get_question_object(); + return $question_object; + } + // Create the question message for API. function get_question_object() { $question_object = array( diff --git a/start.php b/start.php index ee5bbb7..4d338d1 100644 --- a/start.php +++ b/start.php @@ -45,6 +45,9 @@ } } + $next_question = Question::get_next_question($db, $uid); + $data = array('next' => $next_question); + $response = Database::create_response($data, $error, $values); - print $response; + print_r($response); ?> \ No newline at end of file