mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-05 20:44:19 +01:00
- Refactor ORM annotations across entities for consistency.
- Adjusted migrations to align with refactored ORM annotations. - Added new PHPStan and PHP-CS-Fixer configurations, including stricter rules. - Introduced `tests/object-manager.php` to improve test environment setup.
This commit is contained in:
@@ -5,13 +5,13 @@ use PhpCsFixer\Config;
|
|||||||
use PhpCsFixer\Finder;
|
use PhpCsFixer\Finder;
|
||||||
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
|
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
|
||||||
|
|
||||||
$finder = (new Finder())
|
$finder = new Finder()
|
||||||
->in(__DIR__)
|
->in(__DIR__)
|
||||||
->exclude('var')
|
->exclude('var')
|
||||||
->exclude('bin')
|
->exclude('bin')
|
||||||
;
|
;
|
||||||
|
|
||||||
return (new Config())
|
return new Config()
|
||||||
->setParallelConfig(ParallelConfigFactory::detect())
|
->setParallelConfig(ParallelConfigFactory::detect())
|
||||||
->setRules([
|
->setRules([
|
||||||
'@Symfony' => true,
|
'@Symfony' => true,
|
||||||
@@ -30,8 +30,9 @@ return (new Config())
|
|||||||
'single_line_empty_body' => true,
|
'single_line_empty_body' => true,
|
||||||
'strict_comparison' => true,
|
'strict_comparison' => true,
|
||||||
'strict_param' => true,
|
'strict_param' => true,
|
||||||
|
'ordered_attributes' => true,
|
||||||
|
'heredoc_indentation' => ['indentation' => 'start_plus_one'],
|
||||||
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters']],
|
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters']],
|
||||||
|
|
||||||
])
|
])
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ services:
|
|||||||
# See https://xdebug.org/docs/all_settings#mode
|
# See https://xdebug.org/docs/all_settings#mode
|
||||||
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
|
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
|
||||||
MAILER_DSN: "smtp://mailer:1025"
|
MAILER_DSN: "smtp://mailer:1025"
|
||||||
PHP_CS_FIXER_IGNORE_ENV: 1
|
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
# Ensure that host.docker.internal is correctly defined on Linux
|
# Ensure that host.docker.internal is correctly defined on Linux
|
||||||
- host.docker.internal:host-gateway
|
- host.docker.internal:host-gateway
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ final class Version20250420111904 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE "user" ADD is_verified BOOLEAN NOT NULL
|
ALTER TABLE "user" ADD is_verified BOOLEAN NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE "user" DROP is_verified
|
ALTER TABLE "user" DROP is_verified
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ final class Version20250420125040 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season DROP preregister_candidates
|
ALTER TABLE season DROP preregister_candidates
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season ADD preregister_candidates BOOLEAN NOT NULL DEFAULT true
|
ALTER TABLE season ADD preregister_candidates BOOLEAN NOT NULL DEFAULT true
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ final class Version20250427174822 extends AbstractMigration
|
|||||||
// this up() migration is auto-generated, please modify it to your needs
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE answer ADD ordering SMALLINT DEFAULT 0 NOT NULL
|
ALTER TABLE answer ADD ordering SMALLINT DEFAULT 0 NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE question ADD ordering SMALLINT DEFAULT 0 NOT NULL
|
ALTER TABLE question ADD ordering SMALLINT DEFAULT 0 NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
@@ -33,9 +33,9 @@ final class Version20250427174822 extends AbstractMigration
|
|||||||
// this down() migration is auto-generated, please modify it to your needs
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE answer DROP ordering
|
ALTER TABLE answer DROP ordering
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE question DROP ordering
|
ALTER TABLE question DROP ordering
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ final class Version20250504101440 extends AbstractMigration
|
|||||||
// this up() migration is auto-generated, please modify it to your needs
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE UNIQUE INDEX UNIQ_C8B28E445E237E064EC001D1 ON candidate (name, season_id)
|
CREATE UNIQUE INDEX UNIQ_C8B28E445E237E064EC001D1 ON candidate (name, season_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE UNIQUE INDEX UNIQ_A412FA925E237E064EC001D1 ON quiz (name, season_id)
|
CREATE UNIQUE INDEX UNIQ_A412FA925E237E064EC001D1 ON quiz (name, season_id)
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
@@ -33,9 +33,9 @@ final class Version20250504101440 extends AbstractMigration
|
|||||||
// this down() migration is auto-generated, please modify it to your needs
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
DROP INDEX UNIQ_A412FA925E237E064EC001D1
|
DROP INDEX UNIQ_A412FA925E237E064EC001D1
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
DROP INDEX UNIQ_C8B28E445E237E064EC001D1
|
DROP INDEX UNIQ_C8B28E445E237E064EC001D1
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,37 +18,37 @@ final class Version20250521192752 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination ADD quiz_id UUID NOT NULL
|
ALTER TABLE elimination ADD quiz_id UUID NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination ADD CONSTRAINT FK_5947284F853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE elimination ADD CONSTRAINT FK_5947284F853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE INDEX IDX_5947284F853CD175 ON elimination (quiz_id)
|
CREATE INDEX IDX_5947284F853CD175 ON elimination (quiz_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz ALTER dropouts SET DEFAULT 1
|
ALTER TABLE quiz ALTER dropouts SET DEFAULT 1
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz ALTER dropouts SET NOT NULL
|
ALTER TABLE quiz ALTER dropouts SET NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz ALTER dropouts DROP DEFAULT
|
ALTER TABLE quiz ALTER dropouts DROP DEFAULT
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz ALTER dropouts DROP NOT NULL
|
ALTER TABLE quiz ALTER dropouts DROP NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination DROP CONSTRAINT FK_5947284F853CD175
|
ALTER TABLE elimination DROP CONSTRAINT FK_5947284F853CD175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
DROP INDEX IDX_5947284F853CD175
|
DROP INDEX IDX_5947284F853CD175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination DROP quiz_id
|
ALTER TABLE elimination DROP quiz_id
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ final class Version20250521194035 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination ADD created TIMESTAMP(0) WITHOUT TIME ZONE
|
ALTER TABLE elimination ADD created TIMESTAMP(0) WITHOUT TIME ZONE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
UPDATE elimination SET created = NOW()
|
UPDATE elimination SET created = NOW()
|
||||||
SQL
|
SQL
|
||||||
@@ -33,6 +33,6 @@ final class Version20250521194035 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination DROP created
|
ALTER TABLE elimination DROP created
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,73 +18,73 @@ final class Version20250606192337 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE TABLE quiz_candidate (id UUID NOT NULL, corrections DOUBLE PRECISION NOT NULL, created TIMESTAMP(0) WITH TIME ZONE NOT NULL, quiz_id UUID NOT NULL, candidate_id UUID NOT NULL, PRIMARY KEY(id))
|
CREATE TABLE quiz_candidate (id UUID NOT NULL, corrections DOUBLE PRECISION NOT NULL, created TIMESTAMP(0) WITH TIME ZONE NOT NULL, quiz_id UUID NOT NULL, candidate_id UUID NOT NULL, PRIMARY KEY(id))
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE INDEX IDX_CED2FFA2853CD175 ON quiz_candidate (quiz_id)
|
CREATE INDEX IDX_CED2FFA2853CD175 ON quiz_candidate (quiz_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE INDEX IDX_CED2FFA291BD8781 ON quiz_candidate (candidate_id)
|
CREATE INDEX IDX_CED2FFA291BD8781 ON quiz_candidate (candidate_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE UNIQUE INDEX UNIQ_CED2FFA291BD8781853CD175 ON quiz_candidate (candidate_id, quiz_id)
|
CREATE UNIQUE INDEX UNIQ_CED2FFA291BD8781853CD175 ON quiz_candidate (candidate_id, quiz_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz_candidate ADD CONSTRAINT FK_CED2FFA2853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE quiz_candidate ADD CONSTRAINT FK_CED2FFA2853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz_candidate ADD CONSTRAINT FK_CED2FFA291BD8781 FOREIGN KEY (candidate_id) REFERENCES candidate (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE quiz_candidate ADD CONSTRAINT FK_CED2FFA291BD8781 FOREIGN KEY (candidate_id) REFERENCES candidate (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE correction DROP CONSTRAINT fk_a29da1b891bd8781
|
ALTER TABLE correction DROP CONSTRAINT fk_a29da1b891bd8781
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE correction DROP CONSTRAINT fk_a29da1b8853cd175
|
ALTER TABLE correction DROP CONSTRAINT fk_a29da1b8853cd175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
DROP TABLE correction
|
DROP TABLE correction
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination ALTER created TYPE TIMESTAMP(0) WITH TIME ZONE
|
ALTER TABLE elimination ALTER created TYPE TIMESTAMP(0) WITH TIME ZONE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ALTER created TYPE TIMESTAMP(0) WITH TIME ZONE
|
ALTER TABLE given_answer ALTER created TYPE TIMESTAMP(0) WITH TIME ZONE
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE TABLE correction (id UUID NOT NULL, candidate_id UUID NOT NULL, quiz_id UUID NOT NULL, amount DOUBLE PRECISION NOT NULL, PRIMARY KEY(id))
|
CREATE TABLE correction (id UUID NOT NULL, candidate_id UUID NOT NULL, quiz_id UUID NOT NULL, amount DOUBLE PRECISION NOT NULL, PRIMARY KEY(id))
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE UNIQUE INDEX uniq_a29da1b891bd8781853cd175 ON correction (candidate_id, quiz_id)
|
CREATE UNIQUE INDEX uniq_a29da1b891bd8781853cd175 ON correction (candidate_id, quiz_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE INDEX idx_a29da1b8853cd175 ON correction (quiz_id)
|
CREATE INDEX idx_a29da1b8853cd175 ON correction (quiz_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE INDEX idx_a29da1b891bd8781 ON correction (candidate_id)
|
CREATE INDEX idx_a29da1b891bd8781 ON correction (candidate_id)
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE correction ADD CONSTRAINT fk_a29da1b891bd8781 FOREIGN KEY (candidate_id) REFERENCES candidate (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE correction ADD CONSTRAINT fk_a29da1b891bd8781 FOREIGN KEY (candidate_id) REFERENCES candidate (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE correction ADD CONSTRAINT fk_a29da1b8853cd175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE correction ADD CONSTRAINT fk_a29da1b8853cd175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz_candidate DROP CONSTRAINT FK_CED2FFA2853CD175
|
ALTER TABLE quiz_candidate DROP CONSTRAINT FK_CED2FFA2853CD175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE quiz_candidate DROP CONSTRAINT FK_CED2FFA291BD8781
|
ALTER TABLE quiz_candidate DROP CONSTRAINT FK_CED2FFA291BD8781
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
DROP TABLE quiz_candidate
|
DROP TABLE quiz_candidate
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ALTER created TYPE TIMESTAMP(0) WITHOUT TIME ZONE
|
ALTER TABLE given_answer ALTER created TYPE TIMESTAMP(0) WITHOUT TIME ZONE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination ALTER created TYPE TIMESTAMP(0) WITHOUT TIME ZONE
|
ALTER TABLE elimination ALTER created TYPE TIMESTAMP(0) WITHOUT TIME ZONE
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,22 +21,22 @@ final class Version20250606195952 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
delete from given_answer where answer_id is null
|
delete from given_answer where answer_id is null
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ALTER answer_id TYPE UUID
|
ALTER TABLE given_answer ALTER answer_id TYPE UUID
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ALTER answer_id SET NOT NULL
|
ALTER TABLE given_answer ALTER answer_id SET NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ALTER answer_id TYPE UUID
|
ALTER TABLE given_answer ALTER answer_id TYPE UUID
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ALTER answer_id DROP NOT NULL
|
ALTER TABLE given_answer ALTER answer_id DROP NOT NULL
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ final class Version20250607154730 extends AbstractMigration
|
|||||||
// this up() migration is auto-generated, please modify it to your needs
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season DROP CONSTRAINT FK_F0E45BA96706D6B
|
ALTER TABLE season DROP CONSTRAINT FK_F0E45BA96706D6B
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season ADD CONSTRAINT FK_F0E45BA96706D6B FOREIGN KEY (active_quiz_id) REFERENCES quiz (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE season ADD CONSTRAINT FK_F0E45BA96706D6B FOREIGN KEY (active_quiz_id) REFERENCES quiz (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
@@ -33,9 +33,9 @@ final class Version20250607154730 extends AbstractMigration
|
|||||||
// this down() migration is auto-generated, please modify it to your needs
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season DROP CONSTRAINT fk_f0e45ba96706d6b
|
ALTER TABLE season DROP CONSTRAINT fk_f0e45ba96706d6b
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season ADD CONSTRAINT fk_f0e45ba96706d6b FOREIGN KEY (active_quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE season ADD CONSTRAINT fk_f0e45ba96706d6b FOREIGN KEY (active_quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,16 +22,16 @@ final class Version20250607184525 extends AbstractMigration
|
|||||||
// this up() migration is auto-generated, please modify it to your needs
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination DROP CONSTRAINT FK_5947284F853CD175
|
ALTER TABLE elimination DROP CONSTRAINT FK_5947284F853CD175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination ADD CONSTRAINT FK_5947284F853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE elimination ADD CONSTRAINT FK_5947284F853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer DROP CONSTRAINT FK_9AC61A30853CD175
|
ALTER TABLE given_answer DROP CONSTRAINT FK_9AC61A30853CD175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ADD CONSTRAINT FK_9AC61A30853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE given_answer ADD CONSTRAINT FK_9AC61A30853CD175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
@@ -39,15 +39,15 @@ final class Version20250607184525 extends AbstractMigration
|
|||||||
// this down() migration is auto-generated, please modify it to your needs
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer DROP CONSTRAINT fk_9ac61a30853cd175
|
ALTER TABLE given_answer DROP CONSTRAINT fk_9ac61a30853cd175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE given_answer ADD CONSTRAINT fk_9ac61a30853cd175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE given_answer ADD CONSTRAINT fk_9ac61a30853cd175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination DROP CONSTRAINT fk_5947284f853cd175
|
ALTER TABLE elimination DROP CONSTRAINT fk_5947284f853cd175
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE elimination ADD CONSTRAINT fk_5947284f853cd175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE elimination ADD CONSTRAINT fk_5947284f853cd175 FOREIGN KEY (quiz_id) REFERENCES quiz (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,31 +18,31 @@ final class Version20250610210417 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE TABLE season_settings (id UUID NOT NULL, show_numbers BOOLEAN DEFAULT false NOT NULL, confirm_answers BOOLEAN DEFAULT false NOT NULL, PRIMARY KEY(id))
|
CREATE TABLE season_settings (id UUID NOT NULL, show_numbers BOOLEAN DEFAULT false NOT NULL, confirm_answers BOOLEAN DEFAULT false NOT NULL, PRIMARY KEY(id))
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season ADD settings_id UUID DEFAULT NULL
|
ALTER TABLE season ADD settings_id UUID DEFAULT NULL
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season ADD CONSTRAINT FK_F0E45BA959949888 FOREIGN KEY (settings_id) REFERENCES season_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
ALTER TABLE season ADD CONSTRAINT FK_F0E45BA959949888 FOREIGN KEY (settings_id) REFERENCES season_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
CREATE UNIQUE INDEX UNIQ_F0E45BA959949888 ON season (settings_id)
|
CREATE UNIQUE INDEX UNIQ_F0E45BA959949888 ON season (settings_id)
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
DROP TABLE season_settings
|
DROP TABLE season_settings
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season DROP CONSTRAINT FK_F0E45BA959949888
|
ALTER TABLE season DROP CONSTRAINT FK_F0E45BA959949888
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
DROP INDEX UNIQ_F0E45BA959949888
|
DROP INDEX UNIQ_F0E45BA959949888
|
||||||
SQL);
|
SQL);
|
||||||
$this->addSql(<<<'SQL'
|
$this->addSql(<<<'SQL'
|
||||||
ALTER TABLE season DROP settings_id
|
ALTER TABLE season DROP settings_id
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,3 +8,7 @@ parameters:
|
|||||||
- src/
|
- src/
|
||||||
- tests/
|
- tests/
|
||||||
treatPhpDocTypesAsCertain: false
|
treatPhpDocTypesAsCertain: false
|
||||||
|
symfony:
|
||||||
|
containerXmlPath: var/cache/dev/Tvdt_KernelDevDebugContainer.xml
|
||||||
|
doctrine:
|
||||||
|
objectManagerLoader: tests/object-manager.php
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ class QuizController extends AbstractController
|
|||||||
private readonly TranslatorInterface $translator,
|
private readonly TranslatorInterface $translator,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/season/{seasonCode:season}/quiz/{quiz}',
|
'/backoffice/season/{seasonCode:season}/quiz/{quiz}',
|
||||||
name: 'tvdt_backoffice_quiz',
|
name: 'tvdt_backoffice_quiz',
|
||||||
requirements: ['seasonCode' => self::SEASON_CODE_REGEX, 'quiz' => Requirement::UUID],
|
requirements: ['seasonCode' => self::SEASON_CODE_REGEX, 'quiz' => Requirement::UUID],
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
|
||||||
public function index(Season $season, Quiz $quiz): Response
|
public function index(Season $season, Quiz $quiz): Response
|
||||||
{
|
{
|
||||||
return $this->render('backoffice/quiz.html.twig', [
|
return $this->render('backoffice/quiz.html.twig', [
|
||||||
@@ -48,12 +48,12 @@ class QuizController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/season/{seasonCode:season}/quiz/{quiz}/enable',
|
'/backoffice/season/{seasonCode:season}/quiz/{quiz}/enable',
|
||||||
name: 'tvdt_backoffice_enable',
|
name: 'tvdt_backoffice_enable',
|
||||||
requirements: ['seasonCode' => self::SEASON_CODE_REGEX, 'quiz' => Requirement::UUID.'|null'],
|
requirements: ['seasonCode' => self::SEASON_CODE_REGEX, 'quiz' => Requirement::UUID.'|null'],
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
|
||||||
public function enableQuiz(Season $season, ?Quiz $quiz, EntityManagerInterface $em): RedirectResponse
|
public function enableQuiz(Season $season, ?Quiz $quiz, EntityManagerInterface $em): RedirectResponse
|
||||||
{
|
{
|
||||||
$season->setActiveQuiz($quiz);
|
$season->setActiveQuiz($quiz);
|
||||||
@@ -66,12 +66,12 @@ class QuizController extends AbstractController
|
|||||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/quiz/{quiz}/clear',
|
'/backoffice/quiz/{quiz}/clear',
|
||||||
name: 'tvdt_backoffice_quiz_clear',
|
name: 'tvdt_backoffice_quiz_clear',
|
||||||
requirements: ['quiz' => Requirement::UUID],
|
requirements: ['quiz' => Requirement::UUID],
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
|
|
||||||
public function clearQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse
|
public function clearQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -84,12 +84,12 @@ class QuizController extends AbstractController
|
|||||||
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->getSeason()->getSeasonCode(), 'quiz' => $quiz->getId()]);
|
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->getSeason()->getSeasonCode(), 'quiz' => $quiz->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::DELETE, subject: 'quiz')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/quiz/{quiz}/delete',
|
'/backoffice/quiz/{quiz}/delete',
|
||||||
name: 'tvdt_backoffice_quiz_delete',
|
name: 'tvdt_backoffice_quiz_delete',
|
||||||
requirements: ['quiz' => Requirement::UUID],
|
requirements: ['quiz' => Requirement::UUID],
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::DELETE, subject: 'quiz')]
|
|
||||||
public function deleteQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse
|
public function deleteQuiz(Quiz $quiz, QuizRepository $quizRepository): RedirectResponse
|
||||||
{
|
{
|
||||||
$quizRepository->deleteQuiz($quiz);
|
$quizRepository->deleteQuiz($quiz);
|
||||||
@@ -99,12 +99,12 @@ class QuizController extends AbstractController
|
|||||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $quiz->getSeason()->getSeasonCode()]);
|
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $quiz->getSeason()->getSeasonCode()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/quiz/{quiz}/candidate/{candidate}/modify_correction',
|
'/backoffice/quiz/{quiz}/candidate/{candidate}/modify_correction',
|
||||||
name: 'tvdt_backoffice_modify_correction',
|
name: 'tvdt_backoffice_modify_correction',
|
||||||
requirements: ['quiz' => Requirement::UUID, 'candidate' => Requirement::UUID],
|
requirements: ['quiz' => Requirement::UUID, 'candidate' => Requirement::UUID],
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
|
|
||||||
public function modifyCorrection(Quiz $quiz, Candidate $candidate, QuizCandidateRepository $quizCandidateRepository, Request $request): RedirectResponse
|
public function modifyCorrection(Quiz $quiz, Candidate $candidate, QuizCandidateRepository $quizCandidateRepository, Request $request): RedirectResponse
|
||||||
{
|
{
|
||||||
if (!$request->isMethod('POST')) {
|
if (!$request->isMethod('POST')) {
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ class SeasonController extends AbstractController
|
|||||||
private readonly EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/season/{seasonCode:season}',
|
'/backoffice/season/{seasonCode:season}',
|
||||||
name: 'tvdt_backoffice_season',
|
name: 'tvdt_backoffice_season',
|
||||||
requirements: ['seasonCode' => self::SEASON_CODE_REGEX],
|
requirements: ['seasonCode' => self::SEASON_CODE_REGEX],
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
|
||||||
public function index(Season $season, Request $request): Response
|
public function index(Season $season, Request $request): Response
|
||||||
{
|
{
|
||||||
$form = $this->createForm(SettingsForm::class, $season->getSettings());
|
$form = $this->createForm(SettingsForm::class, $season->getSettings());
|
||||||
@@ -54,13 +54,13 @@ class SeasonController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/season/{seasonCode:season}/add-candidate',
|
'/backoffice/season/{seasonCode:season}/add-candidate',
|
||||||
name: 'tvdt_backoffice_add_candidates',
|
name: 'tvdt_backoffice_add_candidates',
|
||||||
requirements: ['seasonCode' => self::SEASON_CODE_REGEX],
|
requirements: ['seasonCode' => self::SEASON_CODE_REGEX],
|
||||||
priority: 10,
|
priority: 10,
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
|
||||||
public function addCandidates(Season $season, Request $request): Response
|
public function addCandidates(Season $season, Request $request): Response
|
||||||
{
|
{
|
||||||
$form = $this->createForm(AddCandidatesFormType::class);
|
$form = $this->createForm(AddCandidatesFormType::class);
|
||||||
@@ -80,13 +80,13 @@ class SeasonController extends AbstractController
|
|||||||
return $this->render('backoffice/season_add_candidates.html.twig', ['form' => $form]);
|
return $this->render('backoffice/season_add_candidates.html.twig', ['form' => $form]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||||
#[Route(
|
#[Route(
|
||||||
'/backoffice/season/{seasonCode:season}/add-quiz',
|
'/backoffice/season/{seasonCode:season}/add-quiz',
|
||||||
name: 'tvdt_backoffice_quiz_add',
|
name: 'tvdt_backoffice_quiz_add',
|
||||||
requirements: ['seasonCode' => self::SEASON_CODE_REGEX],
|
requirements: ['seasonCode' => self::SEASON_CODE_REGEX],
|
||||||
priority: 10,
|
priority: 10,
|
||||||
)]
|
)]
|
||||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
|
||||||
public function addQuiz(Request $request, Season $season, QuizSpreadsheetService $quizSpreadsheet): Response
|
public function addQuiz(Request $request, Season $season, QuizSpreadsheetService $quizSpreadsheet): Response
|
||||||
{
|
{
|
||||||
$quiz = new Quiz();
|
$quiz = new Quiz();
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ final class EliminationController extends AbstractController
|
|||||||
{
|
{
|
||||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||||
|
|
||||||
#[Route('/elimination/{elimination}', name: 'tvdt_elimination', requirements: ['elimination' => Requirement::UUID])]
|
|
||||||
#[IsGranted(SeasonVoter::ELIMINATION, 'elimination')]
|
#[IsGranted(SeasonVoter::ELIMINATION, 'elimination')]
|
||||||
|
#[Route('/elimination/{elimination}', name: 'tvdt_elimination', requirements: ['elimination' => Requirement::UUID])]
|
||||||
public function index(#[MapEntity] Elimination $elimination, Request $request): Response
|
public function index(#[MapEntity] Elimination $elimination, Request $request): Response
|
||||||
{
|
{
|
||||||
$form = $this->createForm(EliminationEnterNameType::class);
|
$form = $this->createForm(EliminationEnterNameType::class);
|
||||||
@@ -48,8 +48,8 @@ final class EliminationController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/elimination/{elimination}/{candidateHash}', name: 'tvdt_elimination_candidate', requirements: ['elimination' => Requirement::UUID, 'candidateHash' => self::CANDIDATE_HASH_REGEX])]
|
|
||||||
#[IsGranted(SeasonVoter::ELIMINATION, 'elimination')]
|
#[IsGranted(SeasonVoter::ELIMINATION, 'elimination')]
|
||||||
|
#[Route('/elimination/{elimination}/{candidateHash}', name: 'tvdt_elimination_candidate', requirements: ['elimination' => Requirement::UUID, 'candidateHash' => self::CANDIDATE_HASH_REGEX])]
|
||||||
public function candidateScreen(Elimination $elimination, string $candidateHash, CandidateRepository $candidateRepository): Response
|
public function candidateScreen(Elimination $elimination, string $candidateHash, CandidateRepository $candidateRepository): Response
|
||||||
{
|
{
|
||||||
$candidate = $candidateRepository->getCandidateByHash($elimination->getQuiz()->getSeason(), $candidateHash);
|
$candidate = $candidateRepository->getCandidateByHash($elimination->getQuiz()->getSeason(), $candidateHash);
|
||||||
|
|||||||
@@ -16,17 +16,17 @@ use Tvdt\Repository\AnswerRepository;
|
|||||||
#[ORM\Entity(repositoryClass: AnswerRepository::class)]
|
#[ORM\Entity(repositoryClass: AnswerRepository::class)]
|
||||||
class Answer
|
class Answer
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME)]
|
#[ORM\Column(type: UuidType::NAME)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
||||||
private int $ordering = 0;
|
private int $ordering = 0;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'answers')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'answers')]
|
||||||
private Question $question;
|
private Question $question;
|
||||||
|
|
||||||
/** @var Collection<int, Candidate> */
|
/** @var Collection<int, Candidate> */
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ use Tvdt\Repository\CandidateRepository;
|
|||||||
#[ORM\UniqueConstraint(fields: ['name', 'season'])]
|
#[ORM\UniqueConstraint(fields: ['name', 'season'])]
|
||||||
class Candidate
|
class Candidate
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'candidates')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'candidates')]
|
||||||
private Season $season;
|
private Season $season;
|
||||||
|
|
||||||
/** @var Collection<int, Answer> */
|
/** @var Collection<int, Answer> */
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ class Elimination
|
|||||||
|
|
||||||
public const string SCREEN_RED = 'red';
|
public const string SCREEN_RED = 'red';
|
||||||
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
/** @var array<string, mixed> */
|
/** @var array<string, mixed> */
|
||||||
@@ -35,8 +35,8 @@ class Elimination
|
|||||||
private \DateTimeImmutable $created;
|
private \DateTimeImmutable $created;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
#[ORM\ManyToOne(inversedBy: 'eliminations')]
|
|
||||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'eliminations')]
|
||||||
private Quiz $quiz,
|
private Quiz $quiz,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|||||||
@@ -16,26 +16,26 @@ use Tvdt\Repository\GivenAnswerRepository;
|
|||||||
#[ORM\HasLifecycleCallbacks]
|
#[ORM\HasLifecycleCallbacks]
|
||||||
class GivenAnswer
|
class GivenAnswer
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
|
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
|
||||||
private \DateTimeImmutable $created;
|
private \DateTimeImmutable $created;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
#[ORM\ManyToOne(inversedBy: 'givenAnswers')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'givenAnswers')]
|
||||||
private Candidate $candidate,
|
private Candidate $candidate,
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||||
|
#[ORM\ManyToOne]
|
||||||
private Quiz $quiz,
|
private Quiz $quiz,
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'givenAnswers')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'givenAnswers')]
|
||||||
private Answer $answer,
|
private Answer $answer,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ use Tvdt\Repository\QuestionRepository;
|
|||||||
#[ORM\Entity(repositoryClass: QuestionRepository::class)]
|
#[ORM\Entity(repositoryClass: QuestionRepository::class)]
|
||||||
class Question
|
class Question
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME)]
|
#[ORM\Column(type: UuidType::NAME)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
||||||
@@ -28,8 +28,8 @@ class Question
|
|||||||
#[ORM\Column(type: Types::STRING, length: 255)]
|
#[ORM\Column(type: Types::STRING, length: 255)]
|
||||||
private string $question;
|
private string $question;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'questions')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'questions')]
|
||||||
private Quiz $quiz;
|
private Quiz $quiz;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
|||||||
@@ -16,17 +16,17 @@ use Tvdt\Repository\QuizRepository;
|
|||||||
#[ORM\UniqueConstraint(fields: ['name', 'season'])]
|
#[ORM\UniqueConstraint(fields: ['name', 'season'])]
|
||||||
class Quiz
|
class Quiz
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME)]
|
#[ORM\Column(type: UuidType::NAME)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column(length: 64)]
|
#[ORM\Column(length: 64)]
|
||||||
private string $name;
|
private string $name;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'quizzes')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'quizzes')]
|
||||||
private Season $season;
|
private Season $season;
|
||||||
|
|
||||||
/** @var Collection<int, Question> */
|
/** @var Collection<int, Question> */
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ use Symfony\Component\Uid\Uuid;
|
|||||||
use Tvdt\Repository\QuizCandidateRepository;
|
use Tvdt\Repository\QuizCandidateRepository;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: QuizCandidateRepository::class)]
|
#[ORM\Entity(repositoryClass: QuizCandidateRepository::class)]
|
||||||
#[ORM\UniqueConstraint(columns: ['candidate_id', 'quiz_id'])]
|
|
||||||
#[ORM\HasLifecycleCallbacks]
|
#[ORM\HasLifecycleCallbacks]
|
||||||
|
#[ORM\UniqueConstraint(columns: ['candidate_id', 'quiz_id'])]
|
||||||
class QuizCandidate
|
class QuizCandidate
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
@@ -30,12 +30,12 @@ class QuizCandidate
|
|||||||
private \DateTimeImmutable $created;
|
private \DateTimeImmutable $created;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
#[ORM\ManyToOne(inversedBy: 'candidateData')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'candidateData')]
|
||||||
private Quiz $quiz,
|
private Quiz $quiz,
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'quizData')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'quizData')]
|
||||||
private Candidate $candidate,
|
private Candidate $candidate,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ class Season
|
|||||||
{
|
{
|
||||||
private const string SEASON_CODE_CHARACTERS = 'bcdfghjklmnpqrstvwxz';
|
private const string SEASON_CODE_CHARACTERS = 'bcdfghjklmnpqrstvwxz';
|
||||||
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME)]
|
#[ORM\Column(type: UuidType::NAME)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column(length: 64)]
|
#[ORM\Column(length: 64)]
|
||||||
@@ -42,12 +42,12 @@ class Season
|
|||||||
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'seasons')]
|
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'seasons')]
|
||||||
private Collection $owners;
|
private Collection $owners;
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
|
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
|
||||||
|
#[ORM\ManyToOne]
|
||||||
private ?Quiz $ActiveQuiz = null;
|
private ?Quiz $ActiveQuiz = null;
|
||||||
|
|
||||||
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
#[ORM\JoinColumn(nullable: true)]
|
||||||
|
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
||||||
private ?SeasonSettings $settings = null;
|
private ?SeasonSettings $settings = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ use Tvdt\Repository\SeasonSettingsRepository;
|
|||||||
#[ORM\Entity(repositoryClass: SeasonSettingsRepository::class)]
|
#[ORM\Entity(repositoryClass: SeasonSettingsRepository::class)]
|
||||||
class SeasonSettings
|
class SeasonSettings
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\Column(type: UuidType::NAME)]
|
#[ORM\Column(type: UuidType::NAME)]
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
|
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ use Tvdt\Repository\UserRepository;
|
|||||||
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
|
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
|
||||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Id]
|
||||||
private Uuid $id;
|
private Uuid $id;
|
||||||
|
|
||||||
#[ORM\Column(length: 180)]
|
#[ORM\Column(length: 180)]
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class CandidateRepository extends ServiceEntityRepository
|
|||||||
select c from Tvdt\Entity\Candidate c
|
select c from Tvdt\Entity\Candidate c
|
||||||
where c.season = :season
|
where c.season = :season
|
||||||
and lower(c.name) = lower(:name)
|
and lower(c.name) = lower(:name)
|
||||||
DQL
|
DQL
|
||||||
)->setParameter('season', $season)
|
)->setParameter('season', $season)
|
||||||
->setParameter('name', $name)
|
->setParameter('name', $name)
|
||||||
->getOneOrNullResult();
|
->getOneOrNullResult();
|
||||||
@@ -57,21 +57,21 @@ class CandidateRepository extends ServiceEntityRepository
|
|||||||
public function getScores(Quiz $quiz): array
|
public function getScores(Quiz $quiz): array
|
||||||
{
|
{
|
||||||
return $this->getEntityManager()->createQuery(<<<DQL
|
return $this->getEntityManager()->createQuery(<<<DQL
|
||||||
select
|
select
|
||||||
c.id,
|
c.id,
|
||||||
c.name,
|
c.name,
|
||||||
sum(case when a.isRightAnswer = true then 1 else 0 end) as correct,
|
count(case when a.isRightAnswer = true then 1 else null end) as correct,
|
||||||
qc.corrections,
|
qc.corrections,
|
||||||
max(ga.created) - qc.created as time,
|
max(ga.created) - qc.created as time,
|
||||||
(sum(case when a.isRightAnswer = true then 1 else 0 end) + qc.corrections) as score
|
(count(case when a.isRightAnswer = true then 1 else null end) + qc.corrections) as score
|
||||||
from Tvdt\Entity\Candidate c
|
from Tvdt\Entity\Candidate c
|
||||||
join c.givenAnswers ga
|
join c.givenAnswers ga
|
||||||
join ga.answer a
|
join ga.answer a
|
||||||
join c.quizData qc
|
join c.quizData qc
|
||||||
where qc.quiz = :quiz and ga.quiz = :quiz
|
where qc.quiz = :quiz and ga.quiz = :quiz
|
||||||
group by ga.quiz, c.id, qc.id
|
group by ga.quiz, c.id, qc.id
|
||||||
order by score desc, time asc
|
order by score desc, time asc
|
||||||
DQL
|
DQL
|
||||||
)->setParameter('quiz', $quiz)->getResult();
|
)->setParameter('quiz', $quiz)->getResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class QuestionRepository extends ServiceEntityRepository
|
|||||||
and q1.quiz = :quiz
|
and q1.quiz = :quiz
|
||||||
)
|
)
|
||||||
and qz = :quiz
|
and qz = :quiz
|
||||||
DQL)
|
DQL)
|
||||||
->setMaxResults(1)
|
->setMaxResults(1)
|
||||||
->setParameter('candidate', $candidate)
|
->setParameter('candidate', $candidate)
|
||||||
->setParameter('quiz', $candidate->getSeason()->getActiveQuiz())
|
->setParameter('quiz', $candidate->getSeason()->getActiveQuiz())
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class SeasonRepository extends ServiceEntityRepository
|
|||||||
{
|
{
|
||||||
return $this->getEntityManager()->createQuery(<<<DQL
|
return $this->getEntityManager()->createQuery(<<<DQL
|
||||||
select s from Tvdt\Entity\Season s where :user member of s.owners order by s.name
|
select s from Tvdt\Entity\Season s where :user member of s.owners order by s.name
|
||||||
DQL
|
DQL
|
||||||
)->setParameter('user', $user)->getResult();
|
)->setParameter('user', $user)->getResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
tests/object-manager.php
Normal file
15
tests/object-manager.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
use Tvdt\Kernel;
|
||||||
|
|
||||||
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
|
new Dotenv()->bootEnv(__DIR__.'/../.env');
|
||||||
|
|
||||||
|
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
|
||||||
|
$kernel->boot();
|
||||||
|
|
||||||
|
return $kernel->getContainer()->get('doctrine')->getManager();
|
||||||
Reference in New Issue
Block a user