Merge branch 'master' into devFront
commit
781fcd581b
18
README.md
18
README.md
|
@ -10,14 +10,24 @@ Rise and shine, 9 AM and your hand can't make it to the alarm clock before the v
|
|||
|
||||
You have to get into the class **before** 10 AM. Welcome to the grind.
|
||||
|
||||
<p align="center"><img src="./docs/plan.jpeg" /></p>
|
||||
<p align="center">
|
||||
<img src="./docs/plan.jpeg" alt="" />
|
||||
</p>
|
||||
|
||||
## Installation
|
||||
## Installation (manual)
|
||||
|
||||
~~~
|
||||
$ git clone https://github.com/SundownDEV/Am-I-late
|
||||
$ cd Am-I-late/
|
||||
$ composer install && npm install
|
||||
$ make install
|
||||
~~~
|
||||
|
||||
## Installation (docker)
|
||||
|
||||
~~~
|
||||
$ git clone https://github.com/SundownDEV/Am-I-late
|
||||
$ cd Am-I-late/
|
||||
$ docker-compose up
|
||||
~~~
|
||||
|
||||
## Usage
|
||||
|
@ -44,4 +54,4 @@ Load test data fixtures
|
|||
|
||||
~~~
|
||||
php bin/console doctrine:fixture:load
|
||||
~~~
|
||||
~~~
|
||||
|
|
|
@ -6737,11 +6737,6 @@
|
|||
"yallist": "2.1.2"
|
||||
}
|
||||
},
|
||||
"macaddress": {
|
||||
"version": "0.2.8",
|
||||
"resolved": "https://registry.npmjs.org/macaddress/-/macaddress-0.2.8.tgz",
|
||||
"integrity": "sha1-WQTcU3w57G2+/q6QIycTX6hRHxI="
|
||||
},
|
||||
"make-dir": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz",
|
||||
|
@ -7935,12 +7930,14 @@
|
|||
}
|
||||
},
|
||||
"postcss-filter-plugins": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/postcss-filter-plugins/-/postcss-filter-plugins-2.0.2.tgz",
|
||||
"integrity": "sha1-bYWGJTTXNaxCDkqFgG4fXUKG2Ew=",
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/postcss-filter-plugins/-/postcss-filter-plugins-2.0.3.tgz",
|
||||
"integrity": "sha512-T53GVFsdinJhgwm7rg1BzbeBRomOg9y5MBVhGcsV0CxurUdVj1UlPdKtn7aqYA/c/QVkzKMjq2bSV5dKG5+AwQ==",
|
||||
"requires": {
|
||||
"postcss": "5.2.18",
|
||||
"uniqid": "4.1.1"
|
||||
|
||||
"uniqid": "4.1.1",
|
||||
"postcss": "^5.0.4"
|
||||
|
||||
},
|
||||
"dependencies": {
|
||||
"has-flag": {
|
||||
|
@ -10741,6 +10738,7 @@
|
|||
"resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz",
|
||||
"integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8="
|
||||
},
|
||||
|
||||
"uniqid": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/uniqid/-/uniqid-4.1.1.tgz",
|
||||
|
@ -10749,6 +10747,7 @@
|
|||
"macaddress": "0.2.8"
|
||||
}
|
||||
},
|
||||
|
||||
"uniqs": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/uniqs/-/uniqs-2.0.0.tgz",
|
||||
|
|
|
@ -149,9 +149,9 @@ class App extends Component {
|
|||
</header>
|
||||
<div className="jumbotron">
|
||||
<div className="currentSection vertical-center container">
|
||||
<h1 className="currentState">{this.state.currentQuestion}</h1>
|
||||
<h2 className="currentState">{this.state.currentQuestion}</h2>
|
||||
{this.state.currentSticker ?
|
||||
<img src={this.state.currentSticker} />
|
||||
<img src={this.state.currentSticker} style={{margin:'25px 0'}} />
|
||||
: null}
|
||||
<div className="currentOptions">
|
||||
{this.state.currentResponses ? currentOptions : null}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
-- MySQL dump 10.13 Distrib 5.7.22, for Linux (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: amilate
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.7.22-0ubuntu18.04.1
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `migration_versions`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `migration_versions`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `migration_versions` (
|
||||
`version` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`version`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `migration_versions`
|
||||
--
|
||||
|
||||
LOCK TABLES `migration_versions` WRITE;
|
||||
/*!40000 ALTER TABLE `migration_versions` DISABLE KEYS */;
|
||||
INSERT INTO `migration_versions` VALUES ('20180507081943'),('20180507084936');
|
||||
/*!40000 ALTER TABLE `migration_versions` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `question`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `question`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `question` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`text` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`sticker` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `question`
|
||||
--
|
||||
|
||||
LOCK TABLES `question` WRITE;
|
||||
/*!40000 ALTER TABLE `question` DISABLE KEYS */;
|
||||
INSERT INTO `question` VALUES (36,'Vous arrivez devant l\'entrée d\'HETIC, qui est fermée. Que faites-vous ?','2018-06-06 10:12:28','https://risibank.fr/cache/stickers/d325/32563-static.png'),(37,'Un passant vous vois essayer d\'escalader le mur et appelle la police','2018-06-06 10:12:28','https://risibank.fr/cache/stickers/d52/5245-thumb.jpg'),(38,'A peine entré, un étudiant vous demande si vous ne vous êtes pas perdu, que faites-vous ?','2018-06-06 11:39:34','https://risibank.fr/cache/stickers/d760/76074-thumb.png'),(39,'Il vous croit, mais les gilberts sont déjà sur les lieux.','2018-06-06 11:51:14','https://risibank.fr/cache/stickers/d35/3522-thumb.png');
|
||||
/*!40000 ALTER TABLE `question` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `response`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `response`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `response` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`text` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`question_id` int(11) DEFAULT NULL,
|
||||
`child_id` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `IDX_3E7B0BFB1E27F6BF` (`question_id`),
|
||||
KEY `IDX_3E7B0BFBDD62C21B` (`child_id`),
|
||||
CONSTRAINT `FK_3E7B0BFB1E27F6BF` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`),
|
||||
CONSTRAINT `FK_3E7B0BFBDD62C21B` FOREIGN KEY (`child_id`) REFERENCES `question` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=172 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `response`
|
||||
--
|
||||
|
||||
LOCK TABLES `response` WRITE;
|
||||
/*!40000 ALTER TABLE `response` DISABLE KEYS */;
|
||||
INSERT INTO `response` VALUES (164,'J\'abandonne, tempis pour le cours.',36,NULL),(165,'J\'escalade le mur à mains nues',36,37),(166,'Vous lui expliquez qu\'il s\'agit d\'un malentendu, vous testez la sécurité du batiment',37,39),(167,'-',37,NULL),(168,'-',37,NULL),(169,'J\'appelle le directeur Mr. Beaux',36,NULL),(170,'Je passe par le bâtiment des H',36,38),(171,'J\'ai glissé chef',39,NULL);
|
||||
/*!40000 ALTER TABLE `response` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2018-06-06 12:03:52
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Question;
|
||||
use App\Form\QuestionType;
|
||||
use App\Repository\QuestionRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
* @Route("/")
|
||||
*/
|
||||
class QuestionApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/questions/first", name="api_questions_first")
|
||||
*/
|
||||
public function getFirst(QuestionRepository $questionRepository)
|
||||
{
|
||||
$data = $questionRepository->findFirst();
|
||||
|
||||
return JsonResponse::create($data, 200, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,10 @@ use ApiPlatform\Core\Annotation\ApiSubresource;
|
|||
/**
|
||||
* @ApiResource(
|
||||
* collectionOperations={"get"={"method"="GET"}},
|
||||
* itemOperations={"get"={"method"="GET"}}
|
||||
* itemOperations={
|
||||
* "get"={"method"="GET"},
|
||||
* "special"={"route_name"="api_questions_first"}
|
||||
* }
|
||||
* )
|
||||
* @ORM\Table(name="question")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\QuestionRepository")
|
||||
|
@ -53,13 +56,6 @@ class Question
|
|||
$this->date = new \DateTime();
|
||||
}
|
||||
|
||||
/*public function __invoke(Question $question): Question
|
||||
{
|
||||
$this->testSerializer->test();
|
||||
|
||||
return $question;
|
||||
}*/
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getText();
|
||||
|
@ -70,7 +66,7 @@ class Question
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
public function getText(): ?string
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Form;
|
||||
|
||||
use App\Entity\Question;
|
||||
use Doctrine\DBAL\Types\TextType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
@ -12,8 +13,12 @@ class QuestionType extends AbstractType
|
|||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('text')
|
||||
->add('sticker')
|
||||
->add('text', null, [
|
||||
'attr' => ['class' => 'form-control'],
|
||||
])
|
||||
->add('sticker', null, [
|
||||
'attr' => ['class' => 'form-control'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,15 @@ class ResponseType extends AbstractType
|
|||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('text')
|
||||
->add('question')
|
||||
->add('child')
|
||||
->add('text', null, [
|
||||
'attr' => ['class' => 'form-control'],
|
||||
])
|
||||
->add('question', null, [
|
||||
'attr' => ['class' => 'form-control'],
|
||||
])
|
||||
->add('child', null, [
|
||||
'attr' => ['class' => 'form-control'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,13 @@ class QuestionRepository extends ServiceEntityRepository
|
|||
/**
|
||||
* @return Question[] Returns an array of Question objects
|
||||
*/
|
||||
public function findByToken($token)
|
||||
public function findFirst()
|
||||
{
|
||||
return $this->createQueryBuilder('q')
|
||||
->andWhere('q.token = :token')
|
||||
->setParameter('token', $token)
|
||||
->orderBy('q.id', 'ASC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
->getArrayResult()
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sundowndev
|
||||
* Date: 30/05/18
|
||||
* Time: 17:20
|
||||
*/
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Response;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
class ResponseService
|
||||
{
|
||||
//private $object;
|
||||
private $response;
|
||||
|
||||
public function __construct(Response $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function persistResponses(array $data, $question)
|
||||
{
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
foreach ($data as $text) {
|
||||
$entity = new Response();
|
||||
$entity->setText($text);
|
||||
$entity->setQuestion($question);
|
||||
|
||||
// tell Doctrine you want to (eventually) save the Product (no queries yet)
|
||||
$entityManager->persist($entity);
|
||||
|
||||
// actually executes the queries (i.e. the INSERT query)
|
||||
$entityManager->flush();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sundowndev
|
||||
* Date: 30/05/18
|
||||
* Time: 16:31
|
||||
*/
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
|
||||
|
||||
class TestSerializer
|
||||
{
|
||||
public function test ($data, Serializer $serializer)
|
||||
{
|
||||
return $serializer->denormalize($data);
|
||||
}
|
||||
}
|
|
@ -17,10 +17,10 @@
|
|||
<tr>
|
||||
<td>{{ question.id }}</td>
|
||||
<td>{{ question.text }}</td>
|
||||
<td>{{ question.date ? question.date|date('Y-m-d H:i:s') : '' }}</td>
|
||||
<td>{{ question.date ? question.date|date('d/m/Y à H:i') : '' }}</td>
|
||||
<td>
|
||||
<a href="{{ path('question_show', {'id': question.id}) }}">show</a>
|
||||
<a href="{{ path('question_edit', {'id': question.id}) }}">edit</a>
|
||||
<a href="{{ path('question_show', {'id': question.id}) }}">Afficher</a>
|
||||
<a href="{{ path('question_edit', {'id': question.id}) }}" class="btn btn-primary">Modifier</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
|
@ -33,5 +33,5 @@
|
|||
|
||||
<hr>
|
||||
|
||||
<a href="{{ path('question_new') }}">Create new</a>
|
||||
<a href="{{ path('question_new') }}" class="btn btn-primary">Create new</a>
|
||||
{% endblock %}
|
|
@ -8,7 +8,8 @@
|
|||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Text</th>
|
||||
<th>actions</th>
|
||||
<th>Question</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -16,9 +17,10 @@
|
|||
<tr>
|
||||
<td>{{ response.id }}</td>
|
||||
<td>{{ response.text }}</td>
|
||||
<td>{{ response.question }}</td>
|
||||
<td>
|
||||
<a href="{{ path('response_show', {'id': response.id}) }}">show</a>
|
||||
<a href="{{ path('response_edit', {'id': response.id}) }}">edit</a>
|
||||
<a href="{{ path('response_show', {'id': response.id}) }}">Afficher</a>
|
||||
<a href="{{ path('response_edit', {'id': response.id}) }}" class="btn btn-primary btn-xs">Modifier</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
|
@ -29,5 +31,5 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('response_new') }}">Create new</a>
|
||||
<a href="{{ path('response_new') }}" class="btn btn-primary">Create new</a>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue