11-- Redirect to the next question when all players have answered
22set page_params = json_object(' game_id' , $game_id, ' player' , $player);
33select CASE
4- (SELECT count (* ) FROM answers WHERE question_id = $question_id AND game_id = $game_id:: integer )
5- WHEN (SELECT count (* ) FROM players WHERE game_id = $game_id:: integer )
4+ (SELECT count (* ) FROM answers WHERE question_id = $question_id AND game_id = CAST( $game_id AS INTEGER ) )
5+ WHEN (SELECT count (* ) FROM players WHERE game_id = CAST( $game_id AS INTEGER ) )
66 THEN ' 0; ' || sqlpage .link (' next-question.sql' , $page_params)
77 ELSE 3
88 END as refresh,
@@ -11,22 +11,22 @@ FROM sqlpage_shell;
1111
1212-- Insert the answer into the answers table
1313INSERT INTO answers(game_id, player_name, question_id, answer_value)
14- SELECT $game_id:: integer as game_id,
14+ SELECT CAST( $game_id AS INTEGER ) as game_id,
1515 $player as player_name,
16- $question_id:: integer as question_id,
17- $answer:: integer as answer_value
16+ CAST( $question_id AS INTEGER ) as question_id,
17+ CAST( $answer AS INTEGER ) as answer_value
1818WHERE $answer IS NOT NULL ;
1919-- Redirect to the next question
2020SELECT ' text' as component,
2121 ' Waiting for other players to answer... The following players still have not answered: ' as contents;
2222select group_concat(name, ' , ' ) as contents,
2323 TRUE as bold
2424from players
25- where game_id = $game_id:: integer
25+ where game_id = CAST( $game_id AS INTEGER )
2626 and not EXISTS (
2727 SELECT 1
2828 FROM answers
29- WHERE answers .game_id = $game_id:: integer
29+ WHERE answers .game_id = CAST( $game_id AS INTEGER )
3030 AND answers .player_name = players .name
31- AND answers .question_id = $question_id:: integer
32- );
31+ AND answers .question_id = CAST( $question_id AS INTEGER )
32+ );
0 commit comments