public function configure() { $student_id = $this->getOption('student_id'); $this->student = StudentPeer::retrieveByPK($student_id); $this->career_school_year_id = $this->getOption('career_school_year_id'); $this->course_subject_id = $this->getOption('course_subject_id'); $this->division_id = $this->getOption('division_id'); $sf_formatter_attendance_week = new sfWidgetFormSchemaFormatterAttendanceWeek($this->getWidgetSchema()); $this->getWidgetSchema()->addFormFormatter("AttendanceWeek", $sf_formatter_attendance_week); $this->getWidgetSchema()->setFormFormatterName('AttendanceWeek'); $day = $this->getOption('day'); $this->widgetSchema->setNameFormat('attendance_' . $student_id . '][%s]'); #student $this->setWidget("student_id", new sfWidgetFormInputHidden()); $this->setValidator("student_id", new sfValidatorPropelChoice(array("model" => "Student", "required" => true))); $this->setWidget("student", new mtWidgetFormPlain(array('object' => $this->student))); for ($i = 0; $i <= 6; $i++) { $day_i = date('Y-m-d', strtotime($day . '-' . $i . 'day a go')); $student_attendance = StudentAttendancePeer::retrieveOrCreateByDateAndStudent($day_i, $this->student, $this->getOption('course_subject_id')); if ($student_attendance) { $this->setDefault("value_" . $i, $student_attendance->getAbsenceTypeId()); } $this->setWidget("value_" . $i, $this->getAttendanceWidget()); $this->getWidget("value_" . $i, $this->getAttendanceWidget())->setAttribute('class', 'attendance_week_input'); $this->setValidator("value_" . $i, $this->getAttendanceValidator()); } $this->setDefault("student_id", $student_id); $this->disableCSRFProtection(); $this->course_subject = CourseSubjectPeer::retrieveByPK($this->course_subject_id); $period = CareerSchoolYearPeriodPeer::retrieveByPK($this->course_subject->getCourse()->getCurrentPeriod()); $this->setWidget('period', new mtWidgetFormPartial(array('module' => 'student_attendance', 'partial' => 'totalAbsences', 'form' => $this, 'parameters' => array('career_school_year_id' => $this->career_school_year_id, 'period' => $period, 'course_subject_id' => $this->course_subject_id, 'student' => $this->student)))); $this->getWidgetSchema()->moveField('period', sfWidgetFormSchema::LAST); }
public static function getCourseSubjects($widget, $values) { $sf_user = sfContext::getInstance()->getUser(); $career_school_year = CareerSchoolYearPeer::retrieveByPK(sfContext::getInstance()->getUser()->getAttribute('career_school_year_id')); $career = $career_school_year->getCareer(); $c = new Criteria(); $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID); $c->add(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year->getId()); $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID); $c->add(CoursePeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId()); $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, CareerSubjectPeer::ID); $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID); $c->add(CareerSubjectPeer::YEAR, $values); if ($sf_user->isPreceptor()) { $course_ids = PersonalPeer::retrieveCourseIdsjoinWithDivisionCourseOrCommission($sf_user->getGuardUser()->getId(), true); $c->add(CoursePeer::ID, $course_ids, Criteria::IN); $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID); } $course_ids = array(); foreach (CourseSubjectPeer::doSelect($c) as $course_subject) { if ($course_subject->hasAttendanceForSubject()) { $course_ids[] = $course_subject->getId(); } } $criteria = new Criteria(); $criteria->add(CourseSubjectPeer::ID, $course_ids, Criteria::IN); $criteria->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID); CareerSubjectSchoolYearPeer::sorted($criteria); $widget->setOption('criteria', $criteria); }
public function configureStudents() { $this->year = $this->getDefault('year'); $this->division_id = $this->getDefault('division_id'); $this->course_subject_id = $this->getDefault('course_subject_id') == '' || $this->getDefault('course_subject_id') === null ? null : $this->getDefault('course_subject_id'); $this->division = DivisionPeer::retrieveByPK($this->division_id); $this->course_subject = CourseSubjectPeer::retrieveByPK($this->course_subject_id); $this->career_school_year_id = $this->getDefault('career_school_year_id'); $this->configureDays(); $sf_user = sfContext::getInstance()->getUser(); //$this->students = StudentPeer::getStudentsForAttendance($sf_user, $this->division_id, $this->course_subject_id, $this->career_school_year_id); $this->students = $this->getStudents(); $days_disabled = array(); foreach ($this->students as $student) { $name = 'student_name_' . $student->getId(); $this->setWidget($name, new mtWidgetFormPlain(array('object' => $student))); $this->setValidator($name, new sfValidatorPass()); foreach ($this->days as $day => $day_i) { if (!isset($days_disabled[$day])) { $days_disabled[$day] = true; } $name = 'student_attendance_' . $student->getId() . '_' . $day; $this->setAbsenceWidget($name); $student_attendance = StudentAttendancePeer::retrieveByDateAndStudent($day_i, $student, $this->course_subject_id, $this->career_school_year_id); if (!is_null($student_attendance)) { $this->setAttendanceDefault($name, $student_attendance); $days_disabled[$day] = false; } } } $this->configureDaysWidget($days_disabled); return $days_disabled; }
public function getCourseSubjectCriteria() { $criteria = new Criteria(); $criteria->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getObject()->getStudentId()); $criteria->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID, Criteria::INNER_JOIN); CourseSubjectPeer::retrieveCriteriaForCurrentYear($criteria); return $criteria; }
public static function countStudentInscriptionsForCareerSubjectSchoolYear($course_subject_id, $student_id) { $course_subject = CourseSubjectPeer::retrieveByPk($course_subject_id); $c = new Criteria(); $c->addJoin(CourseSubjectStudentPathwayPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID); $c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $course_subject->getCareerSubjectSchoolYearId()); $c->add(CourseSubjectStudentPathwayPeer::STUDENT_ID, $student_id); $c->addAnd(CourseSubjectPeer::ID, $course_subject_id, Criteria::NOT_EQUAL); return CourseSubjectStudentPathwayPeer::doCount($c); }
public function doSave($con = null) { parent::doSave($con); $student = StudentPeer::retrieveByPk($this->getValue('student_id')); $career_school_year_period = CareerSchoolYearPeriodPeer::retrieveByPk($this->getValue('career_school_year_period_id')); $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year_period->getCareerSchoolYear()); $course_subject = CourseSubjectPeer::retrieveByPk($this->getValue('course_subject_id')); $student_free = StudentFreePeer::retrieveByStudentCareerSchoolYearCareerSchoolYearPeriodAndCourse($student_career_school_year, $career_school_year_period, $course_subject); $student_free->setIsFree(false); $student_free->save($con); }
public function executeDeleteSubject(sfWebRequest $request) { //TODO: Ver de extenderlo de commissionActions $cs = CourseSubjectPeer::retrieveByPK($request->getParameter('course_subject_id')); if ($cs and $course = $cs->getCourse() and $course->isPathway()) { try { $cs->delete(); $this->getUser()->setFlash("notice", "The item was deleted successfully."); } catch (PropelException $e) { $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items.'); } } else { $this->getUser()->setFlash('error', 'The selected item is not a pathway commission.'); } $this->redirect("@pathway_commission"); }
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 executePrintAttendanceTemplate(sfWebRequest $request) { $this->month = $request->getParameter('month'); $this->url = $request->getParameter('url'); $this->id = $request->getParameter('id'); $this->nextMonth = $this->month < 12 ? $this->month + 1 : 1; $this->prevMonth = $this->month > 1 ? $this->month - 1 : 12; $this->monthName = date("F", mktime(0, 0, 0, $this->month, 1, 2015)); if ($this->url == "division") { $this->division_id = $request->getParameter('division_id'); $this->division = DivisionPeer::retrieveByPK($this->id); $this->students = $this->division->getStudents(); $this->days = $this->getDaysOfMonth($this->month); $this->course_subject = null; } elseif ($this->url == "commission") { $this->course_subject = CourseSubjectPeer::retrieveByPK($this->id); $this->students = $this->course_subject->getStudents(); $this->days = $this->getDaysOfMonth($this->month); } $this->setLayout('cleanLayout'); }
public static function getCourseSubjectForStudents($students_ids) { $c = new Criteria(); $c->add(CourseSubjectStudentPeer::STUDENT_ID, $students_ids, Criteria::IN); $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID); $c->setDistinct(CourseSubjectPeer::ID); return CourseSubjectPeer::doSelect($c); }
</div> <?php } ?> <?php echo $form->renderHiddenFields(); ?> <?php echo $form->renderGlobalErrors(); ?> <?php $course_subject_id = isset($form->course_subject_id) ? $form->course_subject_id : null; ?> <?php $course_subject = CourseSubjectPeer::retrieveByPK($course_subject_id); ?> <?php $career_school_year = $form->getCareerSchoolYear(); ?> <?php $absence_for_period = $form->isAbsenceForPeriod(); ?> <?php if ($absence_for_period) { ?> <?php $career_school_year_periods = $form->getCareerSchoolYearPeriods(); ?>
public function executeUpdateConfiguration(sfWebRequest $request) { $this->career_subject_school_year = CareerSubjectSchoolYearPeer::retrieveByPK($request->getParameter('id')); if (null === $this->career_school_year) { $this->getUser()->setFlash('error', 'Debe seleccionar una carrera para editar su configuracion'); $this->redirect('@career_school_year'); } $subject_configuration = $this->career_subject_school_year->getSubjectConfigurationOrCreate(); $this->career_subject_school_year->setSubjectConfiguration($subject_configuration); $parameters = $request->getPostParameters(); $parameter = $parameters["subject_configuration"]; if ($this->career_subject_school_year->hasChoices()) { $course_subjects = array(); foreach ($this->career_subject_school_year->getChoices() as $option) { $course_subjects = array_merge($course_subjects, CourseSubjectPeer::retrieveByCareerSubjectSchoolYear($option->getChoiceCareerSubjectSchoolYearId())); } } else { $course_subjects = CourseSubjectPeer::retrieveByCareerSubjectSchoolYear($this->career_subject_school_year->getId()); } //actualización de las notas para los cursos $this->updateCourseMarksConfiguration($parameter, $subject_configuration, $course_subjects); //actualización del tipo de curso para los cursos $this->updateCourseTypeConfiguration($parameter, $subject_configuration, $course_subjects); //actualización del tipo de asistencia para los cursos y las asistencias de los alumnos $this->updateStudentAssistanceConfiguration($parameter, $subject_configuration, $course_subjects); $form_name = SchoolBehaviourFactory::getInstance()->getFormFactory()->getCareerSubjectSchoolYearConfigurationForm(); $this->form = new $form_name($subject_configuration); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $notice = $this->getProcessFormNotice($this->form->getObject()->isNew()); $subject_configuration = $this->form->save(); $this->getUser()->setFlash('notice', $notice); } else { $this->setProcessFormErrorFlash(); } $this->setTemplate('configuration'); }
public function executeSubject(sfWebRequest $request) { $params = $request->getParameter('subject_rating_report'); $this->course_subject = CourseSubjectPeer::retrieveByPk($params['course_subject_id']); $this->getUser()->setReferenceFor($this, 'rating_report'); }
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; }
public function executeDeleteSubject(sfWebRequest $request) { $cs = CourseSubjectPeer::retrieveByPK($request->getParameter('course_subject_id')); try { $cs->delete(); $this->getUser()->setFlash("notice", "The item was deleted successfully."); } catch (PropelException $e) { $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items.'); } $this->redirect("@commission"); }
public function getCourseSubjectForCareerSubjectSchoolYear(CareerSubjectSchoolYear $cssy) { $c = new Criteria(); $c->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID, Criteria::INNER_JOIN); $c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $cssy->getId()); $c->add(CoursePeer::DIVISION_ID, $this->getId()); return CourseSubjectPeer::doSelectOne($c); }
public function executeSaveRevertCalificateNonNumericalMark(sfWebRequest $request) { if ($request->isMethod('POST')) { $params = $request->getParameter('revert_course_subject_non_numerical_califications'); $this->course_subject = CourseSubjectPeer::retrieveByPk($params['course_subject_id']); $this->form = new RevertCourseSubjectNonNumericalCalificationsForm($this->course_subject); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->form->save(); $this->getUser()->setFlash('notice', 'Se han deseximido a los alumnos seleccionados satisfactoriamente.'); return $this->redirect(sprintf('@%s', $this->getUser()->getAttribute('referer_module', 'homepage'))); } else { $this->getUser()->setFlash('error', 'Ocurrieron errores al intentar deseximir a los alumnos. Por favor, intente nuevamente la operación.'); $this->course = $this->course_subject->getCourse(); $this->back_url = $this->getUser()->getAttribute('referer_module'); } $this->setTemplate('revertCalificateNonNumericalMark'); } }
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(); } }
public function executeUpdateMoveStudents(sfWebRequest $request) { $this->origin_course_subject = CourseSubjectPeer::retrieveByPK($request->getParameter('id')); $this->form = new MoveStudentsToCourseSubjectForm(array(), array('course_subject' => $this->origin_course_subject)); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { try { $parameters = $request->getParameter('move_students'); $destiny_course_subject = CourseSubjectPeer::retrieveByPK($parameters['destiny_course_subject_id']); $students = $parameters['students']; $destiny_course_subject->addStudentsFromCourseSubject($students, $this->origin_course_subject); $this->getUser()->setFlash('notice', 'Los alumnos seleccionados han sido correctamente movidos de comisión.'); } catch (Exception $e) { $this->getUser()->setFlash('error', 'Ocurrieron errores que no permitieron concretar la acción. Compruebe que las comisiones origen y destino no estén cerradas. Tampoco se permitirá mover alumnos si ya se calificó a alguno o si se pasó asistencia al curso origen.'); } } else { $this->setProcessFormErrorFlash(); } $this->setTemplate('moveStudents'); }