Example #1
0
 function promedioAlumno($rut, $ramos, $redondeo = true)
 {
     $promedio = null;
     $class_colegio = new colegio();
     $SQL = "\tSELECT * FROM notas AS n\r\n\t\t\t\tINNER JOIN ramos AS r\r\n\t\t\t\tON r.nombre = n.ramo  \r\n\t\t\t\tWHERE n.rut IN {$rut} \r\n\t\t\t\tAND n.ramo IN {$ramos}\r\n\t\t\t\tORDER BY r.num";
     $result = DBQuery($SQL, $this->dbh);
     while ($row = DBFetchArray($result)) {
         $notas = $this->array_notas($row);
         $promedio_aux[$row['rut']]['1S'][$row['ramo']] = $promedio[$row['rut']]['ramos'][$row['ramo']]['1S'] = $class_colegio->ponderaSemestre($this->promedio($notas['1S']), $row['examen1']);
         $promedio_aux[$row['rut']]['2S'][$row['ramo']] = $promedio[$row['rut']]['ramos'][$row['ramo']]['2S'] = $class_colegio->ponderaSemestre($this->promedio($notas['2S']), $row['examen2']);
         $promedio_aux[$row['rut']]['anual'][$row['ramo']] = $promedio[$row['rut']]['ramos'][$row['ramo']]['anual'] = $class_colegio->ponderaAnual($promedio_aux[$row['rut']]['1S'][$row['ramo']], $promedio_aux[$row['rut']]['2S'][$row['ramo']], $row['examen_anual'], $row['examen2']);
     }
     if (isset($promedio_aux)) {
         if (count($promedio_aux) > 0) {
             foreach ($promedio_aux as $rut => $notas) {
                 $notasReligion = $this->obtenerNotasReligion($rut);
                 $promedio[$rut]['ramos']['RELIGION']['notas']['1S'] = $this->promedio($notasReligion['1S']);
                 $promedio[$rut]['ramos']['RELIGION']['notas']['2S'] = $this->promedio($notasReligion['2S']);
                 $promedio[$rut]['ramos']['RELIGION']['1S'] = $this->concepto_religion($notasReligion['1S']);
                 $promedio[$rut]['ramos']['RELIGION']['2S'] = $this->concepto_religion($notasReligion['2S']);
                 //$promedio[$rut]['ramos']['RELIGION']['concepto1S'] = $this->concepto_religion($promedio[$rut]['ramos']['RELIGION']['1S']);
                 $promedio[$rut]['ramos']['RELIGION']['notas']['anual'] = $this->promedio(array($promedio[$rut]['ramos']['RELIGION']['notas']['1S'], $promedio[$rut]['ramos']['RELIGION']['notas']['2S']));
                 $promedio[$rut]['ramos']['RELIGION']['anual'] = $this->concepto_religion(array($promedio[$rut]['ramos']['RELIGION']['notas']['1S'], $promedio[$rut]['ramos']['RELIGION']['notas']['2S']));
                 $promedio[$rut]['1S'] = $this->promedio($promedio_aux[$rut]['1S'], $redondeo);
                 $promedio[$rut]['2S'] = $this->promedio($promedio_aux[$rut]['2S'], $redondeo);
                 if ($promedio[$rut]['1S'] && $promedio[$rut]['2S']) {
                     $promedio[$rut]['anual'] = $this->promedio($promedio_aux[$rut]['anual'], $redondeo);
                 } else {
                     $promedio[$rut]['anual'] = null;
                 }
             }
         }
     }
     return $promedio;
 }