T201704041149
This commit is contained in:
26
answer.php
26
answer.php
@@ -33,17 +33,29 @@
|
|||||||
$error = 13102;
|
$error = 13102;
|
||||||
} else if($chosen_answer == -1) {
|
} else if($chosen_answer == -1) {
|
||||||
$error = 13103;
|
$error = 13103;
|
||||||
} else if($db->query('SELECT EXISTS (SELECT 1 FROM "Games" WHERE "ID" = $1)', array($uid))['data'][0]['exists'] == 'f') {
|
} else if($db->query('SELECT EXISTS (SELECT 1 FROM "Games" WHERE "ID" = $1)', array($uid))
|
||||||
|
['data'][0]['exists'] == 'f') {
|
||||||
$error = 13104;
|
$error = 13104;
|
||||||
print 'no game';
|
|
||||||
} else {
|
} else {
|
||||||
// points in table
|
$old_points = $db->query('SELECT "current_score" FROM "Games" WHERE "ID" = $1', array($uid))
|
||||||
|
['data'][0]['current_score'];
|
||||||
|
$new_points = $old_points + $score;
|
||||||
|
$db->query('UPDATE "Games" SET "current_score" = $1 WHERE "ID" = $2', array($new_points, $uid));
|
||||||
|
$results = array('correct' => $correct, 'score' => $score);
|
||||||
|
$old_time = $db->query('SELECT "total_time" FROM "Games" WHERE "ID" = $1', array($uid))
|
||||||
|
['data'][0]['total_time'];
|
||||||
|
$new_time = $old_time + $time;
|
||||||
|
$db->query('UPDATE "Games" SET "total_time" = $1 WHERE "ID" = $2', array($new_time, $uid));
|
||||||
|
if($db->query('SELECT EXISTS (SELECT 1 FROM "GamesQuestions" WHERE "Games_ID" = $1)',array($uid))
|
||||||
|
['data'][0]['exist'] == 't') {
|
||||||
|
$next_question = Question::get_next_question($db, $uid);
|
||||||
|
$data = array('results' => $results, 'next' => $next_question);
|
||||||
|
} else {
|
||||||
|
$end = array('score' => $new_points, 'time' => $new_time);
|
||||||
|
$data = array('results' => $results, 'end' => $end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = array('correct' => $correct, 'score' => $score);
|
|
||||||
$next_question = Question::get_next_question($db, $uid);
|
|
||||||
$data = array('results' => $results, 'next' => $next_question);
|
|
||||||
|
|
||||||
$response = Database::create_response($data, $error);
|
$response = Database::create_response($data, $error);
|
||||||
print_r($response);
|
print_r($response);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user