Example #1
0
 public static function getMarks($month, $year, $class, $yearNum)
 {
     echo '<table class="table table-striped table-bordered">';
     $students = StudentManagement::getStudentIds($year, $class);
     if ($students[0] == 'none') {
         echo "Ebben az osztályban nincsenek tanulók!";
     } else {
         $subjects = SubjectHandler::getSubjectIds();
         /*var_dump($students);
                     for ($i = 0; $i < count($students) + 1; $i++) {
                         echo '<tr>';
                         for ($j = 0; $j < count($subj)+1; $j++) {
                             echo '<td>';
                             if ($i == 0 && $j == 0) {
                             } else if ($i == 0 && $j != 0) {
                                 $su = new SubjectHandler($subj[$j - 1]['id']);
                                 $sName = $su->getName();
                                 echo '<strong>' . $sName . '</strong>';
                             } else if ($j == 0 && $i != 0) {
                                 $s = new StudentManagement($students[$i-1]['id']);
                                 echo '<strong>' . $s->getName() . '</strong>';
                             } else {
                                 $marks = StudentManagement::getStudentMarks($students[$i-1]['id'],$month,$subj[$j-1]['id'],$yearNum);
                                 for($k = 0; $k<count($marks);$k++){
                                     if($marks[$k] == 'none'){}
                                     else {
                                         if($k==0) {
                                             echo $marks[$k]['mark'];
                                         }
                                         else{
                                             echo ", ".$marks[$k]['mark'];
                                         }
                                     }
                                 }
                             }
                             echo '</td>';
         
                         }
                         echo '</tr>';
                     }*/
         $nyear = $yearNum + 1;
         $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
         $sql = "SELECT s.id, m.mark, m.subject_id FROM students s INNER JOIN marks m WHERE s.id = m.student_id AND s.year = ? AND s.class = ? AND (m.year = ? OR m.year = ?) AND m.month = ? ORDER BY s.id, m.subject_id";
         $string = array($year, $class, $yearNum, $nyear, $month);
         $res = $db->select($sql, $string, true, 'isiii');
         $id = $res[0]['id'];
         $subj = $res[0]['subject_id'];
         $s = new StudentManagement($id);
         echo '<thead><tr>';
         for ($i = 0; $i < count($subjects) + 1; $i++) {
             if ($i != 0) {
                 $subjObj = new SubjectHandler($subjects[$i - 1]['id']);
                 echo '<td><strong>' . $subjObj->getName() . '</strong></td>';
             } else {
                 echo '<td></td>';
             }
         }
         echo '</tr></thead>';
         echo "<tr><td><strong>" . $s->getName() . "</strong></td>";
         echo '<td>';
         for ($i = 0; $i < count($res); $i++) {
             /*echo '<tr>';
               $id = 1;
               $subj = 1;
               echo '</tr>';*/
             if ($res[$i]['id'] != $id) {
                 $s = new StudentManagement($res[$i]['id']);
                 echo '</tr><tr><td><strong>' . $s->getName() . '</strong></td>';
                 $id = $res[$i]['id'];
             }
             if ($res[$i]['subject_id'] != $subj) {
                 echo '</td><td>';
                 $subj = $res[$i]['subject_id'];
             }
             echo $res[$i]['mark'] . " ";
         }
         echo "</tr>";
         echo '</td>';
     }
     echo '</table>';
 }
Example #2
0
 public function getStudentMarks($year)
 {
     echo '<table class="table table-striped table-bordered">';
     $nextYear = $year + 1;
     $months = array(9, 10, 11, 12, 1, 2, 3, 4, 5, 6);
     $subj = SubjectHandler::getSubjectIds();
     echo '<caption>Osztályzatok ' . $year . '/' . $nextYear . '</caption>';
     for ($i = 0; $i < count($subj) + 1; $i++) {
         echo '<tr>';
         for ($j = 0; $j < count($months) + 1; $j++) {
             echo '<td>';
             if ($i == 0 && $j == 0) {
             } else {
                 if ($i == 0 && $j != 0) {
                     echo '<strong>' . $this->getMonth($months[$j - 1]) . '</strong>';
                 } else {
                     if ($j == 0 && $i != 0) {
                         $su = new SubjectHandler($subj[$i - 1]['id']);
                         $sName = $su->getName();
                         echo '<strong>' . $sName . '</strong>';
                     } else {
                         $marks = $this->getMarks($i, $year, $nextYear, $months[$j - 1]);
                         for ($k = 0; $k < count($marks); $k++) {
                             if ($marks[$k] == 'none') {
                             } else {
                                 if ($k == 0) {
                                     echo $marks[$k]['mark'];
                                 } else {
                                     echo ", " . $marks[$k]['mark'];
                                 }
                             }
                         }
                     }
                 }
             }
             echo '</td>';
         }
         echo '</tr>';
     }
     echo '</table>';
 }