diff --git a/.gitignore b/.gitignore index a67f91e..d7b1f85 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /public/bundles/ /var/ /vendor/ +.idea/ ###< symfony/framework-bundle ### diff --git a/composer.json b/composer.json index 3226016..b6252f7 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "doctrine/doctrine-bundle": "^2.5", "doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/orm": "^2.10", + "sensio/framework-extra-bundle": "^6.2", "symfony/console": "6.0.*", "symfony/dotenv": "6.0.*", "symfony/flex": "^2", @@ -71,5 +72,9 @@ "require": "6.0.*", "docker": true } + }, + "require-dev": { + "doctrine/doctrine-fixtures-bundle": "^3.4", + "symfony/maker-bundle": "^1.36" } } diff --git a/composer.lock b/composer.lock index f080f89..3799ba1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ae58b4d8b7fa3dceb53efed96aac238d", + "content-hash": "24f66bfef080dd3c1a4af00772f451ac", "packages": [ { "name": "composer/package-versions-deprecated", @@ -1789,6 +1789,84 @@ }, "time": "2021-07-14T16:46:02+00:00" }, + { + "name": "sensio/framework-extra-bundle", + "version": "v6.2.3", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git", + "reference": "eeab0bbe6ac94a600a7da7aac020646dcd739484" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/eeab0bbe6ac94a600a7da7aac020646dcd739484", + "reference": "eeab0bbe6ac94a600a7da7aac020646dcd739484", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.0", + "php": ">=7.2.5", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/framework-bundle": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0" + }, + "conflict": { + "doctrine/doctrine-cache-bundle": "<1.3.1", + "doctrine/persistence": "<1.3" + }, + "require-dev": { + "doctrine/dbal": "^2.10|^3.0", + "doctrine/doctrine-bundle": "^1.11|^2.0", + "doctrine/orm": "^2.5", + "symfony/browser-kit": "^4.4|^5.0|^6.0", + "symfony/doctrine-bridge": "^4.4|^5.0|^6.0", + "symfony/dom-crawler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/monolog-bridge": "^4.0|^5.0|^6.0", + "symfony/monolog-bundle": "^3.2", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0", + "symfony/security-bundle": "^4.4|^5.0|^6.0", + "symfony/twig-bundle": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0", + "twig/twig": "^1.34|^2.4|^3.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "6.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sensio\\Bundle\\FrameworkExtraBundle\\": "src/" + }, + "exclude-from-classmap": [ + "/tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "This bundle provides a way to configure your controllers with annotations", + "keywords": [ + "annotations", + "controllers" + ], + "support": { + "issues": "https://github.com/sensiolabs/SensioFrameworkExtraBundle/issues", + "source": "https://github.com/sensiolabs/SensioFrameworkExtraBundle/tree/v6.2.3" + }, + "time": "2021-12-17T14:36:53+00:00" + }, { "name": "symfony/cache", "version": "v6.0.1", @@ -4247,7 +4325,312 @@ "time": "2021-12-08T15:13:44+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "doctrine/data-fixtures", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/data-fixtures.git", + "reference": "f18adf13f6c81c67a88360dca359ad474523f8e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/f18adf13f6c81c67a88360dca359ad474523f8e3", + "reference": "f18adf13f6c81c67a88360dca359ad474523f8e3", + "shasum": "" + }, + "require": { + "doctrine/common": "^2.13|^3.0", + "doctrine/persistence": "^1.3.3|^2.0", + "php": "^7.2 || ^8.0" + }, + "conflict": { + "doctrine/phpcr-odm": "<1.3.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9.0", + "doctrine/dbal": "^2.5.4 || ^3.0", + "doctrine/mongodb-odm": "^1.3.0 || ^2.0.0", + "doctrine/orm": "^2.7.0", + "ext-sqlite3": "*", + "phpunit/phpunit": "^8.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "For using MongoDB ODM 1.3 with PHP 7 (deprecated)", + "doctrine/mongodb-odm": "For loading MongoDB ODM fixtures", + "doctrine/orm": "For loading ORM fixtures", + "doctrine/phpcr-odm": "For loading PHPCR ODM fixtures" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\DataFixtures\\": "lib/Doctrine/Common/DataFixtures" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Data Fixtures for all Doctrine Object Managers", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database" + ], + "support": { + "issues": "https://github.com/doctrine/data-fixtures/issues", + "source": "https://github.com/doctrine/data-fixtures/tree/1.5.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdata-fixtures", + "type": "tidelift" + } + ], + "time": "2021-09-20T21:51:43+00:00" + }, + { + "name": "doctrine/doctrine-fixtures-bundle", + "version": "3.4.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/DoctrineFixturesBundle.git", + "reference": "31ba202bebce0b66fe830f49f96228dcdc1503e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/31ba202bebce0b66fe830f49f96228dcdc1503e7", + "reference": "31ba202bebce0b66fe830f49f96228dcdc1503e7", + "shasum": "" + }, + "require": { + "doctrine/data-fixtures": "^1.3", + "doctrine/doctrine-bundle": "^1.11|^2.0", + "doctrine/orm": "^2.6.0", + "doctrine/persistence": "^1.3.7|^2.0", + "php": "^7.1 || ^8.0", + "symfony/config": "^3.4|^4.3|^5.0|^6.0", + "symfony/console": "^3.4|^4.3|^5.0|^6.0", + "symfony/dependency-injection": "^3.4.47|^4.3|^5.0|^6.0", + "symfony/doctrine-bridge": "^3.4|^4.1|^5.0|^6.0", + "symfony/http-kernel": "^3.4|^4.3|^5.0|^6.0" + }, + "require-dev": { + "doctrine/coding-standard": "^8.0", + "phpstan/phpstan": "^0.12.99", + "phpunit/phpunit": "^7.4 || ^8.0 || ^9.2", + "symfony/phpunit-bridge": "^4.1|^5.0|^6.0", + "vimeo/psalm": "^4.10" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Doctrine\\Bundle\\FixturesBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Doctrine Project", + "homepage": "http://www.doctrine-project.org" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DoctrineFixturesBundle", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "Fixture", + "persistence" + ], + "support": { + "issues": "https://github.com/doctrine/DoctrineFixturesBundle/issues", + "source": "https://github.com/doctrine/DoctrineFixturesBundle/tree/3.4.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdoctrine-fixtures-bundle", + "type": "tidelift" + } + ], + "time": "2021-10-28T05:46:28+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.13.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" + }, + "time": "2021-11-30T19:35:32+00:00" + }, + { + "name": "symfony/maker-bundle", + "version": "v1.36.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/maker-bundle.git", + "reference": "716eee9c8b10b33e682df1b7d80b9061887e9691" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/maker-bundle/zipball/716eee9c8b10b33e682df1b7d80b9061887e9691", + "reference": "716eee9c8b10b33e682df1b7d80b9061887e9691", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^1.2|^2.0", + "nikic/php-parser": "^4.11", + "php": ">=7.1.3", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/deprecation-contracts": "^2.2|^3", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/framework-bundle": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0" + }, + "require-dev": { + "composer/semver": "^3.0", + "doctrine/doctrine-bundle": "^1.12.3|^2.0", + "doctrine/orm": "^2.3", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/phpunit-bridge": "^4.4|^5.0|^6.0", + "symfony/polyfill-php80": "^1.16.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/security-core": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0", + "twig/twig": "^2.0|^3.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-main": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bundle\\MakerBundle\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.", + "homepage": "https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html", + "keywords": [ + "code generator", + "generator", + "scaffold", + "scaffolding" + ], + "support": { + "issues": "https://github.com/symfony/maker-bundle/issues", + "source": "https://github.com/symfony/maker-bundle/tree/v1.36.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-12-01T00:27:38+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/composer.phar b/composer.phar deleted file mode 100755 index f046190..0000000 Binary files a/composer.phar and /dev/null differ diff --git a/config/bundles.php b/config/bundles.php index c1fa06a..7431a2a 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -4,4 +4,7 @@ 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], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], + Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], ]; diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index c319176..839d52f 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -12,7 +12,7 @@ doctrine: mappings: App: is_bundle: false - type: annotation - dir: '%kernel.project_dir%/src/Entity' - prefix: 'App\Entity' + type: attribute + dir: '%kernel.project_dir%/src/Domain/Quiz/Entity' + prefix: 'App\Domain\Quiz\Entity' alias: App diff --git a/config/packages/sensio_framework_extra.yaml b/config/packages/sensio_framework_extra.yaml new file mode 100644 index 0000000..1821ccc --- /dev/null +++ b/config/packages/sensio_framework_extra.yaml @@ -0,0 +1,3 @@ +sensio_framework_extra: + router: + annotations: false diff --git a/config/routes.yaml b/config/routes.yaml index 5b102f6..a27f19a 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -1,5 +1,5 @@ controllers: - resource: ../src/Controller/ + resource: ../src/Presentation/Controller/ type: annotation kernel: diff --git a/config/routes/annotations.yaml b/config/routes/annotations.yaml index e92efc5..dafe4ab 100644 --- a/config/routes/annotations.yaml +++ b/config/routes/annotations.yaml @@ -1,5 +1,5 @@ controllers: - resource: ../../src/Controller/ + resource: ../../src/Presentation/Controller/ type: annotation kernel: diff --git a/src/Controller/.gitignore b/src/Domain/Quiz/Entity/.gitignore similarity index 100% rename from src/Controller/.gitignore rename to src/Domain/Quiz/Entity/.gitignore diff --git a/src/Domain/Quiz/Entity/Answer.php b/src/Domain/Quiz/Entity/Answer.php new file mode 100644 index 0000000..45b112c --- /dev/null +++ b/src/Domain/Quiz/Entity/Answer.php @@ -0,0 +1,104 @@ + 0 + ])] + private bool $correct; + + /** + * @var + */ + #[ORM\ManyToOne(targetEntity: "Question", inversedBy:"answers")] + private $question; + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id): void + { + $this->id = $id; + } + + /** + * @return string + */ + public function getText(): string + { + return $this->text; + } + + /** + * @param string $text + */ + public function setText(string $text): void + { + $this->text = $text; + } + + /** + * @return bool + */ + public function isCorrect(): bool + { + return $this->correct; + } + + /** + * @param bool $correct + */ + public function setCorrect(bool $correct): void + { + $this->correct = $correct; + } + + /** + * @return Question + */ + public function getQuestion(): Question + { + return $this->question; + } + + /** + * @param Question $question + */ + public function setQuestion(Question $question): void + { + $this->question = $question; + } +} diff --git a/src/Domain/Quiz/Entity/Customer.php b/src/Domain/Quiz/Entity/Customer.php new file mode 100644 index 0000000..b08b468 --- /dev/null +++ b/src/Domain/Quiz/Entity/Customer.php @@ -0,0 +1,137 @@ + 0 + ])] + private bool $active = true; + + #[ORM\ManyToOne(targetEntity: "CustomerType", inversedBy:"customers")] + #[ORM\JoinColumn(name: "customer_type", referencedColumnName: "id")] + private $customerType; + + public function __construct() + { + $this->quiz = new ArrayCollection(); + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id): void + { + $this->id = $id; + } + + /** + * @return string + */ + public function getFirstName(): string + { + return $this->firstName; + } + + /** + * @param string $firstName + */ + public function setFirstName(string $firstName): void + { + $this->firstName = $firstName; + } + + /** + * @return string + */ + public function getLastName(): string + { + return $this->lastName; + } + + /** + * @param string $lastName + */ + public function setLastName(string $lastName): void + { + $this->lastName = $lastName; + } + + /** + * @return Collection + */ + public function getQuiz(): Collection + { + return $this->quiz; + } + + /** + * @param Quiz $quiz + */ + public function setQuiz(Quiz $quiz): void + { + $this->quiz->add($quiz); + } + + /** + * @return CustomerType + */ + public function getCustomerType(): CustomerType + { + return $this->customerType; + } + + /** + * @param CustomerType $customerType + */ + public function setCustomerType(CustomerType $customerType): void + { + $this->customerType = $customerType; + } +} diff --git a/src/Domain/Quiz/Entity/CustomerType.php b/src/Domain/Quiz/Entity/CustomerType.php new file mode 100644 index 0000000..0479c47 --- /dev/null +++ b/src/Domain/Quiz/Entity/CustomerType.php @@ -0,0 +1,156 @@ + 1 + ])] + private bool $show = true; + + /** + * @var bool + */ + #[ORM\Column(name:"add", type: 'boolean', options: [ + "default" => 1 + ])] + private bool $add; + + /** + * @var bool + */ + #[ORM\Column(name:"edit", type: 'boolean', options: [ + "default" => 1 + ])] + private bool $edit; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: "customerType", targetEntity: "Customer")] + private Collection $customers; + + public function __construct() + { + $this->customers = new ArrayCollection(); + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id): void + { + $this->id = $id; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name): void + { + $this->name = $name; + } + + /** + * @return bool + */ + public function isShow(): bool + { + return $this->show; + } + + /** + * @param bool $show + */ + public function setShow(bool $show): void + { + $this->show = $show; + } + + /** + * @return bool + */ + public function isAdd(): bool + { + return $this->add; + } + + /** + * @param bool $add + */ + public function setAdd(bool $add): void + { + $this->add = $add; + } + + /** + * @return bool + */ + public function isEdit(): bool + { + return $this->edit; + } + + /** + * @param bool $edit + */ + public function setEdit(bool $edit): void + { + $this->edit = $edit; + } + + /** + * @return ArrayCollection + */ + public function getCustomers(): ArrayCollection + { + return $this->customers; + } + + /** + * @param Customer $customer + */ + public function setCustomers(Customer $customer): void + { + $this->customers->add($customer); + } +} diff --git a/src/Domain/Quiz/Entity/Question.php b/src/Domain/Quiz/Entity/Question.php new file mode 100644 index 0000000..e4b99ff --- /dev/null +++ b/src/Domain/Quiz/Entity/Question.php @@ -0,0 +1,107 @@ +answers = new ArrayCollection(); + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id): void + { + $this->id = $id; + } + + /** + * @return string + */ + public function getText(): string + { + return $this->text; + } + + /** + * @param string $text + */ + public function setText(string $text): void + { + $this->text = $text; + } + + /** + * @return mixed + */ + public function getQuiz() + { + return $this->quiz; + } + + /** + * @param Quiz $quiz + */ + public function setQuiz(Quiz $quiz): void + { + $this->quiz = $quiz; + } + + /** + * @return Collection + */ + public function getAnswers(): Collection + { + return $this->answers; + } + + /** + * @param Answer $answer + */ + public function setAnswer(Answer $answer): void + { + $this->answers->add($answer); + } +} diff --git a/src/Domain/Quiz/Entity/Quiz.php b/src/Domain/Quiz/Entity/Quiz.php new file mode 100644 index 0000000..346e45f --- /dev/null +++ b/src/Domain/Quiz/Entity/Quiz.php @@ -0,0 +1,181 @@ + 0 + ])] + private bool $active = false; + + /** + * @var Customer + */ + #[ORM\ManyToOne(targetEntity: "Customer", inversedBy:"quizzes")] + #[ORM\JoinColumn(name: "customer_id", referencedColumnName: "id")] + private Customer $customer; + + /** + * @var DateTimeInterface|null + * + */ + #[ORM\Column(name:"start_time", type: 'datetime', nullable: true)] + private ?DateTimeInterface $startTime; + + /** + * @var DateTimeInterface|null + */ + #[ORM\Column(name:"end_time", type: 'datetime', nullable: true)] + private ?DateTimeInterface $endTime; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: "quiz", targetEntity: "Question")] + private Collection $questions; + + public function __construct() + { + $this->questions = new ArrayCollection(); + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id): void + { + $this->id = $id; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name): void + { + $this->name = $name; + } + + /** + * @return bool + */ + public function isActive(): bool + { + return $this->active; + } + + /** + * @param bool $active + */ + public function setActive(bool $active): void + { + $this->active = $active; + } + + /** + * @return DateTimeInterface|null + */ + public function getStartTime(): ?DateTimeInterface + { + return $this->startTime; + } + + /** + * @param DateTimeInterface|null $startTime + */ + public function setStartTime(?DateTimeInterface $startTime): void + { + $this->startTime = $startTime; + } + + /** + * @return DateTimeInterface|null + */ + public function getEndTime(): ?DateTimeInterface + { + return $this->endTime; + } + + /** + * @param DateTimeInterface|null $endTime + */ + public function setEndTime(?DateTimeInterface $endTime): void + { + $this->endTime = $endTime; + } + + /** + * @return Customer + */ + public function getCustomer(): Customer + { + return $this->customer; + } + + /** + * @param Customer $customer + */ + public function setCustomer(Customer $customer): void + { + $this->customer = $customer; + } + + /** + * @return ArrayCollection + */ + public function getQuestions(): ArrayCollection + { + return $this->questions; + } + + /** + * @param Question $question + */ + public function setQuestions(Question $question): void + { + $this->questions->add($question); + } + +} diff --git a/src/Domain/Quiz/Entity/Timestamps.php b/src/Domain/Quiz/Entity/Timestamps.php new file mode 100644 index 0000000..669049e --- /dev/null +++ b/src/Domain/Quiz/Entity/Timestamps.php @@ -0,0 +1,79 @@ +createdAt; + } + + /** + * @param DateTimeInterface|null $createdAt + * @return Answer|Customer|Question|Quiz|Timestamps + */ + public function setCreatedAt(?DateTimeInterface $createdAt): self + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @return DateTimeInterface|null + */ + public function getUpdatedAt(): ?DateTimeInterface + { + return $this->updatedAt; + } + + /** + * @param DateTimeInterface|null $updatedAt + * @return Answer|Customer|Question|Quiz|Timestamps + */ + public function setUpdatedAt(?DateTimeInterface $updatedAt): self + { + $this->updatedAt = $updatedAt; + + return $this; + } + + /** + * @ORM\PrePersist + */ + public function setCreatedAtAutomatically(): self + { + if ($this->getCreatedAt() === null) { + $this->setCreatedAt(new \DateTime()); + } + + return $this; + } + + /** + * @ORM\PreUpdate + */ + public function setUpdatedAtAutomatically(): self + { + $this->setUpdatedAt(new \DateTime()); + + return $this; + } +} diff --git a/src/Infractructure/DataFixtures/AnswerFixtures.php b/src/Infractructure/DataFixtures/AnswerFixtures.php new file mode 100644 index 0000000..c30d6a9 --- /dev/null +++ b/src/Infractructure/DataFixtures/AnswerFixtures.php @@ -0,0 +1,105 @@ + [ + '4' => false, + '5' => true, + '6' => false + ], + QuestionFixtures::FIRST_QUIZ_QUESTION_SECOND => [ + 'All oceans are taken together' => true, + 'Atlantic and Indian' => false, + 'Arctic and Pacific' => false + ], + QuestionFixtures::FIRST_QUIZ_QUESTION_THIRD => [ + '60%' => false, + '70%' => true, + '80%' => false + ], + QuestionFixtures::FIRST_QUIZ_QUESTION_FOURTH => [ + 'Pacific' => true, + 'Atlantic' => false, + 'Indian' => false + ], + QuestionFixtures::FIRST_QUIZ_QUESTION_FIFTH => [ + 'Pacific' => true, + 'Indian' => false, + 'Atlantic' => false + ] + ]; + $this->fillOutAnswers($firstQuestion, $manager); + + + $secondQuestion = [ + QuestionFixtures::SECOND_QUIZ_QUESTION_ONE => [ + 'coal' => true, + 'ground' => false, + 'oil' => false + ], + QuestionFixtures::SECOND_QUIZ_QUESTION_SECOND => [ + 'Colombo' => false, + 'Tokio' => true, + 'Cairo' => false + ], + QuestionFixtures::SECOND_QUIZ_QUESTION_THIRD => [ + 'Dnieper' => false, + 'Seine' => false, + 'Volga' => true + ], + QuestionFixtures::SECOND_QUIZ_QUESTION_FOURTH => [ + 'Amazon' => false, + 'Congo' => true, + 'Mississippi' => false, + 'Don' => false + ], + QuestionFixtures::SECOND_QUIZ_QUESTION_FIFTH => [ + 'Greenland' => true, + 'Bali' => false, + 'Madagascar' => false, + 'Mauritius' => false + ] + ]; + + $this->fillOutAnswers($secondQuestion, $manager); + } + + /** + * @return array + */ + public function getDependencies(): array + { + return [ + QuestionFixtures::class + ]; + } + + /** + * @param array $values + * @param ObjectManager $manager + * @return void + */ + private function fillOutAnswers(array $values, ObjectManager $manager) + { + foreach ($values as $key => $itemsArray) { + foreach ($itemsArray as $keyItem => $isCorrectAnswer) { + $answer = new Answer(); + $answer->setText($keyItem); + $answer->setCorrect($isCorrectAnswer); + $answer->setQuestion($this->getReference($key)); + $manager->persist($answer); + $manager->flush(); + } + } + } +} diff --git a/src/Infractructure/DataFixtures/CustomerFixtures.php b/src/Infractructure/DataFixtures/CustomerFixtures.php new file mode 100644 index 0000000..89d6f5e --- /dev/null +++ b/src/Infractructure/DataFixtures/CustomerFixtures.php @@ -0,0 +1,35 @@ +setFirstName('Admin'); + $userAdmin->setLastName('Admin'); + $userAdmin->setCustomerType($this->getReference(CustomerTypeFixtures::ADMIN_TYPE)); + $manager->persist($userAdmin); + $manager->flush(); + + $this->addReference(self::ADMIN_USER, $userAdmin); + } + + /** + * @return array + */ + public function getDependencies(): array + { + return [ + CustomerTypeFixtures::class + ]; + } +} diff --git a/src/Infractructure/DataFixtures/CustomerTypeFixtures.php b/src/Infractructure/DataFixtures/CustomerTypeFixtures.php new file mode 100644 index 0000000..97e3909 --- /dev/null +++ b/src/Infractructure/DataFixtures/CustomerTypeFixtures.php @@ -0,0 +1,24 @@ +setName('Admin'); + $customerType->setAdd(true); + $customerType->setEdit(true); + $customerType->setShow(true); + $manager->persist($customerType); + $manager->flush(); + + $this->addReference(self::ADMIN_TYPE, $customerType); + } +} diff --git a/src/Infractructure/DataFixtures/QuestionFixtures.php b/src/Infractructure/DataFixtures/QuestionFixtures.php new file mode 100644 index 0000000..7bdddec --- /dev/null +++ b/src/Infractructure/DataFixtures/QuestionFixtures.php @@ -0,0 +1,69 @@ + 'How many ocean on Earth?', + self::FIRST_QUIZ_QUESTION_SECOND => 'What does it mean world ocean?', + self::FIRST_QUIZ_QUESTION_THIRD => 'Which area take oceans?', + self::FIRST_QUIZ_QUESTION_FOURTH => 'Which is ocean the biggest?', + self::FIRST_QUIZ_QUESTION_FIFTH => 'Which is ocean the deeper?', + ]; + $this->fillOutData($firstQuizQuestion, $manager, QuizFixtures::FIRST_QUIZ); + + + $secondQuizQuestion = [ + self::SECOND_QUIZ_QUESTION_ONE => 'What is the black gold?', + self::SECOND_QUIZ_QUESTION_SECOND => 'What is the biggest city in Eastern?', + self::SECOND_QUIZ_QUESTION_THIRD => 'What is the longest river in Europe?', + self::SECOND_QUIZ_QUESTION_FOURTH => 'Which does the river cross Equator two times?', + self::SECOND_QUIZ_QUESTION_FIFTH => 'What is the biggest island?', + ]; + + $this->fillOutData($secondQuizQuestion, $manager, QuizFixtures::SECOND_QUIZ); + } + + /** + * @return array + */ + public function getDependencies(): array + { + return [ + QuizFixtures::class + ]; + } + + private function fillOutData(array $values, ObjectManager $manager, $type) + { + foreach ($values as $valueKey => $valueItem) { + $firstQuizQuestion = new Question(); + $firstQuizQuestion->setText($valueItem); + $firstQuizQuestion->setQuiz($this->getReference($type)); + $manager->persist($firstQuizQuestion); + $manager->flush(); + + $this->addReference($valueKey, $firstQuizQuestion); + } + } +} diff --git a/src/Infractructure/DataFixtures/QuizFixtures.php b/src/Infractructure/DataFixtures/QuizFixtures.php new file mode 100644 index 0000000..740c01b --- /dev/null +++ b/src/Infractructure/DataFixtures/QuizFixtures.php @@ -0,0 +1,43 @@ +setName($quiz); + $quizFirst->setActive(true); + $quizFirst->setCustomer($this->getReference(CustomerFixtures::ADMIN_USER)); + $manager->persist($quizFirst); + $manager->flush(); + + $this->addReference($quiz, $quizFirst); + } + } + + /** + * @return array + */ + public function getDependencies(): array + { + return [ + CustomerFixtures::class + ]; + } +} diff --git a/src/Entity/.gitignore b/src/Presentation/Controller/.gitignore similarity index 100% rename from src/Entity/.gitignore rename to src/Presentation/Controller/.gitignore diff --git a/src/Presentation/Controller/QuizController.php b/src/Presentation/Controller/QuizController.php new file mode 100644 index 0000000..3eae6ac --- /dev/null +++ b/src/Presentation/Controller/QuizController.php @@ -0,0 +1,19 @@ +Quiz' + ); + } +} diff --git a/symfony.lock b/symfony.lock index 0d8e14f..68efa3b 100644 --- a/symfony.lock +++ b/symfony.lock @@ -23,6 +23,9 @@ "doctrine/common": { "version": "3.2.0" }, + "doctrine/data-fixtures": { + "version": "1.5.1" + }, "doctrine/dbal": { "version": "3.2.0" }, @@ -45,6 +48,18 @@ "src/Repository/.gitignore" ] }, + "doctrine/doctrine-fixtures-bundle": { + "version": "3.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "3.0", + "ref": "1f5514cfa15b947298df4d771e694e578d4c204d" + }, + "files": [ + "src/DataFixtures/AppFixtures.php" + ] + }, "doctrine/doctrine-migrations-bundle": { "version": "3.2", "recipe": { @@ -88,6 +103,9 @@ "laminas/laminas-code": { "version": "4.5.0" }, + "nikic/php-parser": { + "version": "v4.13.2" + }, "psr/cache": { "version": "3.0.0" }, @@ -100,6 +118,18 @@ "psr/log": { "version": "3.0.0" }, + "sensio/framework-extra-bundle": { + "version": "6.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.2", + "ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b" + }, + "files": [ + "config/packages/sensio_framework_extra.yaml" + ] + }, "symfony/cache": { "version": "v6.0.1" }, @@ -185,6 +215,15 @@ "symfony/http-kernel": { "version": "v6.0.1" }, + "symfony/maker-bundle": { + "version": "1.36", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "1.0", + "ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f" + } + }, "symfony/polyfill-intl-grapheme": { "version": "v1.23.1" },