public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(Cur13GradePeer::ID, $pks, Criteria::IN);
         $objs = Cur13GradePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemple #2
0
 public function executeSaveElse()
 {
     $course_schedule = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('course_id'));
     $this->forward404Unless($course_schedule);
     $this->course_schedule = $course_schedule;
     $cur13_term_id = $this->getRequestParameter('cur13_term_id');
     $cur13_term = Cur13TermPeer::retrieveByPK($cur13_term_id);
     $this->forward404Unless($cur13_term);
     $this->cur13_term = $cur13_term;
     if ($cur13_term->getCur13KiId() == ScoreRule::THREE) {
         $ct = new Criteria();
         $ct->add(GradeConversionPeer::TYPE_CONVERSION, ScoreRule::ONE);
     } else {
         $ct = new Criteria();
         $ct->add(GradeConversionPeer::TYPE_CONVERSION, ScoreRule::TWO);
     }
     $grade_convs = GradeConversionPeer::doSelect($ct);
     $scores = $this->getRequestParameter('score');
     foreach ($scores as $k => $score) {
         if ($score != null) {
             ## Simpan
             if ($score != '-') {
                 $ids = split('_', $k);
                 ## $ids[0] = Student Accal Id
                 ## $ids[1] = Cur13 Term Spec Id
                 $cr = new Criteria();
                 $cr->add(Cur13GradePeer::STUDENT_ACCAL_ID, $ids[0]);
                 $cr->add(Cur13GradePeer::CUR13_TERM_SPEC_ID, $ids[1]);
                 $g = Cur13GradePeer::doSelectOne($cr);
                 if ($g == null) {
                     $g = new Cur13Grade();
                 }
                 $g->setStudentAccalId($ids[0]);
                 $g->setCur13TermSpecId($ids[1]);
                 $g->setGradeScale($score);
                 $g->save();
                 $crm = new Criteria();
                 $crm->add(Cur13TermSpecPeer::CUR13_TERM_ID, $cur13_term->getId());
                 $crm->addJoin(Cur13GradePeer::CUR13_TERM_SPEC_ID, Cur13TermSpecPeer::ID);
                 $crm->add(Cur13GradePeer::STUDENT_ACCAL_ID, $ids[0]);
                 #$crm->addDescendingOrderByColumn(Cur13GradePeer::GRADE_SCALE);
                 #$crm->setLimit(1);
                 #$modus = Cur13GradePeer::doSelectOne($crm);
                 $alls = Cur13GradePeer::doSelect($crm);
                 $total = 0;
                 $count = 0;
                 foreach ($alls as $all) {
                     $total += $all->getGradeScale();
                     $count += 1;
                 }
                 $avg = number_format($total / $count, 2);
                 $avg_scale = number_format($avg / 100 * 4, 2);
                 #$avg = $modus->getGradeScale();
                 $remark = '';
                 foreach ($grade_convs as $gc) {
                     if ($avg_scale >= $gc->getMinScale() && $avg_scale <= $gc->getMaxScale()) {
                         $remark = $gc->getName();
                     }
                 }
                 $cri = new Criteria();
                 $cri->add(Cur13GradeTermPeer::STUDENT_ACCAL_ID, $ids[0]);
                 $cri->add(Cur13GradeTermPeer::CUR13_TERM_ID, $cur13_term->getId());
                 $gi = Cur13GradeTermPeer::doSelectOne($cri);
                 if ($gi == null) {
                     $gi = new Cur13GradeTerm();
                 }
                 $gi->setStudentAccalId($ids[0]);
                 $gi->setCur13TermId($cur13_term->getId());
                 $gi->setGrade($avg);
                 $gi->setGradeScale($avg_scale);
                 $gi->setRemark($remark);
                 $gi->save();
                 ## Delete
             } else {
                 $cr = new Criteria();
                 $cr->add(Cur13GradePeer::STUDENT_ACCAL_ID, $ids[0]);
                 $cr->add(Cur13GradePeer::CUR13_TERM_SPEC_ID, $ids[1]);
                 $g = Cur13GradePeer::doSelectOne($cr);
                 if ($g != null) {
                     $g->delete();
                 }
             }
         }
     }
     if ($cur13_term->getCur13KiId() == ScoreRule::THREE) {
         return $this->redirect('course_sd/listScoreKi3?course_id=' . $course_schedule->getId() . '&cur13_ki_id=' . $cur13_term->getCur13KiId() . '&cur13_term_id=' . $cur13_term->getId());
     } else {
         return $this->redirect('course_sd/listScoreKi4?course_id=' . $course_schedule->getId() . '&cur13_ki_id=' . $cur13_term->getCur13KiId() . '&cur13_term_id=' . $cur13_term->getId());
     }
 }
Exemple #3
0
 /**
  * getGrades function
  * function to get grades of each students
  * Have to set students and termSpecs  before call this function
  * @return array
  */
 public function getGrades()
 {
     $grades = array();
     foreach ($this->getStudents() as $student) {
         $termSpecId = array();
         $grades[$student->getId()] = array();
         foreach ($this->getTermSpecs() as $termSpec) {
             $termSpecId[] = $termSpec->getId();
             $grades[$student->getId()][$termSpec->getId()] = false;
         }
         $c = new Criteria();
         $c->add(Cur13GradePeer::CUR13_TERM_SPEC_ID, $termSpecId, Criteria::IN);
         $c->add(Cur13GradePeer::STUDENT_ACCAL_ID, $student->getId(), Criteria::EQUAL);
         $c->addDescendingOrderByColumn(Cur13GradePeer::GRADE);
         $nilai = Cur13GradePeer::doSelect($c);
         foreach ($nilai as $n) {
             $grades[$student->getId()][$n->getCur13TermSpecId()] = $n;
         }
     }
     $this->grades = $grades;
     return $this->grades;
 }
Exemple #4
0
 public function getCur13Grades($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseCur13GradePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collCur13Grades === null) {
         if ($this->isNew()) {
             $this->collCur13Grades = array();
         } else {
             $criteria->add(Cur13GradePeer::CUR13_TERM_SPEC_ID, $this->getId());
             Cur13GradePeer::addSelectColumns($criteria);
             $this->collCur13Grades = Cur13GradePeer::doSelect($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(Cur13GradePeer::CUR13_TERM_SPEC_ID, $this->getId());
             Cur13GradePeer::addSelectColumns($criteria);
             if (!isset($this->lastCur13GradeCriteria) || !$this->lastCur13GradeCriteria->equals($criteria)) {
                 $this->collCur13Grades = Cur13GradePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastCur13GradeCriteria = $criteria;
     return $this->collCur13Grades;
 }