add options in poll model to limit people number to answer, migrate poll properties, and create owner

This commit is contained in:
Tykayn 2021-04-17 15:52:08 +02:00 committed by tykayn
parent 56126c6649
commit 116e1237fa
2 changed files with 68 additions and 13 deletions

View File

@ -1,9 +1,16 @@
<?php
namespace App\Controller;
use App\Entity\Poll;
//use FOS\RestBundle\Controller\Annotations\Get;
//use FOS\RestBundle\Controller\Annotations\Route;
use App\Repository\PollRepository;
use App\Service\MailService;
use FOS\RestBundle\Controller\Annotations\Get;
use FOS\RestBundle\Controller\Annotations\Route;
use JMS\Serializer\Type\Exception\Exception;
use Symfony\Component\HttpFoundation\JsonResponse;
use App\Entity\Owner;
use App\Entity\Poll;
/**
* Class DefaultController
@ -31,7 +38,7 @@ class MigrationController extends FramadateController {
$debug = '';
$em = $this->getDoctrine()->getManager();
$pollsByID = [];
$pollsBySlug = [];
$pdo_options[ \PDO::ATTR_ERRMODE ] = \PDO::ERRMODE_EXCEPTION;
$bdd = new \PDO( 'mysql:host=localhost;dbname=' . $this->getParameter( 'OLD_DATABASE_NAME' ),
@ -41,24 +48,37 @@ class MigrationController extends FramadateController {
$res_Poll = $bdd->query( 'SELECT * FROM fd_poll' );
//boucler pour ranger
while ( $d = $res_Poll->fetch( \PDO::FETCH_OBJ ) ) {
echo "<br> migration du sondage $d->title , $d->id";
echo "<html> <body> ";
echo "<br> migration du sondage $d->title , $d->id , ";
$u = new Poll();
var_dump($d);
$u
$newPoll = new Poll();
$owner = new Owner();
$owner->setEmail( $d->admin_mail )
->setPseudo( $d->admin_name );
$owner->addPoll($newPoll);
$newPoll
->setOwner( $owner )
->setCustomURL( $d->id )
// ->setKind( $d->id === 'D' ? 'date' : 'text' )
->setHideResults( ! $d->results_publicly_visible )
->setAdminKey( $d->admin_id )
->setTitle( $d->title )
// ->setVotesAllowed( $d->receiveNewVotes )
// ->setCommentsAllowed( $d->receiveNewComments )
->setChoicesMax( $d->ValueMax )
->setPassword( $d->password_hash )
->setDescription( $d->description )
->setCreationDate( date_create( $d->creation_date ) );
$pollsByID[ $d->id ] = $u;
$pollsBySlug[ $d->id ] = $newPoll;
// $u->setPseudo($d->pseudo)
// ->setIp($d->ip)
// ->setAge($d->age)
// ->setsondage($s);
// $em->persist( $u );
// $em->persist( $owner );
// $em->persist( $newPoll );
}
// $em->flush();

View File

@ -58,7 +58,7 @@
*/
public $owner;
/**
* kind of poll, text or date
* kind of poll, 'text' or 'date'
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
* @Serializer\Expose()
@ -72,6 +72,41 @@
* @Serializer\Expose()
*/
public $allowedAnswers;
/**
* people can add votes
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Type("boolean")
* @Serializer\Expose()
*/
public $votesAllowed;
/**
* max number of stack of votes possible.
* limits the number of people who can answer. as long as you trust the people to give only one answer with a reliable system.
* @ORM\Column(type="number", nullable=true)
* @Serializer\Type("number")
* @Serializer\Expose()
*/
public $votesMax;
/**
* max number of choices people can answer in a stack of vote. for text polls only, not date kind.
* by default, people can check as many answers as they want.
* If the question is "check your 3 favourite flavours" and displays 10 flavours, only the first 3 clicked will be taken into account. GUI should be able to make this clear and togglable so that people can change their 3 favourite flavours in their answer.
* @ORM\Column(type="number", nullable=true)
* @Serializer\Type("number")
* @Serializer\Expose()
*/
public $choicesMax;
/**
* people can add comments
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Type("boolean")
* @Serializer\Expose()
*/
public $commentsAllowed;
/**
* kind of way the people can modify the poll
* everybody - can modify votes