d718c5a372
CI / compile_and_lint (push) Failing after 0s
CI / docker_build (linux/amd64, -linux-amd64-duckdb, duckdb) (push) Failing after 0s
CI / docker_build (linux/arm64, -linux-arm64, minimal) (push) Failing after 2s
CI / docker_build (linux/arm64, -linux-arm64-duckdb, duckdb) (push) Failing after 1s
CI / docker_build (linux/amd64, minimal) (push) Failing after 1s
CI / test (, sqlite, sqlite::memory:) (push) Has been skipped
CI / test (mssql, mssql, mssql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (mysql, mysql, mysql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (oracle, oracle, Driver=Oracle 21 ODBC driver;Dbq=//127.0.0.1:1521/FREEPDB1;Uid=root;Pwd=Password123!) (push) Has been skipped
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been skipped
CI / test (postgres, postgres, postgres://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / playwright (push) Has been skipped
CI / docker_build (linux/arm/v7, -linux-arm-v7, minimal) (push) Failing after 0s
CI / hurl_examples (push) Failing after 8s
deploy website / deploy_official_site (push) Failing after 1s
CI / hurl (${{ matrix.example }}) (push) Has been skipped
CI / docker_push (duckdb) (push) Has been cancelled
CI / docker_push (minimal) (push) Has been cancelled
CI / windows_test (push) Has been cancelled
33 lines
1.3 KiB
SQL
33 lines
1.3 KiB
SQL
-- Redirect to the next question when all players have answered
|
|
set page_params = json_object('game_id', $game_id, 'player', $player);
|
|
select CASE
|
|
(SELECT count(*) FROM answers WHERE question_id = $question_id AND game_id = CAST($game_id AS INTEGER))
|
|
WHEN (SELECT count(*) FROM players WHERE game_id = CAST($game_id AS INTEGER))
|
|
THEN '0; ' || sqlpage.link('next-question.sql', $page_params)
|
|
ELSE 3
|
|
END as refresh,
|
|
sqlpage_shell.*
|
|
FROM sqlpage_shell;
|
|
|
|
-- Insert the answer into the answers table
|
|
INSERT INTO answers(game_id, player_name, question_id, answer_value)
|
|
SELECT CAST($game_id AS INTEGER) as game_id,
|
|
$player as player_name,
|
|
CAST($question_id AS INTEGER) as question_id,
|
|
CAST($answer AS INTEGER) as answer_value
|
|
WHERE $answer IS NOT NULL;
|
|
-- Redirect to the next question
|
|
SELECT 'text' as component,
|
|
'Waiting for other players to answer... The following players still have not answered: ' as contents;
|
|
select group_concat(name, ', ') as contents,
|
|
TRUE as bold
|
|
from players
|
|
where game_id = CAST($game_id AS INTEGER)
|
|
and not EXISTS (
|
|
SELECT 1
|
|
FROM answers
|
|
WHERE answers.game_id = CAST($game_id AS INTEGER)
|
|
AND answers.player_name = players.name
|
|
AND answers.question_id = CAST($question_id AS INTEGER)
|
|
);
|