Exemple #1
0
 public function executeSaveScore()
 {
     $student_id = $this->getRequestParameter('student_id');
     $student = StudentPeer::retrieveByPK($student_id);
     $this->forward404Unless($student);
     $academic_calendar_id = $this->getRequestParameter('academic_calendar_id');
     $academic_calendar = AcademicCalendarPeer::retrieveByPK($academic_calendar_id);
     $this->forward404Unless($academic_calendar);
     $counseling_id = $this->getRequestParameter('counseling_id');
     $counseling = CounselingPeer::retrieveByPK($counseling_id);
     $this->forward404Unless($counseling);
     $student_accal_id = $this->getRequestParameter('student_accal_id');
     $student_accal = StudentAccalPeer::retrieveByPK($student_accal_id);
     $this->forward404Unless($student_accal);
     $scores = $this->getRequestParameter('score');
     foreach ($scores as $k => $score) {
         if ($score != null) {
             $cb = new Criteria();
             $cb->add(CounselingRaportPeer::STUDENT_ACCAL_ID, $student_accal->getId());
             $cb->add(CounselingRaportPeer::COUNSELING_SPEC_ID, $k);
             $raport = CounselingRaportPeer::doSelectOne($cb);
             if ($raport == null) {
                 $raport = new CounselingRaport();
             }
             $raport->setStudentAccalId($student_accal->getId());
             $raport->setCounselingSpecId($k);
             $raport->setGrade($score);
             $raport->save();
         } else {
             $cb = new Criteria();
             $cb->add(CounselingRaportPeer::STUDENT_ACCAL_ID, $student_accal->getId());
             $cb->add(CounselingRaportPeer::COUNSELING_SPEC_ID, $k);
             $raport = CounselingRaportPeer::doSelectOne($cb);
             if ($raport != null) {
                 $raport->delete();
             }
         }
     }
     return $this->redirect('counseling_raport/listCounselingScore?accal_id=' . $academic_calendar->getId() . '&counseling_id=' . $counseling->getId());
 }
 public function addCounselingRaport(CounselingRaport $l)
 {
     $this->collCounselingRaports[] = $l;
     $l->setCounselingSpec($this);
 }