public function rateAction() { $sefssion = $this->getEntityManager()->getRepository('Admin\\Entity\\Session')->findOneBy(array(), array('id' => 'DESC')); $session = $sefssion->getId(); $student = $_POST['student']; $rate = $_POST['rate']; $traits = $_POST['traits']; //$total=$ftest+$stest+$exam; //var_dump($name);die; foreach ($rate as $key => $n) { $studentobject = $this->getEntityManager()->getRepository('Admin\\Entity\\Student')->findOneBy(array('id' => $student)); $traitobject = $this->getEntityManager()->getRepository('Admin\\Entity\\Traits')->findOneBy(array('id' => $traits[$key])); $rating = $this->getEntityManager()->getRepository('Admin\\Entity\\Rating')->findOneBy(array('student' => $student, 'session' => $session, 'traits' => $traits[$key])); if (isset($rating)) { $rating->setRate($n); $this->getEntityManager()->persist($rating); $studentobject->setRating($rating); $this->getEntityManager()->persist($studentobject); } else { $rating = new Rating(); $rating->setRate($n); $rating->setTraits($traitobject); $rating->setStudent($studentobject); $rating->setSession($sefssion); $this->getEntityManager()->persist($rating); $studentobject->setRating($rating); $this->getEntityManager()->persist($studentobject); } } $this->getEntityManager()->flush(); return $this->redirect()->toRoute('rating', array('controller' => 'rating', 'action' => 'index')); return new ViewModel(); }
/** * {@inheritDoc} */ public function getSession() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSession', array()); return parent::getSession(); }