public function getCourseSubjectStudent()
 {
     $c = new Criteria();
     $c->add(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, $this->getCourseSubjectId());
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getStudentId());
     return CourseSubjectStudentPeer::doSelectOne($c);
 }
 public function getRelatedCourseSubjectStudent()
 {
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID, Criteria::INNER_JOIN);
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getStudentId());
     $c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $this->getCourseSubject()->getCareerSubjectSchoolYearId());
     return CourseSubjectStudentPeer::doSelectOne($c);
 }
 public function renderStudentCalificationRow($student, $course_subjects)
 {
     $row = array($student->__toString());
     foreach ($course_subjects as $course_subject) {
         foreach ($student->getMarksForCourse($course_subject) as $mark) {
             $row[] = array('size' => BaseReportRenderer::FONT_SIZE_NORMAL, 'style' => BaseReportRenderer::STYLE_CENTERED, 'content' => $mark->__toString());
         }
         $course_subject_student = CourseSubjectStudentPeer::retrieveByCourseSubjectAndStudent($course_subject->getId(), $student->getId());
         $row[] = array('size' => BaseReportRenderer::FONT_SIZE_NORMAL, 'style' => BaseReportRenderer::STYLE_CENTERED, 'content' => $course_subject_student->getMarksAverage());
     }
     $this->renderRow($row);
 }
Exemplo n.º 4
0
 public function deleteStudentFromCourses($id, $con)
 {
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID, Criteria::INNER_JOIN);
     $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID, Criteria::INNER_JOIN);
     $c->addAnd(CoursePeer::DIVISION_ID, $this->getId());
     $c->addAnd(CourseSubjectStudentPeer::STUDENT_ID, $id);
     foreach (CourseSubjectStudentPeer::doSelect($c) as $css) {
         if ($css->countValidCourseSubjectStudentMarks() > 0) {
             throw new Exception('Los alumnos seleccionados poseen datos que le impiden ser borrados de esta division y sus cursos.');
         }
         $css->delete($con);
     }
 }
