add options in poll model to limit people number to answer, migrate poll properties, and create owner
This commit is contained in:
parent
56126c6649
commit
116e1237fa
|
@ -1,9 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
//use FOS\RestBundle\Controller\Annotations\Get;
|
||||||
use App\Entity\Poll;
|
//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 Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use App\Entity\Owner;
|
||||||
|
use App\Entity\Poll;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DefaultController
|
* Class DefaultController
|
||||||
|
@ -31,7 +38,7 @@ class MigrationController extends FramadateController {
|
||||||
$debug = '';
|
$debug = '';
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$pollsByID = [];
|
$pollsBySlug = [];
|
||||||
|
|
||||||
$pdo_options[ \PDO::ATTR_ERRMODE ] = \PDO::ERRMODE_EXCEPTION;
|
$pdo_options[ \PDO::ATTR_ERRMODE ] = \PDO::ERRMODE_EXCEPTION;
|
||||||
$bdd = new \PDO( 'mysql:host=localhost;dbname=' . $this->getParameter( 'OLD_DATABASE_NAME' ),
|
$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' );
|
$res_Poll = $bdd->query( 'SELECT * FROM fd_poll' );
|
||||||
//boucler pour ranger
|
//boucler pour ranger
|
||||||
while ( $d = $res_Poll->fetch( \PDO::FETCH_OBJ ) ) {
|
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 )
|
->setCustomURL( $d->id )
|
||||||
|
// ->setKind( $d->id === 'D' ? 'date' : 'text' )
|
||||||
|
->setHideResults( ! $d->results_publicly_visible )
|
||||||
->setAdminKey( $d->admin_id )
|
->setAdminKey( $d->admin_id )
|
||||||
->setTitle( $d->title )
|
->setTitle( $d->title )
|
||||||
|
// ->setVotesAllowed( $d->receiveNewVotes )
|
||||||
|
// ->setCommentsAllowed( $d->receiveNewComments )
|
||||||
|
->setChoicesMax( $d->ValueMax )
|
||||||
|
->setPassword( $d->password_hash )
|
||||||
->setDescription( $d->description )
|
->setDescription( $d->description )
|
||||||
->setCreationDate( date_create( $d->creation_date ) );
|
->setCreationDate( date_create( $d->creation_date ) );
|
||||||
|
|
||||||
$pollsByID[ $d->id ] = $u;
|
$pollsBySlug[ $d->id ] = $newPoll;
|
||||||
|
|
||||||
// $u->setPseudo($d->pseudo)
|
|
||||||
// ->setIp($d->ip)
|
// $em->persist( $owner );
|
||||||
// ->setAge($d->age)
|
// $em->persist( $newPoll );
|
||||||
// ->setsondage($s);
|
|
||||||
// $em->persist( $u );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $em->flush();
|
// $em->flush();
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
*/
|
*/
|
||||||
public $owner;
|
public $owner;
|
||||||
/**
|
/**
|
||||||
* kind of poll, text or date
|
* kind of poll, 'text' or 'date'
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
* @Serializer\Type("string")
|
* @Serializer\Type("string")
|
||||||
* @Serializer\Expose()
|
* @Serializer\Expose()
|
||||||
|
@ -72,6 +72,41 @@
|
||||||
* @Serializer\Expose()
|
* @Serializer\Expose()
|
||||||
*/
|
*/
|
||||||
public $allowedAnswers;
|
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
|
* kind of way the people can modify the poll
|
||||||
* everybody - can modify votes
|
* everybody - can modify votes
|
||||||
|
|
Loading…
Reference in New Issue