/**
  * @param Exercise $exercise
  * @param int      $orderStep
  *
  * @return Step
  */
 public function createStep(Exercise $exercise, $orderStep)
 {
     $em = $this->doctrine->getManager();
     //Creating a step by question
     $step = new Step();
     $step->setText(' ');
     $step->setExercise($exercise);
     $step->setNbQuestion(0);
     $step->setDuration(0);
     $step->setMaxAttempts(0);
     $step->setOrder($orderStep);
     $em->persist($step);
     return $step;
 }
示例#2
0
 /**
  * create the exercise.
  *
  * @param array    $step     - properties of the step
  * @param Exercise $exercise
  *
  * @return Step
  */
 private function createStep(array $step, Exercise $exercise)
 {
     $newStep = new Step();
     $newStep->setText($step['text']);
     $newStep->setOrder($step['order']);
     $newStep->setShuffle($step['shuffle']);
     $newStep->setNbQuestion($step['nbQuestion']);
     $newStep->setKeepSameQuestion($step['keepSameQuestion']);
     $newStep->setDuration($step['duration']);
     $newStep->setMaxAttempts($step['maxAttempts']);
     $newStep->setExercise($exercise);
     $this->om->persist($newStep);
     $this->om->flush();
     return $newStep;
 }
示例#3
0
 /**
  * Create a copy of a Step.
  *
  * @param Step $step
  *
  * @return Step the copy of the Step
  */
 public function copyStep(Step $step)
 {
     $newStep = new Step();
     // Populate Step properties
     $newStep->setOrder($step->getOrder());
     $newStep->setText($step->getText());
     $newStep->setNbQuestion($step->getNbQuestion());
     $newStep->setShuffle($step->getShuffle());
     $newStep->setDuration($step->getDuration());
     $newStep->setMaxAttempts($step->getMaxAttempts());
     $newStep->setKeepSameQuestion($step->getKeepSameQuestion());
     // Link questions to Step
     /** @var StepQuestion $stepQuestion */
     foreach ($step->getStepQuestions() as $stepQuestion) {
         $newStepQuestion = new StepQuestion();
         $newStepQuestion->setStep($newStep);
         $newStepQuestion->setQuestion($stepQuestion->getQuestion());
         $newStepQuestion->setOrdre($stepQuestion->getOrdre());
     }
     return $newStep;
 }