public function saveStudentList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['student_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     foreach ($this->getObject()->getStudentExaminationRepprovedSubjects() as $sr) {
         $sr->delete($con);
     }
     $values = $this->getValue('student_list');
     if (is_array($values)) {
         $con->beginTransaction();
         try {
             foreach ($values as $value) {
                 $student_repproved = StudentRepprovedCourseSubjectPeer::retrieveByCareerSubjectIdAndStudentId($this->getObject()->getCareerSubjectId(), $value);
                 $student_examination_repproved_subject = new StudentExaminationRepprovedSubject();
                 $student_examination_repproved_subject->setStudentRepprovedCourseSubject($student_repproved);
                 $student_examination_repproved_subject->setExaminationRepprovedSubject($this->getObject());
                 $student_examination_repproved_subject->save($con);
             }
             $con->commit();
         } catch (Exception $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }
 public function saveExaminationRepprovedSubjectStudentList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['examination_repproved_subject_student_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     $con->beginTransaction();
     try {
         $values = $this->getValue('examination_repproved_subject_student_list');
         foreach ($this->getObject()->getStudentExaminationRepprovedSubjects() as $sers) {
             if (!is_array($values)) {
                 $values = array();
             }
             if (!in_array($sers->getStudent()->getId(), $values)) {
                 $sers->delete($con);
             } else {
                 unset($values[array_search($sers->getStudent()->getId(), $values)]);
             }
         }
         $career_subject_id = $this->getObject()->getCareerSubjectId();
         if (is_array($values)) {
             foreach ($values as $student_id) {
                 $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveByCareerSubjectIdAndStudentId($career_subject_id, $student_id);
                 $student_examination_repproved_subject = new StudentExaminationRepprovedSubject();
                 $student_examination_repproved_subject->setExaminationRepprovedSubject($this->getObject());
                 $student_examination_repproved_subject->setStudentRepprovedCourseSubject($student_repproved_course_subject);
                 $student_repproved_course_subject->save($con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 public function getExaminationNoteForStudent($student)
 {
     $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveByCareerSubjectIdAndStudentId($this->getCareerSubject()->getId(), $student->getId());
     $c = new Criteria();
     $c->add(StudentExaminationRepprovedSubjectPeer::STUDENT_REPPROVED_COURSE_SUBJECT_ID, $student_repproved_course_subject->getId());
     $c->add(StudentExaminationRepprovedSubjectPeer::EXAMINATION_REPPROVED_SUBJECT_ID, $this->getId());
     return StudentExaminationRepprovedSubjectPeer::doSelectOne($c);
 }
示例#4
0
 /**
  * Returns the status for $this (CourseSubjectStudent) when it's disapproved.
  *
  * @return string
  */
 public function getDisapprovedStatus()
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array("I18N"));
     $repproved = StudentRepprovedCourseSubjectPeer::retrieveByCareerSubjectIdAndStudentId($this->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubjectId(), $this->getStudentId());
     if ($repproved) {
         return __("Previous");
     } else {
         $c = new Criteria();
         $c->addDescendingOrderByColumn(CourseSubjectStudentExaminationPeer::EXAMINATION_NUMBER);
         $examinations = $this->getCourseSubjectStudentExaminations($c);
         return SchoolBehaviourFactory::getEvaluatorInstance()->getStringFor($examinations[0]->getExaminationNumber());
     }
 }