Compare commits

..

No commits in common. "b7358021a79665a84d561426379bf062789e8aaf" and "56126c6649eb42474891b7782d85354488059067" have entirely different histories.

2 changed files with 14 additions and 123 deletions

View File

@ -1,18 +1,9 @@
<?php
namespace App\Controller;
//use FOS\RestBundle\Controller\Annotations\Get;
//use FOS\RestBundle\Controller\Annotations\Route;
use App\Entity\Choice;
use App\Entity\StackOfVotes;
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;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* Class DefaultController
@ -40,7 +31,7 @@ class MigrationController extends FramadateController {
$debug = '';
$em = $this->getDoctrine()->getManager();
$pollsBySlug = [];
$pollsByID = [];
$pdo_options[ \PDO::ATTR_ERRMODE ] = \PDO::ERRMODE_EXCEPTION;
$bdd = new \PDO( 'mysql:host=localhost;dbname=' . $this->getParameter( 'OLD_DATABASE_NAME' ),
@ -48,91 +39,26 @@ class MigrationController extends FramadateController {
$this->getParameter( 'OLD_DATABASE_PASS' ),
$pdo_options );
$res_Poll = $bdd->query( 'SELECT * FROM fd_poll' );
//boucler pour ranger
while ( $d = $res_Poll->fetch( \PDO::FETCH_OBJ ) ) {
echo "<html> <body> ";
echo "<br> migration du sondage $d->title , $d->id , ";
echo "<br> migration du sondage $d->title , $d->id";
var_dump($d);
$u = new Poll();
$newPoll = new Poll();
$owner = new Owner();
$owner->setEmail( $d->admin_mail )
->setPseudo( $d->admin_name );
$owner->addPoll($newPoll);
$newPoll
->setOwner( $owner )
$u
->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 ) );
$pollsBySlug[ $d->id ] = $newPoll;
// $em->persist( $owner );
// $em->persist( $newPoll );
}
// get choices, slots and link them with poll by their slug
$res_slots = $bdd->query( 'SELECT * FROM fd_slot' );
while ( $d = $res_slots->fetch( \PDO::FETCH_OBJ ) ) {
$pollSlug = $d->poll_id;
$poll = $pollsBySlug[$pollSlug];
$moments = explode(',' , $d->moments);
foreach ( $moments as $moment ) {
$newChoice = new Choice();
$newChoice
->setPoll($poll)
->setDateTime($d->title)
->setName($moment);
$poll->addChoice($newChoice);
// $em->persist( $newChoice );
// $em->persist( $newPoll );
}
}
// get choices, slots and link them with poll by their slug
$res_votes = $bdd->query( 'SELECT * FROM fd_vote' );
while ( $d = $res_votes->fetch( \PDO::FETCH_OBJ ) ) {
$pollSlug = $d->poll_id;
$poll = $pollsBySlug[ $pollSlug ];
$newStack = new StackOfVotes();
$newStack->setPoll($poll)
->setPseudo($d->name)
;
// each choice answer is encoded in a value :
// space character : no answer, 0 : no , 1 : maybe , 2 : yes
$voteCodes = explode( '', $d->moments );
// get choices of the poll and answer accordingly
$ii=0;
foreach ( $voteCodes as $vote_code ) {
if($vote_code !== ' '){
// TODO
// $newStack->addVote($newVote);
}
$ii++;
}
$poll->addStackOfVotes($newStack);
$pollsByID[ $d->id ] = $u;
// $u->setPseudo($d->pseudo)
// ->setIp($d->ip)
// ->setAge($d->age)
// ->setsondage($s);
// $em->persist( $u );
}
// $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,41 +72,6 @@
* @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