Ejemplo n.º 1
0
 public function getFinalGrade()
 {
     $c = new Criteria();
     $c->addDescendingOrderByColumn(GradeConversionPeer::GRADE);
     $grade_convs = GradeConversionPeer::doSelect($c);
     $subject_accal = $this->getSubjectAccal();
     $student_scores = $this->getStudentScores();
     if (!$subject_accal) {
         return array('-', 0);
     }
     $subject_gradings = $subject_accal->getSubjectGradings();
     $final_score = 0;
     $final_grade = '-';
     $has_grade = false;
     foreach ($subject_gradings as $sg) {
         $gc = $sg->getGradeComponent();
         $c = new Criteria();
         $c->add(StudentScorePeer::GRADE_COMPONENT_ID, $gc->getId());
         $c->add(StudentScorePeer::STUDENT_COURSE_ID, $this->getId());
         $scores = StudentScorePeer::doSelect($c);
         $score_count = count($scores);
         if ($score_count > 0) {
             $has_grade = true;
         }
         $total_score = 0;
         foreach ($scores as $s) {
             $total_score += $s->getGrade();
         }
         if ($score_count) {
             $score = intval($total_score) / intval($score_count);
             $score = $score * $sg->getPercentage() / 100;
             $final_score += $score;
         }
     }
     foreach ($grade_convs as $gc) {
         if ($final_score >= $gc->getMinValue() && $final_score <= $gc->getMaxValue()) {
             $final_grade = $gc->getName();
             break;
         }
     }
     if ($has_grade) {
         return array($final_grade, $final_score);
     }
     return array('-', 0);
 }
Ejemplo n.º 2
0
 public function getStudentScores($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseStudentScorePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collStudentScores === null) {
         if ($this->isNew()) {
             $this->collStudentScores = array();
         } else {
             $criteria->add(StudentScorePeer::STUDENT_COURSE_ID, $this->getId());
             StudentScorePeer::addSelectColumns($criteria);
             $this->collStudentScores = StudentScorePeer::doSelect($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(StudentScorePeer::STUDENT_COURSE_ID, $this->getId());
             StudentScorePeer::addSelectColumns($criteria);
             if (!isset($this->lastStudentScoreCriteria) || !$this->lastStudentScoreCriteria->equals($criteria)) {
                 $this->collStudentScores = StudentScorePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastStudentScoreCriteria = $criteria;
     return $this->collStudentScores;
 }
Ejemplo n.º 3
0
 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(StudentScorePeer::ID, $pks, Criteria::IN);
         $objs = StudentScorePeer::doSelect($criteria, $con);
     }
     return $objs;
 }