Exemplo n.º 5
0
 /**
  * Returns the array with CourseSubjecStudent.
  *
  * Posiciones del vector ['ANUAL']['QUATERLY']['BIMESTER'], no necesariamente se cargan todos..
  * El mismo vector, devuelve la cantidad de notas maximas en cada arreglo.
  * @return array
  */
 public function getCourses()
 {
     $css = CourseSubjectStudentPeer::retrieveByCareerSchoolYearAndStudent($this->getCareerSchoolYear(), $this->getStudent());
     $course_subject_per_type = array();
     $anual_max = 0;
     $quaterly_max = 0;
     $bimester_max = 0;
     $quaterly_of_a_term_max = 0;
     $anual_period_max = 1;
     $quaterly_period_max = 1;
     $bimester_period_max = 1;
     $quaterly_of_a_term_period_max = 1;
     foreach ($css as $course_subject_student) {
         $course_type = $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration()->getCourseType();
         $course_type;
         switch ($course_type) {
             case 1:
                 $course_subject_per_type['ANUAL'][] = $course_subject_student;
                 $course_subject_per_type['ANUAL']['marks'] = max($anual_max, $course_subject_student->countCourseSubjectStudentMarks());
                 $course_subject_per_type['ANUAL']['periods'] = max($anual_period_max, $course_subject_student->countCourseSubjectStudentPeriods());
                 $anual_max = $anual_max > $course_subject_student->countCourseSubjectStudentMarks() ? $anual_max : $course_subject_student->countCourseSubjectStudentMarks();
                 $anual_period_max = $anual_period_max > $course_subject_student->countCourseSubjectStudentPeriods() ? $anual_period_max : $course_subject_student->countCourseSubjectStudentPeriods();
                 break;
             case 2:
                 $course_subject_per_type['QUATERLY'][] = $course_subject_student;
                 $course_subject_per_type['QUATERLY']['marks'] = max($quaterly_max, $course_subject_student->countCourseSubjectStudentMarks());
                 $course_subject_per_type['QUATERLY']['periods'] = max($quaterly_period_max, $course_subject_student->countCourseSubjectStudentPeriods());
                 $quaterly_max = $quaterly_max > $course_subject_student->countCourseSubjectStudentMarks() ? $quaterly_max : $course_subject_student->countCourseSubjectStudentMarks();
                 $quaterly_period_max = $quaterly_period_max > $course_subject_student->countCourseSubjectStudentPeriods() ? $quaterly_period_max : $course_subject_student->countCourseSubjectStudentPeriods();
                 break;
             case 3:
                 $course_subject_per_type['BIMESTER'][] = $course_subject_student;
                 $course_subject_per_type['BIMESTER']['marks'] = max($bimester_max, $course_subject_student->countCourseSubjectStudentMarks());
                 $course_subject_per_type['BIMESTER']['periods'] = max($bimester_period_max, $course_subject_student->countCourseSubjectStudentPeriods());
                 $bimester_max = $bimester_max > $course_subject_student->countCourseSubjectStudentMarks() ? $bimester_max : $course_subject_student->countCourseSubjectStudentMarks();
                 $bimester_period_max = $bimester_period_max > $course_subject_student->countCourseSubjectStudentPeriods() ? $bimester_period_max : $course_subject_student->countCourseSubjectStudentPeriods();
                 break;
             case 4:
                 $course_subject_per_type['QUATERLY_OF_A_TERM'][] = $course_subject_student;
                 $course_subject_per_type['QUATERLY_OF_A_TERM']['marks'] = max($quaterly_of_a_term_max, $course_subject_student->countCourseSubjectStudentMarks());
                 $course_subject_per_type['QUATERLY_OF_A_TERM']['periods'] = max($quaterly_of_a_term_period_max, $course_subject_student->countCourseSubjectStudentPeriods());
                 $quaterly_of_a_term_max = $quaterly_of_a_term_max > $course_subject_student->countCourseSubjectStudentMarks() ? $bimester_max : $course_subject_student->countCourseSubjectStudentMarks();
                 $quaterly_of_a_term_period_max = $quaterly_of_a_term_period_max > $course_subject_student->countCourseSubjectStudentPeriods() ? $quaterly_of_a_term_period_max : $course_subject_student->countCourseSubjectStudentPeriods();
                 break;
         }
     }
     return $course_subject_per_type;
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $this->createContextInstance('backend');
     $criteria = new Criteria();
     $criteria->add(CoursePeer::IS_CLOSED, false);
     $criteria->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID, Criteria::INNER_JOIN);
     $criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID, Criteria::INNER_JOIN);
     $course_subject_students = CourseSubjectStudentPeer::doSelect($criteria);
     $this->log('Cant. Course Subject Students a procesar:');
     $this->log(count($course_subject_students));
     foreach ($course_subject_students as $course_subject_student) {
         $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId());
         $this->log('Id del course subject student Actual:');
         $this->log($course_subject_student->getId());
         foreach ($course_subject_student_marks as $mark) {
             $mark->setIsClosed(true);
             $mark->save($con);
         }
         $student_approved_course_subject = new StudentApprovedCourseSubject();
         $student_approved_course_subject->setCourseSubject($course_subject_student->getCourseSubject());
         $student_approved_course_subject->setStudentId($course_subject_student->getStudentId());
         $student_approved_course_subject->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
         $student_approved_career_subject = new StudentApprovedCareerSubject();
         $student_approved_career_subject->setStudentId($course_subject_student->getStudentId());
         $student_approved_career_subject->setCareerSubject($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject());
         $student_approved_career_subject->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
         $student_approved_career_subject->save($con);
         $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
         $student_approved_course_subject->save($con);
         $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject);
         $course_subject_student->save($con);
     }
     $criteria = new Criteria();
     $criteria->add(CoursePeer::IS_CLOSED, false);
     $courses = CoursePeer::doSelect($criteria);
     foreach ($courses as $c) {
         $c->setIsClosed(true);
         $c->save($con);
     }
 }
 protected function doSave($con = null)
 {
     $values = $this->getValues();
     $course_subject = CourseSubjectPeer::retrieveByPk($values['course_subject_id']);
     $course = $course_subject->getCourse();
     $con = is_null($con) ? $this->getConnection() : $con;
     try {
         $con->beginTransaction();
         foreach ($values['student_list'] as $student_id) {
             $course_subject_student = CourseSubjectStudentPeer::retrievebyCourseSubjectAndStudent($course_subject->getid(), $student_id);
             $course_subject_student->setIsNotAverageable(true);
             $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId());
             foreach ($course_subject_student_marks as $mark) {
                 if ($mark->getMarkNumber() < $course->getCurrentPeriod()) {
                     $mark->setIsClosed(true);
                 } else {
                     if ($mark->getMarkNumber() >= $course->getCurrentPeriod() && !$course->getIsClosed()) {
                         $mark->setIsClosed(false);
                     }
                 }
                 $mark->save($con);
             }
             //elimino el student_approved_course_subject y el student_approved_career_subject
             $student_approved_course_subject = $course_subject_student->getStudentApprovedCourseSubject();
             $student_approved_career_subject = $student_approved_course_subject->getStudentApprovedCareerSubject();
             $student_approved_course_subject->delete($con);
             $student_approved_career_subject->delete($con);
             $course_subject_student->setStudentApprovedCourseSubject(null);
             $course_subject_student->setIsNotAverageable(false);
             $course_subject_student->save($con);
         }
         //chequeo si la cantidad de alumnos deseximidos es mayor a cero y le curso esta cerrado.
         if (count($course->getIsAverageableCourseSubjectStudent()) > 0 && $course->getIsClosed()) {
             //abro el curso.
             $course->setIsClosed(false);
             $course->save($con);
         }
         $con->commit();
     } catch (Exception $e) {
         throw $e;
         $con->rollBack();
     }
 }
 public function getHistoriaDelArteMark($student, $school_year)
 {
     $historia = array(self::HISTORIA_DEL_ARTE, 261, 262);
     $c = new Criteria();
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $student->getId());
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
     $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
     $c->add(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, $historia, Criteria::IN);
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId());
     $avg = 0;
     foreach (CourseSubjectStudentPeer::doSelect($c) as $course_subject_student) {
         $course_result = $course_subject_student->getCourseResult();
         if (is_null($course_result) || $course_result instanceof StudentDisapprovedCourseSubject) {
             return '';
         }
         $avg += $course_result->getMark();
     }
     $avg = $avg / 2;
     return sprintf('%.4s', $avg);
 }
 public function saveExaminationSubjectStudentList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['examination_subject_student_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     $con->beginTransaction();
     try {
         $values = $this->getValue('examination_subject_student_list');
         foreach ($this->getObject()->getCourseSubjectStudentExaminations() as $csse) {
             if (!is_array($values)) {
                 $values = array();
             }
             if (!in_array($csse->getStudent()->getId(), $values)) {
                 $csse->delete($con);
             } else {
                 unset($values[array_search($csse->getStudent()->getId(), $values)]);
             }
         }
         if (is_array($values)) {
             foreach ($values as $student_id) {
                 $course_subject_student_examination = new CourseSubjectStudentExamination();
                 $course_subject_student_examination->setExaminationSubject($this->getObject());
                 $course_subject_student_examination->setExaminationNumber($this->getObject()->getExamination()->getExaminationNumber());
                 $course_subject_student = CourseSubjectStudentPeer::retrieveByCareerSubjectSchoolYearAndStudent($this->getObject()->getCareerSubjectSchoolYear(), $student_id);
                 $course_subject_student_examination->setCourseSubjectStudent($course_subject_student);
                 $course_subject_student_examination->save($con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * This method returns the available students for a course subject. If $filter_by_orientation == true then filter by orientation too.
  *
  * @param CourseSubject $course_subject
  * @param Criteria $criteria
  * @param Boolean $filter_by_orientation
  * @return Criteria
  */
 public function getAvailableStudentsForCourseSubjectCriteria(CourseSubject $course_subject, $criteria = null, $filter_by_orientation = true)
 {
     $criteria = is_null($criteria) ? new Criteria() : $criteria;
     //IF the course_subject is a option, the cheks are in the parent optional
     //die(var_dump($course_subject->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption()));
     $career_subject_school_year = $course_subject->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption() ? $course_subject->getCareerSubjectSchoolYear()->getOptionalCareerSubjectSchoolYear() : $course_subject->getCareerSubjectSchoolYear();
     $career_subject = $career_subject_school_year->getCareerSubject();
     //Students inscripted in the career
     $criteria->addJoin(StudentPeer::ID, CareerStudentPeer::STUDENT_ID, Criteria::INNER_JOIN);
     $criteria->addAnd(CareerStudentPeer::CAREER_ID, $career_subject->getCareerId());
     //If $filter_by_orientation == true then checks for orientation in the criteria
     if ($filter_by_orientation && !is_null($career_subject->getOrientation())) {
         $criteria->addJoin(CareerStudentPeer::ORIENTATION_ID, $career_subject->getOrientationId());
     }
     if ($filter_by_orientation && !is_null($career_subject->getSubOrientation())) {
         $criteria->addJoin(CareerStudentPeer::SUB_ORIENTATION_ID, $career_subject->getSubOrientationId());
     }
     //Students inscripted in the school_year
     $criteria->addJoin(StudentPeer::ID, SchoolYearStudentPeer::STUDENT_ID, Criteria::INNER_JOIN);
     $criteria->addAnd(SchoolYearStudentPeer::SCHOOL_YEAR_ID, $career_subject_school_year->getCareerSchoolYear()->getSchoolYearId());
     //Check if the students has the corresponds allows required to course this subject
     $criteria->addJoin(StudentPeer::ID, StudentCareerSubjectAllowedPeer::STUDENT_ID);
     $criteria->addAnd(StudentCareerSubjectAllowedPeer::CAREER_SUBJECT_ID, $career_subject->getId());
     //Criteria for eliminate students inscripted in other course_subject of the same course
     $already_criteria = new Criteria();
     $already_criteria->clearSelectColumns();
     $already_criteria->addSelectColumn(CourseSubjectStudentPeer::STUDENT_ID);
     $already_criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID);
     $already_criteria->add(CourseSubjectPeer::COURSE_ID, $course_subject->getCourseId());
     $already_criteria->add(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, $course_subject->getId(), Criteria::NOT_EQUAL);
     $pdo_statement = CourseSubjectStudentPeer::doSelectStmt($already_criteria);
     $student_already_ids = $pdo_statement->fetchAll(PDO::FETCH_COLUMN);
     if (count($student_already_ids)) {
         $criteria->addAnd(StudentPeer::ID, $student_already_ids, Criteria::NOT_IN);
     }
     return $criteria;
 }
 public function postValidateAvailableStudents(sfValidatorBase $validator, $values)
 {
     $duplicated_students = array();
     $student_ids = $values['course_subject_student_list'];
     $course_subject_id = $values['id'];
     foreach ($student_ids as $student_id) {
         if (CourseSubjectStudentPeer::countStudentInscriptionsForCareerSubjectSchoolYear($course_subject_id, $student_id) != 0) {
             $duplicated_students[] = StudentPeer::retrieveByPk($student_id);
         }
     }
     if ($duplicated_students) {
         $error = new sfValidatorError($validator, 'Los siguientes estudiantes seleccionados ya se encuentran inscriptos en otro curso para esta misma materia: ' . implode(',', $duplicated_students));
         throw new sfValidatorErrorSchema($validator, array('course_subject_student_list' => $error));
     }
     return $values;
 }
Exemplo n.º 12
0
 public function getMarksForCourse(CourseSubject $course_subject)
 {
     $css = CourseSubjectStudentPeer::retrieveByCourseSubjectAndStudent($course_subject->getId(), $this->getId());
     if (!is_null($css)) {
         $cssm = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($css->getId());
         return $cssm;
     }
     return NULL;
 }
 public function fixCourseSubjectStudents($con)
 {
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID);
     $c->add(CoursePeer::SCHOOL_YEAR_ID, 1);
     $c->add(CoursePeer::DIVISION_ID, null, Criteria::ISNULL);
     //die(var_dump(count(CourseSubjectStudentPeer::doSelect($c))));
     foreach (CourseSubjectStudentPeer::doSelect($c) as $course_subject_student) {
         $result = $course_subject_student->getCourseResult();
         if (is_null($result->getId())) {
             $result->save($con);
         }
         if ($result instanceof StudentApprovedCourseSubject) {
             $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($course_subject_student->getCourseSubject()->getCareerSubject()->getId(), $course_subject_student->getStudentId());
             $student_approved_career_subject->setSchoolYearId(1);
             $result->setStudentApprovedCareerSubject($student_approved_career_subject);
             $result->save($con);
             $student_approved_career_subject->save($con);
         }
         unset($result);
     }
 }
Exemplo n.º 14
0
 public static function countStudentInscriptionsForCareerSubjectSchoolYear($course_subject_id, $student_id)
 {
     $course_subject = CourseSubjectPeer::retrieveByPk($course_subject_id);
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $course_subject->getCareerSubjectSchoolYearId());
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $student_id);
     $c->addAnd(CourseSubjectPeer::ID, $course_subject_id, Criteria::NOT_EQUAL);
     return CourseSubjectStudentPeer::doCount($c);
 }
Exemplo n.º 15
0
 public function deleteCourseSubjectStudent()
 {
     $con = Propel::getConnection();
     try {
         $con->beginTransaction();
         $criteria = new Criteria();
         $criteria->add(CareerPeer::ID, $this->getCareerId());
         $criteria->addJoin(CareerPeer::ID, CareerSchoolYearPeer::CAREER_ID);
         $criteria->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
         $criteria->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
         $criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID);
         $criteria->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getStudentId());
         foreach (CourseSubjectStudentPeer::doSelect($criteria) as $course_subject_student) {
             $course_subject_student->delete($con);
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
 public function hasApprovedAllCourseSubjects($student_career_school_year)
 {
     #Counts the subjects the student did
     $c = new Criteria();
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
     $c->add(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $student_career_school_year->getCareerSchoolYearId());
     #Counts the subjects approved by the student during this year
     $course_subject_students = CourseSubjectStudentPeer::doSelect($c);
     /* @var $course_subject_student CourseSubjectStudent */
     foreach ($course_subject_students as $course_subject_student) {
         if (!$course_subject_student->getIsNotAverageable()) {
             $course_result = $course_subject_student->getCourseResult();
             if (is_null($course_result)) {
                 return false;
             }
             if (!$course_result->isApproved()) {
                 return false;
             }
         }
     }
     return true;
 }
Exemplo n.º 17
0
 public function canRevertCalificate(PropelPDO $con = null)
 {
     $course_subject = CourseSubjectPeer::retrieveByCourseId($this->getId());
     if (!is_null($course_subject)) {
         $c = new Criteria();
         $c->add(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, $course_subject->getId());
         $c->add(CourseSubjectStudentPeer::IS_NOT_AVERAGEABLE, true);
         return CourseSubjectStudentPeer::doCount($c) > 0;
     }
     return true;
 }
Exemplo n.º 18
0
 public function addStudentsFromCourseSubject($students, $origin_course_subject, $con = null)
 {
     if (!$this->getCourse()->canMoveStudents()) {
         throw new Exception();
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     $con->beginTransaction();
     try {
         foreach ($students as $student_id) {
             $css_origin = CourseSubjectStudentPeer::retrieveByCourseSubjectAndStudent($origin_course_subject->getId(), $student_id);
             $css_origin->setCourseSubjectId($this->getId());
             $css_origin->save($con);
             //para las asistencias
             $c = new Criteria();
             $c->add(StudentAttendancePeer::STUDENT_ID, $student_id);
             foreach ($origin_course_subject->getStudentAttendances($c) as $sa) {
                 $sa->setCourseSubject($this);
                 $sa->save($con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 protected function doSave($con = null)
 {
     $values = $this->getValues();
     $course_subject = CourseSubjectPeer::retrieveByPk($values['course_subject_id']);
     $course = $course_subject->getCourse();
     $con = is_null($con) ? $this->getConnection() : $con;
     try {
         $con->beginTransaction();
         if ($values['set_all_course_subject_non_numerical_califications'] == 1) {
             //tomo todos los alumnos que No tienen seteado el flag is_not_averageable
             $course_subject_students = $course->getIsAverageableCourseSubjectStudent();
             foreach ($course_subject_students as $course_subject_student) {
                 $course_subject_student->setIsNotAverageable(true);
                 $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId());
                 foreach ($course_subject_student_marks as $mark) {
                     $mark->setIsClosed(true);
                     $mark->save($con);
                 }
                 $student_id = $course_subject_student->getStudentId();
                 $student_approved_course_subject = new StudentApprovedCourseSubject();
                 $student_approved_course_subject->setCourseSubject($course_subject);
                 $student_approved_course_subject->setStudentId($student_id);
                 $student_approved_course_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject = new StudentApprovedCareerSubject();
                 $student_approved_career_subject->setStudentId($student_id);
                 $student_approved_career_subject->setCareerSubject($course_subject->getCareerSubjectSchoolYear()->getCareerSubject());
                 $student_approved_career_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject->save($con);
                 $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
                 $student_approved_course_subject->save($con);
                 $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject);
                 $course_subject_student->save($con);
             }
         } else {
             foreach ($values['student_list'] as $student_id) {
                 $course_subject_student = CourseSubjectStudentPeer::retrievebyCourseSubjectAndStudent($course_subject->getid(), $student_id);
                 $course_subject_student->setIsNotAverageable(true);
                 $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId());
                 foreach ($course_subject_student_marks as $mark) {
                     $mark->setIsClosed(true);
                     $mark->save($con);
                 }
                 $student_approved_course_subject = new StudentApprovedCourseSubject();
                 $student_approved_course_subject->setCourseSubject($course_subject);
                 $student_approved_course_subject->setStudentId($student_id);
                 $student_approved_course_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject = new StudentApprovedCareerSubject();
                 $student_approved_career_subject->setStudentId($student_id);
                 $student_approved_career_subject->setCareerSubject($course_subject->getCareerSubjectSchoolYear()->getCareerSubject());
                 $student_approved_career_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject->save($con);
                 $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
                 $student_approved_course_subject->save($con);
                 $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject);
                 $course_subject_student->save($con);
             }
         }
         //chequeo si la cantidad de alumnos eximidos es igual a la cantidad de alumnos inscriptos en el curso y el curso esta abierto .
         if (count($course->getIsNotAverageableCourseSubjectStudent()) == $course->countStudents() && !$course->getIsClosed()) {
             //cierro el curso.
             $course->setIsClosed(true);
             $course->save($con);
         }
         $con->commit();
     } catch (Exception $e) {
         throw $e;
         $con->rollBack();
     }
 }
Exemplo n.º 20
0
 public function executeBackToPreviousCourseSubjectStatus(sfWebRequest $request)
 {
     $this->course_subject_student = CourseSubjectStudentPeer::retrieveByPK($request->getParameter("course_subject_student_id"));
     if (is_null($this->course_subject_student)) {
         $this->redirect('@student');
     }
     $this->course_subject_student->backToPreviousCourseSubjectStatus();
     $this->redirect("student/editCourseSubjectStudentHistory?course_subject_student_id=" . $this->course_subject_student->getId());
 }