mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-07 13:14:20 +01:00
Compare commits
28 Commits
php
...
ca08df26b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca08df26b2 | ||
|
|
60723657c2 | ||
|
09d74ed327
|
|||
| 49b7c0f5d5 | |||
|
9bae324447
|
|||
|
4712c01688
|
|||
| 4e22feb256 | |||
|
0f07e7eabf
|
|||
|
7b05e52d95
|
|||
|
66b57ea84a
|
|||
|
daeda4a9b5
|
|||
|
057bc778ed
|
|||
|
f44b63a91f
|
|||
|
acd85bfc2b
|
|||
|
4863fad3ba
|
|||
|
87104889d1
|
|||
|
2c6eb2ecb7
|
|||
|
fe00270637
|
|||
|
e967a8da63
|
|||
|
ffb7df5895
|
|||
|
4885f746f6
|
|||
|
4bcab2724a
|
|||
|
c70f713f7e
|
|||
|
31e6ed406b
|
|||
|
acf5c06fcc
|
|||
|
448daed6ea
|
|||
|
f7b4b98da4
|
|||
|
0ccce51af8
|
@@ -33,6 +33,7 @@ indent_size = 4
|
||||
|
||||
[*.{yaml,yml}]
|
||||
trim_trailing_whitespace = false
|
||||
indent_size = 2
|
||||
|
||||
[.github/workflows/*.yml]
|
||||
indent_size = 2
|
||||
@@ -53,5 +54,5 @@ indent_size = 2
|
||||
[*.*Dockerfile]
|
||||
indent_style = tab
|
||||
|
||||
[*.*Caddyfile]
|
||||
[{*.*Caddyfile,Caddyfile}]
|
||||
indent_style = tab
|
||||
|
||||
8
.env
8
.env
@@ -28,3 +28,11 @@ APP_SECRET=
|
||||
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
|
||||
DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
||||
###> symfony/mailer ###
|
||||
MAILER_DSN=null://null
|
||||
###< symfony/mailer ###
|
||||
|
||||
###> sentry/sentry-symfony ###
|
||||
SENTRY_DSN=
|
||||
###< sentry/sentry-symfony ###
|
||||
|
||||
4
.env.test
Normal file
4
.env.test
Normal file
@@ -0,0 +1,4 @@
|
||||
# define your env variables for the test env here
|
||||
KERNEL_CLASS='App\Kernel'
|
||||
APP_SECRET='$ecretf0rt3st'
|
||||
SYMFONY_DEPRECATIONS_HELPER=999999
|
||||
49
.github/workflows/ci.yml
vendored
49
.github/workflows/ci.yml
vendored
@@ -16,14 +16,11 @@ jobs:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Build Docker images
|
||||
- name: Build Docker images
|
||||
uses: docker/bake-action@v4
|
||||
with:
|
||||
pull: true
|
||||
@@ -35,42 +32,32 @@ jobs:
|
||||
*.cache-from=type=gha,scope=${{github.ref}}
|
||||
*.cache-from=type=gha,scope=refs/heads/main
|
||||
*.cache-to=type=gha,scope=${{github.ref}},mode=max
|
||||
-
|
||||
name: Start services
|
||||
- name: Start services
|
||||
run: docker compose up --wait --no-build
|
||||
-
|
||||
name: Check HTTP reachability
|
||||
- name: Coding Style
|
||||
run: docker compose exec -T php vendor/bin/php-cs-fixer check --diff --show-progress=none
|
||||
- name: Check HTTP reachability
|
||||
run: curl -v --fail-with-body http://localhost
|
||||
-
|
||||
name: Check HTTPS reachability
|
||||
- name: Check HTTPS reachability
|
||||
if: false # Remove this line when the homepage will be configured, or change the path to check
|
||||
run: curl -vk --fail-with-body https://localhost
|
||||
-
|
||||
name: Check Mercure reachability
|
||||
- name: Check Mercure reachability
|
||||
run: curl -vkI --fail-with-body https://localhost/.well-known/mercure?topic=test
|
||||
-
|
||||
name: Create test database
|
||||
if: false # Remove this line if Doctrine ORM is installed
|
||||
- name: Create test database
|
||||
run: docker compose exec -T php bin/console -e test doctrine:database:create
|
||||
-
|
||||
name: Run migrations
|
||||
if: false # Remove this line if Doctrine Migrations is installed
|
||||
- name: Run migrations
|
||||
run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction
|
||||
-
|
||||
name: Run PHPUnit
|
||||
if: false # Remove this line if PHPUnit is installed
|
||||
run: docker compose exec -T php bin/phpunit
|
||||
-
|
||||
name: Doctrine Schema Validator
|
||||
if: false # Remove this line if Doctrine ORM is installed
|
||||
- name: Run PHPUnit
|
||||
if: false # Remove this line when the tests are ready
|
||||
run: docker compose exec -T php vendor/bin/phpunit
|
||||
- name: Doctrine Schema Validator
|
||||
run: docker compose exec -T php bin/console -e test doctrine:schema:validate
|
||||
lint:
|
||||
name: Docker Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Lint Dockerfile
|
||||
- name: Lint Dockerfile
|
||||
uses: hadolint/hadolint-action@v3.1.0
|
||||
|
||||
|
||||
15
.gitignore
vendored
15
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
/frankenphp/data
|
||||
|
||||
### Generated by gibo (https://github.com/simonwhitaker/gibo)
|
||||
### https://raw.github.com/github/gitignore/6eeebe6f49678aacd8311ce079842c971b3ebe96/Symfony.gitignore
|
||||
|
||||
@@ -32,7 +34,6 @@
|
||||
/bin/*
|
||||
!bin/console
|
||||
!bin/symfony_requirements
|
||||
/vendor/
|
||||
|
||||
# Assets and user uploads
|
||||
/web/bundles/
|
||||
@@ -40,7 +41,6 @@
|
||||
|
||||
# PHPUnit
|
||||
/app/phpunit.xml
|
||||
/phpunit.xml
|
||||
|
||||
# Build data
|
||||
/build/
|
||||
@@ -103,5 +103,14 @@ phpstan.neon
|
||||
###< friendsofphp/php-cs-fixer ###
|
||||
###> phpunit/phpunit ###
|
||||
/phpunit.xml
|
||||
.phpunit.result.cache
|
||||
/.phpunit.cache/
|
||||
###< phpunit/phpunit ###
|
||||
|
||||
###> vincentlanglet/twig-cs-fixer ###
|
||||
/.twig-cs-fixer.cache
|
||||
###< vincentlanglet/twig-cs-fixer ###
|
||||
|
||||
###> symfony/phpunit-bridge ###
|
||||
.phpunit.result.cache
|
||||
/phpunit.xml
|
||||
###< symfony/phpunit-bridge ###
|
||||
|
||||
39
.idea/TijdVoorDeTest.iml
generated
39
.idea/TijdVoorDeTest.iml
generated
@@ -6,7 +6,6 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="App\Tests\" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/clue/ndjson-react" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/collections" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/dbal" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/deprecations" />
|
||||
@@ -48,8 +47,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/rector/rector" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/runtime/frankenphp-symfony" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/cli-parser" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/comparator" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/complexity" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/diff" />
|
||||
@@ -84,8 +81,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/options-resolver" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-grapheme" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php83" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/process" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/routing" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/runtime" />
|
||||
@@ -106,7 +101,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/form" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/password-hasher" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-icu" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-uuid" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/property-access" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/property-info" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/security-bundle" />
|
||||
@@ -133,9 +127,42 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/twig/html-extra" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/data-fixtures" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/doctrine-fixtures-bundle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/vincentlanglet/twig-cs-fixer" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/egulias/email-validator" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/masterminds/html5" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/browser-kit" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/dom-crawler" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mailer" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php84" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfonycasts/verify-email-bundle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/psr7" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/jean85/pretty-package-versions" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-factory" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-message" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sentry/sentry" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sentry/sentry-symfony" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/psr-http-message-bridge" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.phpunit.cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/var" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/reflection-common" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/reflection-docblock" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/type-resolver" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpstan/phpdoc-parser" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/css-selector" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/phpunit-bridge" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/serializer" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/maennchen/zipstream-php" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/markbaker/complex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/markbaker/matrix" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpoffice/phpspreadsheet" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-client" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/simple-cache" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="bootstrap" level="application" />
|
||||
<orderEntry type="library" name="bootstrap-icons" level="application" />
|
||||
</component>
|
||||
</module>
|
||||
126
.idea/inspectionProfiles/Project_Default.xml
generated
126
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,7 +1,133 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ForgottenDebugOutputInspection" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="configuration">
|
||||
<list>
|
||||
<option value="\Codeception\Util\Debug::debug" />
|
||||
<option value="\Codeception\Util\Debug::pause" />
|
||||
<option value="\Doctrine\Common\Util\Debug::dump" />
|
||||
<option value="\Doctrine\Common\Util\Debug::export" />
|
||||
<option value="\Illuminate\Support\Debug\Dumper::dump" />
|
||||
<option value="\Symfony\Component\Debug\Debug::enable" />
|
||||
<option value="\Symfony\Component\Debug\DebugClassLoader::enable" />
|
||||
<option value="\Symfony\Component\Debug\ErrorHandler::register" />
|
||||
<option value="\Symfony\Component\Debug\ExceptionHandler::register" />
|
||||
<option value="\TYPO3\CMS\Core\Utility\DebugUtility::debug" />
|
||||
<option value="\Zend\Debug\Debug::dump" />
|
||||
<option value="\Zend\Di\Display\Console::export" />
|
||||
<option value="dd" />
|
||||
<option value="debug_print_backtrace" />
|
||||
<option value="debug_zval_dump" />
|
||||
<option value="dpm" />
|
||||
<option value="dpq" />
|
||||
<option value="dsm" />
|
||||
<option value="dump" />
|
||||
<option value="dvm" />
|
||||
<option value="error_log" />
|
||||
<option value="kpr" />
|
||||
<option value="phpinfo" />
|
||||
<option value="print_r" />
|
||||
<option value="trap" />
|
||||
<option value="var_dump" />
|
||||
<option value="var_export" />
|
||||
<option value="wp_die" />
|
||||
<option value="xdebug_break" />
|
||||
<option value="xdebug_call_class" />
|
||||
<option value="xdebug_call_file" />
|
||||
<option value="xdebug_call_function" />
|
||||
<option value="xdebug_call_line" />
|
||||
<option value="xdebug_code_coverage_started" />
|
||||
<option value="xdebug_debug_zval" />
|
||||
<option value="xdebug_debug_zval_stdout" />
|
||||
<option value="xdebug_dump_superglobals" />
|
||||
<option value="xdebug_enable" />
|
||||
<option value="xdebug_get_code_coverage" />
|
||||
<option value="xdebug_get_collected_errors" />
|
||||
<option value="xdebug_get_declared_vars" />
|
||||
<option value="xdebug_get_function_stack" />
|
||||
<option value="xdebug_get_headers" />
|
||||
<option value="xdebug_get_monitored_functions" />
|
||||
<option value="xdebug_get_profiler_filename" />
|
||||
<option value="xdebug_get_stack_depth" />
|
||||
<option value="xdebug_get_tracefile_name" />
|
||||
<option value="xdebug_is_enabled" />
|
||||
<option value="xdebug_memory_usage" />
|
||||
<option value="xdebug_peak_memory_usage" />
|
||||
<option value="xdebug_print_function_stack" />
|
||||
<option value="xdebug_start_code_coverage" />
|
||||
<option value="xdebug_start_error_collection" />
|
||||
<option value="xdebug_start_function_monitor" />
|
||||
<option value="xdebug_start_trace" />
|
||||
<option value="xdebug_stop_code_coverage" />
|
||||
<option value="xdebug_stop_error_collection" />
|
||||
<option value="xdebug_stop_function_monitor" />
|
||||
<option value="xdebug_stop_trace" />
|
||||
<option value="xdebug_time_index" />
|
||||
<option value="xdebug_var_dump" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="migratedIntoUserSpace" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PhpCSFixerValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PhpFullyQualifiedNameUsageInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="IGNORE_GLOBAL_NAMESPACE" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PhpStanGlobal" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="SecurityAdvisoriesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="optionConfiguration">
|
||||
<list>
|
||||
<option value="barryvdh/laravel-debugbar" />
|
||||
<option value="behat/behat" />
|
||||
<option value="brianium/paratest" />
|
||||
<option value="codeception/codeception" />
|
||||
<option value="codedungeon/phpunit-result-printer" />
|
||||
<option value="composer/composer" />
|
||||
<option value="doctrine/coding-standard" />
|
||||
<option value="filp/whoops" />
|
||||
<option value="friendsofphp/php-cs-fixer" />
|
||||
<option value="humbug/humbug" />
|
||||
<option value="infection/infection" />
|
||||
<option value="jakub-onderka/php-parallel-lint" />
|
||||
<option value="johnkary/phpunit-speedtrap" />
|
||||
<option value="kalessil/production-dependencies-guard" />
|
||||
<option value="mikey179/vfsStream" />
|
||||
<option value="mockery/mockery" />
|
||||
<option value="mybuilder/phpunit-accelerator" />
|
||||
<option value="orchestra/testbench" />
|
||||
<option value="pdepend/pdepend" />
|
||||
<option value="phan/phan" />
|
||||
<option value="phing/phing" />
|
||||
<option value="phpcompatibility/php-compatibility" />
|
||||
<option value="phpmd/phpmd" />
|
||||
<option value="phpro/grumphp" />
|
||||
<option value="phpspec/phpspec" />
|
||||
<option value="phpspec/prophecy" />
|
||||
<option value="phpstan/phpstan" />
|
||||
<option value="phpunit/phpunit" />
|
||||
<option value="povils/phpmnd" />
|
||||
<option value="roave/security-advisories" />
|
||||
<option value="satooshi/php-coveralls" />
|
||||
<option value="sebastian/phpcpd" />
|
||||
<option value="slevomat/coding-standard" />
|
||||
<option value="spatie/phpunit-watcher" />
|
||||
<option value="squizlabs/php_codesniffer" />
|
||||
<option value="sstalle/php7cc" />
|
||||
<option value="symfony/debug" />
|
||||
<option value="symfony/maker-bundle" />
|
||||
<option value="symfony/phpunit-bridge" />
|
||||
<option value="symfony/var-dumper" />
|
||||
<option value="vimeo/psalm" />
|
||||
<option value="wimg/php-compatibility" />
|
||||
<option value="wp-coding-standards/wpcs" />
|
||||
<option value="yiisoft/yii2-coding-standards" />
|
||||
<option value="yiisoft/yii2-debug" />
|
||||
<option value="yiisoft/yii2-gii" />
|
||||
<option value="zendframework/zend-coding-standard" />
|
||||
<option value="zendframework/zend-debug" />
|
||||
<option value="zendframework/zend-test" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
2
.idea/jsLibraryMappings.xml
generated
2
.idea/jsLibraryMappings.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<file url="PROJECT" libraries="{bootstrap}" />
|
||||
<file url="PROJECT" libraries="{bootstrap, bootstrap-icons}" />
|
||||
</component>
|
||||
</project>
|
||||
2
.idea/php-test-framework.xml
generated
2
.idea/php-test-framework.xml
generated
@@ -5,7 +5,7 @@
|
||||
<tool tool_name="PHPUnit">
|
||||
<cache>
|
||||
<versions>
|
||||
<info id="interpreter-c1266788-d465-407a-ac5d-1f67a9cf3e8a" version="11.5.2" />
|
||||
<info id="interpreter-96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" version="12.1.2" />
|
||||
</versions>
|
||||
</cache>
|
||||
</tool>
|
||||
|
||||
74
.idea/php.xml
generated
74
.idea/php.xml
generated
@@ -1,16 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetector">
|
||||
<phpmd_settings>
|
||||
<phpmd_by_interpreter asDefaultInterpreter="true" interpreter_id="c1266788-d465-407a-ac5d-1f67a9cf3e8a" timeout="30000" />
|
||||
</phpmd_settings>
|
||||
</component>
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCSFixerOptionsConfiguration">
|
||||
<option name="codingStandard" value="Custom" />
|
||||
<option name="rulesetPath" value="/app/.php-cs-fixer.dist.php" />
|
||||
<option name="rulesetPath" value=".php-cs-fixer.dist.php" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
@@ -19,14 +14,14 @@
|
||||
</component>
|
||||
<component name="PhpCSFixer">
|
||||
<phpcsfixer_settings>
|
||||
<phpcs_fixer_by_interpreter interpreter_id="c1266788-d465-407a-ac5d-1f67a9cf3e8a" tool_path="/app/vendor/bin/php-cs-fixer" timeout="30000" />
|
||||
<phpcs_fixer_by_interpreter asDefaultInterpreter="true" deletedFromTheList="true" interpreter_id="c1266788-d465-407a-ac5d-1f67a9cf3e8a" standards="DoctrineAnnotation;PER;PER-CS;PER-CS1.0;PER-CS2.0;PHP54Migration;PHP56Migration;PHP70Migration;PHP71Migration;PHP73Migration;PHP74Migration;PHP80Migration;PHP81Migration;PHP82Migration;PHP83Migration;PHP84Migration;PHPUnit100Migration;PHPUnit30Migration;PHPUnit32Migration;PHPUnit35Migration;PHPUnit43Migration;PHPUnit48Migration;PHPUnit50Migration;PHPUnit52Migration;PHPUnit54Migration;PHPUnit55Migration;PHPUnit56Migration;PHPUnit57Migration;PHPUnit60Migration;PHPUnit75Migration;PHPUnit84Migration;PHPUnit91Migration;PSR1;PSR12;PSR2;PhpCsFixer;Symfony" tool_path="/app/vendor/bin/php-cs-fixer" timeout="30000" />
|
||||
<PhpCSFixerConfiguration deletedFromTheList="true" tool_path="$PROJECT_DIR$/vendor/bin/php-cs-fixer" />
|
||||
<phpcs_fixer_by_interpreter interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" standards="DoctrineAnnotation;PER;PER-CS;PER-CS1.0;PER-CS2.0;PHP54Migration;PHP56Migration;PHP70Migration;PHP71Migration;PHP73Migration;PHP74Migration;PHP80Migration;PHP81Migration;PHP82Migration;PHP83Migration;PHP84Migration;PHPUnit100Migration;PHPUnit30Migration;PHPUnit32Migration;PHPUnit35Migration;PHPUnit43Migration;PHPUnit48Migration;PHPUnit50Migration;PHPUnit52Migration;PHPUnit54Migration;PHPUnit55Migration;PHPUnit56Migration;PHPUnit57Migration;PHPUnit60Migration;PHPUnit75Migration;PHPUnit84Migration;PHPUnit91Migration;PSR1;PSR12;PSR2;PhpCsFixer;Symfony" tool_path="vendor/bin/php-cs-fixer" timeout="30000" />
|
||||
<PhpCSFixerConfiguration deletedFromTheList="true" standards="PSR1;PSR2;Symfony;DoctrineAnnotation;PHP70Migration;PHP71Migration" tool_path="$PROJECT_DIR$/vendor/bin/php-cs-fixer" />
|
||||
<phpcs_fixer_by_interpreter asDefaultInterpreter="true" deletedFromTheList="true" interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" standards="DoctrineAnnotation;PER;PER-CS;PER-CS1.0;PER-CS2.0;PHP54Migration;PHP56Migration;PHP70Migration;PHP71Migration;PHP73Migration;PHP74Migration;PHP80Migration;PHP81Migration;PHP82Migration;PHP83Migration;PHP84Migration;PHPUnit100Migration;PHPUnit30Migration;PHPUnit32Migration;PHPUnit35Migration;PHPUnit43Migration;PHPUnit48Migration;PHPUnit50Migration;PHPUnit52Migration;PHPUnit54Migration;PHPUnit55Migration;PHPUnit56Migration;PHPUnit57Migration;PHPUnit60Migration;PHPUnit75Migration;PHPUnit84Migration;PHPUnit91Migration;PSR1;PSR12;PSR2;PhpCsFixer;Symfony" tool_path="vendor/bin/php-cs-fixer" timeout="30000" />
|
||||
</phpcsfixer_settings>
|
||||
</component>
|
||||
<component name="PhpCodeSniffer">
|
||||
<phpcs_settings>
|
||||
<phpcs_by_interpreter asDefaultInterpreter="true" interpreter_id="c1266788-d465-407a-ac5d-1f67a9cf3e8a" timeout="30000" />
|
||||
<phpcs_by_interpreter asDefaultInterpreter="true" interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" timeout="30000" />
|
||||
</phpcs_settings>
|
||||
</component>
|
||||
<component name="PhpExternalFormatter">
|
||||
@@ -36,9 +31,7 @@
|
||||
<include_path>
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/string" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/yaml" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/dotenv" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
|
||||
<path value="$PROJECT_DIR$/vendor/runtime/frankenphp-symfony" />
|
||||
<path value="$PROJECT_DIR$/vendor/composer" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/cache-contracts" />
|
||||
@@ -46,7 +39,6 @@
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/finder" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/runtime" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php83" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/var-exporter" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/cache" />
|
||||
@@ -71,7 +63,6 @@
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/stopwatch" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-migrations-bundle" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/migrations" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/cache" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/dbal" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
|
||||
@@ -113,8 +104,6 @@
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
||||
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
|
||||
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
|
||||
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
|
||||
@@ -131,7 +120,6 @@
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/twig/twig" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/uid" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-uuid" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/clock" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/security-bundle" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/type-info" />
|
||||
@@ -163,11 +151,42 @@
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/translation" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/data-fixtures" />
|
||||
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-fixtures-bundle" />
|
||||
<path value="$PROJECT_DIR$/vendor/webmozart/assert" />
|
||||
<path value="$PROJECT_DIR$/vendor/vincentlanglet/twig-cs-fixer" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php84" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/browser-kit" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/dom-crawler" />
|
||||
<path value="$PROJECT_DIR$/vendor/masterminds/html5" />
|
||||
<path value="$PROJECT_DIR$/vendor/egulias/email-validator" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/mailer" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfonycasts/verify-email-bundle" />
|
||||
<path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
|
||||
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
|
||||
<path value="$PROJECT_DIR$/vendor/jean85/pretty-package-versions" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
|
||||
<path value="$PROJECT_DIR$/vendor/sentry/sentry-symfony" />
|
||||
<path value="$PROJECT_DIR$/vendor/sentry/sentry" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/css-selector" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/phpunit-bridge" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/serializer" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-common" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/type-resolver" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-docblock" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpstan/phpdoc-parser" />
|
||||
<path value="$PROJECT_DIR$/vendor/markbaker/complex" />
|
||||
<path value="$PROJECT_DIR$/vendor/markbaker/matrix" />
|
||||
<path value="$PROJECT_DIR$/vendor/phpoffice/phpspreadsheet" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/http-client" />
|
||||
<path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
|
||||
<path value="$PROJECT_DIR$/vendor/maennchen/zipstream-php" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/yaml" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpInterpreters">
|
||||
<interpreters>
|
||||
<interpreter id="c1266788-d465-407a-ac5d-1f67a9cf3e8a" name="php" home="docker-compose://DATA" auto="false" debugger_id="php.debugger.XDebug">
|
||||
<interpreter id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" name="Compose PHP 8.3" home="docker-compose://DATA" auto="false" debugger_id="php.debugger.XDebug">
|
||||
<remote_data INTERPRETER_PATH="php" HELPERS_PATH="/opt/.phpstorm_helpers" VALID="true" RUN_AS_ROOT_VIA_SUDO="false" DOCKER_ACCOUNT_NAME="Colima" DOCKER_COMPOSE_SERVICE_NAME="php" DOCKER_REMOTE_PROJECT_PATH="/opt/project">
|
||||
<type_data command="EXEC" />
|
||||
<dockerComposeConfigurationPaths>
|
||||
@@ -181,15 +200,15 @@
|
||||
</component>
|
||||
<component name="PhpInterpretersPhpInfoCache">
|
||||
<phpInfoCache>
|
||||
<interpreter name="php">
|
||||
<phpinfo binary_type="PHP" php_cgi="/usr/local/bin/php-cgi" php_cli="/usr/local/bin/php" path_separator=":" version="8.3.15">
|
||||
<interpreter name="Compose PHP 8.3">
|
||||
<phpinfo binary_type="PHP" php_cgi="/usr/local/bin/php-cgi" php_cli="/usr/local/bin/php" path_separator=":" version="8.3.19">
|
||||
<additional_php_ini>/usr/local/etc/php/conf.d/docker-php-ext-apcu.ini, /usr/local/etc/php/conf.d/docker-php-ext-intl.ini, /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini, /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini, /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini, /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini, /usr/local/etc/php/conf.d/docker-php-ext-zip.ini, /usr/local/etc/php/app.conf.d/10-app.ini, /usr/local/etc/php/app.conf.d/20-app.dev.ini</additional_php_ini>
|
||||
<configuration_file>/usr/local/etc/php/php.ini</configuration_file>
|
||||
<configuration_options>
|
||||
<configuration_option name="include_path" value=".:/usr/local/lib/php" />
|
||||
</configuration_options>
|
||||
<debuggers>
|
||||
<debugger_info debugger="xdebug" debugger_version="3.4.0">
|
||||
<debugger_info debugger="xdebug" debugger_version="3.4.2">
|
||||
<debug_extensions />
|
||||
</debugger_info>
|
||||
</debuggers>
|
||||
@@ -241,25 +260,24 @@
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.3" />
|
||||
<component name="PhpStan">
|
||||
<PhpStan_settings>
|
||||
<phpstan_by_interpreter interpreter_id="c1266788-d465-407a-ac5d-1f67a9cf3e8a" tool_path="/app/vendor/bin/phpstan" timeout="60000" />
|
||||
<phpstan_by_interpreter asDefaultInterpreter="true" deletedFromTheList="true" interpreter_id="afbe50d9-a569-498c-8dcc-cf68a5d73813" timeout="60000" />
|
||||
<phpstan_by_interpreter interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" tool_path="vendor/bin/phpstan" timeout="60000" />
|
||||
<PhpStanConfiguration deletedFromTheList="true" tool_path="$PROJECT_DIR$/vendor/bin/phpstan" />
|
||||
<phpstan_by_interpreter asDefaultInterpreter="true" deletedFromTheList="true" interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" tool_path="vendor/bin/phpstan" timeout="60000" />
|
||||
</PhpStan_settings>
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="config" value="$PROJECT_DIR$/phpstan.dist.neon" />
|
||||
<option name="level" value="8" />
|
||||
<option name="config" value="phpstan.dist.neon" />
|
||||
<option name="fullProject" value="true" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpUnit">
|
||||
<phpunit_settings>
|
||||
<phpunit_by_interpreter interpreter_id="c1266788-d465-407a-ac5d-1f67a9cf3e8a" custom_loader_path="/app/vendor/autoload.php" phpunit_phar_path="" />
|
||||
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
|
||||
<phpunit_by_interpreter interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" configuration_file_path="phpunit.xml.dist" custom_loader_path="vendor/autoload.php" phpunit_phar_path="" use_configuration_file="true" />
|
||||
</phpunit_settings>
|
||||
</component>
|
||||
<component name="Psalm">
|
||||
<Psalm_settings>
|
||||
<psalm_fixer_by_interpreter asDefaultInterpreter="true" interpreter_id="afbe50d9-a569-498c-8dcc-cf68a5d73813" timeout="60000" />
|
||||
<psalm_fixer_by_interpreter asDefaultInterpreter="true" interpreter_id="96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8" timeout="60000" />
|
||||
</Psalm_settings>
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
|
||||
16
.idea/remote-mappings.xml
generated
Normal file
16
.idea/remote-mappings.xml
generated
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteMappingsManager">
|
||||
<list>
|
||||
<list>
|
||||
<remote-mappings server-id="php@96512cb2-7b9e-4e1d-bfa2-bf7f3be424c8">
|
||||
<settings>
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</settings>
|
||||
</remote-mappings>
|
||||
</list>
|
||||
</list>
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/sonarlint.xml
generated
Normal file
8
.idea/sonarlint.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SonarLintProjectSettings">
|
||||
<option name="bindingEnabled" value="true" />
|
||||
<option name="projectKey" value="MarijnDoeve_TijdVoorDeTest" />
|
||||
<option name="serverId" value="SonarQube" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/sqldialects.xml
generated
Normal file
6
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="PROJECT" dialect="PostgreSQL" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,17 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
|
||||
|
||||
$finder = (new PhpCsFixer\Finder())
|
||||
$finder = (new Finder())
|
||||
->in(__DIR__)
|
||||
->exclude('var')
|
||||
->exclude('bin')
|
||||
;
|
||||
|
||||
return (new PhpCsFixer\Config())
|
||||
return (new Config())
|
||||
->setParallelConfig(ParallelConfigFactory::detect())
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'declare_strict_types' => true,
|
||||
'fully_qualified_strict_types' => ['import_symbols' => true],
|
||||
'linebreak_after_opening_tag' => true,
|
||||
'mb_str_functions' => true,
|
||||
'no_php4_constructor' => true,
|
||||
@@ -19,11 +25,11 @@ return (new PhpCsFixer\Config())
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
'php_unit_strict' => true,
|
||||
'phpdoc_line_span' => ['const' => 'single', 'method' => 'single', 'property' => 'single'],
|
||||
'phpdoc_order' => true,
|
||||
'single_line_empty_body' => true,
|
||||
'strict_comparison' => true,
|
||||
'strict_param' => true,
|
||||
'blank_line_between_import_groups' => false,
|
||||
'phpdoc_line_span' => ['const' => 'single', 'method' => 'single', 'property' => 'single'],
|
||||
])
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder($finder)
|
||||
|
||||
@@ -31,6 +31,9 @@ RUN set -eux; \
|
||||
intl \
|
||||
opcache \
|
||||
zip \
|
||||
uuid \
|
||||
gd \
|
||||
excimer \
|
||||
;
|
||||
|
||||
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
|
||||
@@ -67,6 +70,8 @@ RUN set -eux; \
|
||||
|
||||
COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/
|
||||
|
||||
RUN git config --global --add safe.directory /app
|
||||
|
||||
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]
|
||||
|
||||
# Prod FrankenPHP image
|
||||
|
||||
36
Justfile
Normal file
36
Justfile
Normal file
@@ -0,0 +1,36 @@
|
||||
up:
|
||||
docker compose up -d
|
||||
|
||||
down *args:
|
||||
docker compose down {{ args }} --remove-orphans
|
||||
|
||||
stop:
|
||||
docker compose stop
|
||||
|
||||
exec *args:
|
||||
docker compose exec php {{ args }}
|
||||
|
||||
[no-exit-message]
|
||||
shell:
|
||||
@docker compose exec php bash
|
||||
|
||||
bash: shell
|
||||
|
||||
migrate: up
|
||||
docker compose run --rm php bin/console doctrine:migrations:migrate --no-interaction
|
||||
|
||||
fixtures:
|
||||
docker compose exec php bin/console doctrine:fixtures:load --purge-with-truncate --no-interaction
|
||||
|
||||
translations:
|
||||
docker compose exec php bin/console translation:extract --domain=messages --force --format=yaml --sort=asc --clean nl
|
||||
|
||||
fix-cs:
|
||||
docker compose exec php vendor/bin/php-cs-fixer fix
|
||||
docker compose exec php vendor/bin/twig-cs-fixer fix
|
||||
|
||||
rector *args:
|
||||
docker compose exec php vendor/bin/rector {{ args }}
|
||||
|
||||
phpstan *args:
|
||||
docker compose exec php vendor/bin/phpstan analyse {{ args }}
|
||||
16
README.md
16
README.md
@@ -6,39 +6,33 @@
|
||||
|
||||
- WIDM-tests met een variabel aantal vragen.
|
||||
- Vragen in een vaste volgorde zijn samen één test (een vraag kan niet bij
|
||||
meerdere test horen).
|
||||
- Vragen hebben 2 of meer antwoordmogelijkheden. Slechts één vraag is correct.
|
||||
meerdere tests horen).
|
||||
- Vragen hebben 2 of meer antwoordmogelijkheden. Slechts één antwoord is correct.
|
||||
- Meerdere test samen vormen een seizoen.
|
||||
- Een seizoen heeft één of geen actieve tests, als er een test actief is kan
|
||||
Uitsluitend die test gemaakt worden.
|
||||
- Kandidaten kunnen een test maximaal 1 keer invullen. Indien ingeschakeld
|
||||
kunnen alleen vooraf ingevoerde namen gebruikt worden in een test.
|
||||
uitsluitend die test gemaakt worden.
|
||||
- Kandidaten kunnen een test maximaal 1 keer invullen.
|
||||
- Vanaf het moment dat de kandidaat op start klikt na het intypen van hun naam
|
||||
gaat de tijd lopen. Deze stopt na het aanklikken van een antwoord op de laatste
|
||||
vraag van de test.
|
||||
- Achtergrondmuziek
|
||||
|
||||
|
||||
### Schermen kijken
|
||||
|
||||
- Nadat een speler een test heeft gemaakt (of vooraf als de namen vooraf
|
||||
ingevoerd zijn) kunnen jokers toegekend worden aan de test van kandidaat. Een
|
||||
positief getal om antwoorden goed te rekenen, een negatief getal om
|
||||
antwoorden fout te rekenen. Een vrijstelling kan gegeven worden door evenveel
|
||||
of meer jokers toe te kennen als dat er vragen in een test zitten.
|
||||
antwoorden fout te rekenen.
|
||||
- Vooraf kan gekozen worden hoe veel afvallers er zijn.
|
||||
- Bij het kijken naam rode en groene schermen wordt een naam ingevoerd. Er
|
||||
wordt een rood of groen scherm getoond.
|
||||
- Spelers kunnen geforceerd op groen of rood gezet worden, deze worden dan niet
|
||||
meegenomen in de berekening van de slechtste speler.
|
||||
|
||||
|
||||
|
||||
### Statistieken
|
||||
|
||||
TBD
|
||||
|
||||
|
||||
## Nice to haves
|
||||
|
||||
- Optie voor antwoord geven in twee klikken (selecteren en volgende).
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Kernel;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
|
||||
|
||||
@@ -8,17 +8,29 @@ services:
|
||||
- ./:/app
|
||||
- ./frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro
|
||||
- ./frankenphp/conf.d/20-app.dev.ini:/usr/local/etc/php/app.conf.d/20-app.dev.ini:ro
|
||||
# If you develop on Mac or Windows you can remove the vendor/ directory
|
||||
# from the bind-mount for better performance by enabling the next line:
|
||||
#- /app/vendor
|
||||
- ./frankenphp/data:/data
|
||||
environment:
|
||||
MERCURE_EXTRA_DIRECTIVES: demo
|
||||
# See https://xdebug.org/docs/all_settings#mode
|
||||
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
|
||||
MAILER_DSN: "smtp://mailer:1025"
|
||||
extra_hosts:
|
||||
# Ensure that host.docker.internal is correctly defined on Linux
|
||||
- host.docker.internal:host-gateway
|
||||
tty: true
|
||||
ports:
|
||||
# HTTP
|
||||
- target: 80
|
||||
published: ${HTTP_PORT:-80}
|
||||
protocol: tcp
|
||||
# HTTPS
|
||||
- target: 443
|
||||
published: ${HTTPS_PORT:-443}
|
||||
protocol: tcp
|
||||
# HTTP/3
|
||||
- target: 443
|
||||
published: ${HTTP3_PORT:-443}
|
||||
protocol: udp
|
||||
|
||||
###> symfony/mercure-bundle ###
|
||||
###< symfony/mercure-bundle ###
|
||||
@@ -28,3 +40,14 @@ services:
|
||||
ports:
|
||||
- "5432:5432"
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
||||
###> symfony/mailer ###
|
||||
mailer:
|
||||
image: axllent/mailpit
|
||||
ports:
|
||||
- "1025"
|
||||
- "8025"
|
||||
environment:
|
||||
MP_SMTP_AUTH_ACCEPT_ANY: 1
|
||||
MP_SMTP_AUTH_ALLOW_INSECURE: 1
|
||||
###< symfony/mailer ###
|
||||
|
||||
@@ -8,3 +8,23 @@ services:
|
||||
APP_SECRET: ${APP_SECRET}
|
||||
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET}
|
||||
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET}
|
||||
MAILER_SENDER: ${MAILER_SENDER}
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.tvdt.rule=Host(`tijdvoordetest.nl`)"
|
||||
- "traefik.http.routers.tvdt.entrypoints=websecure"
|
||||
- "traefik.http.routers.tvdt.tls.certresolver=marijndoeve"
|
||||
- "traefik.http.routers.tvdt.service=tvdt"
|
||||
- "traefik.http.services.tvdt.loadbalancer.server.port=80"
|
||||
networks:
|
||||
- web
|
||||
- internal
|
||||
database:
|
||||
networks:
|
||||
- internal
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
internal:
|
||||
external: false
|
||||
|
||||
17
compose.yaml
17
compose.yaml
@@ -7,7 +7,7 @@ services:
|
||||
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
|
||||
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
|
||||
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-16}&charset=${POSTGRES_CHARSET:-utf8}
|
||||
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
|
||||
MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure}
|
||||
MERCURE_PUBLIC_URL: ${CADDY_MERCURE_PUBLIC_URL:-https://${SERVER_NAME:-localhost}/.well-known/mercure}
|
||||
@@ -18,19 +18,6 @@ services:
|
||||
volumes:
|
||||
- caddy_data:/data
|
||||
- caddy_config:/config
|
||||
ports:
|
||||
# HTTP
|
||||
- target: 80
|
||||
published: ${HTTP_PORT:-80}
|
||||
protocol: tcp
|
||||
# HTTPS
|
||||
- target: 443
|
||||
published: ${HTTPS_PORT:-443}
|
||||
protocol: tcp
|
||||
# HTTP/3
|
||||
- target: 443
|
||||
published: ${HTTP3_PORT:-443}
|
||||
protocol: udp
|
||||
|
||||
# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service
|
||||
###> symfony/mercure-bundle ###
|
||||
@@ -51,8 +38,6 @@ services:
|
||||
start_period: 60s
|
||||
volumes:
|
||||
- database_data:/var/lib/postgresql/data:rw
|
||||
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
|
||||
# - ./docker/db/data:/var/lib/postgresql/data:rw
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
||||
volumes:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "symfony/skeleton",
|
||||
"name": "marijndoeve/tijdvoordetest",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"description": "A minimal Symfony project recommended to create bare bones applications",
|
||||
@@ -9,39 +9,54 @@
|
||||
"php": ">=8.3.15",
|
||||
"ext-ctype": "*",
|
||||
"ext-iconv": "*",
|
||||
"doctrine/dbal": "^3",
|
||||
"doctrine/doctrine-bundle": "^2.13",
|
||||
"doctrine/doctrine-migrations-bundle": "^3.3",
|
||||
"doctrine/orm": "^3.3",
|
||||
"easycorp/easyadmin-bundle": "^4.23",
|
||||
"doctrine/dbal": "^4.2.3",
|
||||
"doctrine/doctrine-bundle": "^2.14.0",
|
||||
"doctrine/doctrine-migrations-bundle": "^3.4.1",
|
||||
"doctrine/orm": "^3.3.2",
|
||||
"easycorp/easyadmin-bundle": "^4.24.6",
|
||||
"phpdocumentor/reflection-docblock": "^5.6",
|
||||
"phpoffice/phpspreadsheet": "*",
|
||||
"phpstan/phpdoc-parser": "^2.1",
|
||||
"runtime/frankenphp-symfony": "^0.2.0",
|
||||
"sentry/sentry-symfony": "^5.2",
|
||||
"symfony/asset": "7.2.*",
|
||||
"symfony/console": "7.2.*",
|
||||
"symfony/dotenv": "7.2.*",
|
||||
"symfony/flex": "^2.4.7",
|
||||
"symfony/flex": "^2.5.0",
|
||||
"symfony/form": "7.2.*",
|
||||
"symfony/framework-bundle": "7.2.*",
|
||||
"symfony/mailer": "7.2.*",
|
||||
"symfony/property-access": "7.2.*",
|
||||
"symfony/property-info": "7.2.*",
|
||||
"symfony/runtime": "7.2.*",
|
||||
"symfony/security-bundle": "7.2.*",
|
||||
"symfony/security-csrf": "7.2.*",
|
||||
"symfony/serializer": "7.2.*",
|
||||
"symfony/twig-bundle": "7.2.*",
|
||||
"symfony/uid": "7.2.*",
|
||||
"symfony/yaml": "7.2.*",
|
||||
"thecodingmachine/safe": "^2.5"
|
||||
"symfonycasts/verify-email-bundle": "^1.17.3",
|
||||
"thecodingmachine/safe": "^3.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^4.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.65",
|
||||
"phpstan/extension-installer": "^1.4",
|
||||
"phpstan/phpstan": "^2.0",
|
||||
"phpstan/phpstan-doctrine": "^2.0",
|
||||
"phpstan/phpstan-phpunit": "^2.0",
|
||||
"phpstan/phpstan-symfony": "^2.0",
|
||||
"phpunit/phpunit": "^11",
|
||||
"rector/rector": "^2.0",
|
||||
"doctrine/doctrine-fixtures-bundle": "^4.1",
|
||||
"friendsofphp/php-cs-fixer": "^3.75.0",
|
||||
"phpstan/extension-installer": "^1.4.3",
|
||||
"phpstan/phpstan": "^2.1.12",
|
||||
"phpstan/phpstan-doctrine": "^2.0.2",
|
||||
"phpstan/phpstan-phpunit": "^2.0.6",
|
||||
"phpstan/phpstan-symfony": "^2.0.4",
|
||||
"phpunit/phpunit": "^12.1.3",
|
||||
"rector/rector": "^2.0.12",
|
||||
"roave/security-advisories": "dev-latest",
|
||||
"symfony/browser-kit": "7.2.*",
|
||||
"symfony/css-selector": "7.2.*",
|
||||
"symfony/maker-bundle": "^1.62.1",
|
||||
"symfony/phpunit-bridge": "^7.2",
|
||||
"symfony/stopwatch": "7.2.*",
|
||||
"symfony/web-profiler-bundle": "7.2.*",
|
||||
"thecodingmachine/phpstan-safe-rule": "^1.3"
|
||||
"thecodingmachine/phpstan-safe-rule": "^1.4",
|
||||
"vincentlanglet/twig-cs-fixer": "^3.5.1"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
@@ -66,12 +81,15 @@
|
||||
"replace": {
|
||||
"symfony/polyfill-ctype": "*",
|
||||
"symfony/polyfill-iconv": "*",
|
||||
"symfony/polyfill-mbstring": "*",
|
||||
"symfony/polyfill-php72": "*",
|
||||
"symfony/polyfill-php73": "*",
|
||||
"symfony/polyfill-php74": "*",
|
||||
"symfony/polyfill-php80": "*",
|
||||
"symfony/polyfill-php81": "*",
|
||||
"symfony/polyfill-php82": "*"
|
||||
"symfony/polyfill-php82": "*",
|
||||
"symfony/polyfill-php83": "*",
|
||||
"symfony/polyfill-uuid": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"auto-scripts": {
|
||||
|
||||
4614
composer.lock
generated
4614
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
|
||||
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
|
||||
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle;
|
||||
use Sentry\SentryBundle\SentryBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\MakerBundle\MakerBundle;
|
||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||
use Symfony\Bundle\TwigBundle\TwigBundle;
|
||||
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
|
||||
use Symfony\UX\TwigComponent\TwigComponentBundle;
|
||||
use SymfonyCasts\Bundle\VerifyEmail\SymfonyCastsVerifyEmailBundle;
|
||||
use Twig\Extra\TwigExtraBundle\TwigExtraBundle;
|
||||
|
||||
return [
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
||||
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
|
||||
Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true],
|
||||
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||
FrameworkBundle::class => ['all' => true],
|
||||
DoctrineBundle::class => ['all' => true],
|
||||
DoctrineMigrationsBundle::class => ['all' => true],
|
||||
MakerBundle::class => ['dev' => true],
|
||||
TwigBundle::class => ['all' => true],
|
||||
SecurityBundle::class => ['all' => true],
|
||||
WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||
TwigExtraBundle::class => ['all' => true],
|
||||
TwigComponentBundle::class => ['all' => true],
|
||||
EasyAdminBundle::class => ['all' => true],
|
||||
DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||
SymfonyCastsVerifyEmailBundle::class => ['all' => true],
|
||||
SentryBundle::class => ['prod' => true],
|
||||
];
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# Enable stateless CSRF protection for forms and logins/logouts
|
||||
framework:
|
||||
form:
|
||||
csrf_protection:
|
||||
token_id: submit
|
||||
|
||||
csrf_protection:
|
||||
stateless_token_ids:
|
||||
- submit
|
||||
- authenticate
|
||||
- logout
|
||||
@@ -4,9 +4,17 @@ framework:
|
||||
|
||||
# Note that the session will be started ONLY if you read or write from it.
|
||||
session: true
|
||||
|
||||
form:
|
||||
csrf_protection:
|
||||
enabled: true
|
||||
#esi: true
|
||||
#fragments: true
|
||||
when@prod:
|
||||
framework:
|
||||
# shortcut for private IP address ranges of your proxy
|
||||
trusted_proxies: 'private_ranges'
|
||||
# or, if your proxy instead uses the "Forwarded" header
|
||||
trusted_headers: [ 'forwarded' ]
|
||||
|
||||
when@test:
|
||||
framework:
|
||||
|
||||
7
config/packages/mailer.yaml
Normal file
7
config/packages/mailer.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
framework:
|
||||
mailer:
|
||||
dsn: '%env(MAILER_DSN)%'
|
||||
envelope:
|
||||
sender: '%env(MAILER_SENDER)%'
|
||||
headers:
|
||||
From: 'Tijd voor de test <%env(MAILER_SENDER)%>'
|
||||
@@ -18,11 +18,12 @@ security:
|
||||
lazy: true
|
||||
provider: app_user_provider
|
||||
form_login:
|
||||
login_path: app_login
|
||||
check_path: app_login
|
||||
login_path: app_login_login
|
||||
check_path: app_login_login
|
||||
enable_csrf: true
|
||||
default_target_path: app_backoffice_index
|
||||
logout:
|
||||
path: app_logout
|
||||
path: app_login_logout
|
||||
# where to redirect after logout
|
||||
# target: app_any_route
|
||||
|
||||
@@ -35,7 +36,7 @@ security:
|
||||
# Easy way to control access for large sections of your site
|
||||
# Note: Only the *first* access control that matches will be used
|
||||
access_control:
|
||||
# - { path: ^/admin, roles: ROLE_ADMIN }
|
||||
- { path: ^/admin, roles: ROLE_ADMIN }
|
||||
# - { path: ^/profile, roles: ROLE_USER }
|
||||
|
||||
when@test:
|
||||
|
||||
31
config/packages/sentry.yaml
Normal file
31
config/packages/sentry.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
when@prod:
|
||||
sentry:
|
||||
dsn: '%env(SENTRY_DSN)%'
|
||||
# Add request headers, cookies, IP address and the authenticated user
|
||||
# see https://docs.sentry.io/platforms/php/data-management/data-collected/ for more info
|
||||
# send_default_pii: true
|
||||
|
||||
options:
|
||||
traces_sample_rate: 1.0
|
||||
profiles_sample_rate: 1.0
|
||||
ignore_exceptions:
|
||||
- 'Symfony\Component\ErrorHandler\Error\FatalError'
|
||||
- 'Symfony\Component\Debug\Exception\FatalErrorException'
|
||||
|
||||
# If you are using Monolog, you also need this additional configuration to log the errors correctly:
|
||||
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
|
||||
# register_error_listener: false
|
||||
# register_error_handler: false
|
||||
|
||||
# monolog:
|
||||
# handlers:
|
||||
# sentry:
|
||||
# type: sentry
|
||||
# level: !php/const Monolog\Logger::ERROR
|
||||
# hub_id: Sentry\State\HubInterface
|
||||
|
||||
# Uncomment these lines to register a log message processor that resolves PSR-3 placeholders
|
||||
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
|
||||
# services:
|
||||
# Monolog\Processor\PsrLogMessageProcessor:
|
||||
# tags: { name: monolog.processor, handler: sentry }
|
||||
@@ -11,3 +11,6 @@ opcache.interned_strings_buffer = 16
|
||||
opcache.max_accelerated_files = 20000
|
||||
opcache.memory_consumption = 256
|
||||
opcache.enable_file_override = 1
|
||||
|
||||
; for Sentry
|
||||
zend.exception_ignore_args = Off
|
||||
|
||||
119
migrations/Version20250311213417.php
Normal file
119
migrations/Version20250311213417.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250311213417 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE answer ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE answer ALTER question_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN answer.id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN answer.question_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE answer_candidate ALTER answer_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE answer_candidate ALTER candidate_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN answer_candidate.answer_id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN answer_candidate.candidate_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE candidate ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE candidate ALTER season_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN candidate.id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN candidate.season_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE correction ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE correction ALTER candidate_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE correction ALTER quiz_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN correction.id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN correction.candidate_id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN correction.quiz_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER candidate_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER quiz_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER answer_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.candidate_id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.quiz_id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.answer_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE question ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE question ALTER quiz_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN question.id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN question.quiz_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE quiz ADD dropouts INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE quiz ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE quiz ALTER season_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN quiz.id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN quiz.season_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE season ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE season ALTER active_quiz_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN season.id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN season.active_quiz_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE season_user ALTER season_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE season_user ALTER user_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN season_user.season_id IS \'\'');
|
||||
$this->addSql('COMMENT ON COLUMN season_user.user_id IS \'\'');
|
||||
$this->addSql('ALTER TABLE "user" ALTER id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN "user".id IS \'\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE candidate ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE candidate ALTER season_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN candidate.id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN candidate.season_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE correction ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE correction ALTER candidate_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE correction ALTER quiz_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN correction.id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN correction.candidate_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN correction.quiz_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER candidate_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER quiz_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE given_answer ALTER answer_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.candidate_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.quiz_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN given_answer.answer_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE answer_candidate ALTER answer_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE answer_candidate ALTER candidate_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN answer_candidate.answer_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN answer_candidate.candidate_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE quiz DROP dropouts');
|
||||
$this->addSql('ALTER TABLE quiz ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE quiz ALTER season_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN quiz.id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN quiz.season_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE season ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE season ALTER active_quiz_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN season.id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN season.active_quiz_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE answer ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE answer ALTER question_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN answer.id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN answer.question_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE season_user ALTER season_id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE season_user ALTER user_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN season_user.season_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN season_user.user_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE question ALTER id TYPE UUID');
|
||||
$this->addSql('ALTER TABLE question ALTER quiz_id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN question.id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('COMMENT ON COLUMN question.quiz_id IS \'(DC2Type:uuid)\'');
|
||||
$this->addSql('ALTER TABLE "user" ALTER id TYPE UUID');
|
||||
$this->addSql('COMMENT ON COLUMN "user".id IS \'(DC2Type:uuid)\'');
|
||||
}
|
||||
}
|
||||
31
migrations/Version20250402185128.php
Normal file
31
migrations/Version20250402185128.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250402185128 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add elimination table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE elimination (id UUID NOT NULL, data JSON NOT NULL, PRIMARY KEY(id))');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP TABLE elimination');
|
||||
}
|
||||
}
|
||||
30
migrations/Version20250420111904.php
Normal file
30
migrations/Version20250420111904.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20250420111904 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add is_verified column to user table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE "user" ADD is_verified BOOLEAN NOT NULL
|
||||
SQL);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE "user" DROP is_verified
|
||||
SQL);
|
||||
}
|
||||
}
|
||||
30
migrations/Version20250420125040.php
Normal file
30
migrations/Version20250420125040.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20250420125040 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Drop preregister_candidates column from season table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE season DROP preregister_candidates
|
||||
SQL);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE season ADD preregister_candidates BOOLEAN NOT NULL DEFAULT true
|
||||
SQL);
|
||||
}
|
||||
}
|
||||
41
migrations/Version20250427174822.php
Normal file
41
migrations/Version20250427174822.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250427174822 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add ordering to question and answer';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE answer ADD ordering SMALLINT DEFAULT 0 NOT NULL
|
||||
SQL);
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE question ADD ordering SMALLINT DEFAULT 0 NOT NULL
|
||||
SQL);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE answer DROP ordering
|
||||
SQL);
|
||||
$this->addSql(<<<'SQL'
|
||||
ALTER TABLE question DROP ordering
|
||||
SQL);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
parameters:
|
||||
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
|
||||
level: 8
|
||||
paths:
|
||||
- bin/
|
||||
|
||||
34
phpunit.dist.xml
Normal file
34
phpunit.dist.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
failOnNotice="true"
|
||||
failOnWarning="true"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
cacheDirectory=".phpunit.cache"
|
||||
>
|
||||
<php>
|
||||
<ini name="display_errors" value="1" />
|
||||
<ini name="error_reporting" value="-1" />
|
||||
<server name="APP_ENV" value="test" force="true" />
|
||||
<server name="SHELL_VERBOSITY" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Project Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<source ignoreSuppressionOfDeprecations="true" restrictNotices="true" restrictWarnings="true">
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
</include>
|
||||
</source>
|
||||
|
||||
<extensions>
|
||||
</extensions>
|
||||
</phpunit>
|
||||
@@ -7,8 +7,8 @@ use App\Kernel;
|
||||
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
|
||||
|
||||
return static function (array $context): Kernel {
|
||||
$appEnv = !empty($context['APP_ENV']) ? (string) $context['APP_ENV'] : 'prod';
|
||||
$appDebug = !empty($context['APP_DEBUG']) ? filter_var($context['APP_DEBUG'], \FILTER_VALIDATE_BOOL) : 'prod' !== $appEnv;
|
||||
$appEnv = empty($context['APP_ENV']) ? 'prod' : (string) $context['APP_ENV'];
|
||||
$appDebug = empty($context['APP_DEBUG']) ? 'prod' !== $appEnv : filter_var($context['APP_DEBUG'], \FILTER_VALIDATE_BOOL);
|
||||
|
||||
return new Kernel($appEnv, $appDebug);
|
||||
};
|
||||
|
||||
@@ -11,6 +11,8 @@ return RectorConfig::configure()
|
||||
__DIR__.'/src',
|
||||
__DIR__.'/tests',
|
||||
])
|
||||
->withSymfonyContainerXml('var/cache/dev/App_KernelDevDebugContainer.xml')
|
||||
->withParallel()
|
||||
->withPhpSets()
|
||||
->withPreparedSets(
|
||||
deadCode: true,
|
||||
@@ -26,6 +28,7 @@ return RectorConfig::configure()
|
||||
doctrineCodeQuality: true,
|
||||
symfonyCodeQuality: true,
|
||||
)
|
||||
->withComposerBased(twig: true, doctrine: true, phpunit: true)
|
||||
->withAttributesSets(all: true)
|
||||
->withComposerBased(twig: true, doctrine: true, phpunit: true, symfony: true)
|
||||
->withAttributesSets()
|
||||
;
|
||||
|
||||
48
src/Command/MakeAdminCommand.php
Normal file
48
src/Command/MakeAdminCommand.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'app:make-admin',
|
||||
description: 'Give a user the role admin',
|
||||
)]
|
||||
class MakeAdminCommand extends Command
|
||||
{
|
||||
public function __construct(private readonly UserRepository $userRepository)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->addArgument('email', InputArgument::OPTIONAL, 'The email of the user to make admin')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$email = $input->getArgument('email');
|
||||
|
||||
try {
|
||||
$this->userRepository->makeAdmin($email);
|
||||
} catch (\InvalidArgumentException) {
|
||||
$io->error('User not found');
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
21
src/Controller/AbstractController.php
Normal file
21
src/Controller/AbstractController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Enum\FlashType;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as AbstractBaseController;
|
||||
|
||||
abstract class AbstractController extends AbstractBaseController
|
||||
{
|
||||
#[\Override]
|
||||
protected function addFlash(FlashType|string $type, mixed $message): void
|
||||
{
|
||||
if ($type instanceof FlashType) {
|
||||
$type = $type->value;
|
||||
}
|
||||
|
||||
parent::addFlash($type, $message);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Answer;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class AnswerCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class AnswerCrudController extends AbstractCrudController
|
||||
{
|
||||
return Answer::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Candidate;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class CandidateCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class CandidateCrudController extends AbstractCrudController
|
||||
{
|
||||
return Candidate::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Correction;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class CorrectionCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class CorrectionCrudController extends AbstractCrudController
|
||||
{
|
||||
return Correction::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -12,20 +12,19 @@ use App\Entity\Question;
|
||||
use App\Entity\Quiz;
|
||||
use App\Entity\Season;
|
||||
use App\Entity\User;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminDashboard;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[AdminDashboard(routePath: '/admin', routeName: 'admin')]
|
||||
class DashboardController extends AbstractDashboardController
|
||||
{
|
||||
#[Route('/admin', name: 'admin')]
|
||||
#[\Override]
|
||||
public function index(): Response
|
||||
{
|
||||
// return parent::index();
|
||||
|
||||
// Option 1. You can make your dashboard redirect to some common page of your backend
|
||||
//
|
||||
$adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
|
||||
@@ -44,12 +43,14 @@ class DashboardController extends AbstractDashboardController
|
||||
// return $this->render('some/path/my-dashboard.html.twig');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function configureDashboard(): Dashboard
|
||||
{
|
||||
return Dashboard::new()
|
||||
->setTitle('TijdVoorDeTest');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function configureMenuItems(): iterable
|
||||
{
|
||||
yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
|
||||
@@ -61,6 +62,6 @@ class DashboardController extends AbstractDashboardController
|
||||
yield MenuItem::linkToCrud('User', 'fas fa-list', User::class);
|
||||
yield MenuItem::linkToCrud('Given Answer', 'fas fa-list', GivenAnswer::class);
|
||||
yield MenuItem::linkToCrud('Answer', 'fas fa-list', Answer::class);
|
||||
yield MenuItem::linkToLogout('Logout', 'fa fa-exit');
|
||||
yield MenuItem::linkToLogout('Logout', 'fas fa-sign-out');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\GivenAnswer;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class GivenAnswerCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class GivenAnswerCrudController extends AbstractCrudController
|
||||
{
|
||||
return GivenAnswer::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Question;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class QuestionCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class QuestionCrudController extends AbstractCrudController
|
||||
{
|
||||
return Question::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Quiz;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class QuizCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class QuizCrudController extends AbstractCrudController
|
||||
{
|
||||
return Quiz::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Season;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class SeasonCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class SeasonCrudController extends AbstractCrudController
|
||||
{
|
||||
return Season::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\User;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
|
||||
class UserCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -14,15 +13,4 @@ class UserCrudController extends AbstractCrudController
|
||||
{
|
||||
return User::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
163
src/Controller/BackofficeController.php
Normal file
163
src/Controller/BackofficeController.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Candidate;
|
||||
use App\Entity\Quiz;
|
||||
use App\Entity\Season;
|
||||
use App\Entity\User;
|
||||
use App\Enum\FlashType;
|
||||
use App\Form\AddCandidatesFormType;
|
||||
use App\Form\CreateSeasonFormType;
|
||||
use App\Form\UploadQuizFormType;
|
||||
use App\Repository\CandidateRepository;
|
||||
use App\Repository\SeasonRepository;
|
||||
use App\Security\Voter\SeasonVoter;
|
||||
use App\Service\QuizSpreadsheetService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
#[AsController]
|
||||
#[IsGranted('ROLE_USER')]
|
||||
final class BackofficeController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SeasonRepository $seasonRepository,
|
||||
private readonly CandidateRepository $candidateRepository,
|
||||
private readonly Security $security,
|
||||
private readonly TranslatorInterface $translator,
|
||||
) {}
|
||||
|
||||
#[Route('/backoffice/', name: 'app_backoffice_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
\assert($user instanceof User);
|
||||
|
||||
$seasons = $this->security->isGranted('ROLE_ADMIN')
|
||||
? $this->seasonRepository->findAll()
|
||||
: $this->seasonRepository->getSeasonsForUser($user);
|
||||
|
||||
return $this->render('backoffice/index.html.twig', [
|
||||
'seasons' => $seasons,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/backoffice/add', name: 'app_backoffice_season_add', priority: 10)]
|
||||
public function seasonAdd(Request $request, EntityManagerInterface $em): Response
|
||||
{
|
||||
$season = new Season();
|
||||
$form = $this->createForm(CreateSeasonFormType::class, $season);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$user = $this->getUser();
|
||||
\assert($user instanceof User);
|
||||
|
||||
$season->addOwner($user);
|
||||
$season->generateSeasonCode();
|
||||
|
||||
$em->persist($season);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('app_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
}
|
||||
|
||||
return $this->render('backoffice/season_add.html.twig', ['form' => $form]);
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}', name: 'app_backoffice_season')]
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||
public function season(Season $season): Response
|
||||
{
|
||||
return $this->render('backoffice/season.html.twig', [
|
||||
'season' => $season,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/{quiz}', name: 'app_backoffice_quiz')]
|
||||
public function quiz(Season $season, Quiz $quiz): Response
|
||||
{
|
||||
return $this->render('backoffice/quiz.html.twig', [
|
||||
'season' => $season,
|
||||
'quiz' => $quiz,
|
||||
'result' => $this->candidateRepository->getScores($quiz),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/{quiz}/enable', name: 'app_backoffice_enable')]
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||
public function enableQuiz(Season $season, Quiz $quiz, EntityManagerInterface $em): Response
|
||||
{
|
||||
$season->setActiveQuiz($quiz);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('app_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/add_candidate', name: 'app_backoffice_add_candidates', priority: 10)]
|
||||
public function addCandidates(Season $season, Request $request, EntityManagerInterface $em): Response
|
||||
{
|
||||
$form = $this->createForm(AddCandidatesFormType::class);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$candidates = $form->get('candidates')->getData();
|
||||
foreach (explode("\r\n", $candidates) as $candidate) {
|
||||
$season->addCandidate(new Candidate($candidate));
|
||||
}
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('app_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
}
|
||||
|
||||
return $this->render('backoffice/season_add_candidates.html.twig', ['form' => $form]);
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/add', name: 'app_backoffice_quiz_add', priority: 10)]
|
||||
public function addQuiz(Request $request, Season $season, QuizSpreadsheetService $quizSpreadsheet, EntityManagerInterface $em): Response
|
||||
{
|
||||
$quiz = new Quiz();
|
||||
$form = $this->createForm(UploadQuizFormType::class, $quiz);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
/* @var UploadedFile $sheet */
|
||||
$sheet = $form->get('sheet')->getData();
|
||||
|
||||
$quizSpreadsheet->xlsxToQuiz($quiz, $sheet);
|
||||
|
||||
$quiz->setSeason($season);
|
||||
$em->persist($quiz);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash(FlashType::Success, $this->translator->trans('Quiz Added!'));
|
||||
|
||||
return $this->redirectToRoute('app_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
}
|
||||
|
||||
return $this->render('/backoffice/quiz_add.html.twig', ['form' => $form, 'season' => $season]);
|
||||
}
|
||||
|
||||
#[Route('/backoffice/template', name: 'app_backoffice_template', priority: 10)]
|
||||
public function getTemplate(QuizSpreadsheetService $excel): Response
|
||||
{
|
||||
$response = new StreamedResponse($excel->generateTemplate());
|
||||
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
$response->headers->set('Content-Disposition', 'attachment; filename="template.xlsx"');
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,14 @@ namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
|
||||
class LoginController extends AbstractController
|
||||
#[AsController]
|
||||
final class LoginController extends AbstractController
|
||||
{
|
||||
#[Route(path: '/login', name: 'app_login')]
|
||||
#[Route(path: '/login', name: 'app_login_login')]
|
||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||
{
|
||||
// get the login error if there is one
|
||||
@@ -26,8 +28,8 @@ class LoginController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(path: '/logout', name: 'app_logout')]
|
||||
public function logout(): void
|
||||
#[Route(path: '/logout', name: 'app_login_logout')]
|
||||
public function logout(): never
|
||||
{
|
||||
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
|
||||
}
|
||||
|
||||
20
src/Controller/PrepareEliminationController.php
Normal file
20
src/Controller/PrepareEliminationController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class PrepareEliminationController extends AbstractController
|
||||
{
|
||||
#[Route('/backoffice/elimination/prepare', name: 'app_prepare_elimination')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('prepare_elimination/index.html.twig', [
|
||||
'controller_name' => 'PrepareEliminationController',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,44 +4,62 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Answer;
|
||||
use App\Entity\Candidate;
|
||||
use App\Entity\GivenAnswer;
|
||||
use App\Entity\Question;
|
||||
use App\Entity\Season;
|
||||
use App\Enum\FlashType;
|
||||
use App\Form\EnterNameType;
|
||||
use App\Form\SelectSeasonType;
|
||||
use App\Helpers\Base64;
|
||||
use App\Repository\AnswerRepository;
|
||||
use App\Repository\CandidateRepository;
|
||||
use App\Repository\GivenAnswerRepository;
|
||||
use App\Repository\QuestionRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use App\Repository\SeasonRepository;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
#[AsController]
|
||||
class QuizController extends AbstractController
|
||||
final class QuizController extends AbstractController
|
||||
{
|
||||
public const string SEASON_CODE_REGEX = '[A-Za-z\d]{5}';
|
||||
|
||||
private const string CANDIDATE_HASH_REGEX = '[\w\-=]+';
|
||||
|
||||
#[Route(path: '/', name: 'select_season', methods: ['GET', 'POST'])]
|
||||
public function selectSeason(Request $request): Response
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
#[Route(path: '/', name: 'app_quiz_selectseason', methods: ['GET', 'POST'])]
|
||||
public function selectSeason(Request $request, SeasonRepository $seasonRepository): Response
|
||||
{
|
||||
$form = $this->createForm(SelectSeasonType::class);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$seasonCode = $form->get('season_code')->getData();
|
||||
|
||||
return $this->redirectToRoute('enter_name', ['seasonCode' => $data['season_code']]);
|
||||
if ([] === $seasonRepository->findBy(['seasonCode' => $seasonCode])) {
|
||||
$this->addFlash(FlashType::Warning, $this->translator->trans('Invalid season code'));
|
||||
|
||||
return $this->redirectToRoute('app_quiz_selectseason');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_quiz_entername', ['seasonCode' => $seasonCode]);
|
||||
}
|
||||
|
||||
return $this->render('quiz/select_season.html.twig', ['form' => $form]);
|
||||
}
|
||||
|
||||
#[Route(path: '/{seasonCode}', name: 'enter_name', requirements: ['seasonCode' => self::SEASON_CODE_REGEX])]
|
||||
#[Route(path: '/{seasonCode}', name: 'app_quiz_entername', requirements: ['seasonCode' => self::SEASON_CODE_REGEX])]
|
||||
public function enterName(
|
||||
Request $request,
|
||||
#[MapEntity(mapping: ['seasonCode' => 'seasonCode'])]
|
||||
Season $season,
|
||||
): Response {
|
||||
$form = $this->createForm(EnterNameType::class);
|
||||
@@ -49,10 +67,9 @@ class QuizController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$name = $data['name'];
|
||||
$name = $form->get('name')->getData();
|
||||
|
||||
return $this->redirectToRoute('quiz_page', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => Base64::base64_url_encode($name)]);
|
||||
return $this->redirectToRoute('app_quiz_quizpage', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => Base64::base64UrlEncode($name)]);
|
||||
}
|
||||
|
||||
return $this->render('quiz/enter_name.twig', ['season' => $season, 'form' => $form]);
|
||||
@@ -60,26 +77,50 @@ class QuizController extends AbstractController
|
||||
|
||||
#[Route(
|
||||
path: '/{seasonCode}/{nameHash}',
|
||||
name: 'quiz_page',
|
||||
name: 'app_quiz_quizpage',
|
||||
requirements: ['seasonCode' => self::SEASON_CODE_REGEX, 'nameHash' => self::CANDIDATE_HASH_REGEX],
|
||||
)]
|
||||
public function quizPage(
|
||||
#[MapEntity(mapping: ['seasonCode' => 'seasonCode'])]
|
||||
Season $season,
|
||||
string $nameHash,
|
||||
CandidateRepository $candidateRepository,
|
||||
QuestionRepository $questionRepository,
|
||||
AnswerRepository $answerRepository,
|
||||
GivenAnswerRepository $givenAnswerRepository,
|
||||
Request $request,
|
||||
): Response {
|
||||
$candidate = $candidateRepository->getCandidateByHash($season, $nameHash);
|
||||
|
||||
if (!$candidate instanceof Candidate) {
|
||||
// Add option to add new candidate when preregister is disabled
|
||||
$this->addFlash(FlashType::Danger->value, 'Candidate not found');
|
||||
$this->addFlash(FlashType::Danger, $this->translator->trans('Candidate not found'));
|
||||
|
||||
return $this->redirectToRoute('enter_name', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('app_quiz_entername', ['seasonCode' => $season->getSeasonCode()]);
|
||||
}
|
||||
|
||||
if ('POST' === $request->getMethod()) {
|
||||
$answer = $answerRepository->findOneBy(['id' => $request->request->get('answer')]);
|
||||
|
||||
if (!$answer instanceof Answer) {
|
||||
throw new BadRequestException('Invalid Answer ID');
|
||||
}
|
||||
|
||||
$givenAnswer = (new GivenAnswer())
|
||||
->setCandidate($candidate)
|
||||
->setAnswer($answer)
|
||||
->setQuiz($answer->getQuestion()->getQuiz());
|
||||
$givenAnswerRepository->save($givenAnswer);
|
||||
}
|
||||
|
||||
$question = $questionRepository->findNextQuestionForCandidate($candidate);
|
||||
|
||||
if (!$question instanceof Question) {
|
||||
$this->addFlash(FlashType::Success, $this->translator->trans('Quiz completed'));
|
||||
|
||||
return $this->redirectToRoute('app_quiz_entername', ['seasonCode' => $season->getSeasonCode()]);
|
||||
}
|
||||
|
||||
// TODO One first question record time
|
||||
return $this->render('quiz/question.twig', ['candidate' => $candidate, 'question' => $question]);
|
||||
}
|
||||
}
|
||||
|
||||
93
src/Controller/RegistrationController.php
Normal file
93
src/Controller/RegistrationController.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Form\RegistrationFormType;
|
||||
use App\Repository\UserRepository;
|
||||
use App\Security\EmailVerifier;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
|
||||
|
||||
final class RegistrationController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly EmailVerifier $emailVerifier, private readonly TranslatorInterface $translator) {}
|
||||
|
||||
#[Route('/register', name: 'app_register')]
|
||||
public function register(
|
||||
Request $request,
|
||||
UserPasswordHasherInterface $userPasswordHasher,
|
||||
Security $security,
|
||||
EntityManagerInterface $entityManager,
|
||||
): Response {
|
||||
$user = new User();
|
||||
$form = $this->createForm(RegistrationFormType::class, $user);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
/** @var string $plainPassword */
|
||||
$plainPassword = $form->get('plainPassword')->getData();
|
||||
|
||||
$user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword));
|
||||
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
|
||||
// generate a signed url and email it to the user
|
||||
$this->emailVerifier->sendEmailConfirmation('app_verify_email', $user,
|
||||
(new TemplatedEmail())
|
||||
->to((string) $user->getEmail())
|
||||
->subject($this->translator->trans('Please Confirm your Email'))
|
||||
->htmlTemplate('registration/confirmation_email.html.twig')
|
||||
);
|
||||
|
||||
$response = $security->login($user, 'form_login', 'main');
|
||||
\assert($response instanceof Response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->render('registration/register.html.twig', [
|
||||
'registrationForm' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/verify/email', name: 'app_verify_email')]
|
||||
public function verifyUserEmail(Request $request, TranslatorInterface $translator, UserRepository $userRepository): Response
|
||||
{
|
||||
$id = $request->query->get('id');
|
||||
|
||||
if (null === $id) {
|
||||
return $this->redirectToRoute('app_register');
|
||||
}
|
||||
|
||||
$user = $userRepository->find($id);
|
||||
|
||||
if (null === $user) {
|
||||
return $this->redirectToRoute('app_register');
|
||||
}
|
||||
|
||||
// validate email confirmation link, sets User::isVerified=true and persists
|
||||
try {
|
||||
$this->emailVerifier->handleEmailConfirmation($request, $user);
|
||||
} catch (VerifyEmailExceptionInterface $verifyEmailException) {
|
||||
$this->addFlash('verify_email_error', $translator->trans($verifyEmailException->getReason(), [], 'VerifyEmailBundle'));
|
||||
|
||||
return $this->redirectToRoute('app_register');
|
||||
}
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('Your email address has been verified.'));
|
||||
|
||||
return $this->redirectToRoute('app_backoffice_index');
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,7 @@ class KrtekFixtures extends Fixture
|
||||
$manager->persist($season);
|
||||
|
||||
$season->setName('Krtek Weekend')
|
||||
->setSeasonCode('12345')
|
||||
->setPreregisterCandidates(true)
|
||||
->setSeasonCode('krtek')
|
||||
->addCandidate(new Candidate('Claudia'))
|
||||
->addCandidate(new Candidate('Eelco'))
|
||||
->addCandidate(new Candidate('Elise'))
|
||||
@@ -53,6 +52,7 @@ class KrtekFixtures extends Fixture
|
||||
->setQuestion('Is de Krtek een man of een vrouw?')
|
||||
->addAnswer(new Answer('Vrouw', true))
|
||||
->addAnswer(new Answer('Man'))
|
||||
->setOrdering(1)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -60,6 +60,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Geen', true))
|
||||
->addAnswer(new Answer('1'))
|
||||
->addAnswer(new Answer('2'))
|
||||
->setOrdering(2)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -69,15 +70,17 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Koningsdag'))
|
||||
->addAnswer(new Answer('Kerst', true))
|
||||
->addAnswer(new Answer('Oud en Nieuw'))
|
||||
->setOrdering(3)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
->setQuestion('Hoe kwam de Krtek naar Kersteren vandaag?')
|
||||
->addAnswer(new Answer('Met het OV', true))
|
||||
->addAnswer(new Answer('Met de auto'))
|
||||
->setOrdering(4)
|
||||
)
|
||||
->addQuestion((new Question())
|
||||
->setQuestion('Met wie keek de Kretek video bij binnenkomst?')
|
||||
->setQuestion('Met wie keek de Krtek video bij binnenkomst?')
|
||||
->addAnswer(new Answer('Claudia'))
|
||||
->addAnswer(new Answer('Eelco'))
|
||||
->addAnswer(new Answer('Elise'))
|
||||
@@ -91,6 +94,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom', true))
|
||||
->setOrdering(5)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -103,6 +107,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Probeer ook eens buiten de lijntjes te kleuren', true))
|
||||
->addAnswer(new Answer('Ga als je groot bent op groepsreis! '))
|
||||
->addAnswer(new Answer('Trek minder aan van de mening van anderen, het is oké om anders te zijn.'))
|
||||
->setOrdering(6)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -113,6 +118,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Pantoffels'))
|
||||
->addAnswer(new Answer('Hakken'))
|
||||
->addAnswer(new Answer('Geen schoenen, alleen sokken'))
|
||||
->setOrdering(7)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -120,12 +126,14 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Fiets', true))
|
||||
->addAnswer(new Answer('Auto'))
|
||||
->addAnswer(new Answer('Trein'))
|
||||
->setOrdering(8)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
->setQuestion('Heeft de Krtek een eigen auto?')
|
||||
->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true))
|
||||
->setOrdering(9)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -145,12 +153,14 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Pieter'))
|
||||
->addAnswer(new Answer('Renée Fokker'))
|
||||
->addAnswer(new Answer('Sam, Davy', true))
|
||||
->setOrdering(10)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
->setQuestion('Zou de Krtek molboekjes, jokers, vrijstellingen of topito’s uit iemands rugzak stelen om te kunnen winnen?')
|
||||
->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true))
|
||||
->setOrdering(11)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -158,6 +168,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Éénpersoons, losstaand bed'))
|
||||
->addAnswer(new Answer('Éénpersoonsbed, tegen een ander bed aan', true))
|
||||
->addAnswer(new Answer('Tweepersoons bed'))
|
||||
->setOrdering(12)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -166,12 +177,14 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('6', true))
|
||||
->addAnswer(new Answer('7'))
|
||||
->addAnswer(new Answer('8'))
|
||||
->setOrdering(13)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
->setQuestion('Waar zat de Krtek aan tafel bij het diner?')
|
||||
->addAnswer(new Answer('Met de rug naar de accommodatie'))
|
||||
->addAnswer(new Answer('Met de rug naar de buitenmuur', true))
|
||||
->setOrdering(14)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -189,6 +202,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom'))
|
||||
->setOrdering(15)
|
||||
)
|
||||
;
|
||||
}
|
||||
@@ -203,6 +217,7 @@ class KrtekFixtures extends Fixture
|
||||
->setQuestion('Is de Krtek een man of een vrouw?')
|
||||
->addAnswer(new Answer('Man'))
|
||||
->addAnswer(new Answer('Vrouw', true))
|
||||
->setOrdering(1)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -214,6 +229,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('De Krtek heeft een intolerantie'))
|
||||
->addAnswer(new Answer('De Krtek eet geen rundvlees'))
|
||||
->addAnswer(new Answer('De Krtek eet geen waterdieren'))
|
||||
->setOrdering(2)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -225,6 +241,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Tom'))
|
||||
->addAnswer(new Answer('De huisdieren van de Krtek hebben geen naam'))
|
||||
->addAnswer(new Answer('De Krtek heeft geen huisdieren', true))
|
||||
->setOrdering(3)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -235,6 +252,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Melk'))
|
||||
->addAnswer(new Answer('Sap'))
|
||||
->addAnswer(new Answer('Niks'))
|
||||
->setOrdering(4)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -246,6 +264,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Oostenrijk'))
|
||||
->addAnswer(new Answer('Turkije'))
|
||||
->addAnswer(new Answer('Zweden', true))
|
||||
->setOrdering(5)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -255,6 +274,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Het derde groepje'))
|
||||
->addAnswer(new Answer('Het vierde groepje'))
|
||||
->addAnswer(new Answer('Het vijfde groepje'))
|
||||
->setOrdering(6)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -263,12 +283,14 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Het universum', true))
|
||||
->addAnswer(new Answer('Toeval'))
|
||||
->addAnswer(new Answer('De Krtek is hindoeïstisch'))
|
||||
->setOrdering(7)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
->setQuestion('At de Krtek op vrijdagavond heksenkaas tijdens het diner?')
|
||||
->addAnswer(new Answer('Ja', true))
|
||||
->addAnswer(new Answer('Nee'))
|
||||
->setOrdering(8)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -277,6 +299,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Tussen 1:00 en 1:59 uur', true))
|
||||
->addAnswer(new Answer('Tussen 2:00 en 2:59 uur'))
|
||||
->addAnswer(new Answer('Na 3:00'))
|
||||
->setOrdering(9)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -285,6 +308,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('2'))
|
||||
->addAnswer(new Answer('3'))
|
||||
->addAnswer(new Answer('geen', true))
|
||||
->setOrdering(10)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -295,6 +319,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Sesamstraat'))
|
||||
->addAnswer(new Answer('Spongebob Squarepants'))
|
||||
->addAnswer(new Answer('Teletubbies'))
|
||||
->setOrdering(11)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -302,6 +327,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('In koffer(s)', true))
|
||||
->addAnswer(new Answer('In losse tas(sen)'))
|
||||
->addAnswer(new Answer('In een rugzak'))
|
||||
->setOrdering(12)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -314,12 +340,14 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Servies dat tegen elkaar klettert'))
|
||||
->addAnswer(new Answer('Het geroekoe van een duif', true))
|
||||
->addAnswer(new Answer('Piepschuim'))
|
||||
->setOrdering(13)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
->setQuestion('Wilde de Krtek penningmeester worden?')
|
||||
->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true))
|
||||
->setOrdering(14)
|
||||
)
|
||||
|
||||
->addQuestion((new Question())
|
||||
@@ -337,6 +365,7 @@ class KrtekFixtures extends Fixture
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom'))
|
||||
->setOrdering(15)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Entity;
|
||||
use App\Repository\AnswerRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
@@ -21,6 +22,9 @@ class Answer
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
private Uuid $id;
|
||||
|
||||
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
||||
private int $ordering;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'answers')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private Question $question;
|
||||
@@ -72,7 +76,7 @@ class Answer
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isRightAnswer(): ?bool
|
||||
public function isRightAnswer(): bool
|
||||
{
|
||||
return $this->isRightAnswer;
|
||||
}
|
||||
@@ -121,4 +125,16 @@ class Answer
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrdering(): int
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
public function setOrdering(int $ordering): self
|
||||
{
|
||||
$this->ordering = $ordering;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,6 @@ class Candidate
|
||||
|
||||
public function getNameHash(): string
|
||||
{
|
||||
return Base64::base64_url_encode($this->name);
|
||||
return Base64::base64UrlEncode($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
45
src/Entity/Elimination.php
Normal file
45
src/Entity/Elimination.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\EliminationRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: EliminationRepository::class)]
|
||||
class Elimination
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
private Uuid $id;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
#[ORM\Column(type: Types::JSON)]
|
||||
private array $data = [];
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $data */
|
||||
public function setData(array $data): static
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class GivenAnswer
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
private ?Uuid $id = null;
|
||||
private Uuid $id;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'givenAnswers')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
@@ -34,8 +34,8 @@ class GivenAnswer
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Answer $answer = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)]
|
||||
private \DateTimeInterface $created;
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: false)]
|
||||
private \DateTimeImmutable $created;
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
@@ -78,7 +78,7 @@ class GivenAnswer
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreated(): ?\DateTimeInterface
|
||||
public function getCreated(): \DateTimeImmutable
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Entity;
|
||||
use App\Repository\QuestionRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
@@ -21,7 +22,10 @@ class Question
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: false)]
|
||||
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
||||
private int $ordering;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 255)]
|
||||
private string $question;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'questions')]
|
||||
@@ -33,6 +37,7 @@ class Question
|
||||
|
||||
/** @var Collection<int, Answer> */
|
||||
#[ORM\OneToMany(targetEntity: Answer::class, mappedBy: 'question', cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['ordering' => 'ASC'])]
|
||||
private Collection $answers;
|
||||
|
||||
public function __construct()
|
||||
@@ -96,4 +101,35 @@ class Question
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getErrors(): ?string
|
||||
{
|
||||
if (0 === \count($this->answers)) {
|
||||
return 'This question has no answers';
|
||||
}
|
||||
|
||||
$correctAnswers = $this->answers->filter(static fn (Answer $answer): bool => $answer->isRightAnswer())->count();
|
||||
|
||||
if (0 === $correctAnswers) {
|
||||
return 'This question has no correct answers';
|
||||
}
|
||||
|
||||
if ($correctAnswers > 1) {
|
||||
return 'This question has multiple correct answers';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getOrdering(): int
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
public function setOrdering(int $ordering): static
|
||||
{
|
||||
$this->ordering = $ordering;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,16 @@ class Quiz
|
||||
|
||||
/** @var Collection<int, Question> */
|
||||
#[ORM\OneToMany(targetEntity: Question::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['ordering' => 'ASC'])]
|
||||
private Collection $questions;
|
||||
|
||||
/** @var Collection<int, Correction> */
|
||||
#[ORM\OneToMany(targetEntity: Correction::class, mappedBy: 'quiz', orphanRemoval: true)]
|
||||
private Collection $corrections;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $dropouts = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->questions = new ArrayCollection();
|
||||
@@ -102,4 +106,16 @@ class Quiz
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDropouts(): ?int
|
||||
{
|
||||
return $this->dropouts;
|
||||
}
|
||||
|
||||
public function setDropouts(?int $dropouts): static
|
||||
{
|
||||
$this->dropouts = $dropouts;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ use Symfony\Component\Uid\Uuid;
|
||||
#[ORM\Entity(repositoryClass: SeasonRepository::class)]
|
||||
class Season
|
||||
{
|
||||
private const string SEASON_CODE_CHARACTERS = 'bcdfghjklmnpqrstvwxz';
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
@@ -27,9 +29,6 @@ class Season
|
||||
#[ORM\Column(length: 5)]
|
||||
private string $seasonCode;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $preregisterCandidates;
|
||||
|
||||
/** @var Collection<int, Quiz> */
|
||||
#[ORM\OneToMany(targetEntity: Quiz::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)]
|
||||
private Collection $quizzes;
|
||||
@@ -81,18 +80,6 @@ class Season
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isPreregisterCandidates(): bool
|
||||
{
|
||||
return $this->preregisterCandidates;
|
||||
}
|
||||
|
||||
public function setPreregisterCandidates(bool $preregisterCandidates): static
|
||||
{
|
||||
$this->preregisterCandidates = $preregisterCandidates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Quiz> */
|
||||
public function getQuizzes(): Collection
|
||||
{
|
||||
@@ -158,4 +145,23 @@ class Season
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isOwner(User $user): bool
|
||||
{
|
||||
return $this->owners->contains($user);
|
||||
}
|
||||
|
||||
public function generateSeasonCode(): self
|
||||
{
|
||||
$code = '';
|
||||
$len = mb_strlen(self::SEASON_CODE_CHARACTERS) - 1;
|
||||
|
||||
for ($i = 0; $i < 5; ++$i) {
|
||||
$code .= self::SEASON_CODE_CHARACTERS[random_int(0, $len)];
|
||||
}
|
||||
|
||||
$this->seasonCode = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
@@ -17,6 +18,7 @@ use Symfony\Component\Uid\Uuid;
|
||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||
#[ORM\Table(name: '`user`')]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
|
||||
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
|
||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
{
|
||||
#[ORM\Id]
|
||||
@@ -40,6 +42,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\ManyToMany(targetEntity: Season::class, mappedBy: 'owners')]
|
||||
private Collection $seasons;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $isVerified = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->seasons = new ArrayCollection();
|
||||
@@ -71,13 +76,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
*/
|
||||
public function getUserIdentifier(): string
|
||||
{
|
||||
return $this->email;
|
||||
/** @var non-empty-string $identifier */
|
||||
$identifier = $this->email;
|
||||
|
||||
return $identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserInterface
|
||||
*
|
||||
* @return non-empty-list<string>
|
||||
* @return non-empty-array<int<0, max>, string>
|
||||
*/
|
||||
public function getRoles(): array
|
||||
{
|
||||
@@ -140,4 +148,21 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isVerified(): bool
|
||||
{
|
||||
return $this->isVerified;
|
||||
}
|
||||
|
||||
public function setIsVerified(bool $isVerified): static
|
||||
{
|
||||
$this->isVerified = $isVerified;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return \in_array('ROLE_ADMIN', $this->getRoles(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ enum FlashType: string
|
||||
case Danger = 'danger';
|
||||
case Warning = 'warning';
|
||||
case Info = 'info';
|
||||
case Ligt = 'light';
|
||||
case Light = 'light';
|
||||
case Dark = 'dark';
|
||||
}
|
||||
|
||||
18
src/Exception/SpreadsheetDataException.php
Normal file
18
src/Exception/SpreadsheetDataException.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
class SpreadsheetDataException extends SpreadsheetException
|
||||
{
|
||||
/** @param list<string> $errors */
|
||||
public function __construct(
|
||||
public readonly array $errors,
|
||||
string $message = '',
|
||||
int $code = 0,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
7
src/Exception/SpreadsheetException.php
Normal file
7
src/Exception/SpreadsheetException.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
class SpreadsheetException extends \Exception {}
|
||||
33
src/Form/AddCandidatesFormType.php
Normal file
33
src/Form/AddCandidatesFormType.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/** @extends AbstractType<null> */
|
||||
class AddCandidatesFormType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('candidates', TextareaType::class, [
|
||||
'label' => $this->translator->trans('Candidates'),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
// Configure your form options here
|
||||
]);
|
||||
}
|
||||
}
|
||||
34
src/Form/CreateSeasonFormType.php
Normal file
34
src/Form/CreateSeasonFormType.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Season;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/** @extends AbstractType<Season> */
|
||||
class CreateSeasonFormType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'label' => $this->translator->trans('Season Name'),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Season::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,12 @@ namespace App\Form;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/** @extends AbstractType<null> */
|
||||
class EnterNameType extends AbstractType
|
||||
{
|
||||
public function __construct(private TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
@@ -22,14 +20,6 @@ class EnterNameType extends AbstractType
|
||||
->add('name', TextType::class,
|
||||
['required' => true, 'label' => $this->translator->trans('Enter your name')],
|
||||
)
|
||||
// ->add('submit', SubmitType::class, ['label' => 'Start quiz'])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
// Configure your form options here
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
56
src/Form/RegistrationFormType.php
Normal file
56
src/Form/RegistrationFormType.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @extends AbstractType<User>
|
||||
*/
|
||||
class RegistrationFormType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('email', EmailType::class, [
|
||||
'label' => $this->translator->trans('Email'),
|
||||
'attr' => ['autocomplete' => 'email'],
|
||||
])
|
||||
->add('plainPassword', PasswordType::class, [
|
||||
'label' => $this->translator->trans('Password'),
|
||||
'mapped' => false,
|
||||
'attr' => ['autocomplete' => 'new-password'],
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'Please enter a password',
|
||||
]),
|
||||
new Length([
|
||||
'min' => 8,
|
||||
'minMessage' => 'Your password should be at least {{ limit }} characters',
|
||||
// max length allowed by Symfony for security reasons
|
||||
'max' => 4096,
|
||||
]),
|
||||
],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -9,16 +9,19 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Regex;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/** @extends AbstractType<null> */
|
||||
class SelectSeasonType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('season_code', TextType::class,
|
||||
['required' => true, 'constraints' => new Regex(pattern: "/^[A-Za-z\d]{5}$/")],
|
||||
['required' => true, 'constraints' => new Regex(pattern: "/^[A-Za-z\d]{5}$/"), 'label' => $this->translator->trans('Season Code')]
|
||||
)
|
||||
// ->add('submit', SubmitType::class, ['label' => 'Start quiz'])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
50
src/Form/UploadQuizFormType.php
Normal file
50
src/Form/UploadQuizFormType.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Quiz;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\File;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/** @extends AbstractType<Quiz> */
|
||||
class UploadQuizFormType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'label' => $this->translator->trans('Quiz name'),
|
||||
])
|
||||
->add('sheet', FileType::class, [
|
||||
'label' => $this->translator->trans('Quiz (xlsx)'),
|
||||
'mapped' => false,
|
||||
'required' => true,
|
||||
'constraints' => [
|
||||
new File([
|
||||
'maxSize' => '1024k',
|
||||
'mimeTypes' => [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
],
|
||||
'mimeTypesMessage' => $this->translator->trans('Please upload a valid XLSX file'),
|
||||
]),
|
||||
],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Quiz::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,13 @@ use Safe\Exceptions\UrlException;
|
||||
|
||||
class Base64
|
||||
{
|
||||
private function __construct()
|
||||
public static function base64UrlEncode(string $input): string
|
||||
{
|
||||
}
|
||||
|
||||
public static function base64_url_encode(string $input): string
|
||||
{
|
||||
return strtr(base64_encode($input), '+/', '-_');
|
||||
return rtrim(strtr(base64_encode($input), '+/', '-_'), '=');
|
||||
}
|
||||
|
||||
/** @throws UrlException */
|
||||
public static function base64_url_decode(string $input): string
|
||||
public static function base64UrlDecode(string $input): string
|
||||
{
|
||||
return \Safe\base64_decode(strtr($input, '-_', '+/'), true);
|
||||
}
|
||||
|
||||
@@ -5,14 +5,20 @@ declare(strict_types=1);
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Candidate;
|
||||
use App\Entity\Correction;
|
||||
use App\Entity\Quiz;
|
||||
use App\Entity\Season;
|
||||
use App\Helpers\Base64;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Safe\Exceptions\UrlException;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Candidate>
|
||||
*
|
||||
* @phpstan-type Result array{0: Candidate, correct: int, time: \DateInterval, corrections?: float, score: float}
|
||||
* @phpstan-type ResultList list<Result>
|
||||
*/
|
||||
class CandidateRepository extends ServiceEntityRepository
|
||||
{
|
||||
@@ -24,7 +30,7 @@ class CandidateRepository extends ServiceEntityRepository
|
||||
public function getCandidateByHash(Season $season, string $hash): ?Candidate
|
||||
{
|
||||
try {
|
||||
$name = Base64::base64_url_decode($hash);
|
||||
$name = Base64::base64UrlDecode($hash);
|
||||
} catch (UrlException) {
|
||||
return null;
|
||||
}
|
||||
@@ -36,4 +42,59 @@ class CandidateRepository extends ServiceEntityRepository
|
||||
->setParameter('name', $name)
|
||||
->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function save(Candidate $candidate, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($candidate);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/** @return ResultList */
|
||||
public function getScores(Quiz $quiz): array
|
||||
{
|
||||
$scoreTimeQb = $this->createQueryBuilder('c', 'c.id')
|
||||
->select('c', 'sum(case when a.isRightAnswer = true then 1 else 0 end) as correct', 'max(ga.created) - min(ga.created) as time')
|
||||
->join('c.givenAnswers', 'ga')
|
||||
->join('ga.answer', 'a')
|
||||
->where('ga.quiz = :quiz')
|
||||
->groupBy('c.id')
|
||||
->setParameter('quiz', $quiz);
|
||||
|
||||
$correctionsQb = $this->createQueryBuilder('c', 'c.id')
|
||||
->select('c', 'cor.amount as corrections')
|
||||
->innerJoin(Correction::class, 'cor', Join::WITH, 'cor.candidate = c and cor.quiz = :quiz')
|
||||
->setParameter('quiz', $quiz);
|
||||
|
||||
$merged = array_merge_recursive($scoreTimeQb->getQuery()->getArrayResult(), $correctionsQb->getQuery()->getArrayResult());
|
||||
|
||||
return $this->sortResults($this->calculateScore($merged));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, array{0: Candidate, correct: int, time: \DateInterval, corrections?: float}> $in
|
||||
*
|
||||
* @return array<string, Result>
|
||||
* */
|
||||
private function calculateScore(array $in): array
|
||||
{
|
||||
return array_map(static fn ($candidate): array => [
|
||||
...$candidate,
|
||||
'score' => $candidate['correct'] + ($candidate['corrections'] ?? 0.0),
|
||||
], $in);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, Result> $results
|
||||
*
|
||||
* @return ResultList
|
||||
* */
|
||||
private function sortResults(array $results): array
|
||||
{
|
||||
usort($results, static fn ($a, $b): int => $b['score'] <=> $a['score']);
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
45
src/Repository/EliminationRepository.php
Normal file
45
src/Repository/EliminationRepository.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Elimination;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Elimination>
|
||||
*/
|
||||
class EliminationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Elimination::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Elimination[] Returns an array of Elimination objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('e')
|
||||
// ->andWhere('e.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('e.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Elimination
|
||||
// {
|
||||
// return $this->createQueryBuilder('e')
|
||||
// ->andWhere('e.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
@@ -17,4 +17,13 @@ class GivenAnswerRepository extends ServiceEntityRepository
|
||||
{
|
||||
parent::__construct($registry, GivenAnswer::class);
|
||||
}
|
||||
|
||||
public function save(GivenAnswer $givenAnswer, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($givenAnswer);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ class QuestionRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Question::class);
|
||||
}
|
||||
|
||||
public function findNextQuestionForCandidate(Candidate $candidate): Question
|
||||
public function findNextQuestionForCandidate(Candidate $candidate): ?Question
|
||||
{
|
||||
$qb = $this->createQueryBuilder('q');
|
||||
|
||||
return $qb->join('q.quiz', 'qz')
|
||||
->andWhere($qb->expr()->notIn('q.id', $this->getEntityManager()->createQueryBuilder()
|
||||
->select('ga.id')
|
||||
->select('q1')
|
||||
->from(GivenAnswer::class, 'ga')
|
||||
->join('ga.answer', 'a')
|
||||
->join('a.question', 'q1')
|
||||
@@ -38,6 +38,6 @@ class QuestionRepository extends ServiceEntityRepository
|
||||
->setMaxResults(1)
|
||||
->setParameter('candidate', $candidate)
|
||||
->setParameter('quiz', $candidate->getSeason()->getActiveQuiz())
|
||||
->getQuery()->getSingleResult();
|
||||
->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Season;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
@@ -17,4 +18,15 @@ class SeasonRepository extends ServiceEntityRepository
|
||||
{
|
||||
parent::__construct($registry, Season::class);
|
||||
}
|
||||
|
||||
/** @return list<Season> Returns an array of Season objects */
|
||||
public function getSeasonsForUser(User $user): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('s')
|
||||
->where(':user MEMBER OF s.owners')
|
||||
->orderBy('s.name')
|
||||
->setParameter('user', $user);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,7 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<User>
|
||||
*
|
||||
* @implements PasswordUpgraderInterface<User>
|
||||
*/
|
||||
/** @extends ServiceEntityRepository<User> */
|
||||
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
@@ -22,11 +18,24 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
/** Used to upgrade (rehash) the user's password automatically over time. */
|
||||
/** Used to upgrade (rehash) the user's password automatically over time.
|
||||
* @param User $user
|
||||
* */
|
||||
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
|
||||
{
|
||||
$user->setPassword($newHashedPassword);
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
public function makeAdmin(string $email): void
|
||||
{
|
||||
$user = $this->findOneBy(['email' => $email]);
|
||||
if (!$user instanceof User) {
|
||||
throw new \InvalidArgumentException('User not found');
|
||||
}
|
||||
|
||||
$user->setRoles(['ROLE_ADMIN']);
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
52
src/Security/EmailVerifier.php
Normal file
52
src/Security/EmailVerifier.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Security;
|
||||
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
|
||||
use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface;
|
||||
|
||||
class EmailVerifier
|
||||
{
|
||||
public function __construct(
|
||||
private readonly VerifyEmailHelperInterface $verifyEmailHelper,
|
||||
private readonly MailerInterface $mailer,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
) {}
|
||||
|
||||
public function sendEmailConfirmation(string $verifyEmailRouteName, User $user, TemplatedEmail $email): void
|
||||
{
|
||||
$signatureComponents = $this->verifyEmailHelper->generateSignature(
|
||||
$verifyEmailRouteName,
|
||||
(string) $user->getId(),
|
||||
(string) $user->getEmail(),
|
||||
['id' => $user->getId()]
|
||||
);
|
||||
|
||||
$context = $email->getContext();
|
||||
$context['signedUrl'] = $signatureComponents->getSignedUrl();
|
||||
$context['expiresAtMessageKey'] = $signatureComponents->getExpirationMessageKey();
|
||||
$context['expiresAtMessageData'] = $signatureComponents->getExpirationMessageData();
|
||||
|
||||
$email->context($context);
|
||||
|
||||
$this->mailer->send($email);
|
||||
}
|
||||
|
||||
/** @throws VerifyEmailExceptionInterface */
|
||||
public function handleEmailConfirmation(Request $request, User $user): void
|
||||
{
|
||||
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, (string) $user->getId(), (string) $user->getEmail());
|
||||
|
||||
$user->setIsVerified(true);
|
||||
|
||||
$this->entityManager->persist($user);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
49
src/Security/Voter/SeasonVoter.php
Normal file
49
src/Security/Voter/SeasonVoter.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use App\Entity\Season;
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/** @extends Voter<string, Season> */
|
||||
final class SeasonVoter extends Voter
|
||||
{
|
||||
public const string EDIT = 'SEASON_EDIT';
|
||||
|
||||
public const string DELETE = 'SEASON_DELETE';
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
{
|
||||
return \in_array($attribute, [self::EDIT, self::DELETE], true)
|
||||
&& $subject instanceof Season;
|
||||
}
|
||||
|
||||
/** @param Season $subject */
|
||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
||||
{
|
||||
$user = $token->getUser();
|
||||
if (!$user instanceof User) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ($attribute) {
|
||||
case self::EDIT:
|
||||
case self::DELETE:
|
||||
if ($subject->isOwner($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
16
src/Service/EliminationService.php
Normal file
16
src/Service/EliminationService.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Repository\CandidateRepository;
|
||||
|
||||
/**
|
||||
* @phpstan-import-type ResultList from CandidateRepository
|
||||
*/
|
||||
class EliminationService
|
||||
{
|
||||
/** @phpstan-param ResultList $result */
|
||||
public function createEliminationFromResult(array $result): void {}
|
||||
}
|
||||
123
src/Service/QuizSpreadsheetService.php
Normal file
123
src/Service/QuizSpreadsheetService.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Answer;
|
||||
use App\Entity\Question;
|
||||
use App\Entity\Quiz;
|
||||
use App\Exception\SpreadsheetDataException;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
class QuizSpreadsheetService
|
||||
{
|
||||
public function generateTemplate(bool $fillExample = true): \Closure
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$sheet->getStyle('1:1')->getFont()->setBold(true);
|
||||
|
||||
$sheet->setCellValue('A1', 'Question');
|
||||
$sheet->getColumnDimension('A')->setWidth(30);
|
||||
$sheet->getStyle('A:A')->getAlignment()->setWrapText(true);
|
||||
|
||||
$counter = 1;
|
||||
foreach (range('B', 'L', 2) as $column) {
|
||||
$sheet->setCellValue($column.'1', 'Answer '.$counter++);
|
||||
$sheet->getColumnDimension($column)->setWidth(30);
|
||||
$sheet->getStyle($column.':'.$column)->getAlignment()->setWrapText(true);
|
||||
}
|
||||
|
||||
foreach (range('C', 'M', 2) as $column) {
|
||||
$sheet->setCellValue($column.'1', 'Correct');
|
||||
$sheet->getColumnDimension($column)->setAutoSize(true);
|
||||
}
|
||||
|
||||
if ($fillExample) {
|
||||
$sheet->setCellValue('B2', 'Man');
|
||||
$sheet->setCellValue('C2', true);
|
||||
|
||||
$sheet->setCellValue('D2', 'Vrouw');
|
||||
$sheet->setCellValue('E2', false);
|
||||
|
||||
$sheet->setCellValue('A2', 'Is de mol een man of een vrouw?');
|
||||
}
|
||||
|
||||
return $this->toXlsx($spreadsheet);
|
||||
}
|
||||
|
||||
/** @throws SpreadsheetDataException */
|
||||
public function xlsxToQuiz(Quiz $quiz, File $file): Quiz
|
||||
{
|
||||
$spreadsheet = $this->readSheet($file);
|
||||
$sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
|
||||
|
||||
$answerLines = \array_slice($sheet->toArray(formatData: false), 1);
|
||||
|
||||
return $this->fillQuizFromArray($quiz, $answerLines);
|
||||
}
|
||||
|
||||
private function readSheet(File $file): Spreadsheet
|
||||
{
|
||||
return (new \PhpOffice\PhpSpreadsheet\Reader\Xlsx())->setReadDataOnly(true)->load($file->getRealPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<int, string|bool|null>> $sheet
|
||||
*
|
||||
* @throws SpreadsheetDataException
|
||||
*/
|
||||
private function fillQuizFromArray(Quiz $quiz, array $sheet): Quiz
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
$questionCounter = 1;
|
||||
foreach ($sheet as $questionArr) {
|
||||
if (null === $questionArr[0]) {
|
||||
break;
|
||||
}
|
||||
|
||||
$question = new Question();
|
||||
$question->setQuestion((string) $questionArr[0]);
|
||||
$question->setOrdering($questionCounter++);
|
||||
|
||||
$answerCounter = 1;
|
||||
$arrCounter = 1;
|
||||
|
||||
while (true) {
|
||||
if (null === $questionArr[$arrCounter]) {
|
||||
if (1 === $answerCounter) {
|
||||
$errors[] = \sprintf('Question %d has no answers', $answerCounter);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$answer = new Answer((string) $questionArr[$arrCounter++], (bool) $questionArr[$arrCounter++]);
|
||||
$answer->setOrdering($answerCounter++);
|
||||
$question->addAnswer($answer);
|
||||
}
|
||||
|
||||
$quiz->addQuestion($question);
|
||||
}
|
||||
|
||||
if ([] !== $errors) {
|
||||
throw new SpreadsheetDataException($errors);
|
||||
}
|
||||
|
||||
return $quiz;
|
||||
}
|
||||
|
||||
public function quizToXlsx(Quiz $quiz): void {}
|
||||
|
||||
private function toXlsx(Spreadsheet $spreadsheet): \Closure
|
||||
{
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
return static fn () => $writer->save('php://output');
|
||||
}
|
||||
}
|
||||
59
symfony.lock
59
symfony.lock
@@ -72,19 +72,31 @@
|
||||
]
|
||||
},
|
||||
"phpunit/phpunit": {
|
||||
"version": "11.5",
|
||||
"version": "12.1",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "9.6",
|
||||
"ref": "7364a21d87e658eb363c5020c072ecfdc12e2326"
|
||||
"version": "10.0",
|
||||
"ref": "bb22cf8d8c554a623b427d5f3416b538f5525233"
|
||||
},
|
||||
"files": [
|
||||
".env.test",
|
||||
"phpunit.xml.dist",
|
||||
"phpunit.dist.xml",
|
||||
"tests/bootstrap.php"
|
||||
]
|
||||
},
|
||||
"sentry/sentry-symfony": {
|
||||
"version": "5.2",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes-contrib",
|
||||
"branch": "main",
|
||||
"version": "5.0",
|
||||
"ref": "c3decefe8a11a5da43adaf827a6cd66695586113"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/sentry.yaml"
|
||||
]
|
||||
},
|
||||
"symfony/console": {
|
||||
"version": "7.2",
|
||||
"recipe": {
|
||||
@@ -141,6 +153,18 @@
|
||||
"src/Kernel.php"
|
||||
]
|
||||
},
|
||||
"symfony/mailer": {
|
||||
"version": "7.2",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "4.3",
|
||||
"ref": "09051cfde49476e3c12cd3a0e44289ace1c75a4f"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/mailer.yaml"
|
||||
]
|
||||
},
|
||||
"symfony/maker-bundle": {
|
||||
"version": "1.61",
|
||||
"recipe": {
|
||||
@@ -150,6 +174,21 @@
|
||||
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
||||
}
|
||||
},
|
||||
"symfony/phpunit-bridge": {
|
||||
"version": "7.2",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "6.3",
|
||||
"ref": "a411a0480041243d97382cac7984f7dce7813c08"
|
||||
},
|
||||
"files": [
|
||||
".env.test",
|
||||
"bin/phpunit",
|
||||
"phpunit.xml.dist",
|
||||
"tests/bootstrap.php"
|
||||
]
|
||||
},
|
||||
"symfony/routing": {
|
||||
"version": "7.2",
|
||||
"recipe": {
|
||||
@@ -248,7 +287,19 @@
|
||||
"config/routes/web_profiler.yaml"
|
||||
]
|
||||
},
|
||||
"symfonycasts/verify-email-bundle": {
|
||||
"version": "v1.17.3"
|
||||
},
|
||||
"twig/extra-bundle": {
|
||||
"version": "v3.18.0"
|
||||
},
|
||||
"vincentlanglet/twig-cs-fixer": {
|
||||
"version": "3.5",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes-contrib",
|
||||
"branch": "main",
|
||||
"version": "3.0",
|
||||
"ref": "d42582ae1bce86fd43491d6264c738b0867f8ffe"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
templates/backoffice/base.html.twig
Normal file
45
templates/backoffice/base.html.twig
Normal file
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" data-bs-theme="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
||||
crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="icon"
|
||||
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
|
||||
<title>
|
||||
{% block title %}Tijd voor de test{% endblock title %}
|
||||
</title>
|
||||
{% block stylesheets %}
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block nav %}
|
||||
{{ include('backoffice/nav.html.twig') }}
|
||||
{% endblock nav %}
|
||||
<main>
|
||||
<div class="container">
|
||||
{% for label, messages in app.flashes() %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-{{ label }} alert-dismissible " role="alert">
|
||||
{{ message }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% block body %}
|
||||
{% endblock body %}
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
53
templates/backoffice/index.html.twig
Normal file
53
templates/backoffice/index.html.twig
Normal file
@@ -0,0 +1,53 @@
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
|
||||
{% block title %}Hello BackofficeController!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="d-flex flex-row align-items-center">
|
||||
<h2 class="py-2 pe-2">
|
||||
{{ is_granted('ROLE_ADMIN') ? 'All Seasons'|trans : 'Your Seasons'|trans }}
|
||||
</h2>
|
||||
<a class="link" href="{{ path('app_backoffice_season_add') }}">
|
||||
{{ 'Add'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if is_granted('ROLE_ADMIN') %}
|
||||
<th scope="col">{{ 'Owner(s)'|trans }}</th>
|
||||
{% endif %}
|
||||
<th scope="col">{{ 'Name'|trans }}</th>
|
||||
<th scope="col">{{ 'Active Quiz'|trans }}</th>
|
||||
<th scope="col">{{ 'Season Code'|trans }}</th>
|
||||
<th scope="col">{{ 'Manage'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for season in seasons %}
|
||||
<tr class="align-middle">
|
||||
{% if is_granted('ROLE_ADMIN') %}
|
||||
<td>{{ season.owners|map(o => o.email)|join(', ') }}</td>
|
||||
{% endif %}
|
||||
<td>{{ season.name }}</td>
|
||||
<td>
|
||||
{% if season.activeQuiz %}
|
||||
{{ season.activeQuiz.name }}
|
||||
{% else %}
|
||||
{{ 'No active quiz'|trans }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a {% if season.activeQuiz %}href="{{ path('app_quiz_entername', {seasonCode: season.seasonCode}) }}"
|
||||
{% else %}class="disabled" {% endif %}>{{ season.seasonCode }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ path('app_backoffice_season', {seasonCode: season.seasonCode}) }}">{{ 'Manage'|trans }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
EMPTY
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
34
templates/backoffice/nav.html.twig
Normal file
34
templates/backoffice/nav.html.twig
Normal file
@@ -0,0 +1,34 @@
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Tijd voor de test</a>
|
||||
<button class="navbar-toggler"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false"
|
||||
aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
{% if is_granted('IS_AUTHENTICATED') %}
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link{% if 'app_backoffice_index' == app.current_route() %} active{% endif %}"
|
||||
href="{{ path('app_backoffice_index') }}">{{ 'Seasons'|trans }}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link"
|
||||
href="{{ path('app_backoffice_template') }}">{{ 'Download Template'|trans }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav mb-auto me-2 me-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link"
|
||||
href="{{ path('app_login_logout') }}">{{ 'Logout'|trans }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
3
templates/backoffice/prepare_elimination/index.html.twig
Normal file
3
templates/backoffice/prepare_elimination/index.html.twig
Normal file
@@ -0,0 +1,3 @@
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
97
templates/backoffice/quiz.html.twig
Normal file
97
templates/backoffice/quiz.html.twig
Normal file
@@ -0,0 +1,97 @@
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h2 class="py-2">{{ 'Quiz'|trans }}: {{ quiz.season.name }} - {{ quiz.name }}</h2>
|
||||
<a class="py-2 btn btn-primary {% if quiz is same as(season.activeQuiz) %}disabled{% endif %}"
|
||||
href="{{ path('app_backoffice_enable', {seasonCode: season.seasonCode, quiz: quiz.id}) }}">{{ 'Make active'|trans }}</a>
|
||||
<div id="questions">
|
||||
<h4 class="py-2">{{ 'Questions'|trans }}</h4>
|
||||
<div class="accordion">
|
||||
{% for question in quiz.questions %}
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#question-{{ loop.index0 }}"
|
||||
aria-controls="question-{{ loop.index0 }}">
|
||||
{% set questionErrors = question.getErrors %}
|
||||
{% if questionErrors %}
|
||||
<span data-bs-toggle="tooltip"
|
||||
title="{{ questionErrors }}"
|
||||
class="badge text-bg-danger rounded-pill me-2">!</span>
|
||||
{% endif %}
|
||||
{{ loop.index }}. {{ question.question }}
|
||||
</button>
|
||||
</h2>
|
||||
<div id="question-{{ loop.index0 }}"
|
||||
class="accordion-collapse collapse">
|
||||
<div class="accordion-body">
|
||||
<ul>
|
||||
{% for answer in question.answers %}
|
||||
<li {% if answer.isRightAnswer %}class="text-decoration-underline"{% endif %}>{{ answer.text }}</li>
|
||||
{% else %}
|
||||
{{ 'There are no answers for this question'|trans }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
EMPTY
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="scores">
|
||||
<p>
|
||||
<h4>{{ 'Score'|trans }}</h4>
|
||||
</p>
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="btn-group btn-group-lg me-2">
|
||||
<a class="btn btn-primary">{{ 'Start Elimination'|trans }}</a>
|
||||
</div>
|
||||
<div class="btn-group btn-group-lg">
|
||||
<a class="btn btn-secondary">{{ 'Prepare Custom Elimination'|trans }}</a>
|
||||
<a class="btn btn-secondary">{{ 'Load Prepared Elimination'|trans }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<p>{{ 'Number of dropouts:'|trans }} {{ quiz.dropouts }} </p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{ 'Candidate'|trans }}</th>
|
||||
<th scope="col">{{ 'Correct Answers'|trans }}</th>
|
||||
<th scope="col">{{ 'Corrections'|trans }}</th>
|
||||
<th scope="col">{{ 'Score'|trans }}</th>
|
||||
<th scope="col">{{ 'Time'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for candidate in result %}
|
||||
<tr class="table-{% if loop.revindex > quiz.dropouts %}success{% else %}danger{% endif %}">
|
||||
<td>{{ candidate.0.name }}</td>
|
||||
<td>{{ candidate.correct|default('0') }}</td>
|
||||
<td>{{ candidate.corrections|default('0') }}</td>
|
||||
<td>{{ candidate.score|default('x') }}</td>
|
||||
<td>{{ candidate.time }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5">{{ 'No results'|trans }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block javascripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
||||
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
|
||||
});
|
||||
</script>
|
||||
{% endblock javascripts %}
|
||||
{% block title %}
|
||||
|
||||
{% endblock %}
|
||||
25
templates/backoffice/quiz_add.html.twig
Normal file
25
templates/backoffice/quiz_add.html.twig
Normal file
@@ -0,0 +1,25 @@
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-12">
|
||||
<h2 class="py-2">{{ 'Add a quiz to '|trans }} {{ season.name }}</h2>
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.sheet) }}
|
||||
<button type="submit" class="btn btn-primary">{{ 'Submit'|trans }}</button>
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
<div class="col-md-6 col-12">
|
||||
<p class="pt-5">
|
||||
Hier kan nog tekst komen met wat uitleg
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
|
||||
{% endblock %}
|
||||
34
templates/backoffice/season.html.twig
Normal file
34
templates/backoffice/season.html.twig
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
{% block body %}
|
||||
<h2 class="py-2">{{ 'Season'|trans }}: {{ season.name }}</h2>
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-12">
|
||||
<div class="d-flex flex-row align-items-center">
|
||||
<h4 class="py-2 pe-2">{{ 'Quizzes'|trans }}</h4>
|
||||
<a class="link"
|
||||
href="{{ path('app_backoffice_quiz_add', {seasonCode: season.seasonCode}) }}">{{ 'Add'|trans }}</a>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
{% for quiz in season.quizzes %}
|
||||
<a class="list-group-item list-group-item-action{% if season.activeQuiz == quiz %} active{% endif %}"
|
||||
href="{{ path('app_backoffice_quiz', {seasonCode: season.seasonCode, quiz: quiz.id}) }}">{{ quiz.name }}</a>
|
||||
{% else %}
|
||||
No quizzes
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
<div class="d-flex flex-row align-items-center">
|
||||
<h4 class="py-2 pe-2">{{ 'Candidates'|trans }}</h4>
|
||||
<a class="link"
|
||||
href="{{ path('app_backoffice_add_candidates', {seasonCode: season.seasonCode}) }}">{{ 'Add Candidate'|trans }}</a>
|
||||
|
||||
</div>
|
||||
<ul>
|
||||
{% for candidate in season.candidates %}
|
||||
<li>{{ candidate.name }}</li>{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-12 col-md-3"></div>
|
||||
</div>
|
||||
{% endblock body %}
|
||||
22
templates/backoffice/season_add.html.twig
Normal file
22
templates/backoffice/season_add.html.twig
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-12">
|
||||
<h2 class="py-2">{{ 'Create a season'|trans }}</h2>
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.name) }}
|
||||
<button type="submit" class="btn btn-primary">{{ 'Submit'|trans }}</button>
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
<div class="col-md-6 col-12">
|
||||
<p class="pt-5">
|
||||
Hier kan nog tekst komen met wat uitleg
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
|
||||
{% endblock %}
|
||||
22
templates/backoffice/season_add_candidates.html.twig
Normal file
22
templates/backoffice/season_add_candidates.html.twig
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-12">
|
||||
<h2 class="py-2">{{ 'Add Candidates'|trans }}</h2>
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.candidates) }}
|
||||
<button type="submit" class="btn btn-primary">{{ 'Submit'|trans }}</button>
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
<div class="col-md-6 col-12">
|
||||
<p class="pt-5">
|
||||
Hier kan nog tekst komen met wat uitleg
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}Welcome!{% endblock %}</title>
|
||||
<link rel="icon"
|
||||
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
|
||||
{% block stylesheets %}
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,41 +1,41 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
{% extends 'backoffice/base.html.twig' %}
|
||||
|
||||
{% block title %}Log in!{% endblock %}
|
||||
{% block title %}Log in{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<form method="post">
|
||||
{% if error %}
|
||||
<div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.user %}
|
||||
<div class="mb-3">
|
||||
You are logged in as {{ app.user.userIdentifier }}, <a href="{{ path('app_logout') }}">Logout</a>
|
||||
You are logged in as {{ app.user.userIdentifier }}, <a href="{{ path('app_login_logout') }}">Logout</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
|
||||
<label for="username">Email</label>
|
||||
<input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="email" required autofocus>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>
|
||||
|
||||
<input type="hidden" name="_csrf_token"
|
||||
value="{{ csrf_token('authenticate') }}"
|
||||
>
|
||||
|
||||
{#
|
||||
Uncomment this section and add a remember_me option below your firewall to activate remember me functionality.
|
||||
See https://symfony.com/doc/current/security/remember_me.html
|
||||
|
||||
<div class="checkbox mb-3">
|
||||
<input type="checkbox" name="_remember_me" id="_remember_me">
|
||||
<label for="_remember_me">Remember me</label>
|
||||
{% else %}
|
||||
<form method="post">
|
||||
<h1 class="py-2 h3 mb-3 font-weight-normal">{{ 'Please sign in'|trans }}</h1>
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">{{ 'Email'|trans }}</label>
|
||||
<input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control"
|
||||
autocomplete="email" required autofocus>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">{{ 'Password'|trans }}</label>
|
||||
<input type="password" name="_password" id="password" class="form-control"
|
||||
autocomplete="current-password"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="_csrf_token" data-controller="csrf-protection"
|
||||
value="{{ csrf_token('authenticate') }}">
|
||||
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" name="_remember_me" id="_remember_me" class="form-check-input">
|
||||
<label for="_remember_me" class="form-check-label">{{ 'Remember me'|trans }}</label>
|
||||
</div>
|
||||
#}
|
||||
|
||||
<button class="btn btn-lg btn-primary" type="submit">
|
||||
Sign in
|
||||
{{ 'Sign in'|trans }}
|
||||
</button>
|
||||
<a href="{{ path('app_register') }}"
|
||||
class="btn btn-link">{{ 'Create an account'|trans }}</a>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<html lang="en" data-bs-theme="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "quiz/base.html.twig" %}
|
||||
{% extends 'quiz/base.html.twig' %}
|
||||
{% block body %}
|
||||
{{ season.name }}
|
||||
{{ form(form) }}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
{% extends "quiz/base.html.twig" %}
|
||||
{% extends 'quiz/base.html.twig' %}
|
||||
{% block body %}
|
||||
Candiadte: {{ candidate.name }}<br/>
|
||||
|
||||
{{ question.question }}<br/>
|
||||
<form method="post">
|
||||
<input type="hidden" name="token" value="{{ csrf_token('question') }}">
|
||||
{% for answer in question.answers %}
|
||||
<input type="radio" name="answer" value="{{ answer.id }}"> {{ answer.text }}
|
||||
<div>
|
||||
<button class="btn btn-outline-success"
|
||||
type="submit"
|
||||
name="answer"
|
||||
value="{{ answer.id }}">{{ answer.text }}</button>
|
||||
</div>
|
||||
{% else %}
|
||||
Weirdly enough this question has no answers...
|
||||
{% endfor %}
|
||||
</form>
|
||||
{% endblock body %}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% extends "quiz/base.html.twig" %}
|
||||
{% extends 'quiz/base.html.twig' %}
|
||||
{% block body %}
|
||||
{{ form(form) }}
|
||||
<a href="{{ path('app_backoffice_index') }}" class="btn btn-outline-secondary">{{ 'Manage Quiz'|trans }}</a>
|
||||
{% endblock body %}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user