/**
  * @Route("/student/view/{id}", name="student_view")
  */
 public function viewAction($id, Request $request)
 {
     $student = Student::getOne($id);
     //get module results of the student
     $results = student_module_grade::getStudentModuleResults($id);
     //get semester results of the student
     $semResults = Semester_results::getSemesterResults($id);
     return $this->render('student/view.html.twig', array('student' => $student, 'results' => $results, 'semResults' => $semResults));
 }
 /**
  * @Route("/result/view", name="result_viewAll")
  */
 public function viewallAction(Request $request)
 {
     $results = student_module_grade::getAll();
     return $this->render('result/viewall.html.twig', array('results' => $results));
 }
 /**
  * @Route("/module/viewmoduleresults/{mod_code}", name="module_results")
  */
 public function viewmoduleresultsAction($mod_code, Request $request)
 {
     $results = student_module_grade::getModuleResults($mod_code);
     return $this->render('module/viewmoduleresults.html.twig', array('results' => $results, 'code' => $mod_code));
 }
 public static function getStudentModuleResults($stuId)
 {
     $con = Connection::getConnectionObject()->getConnection();
     // Check connection
     if (mysqli_connect_errno()) {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
     $results = array();
     //Make an empty array
     $stmt = $con->prepare('SELECT smg.id, smg.s_id, smg.m_code, m.title, m.sem_id, smg.grade FROM student_module_grade smg INNER JOIN module m ON smg.m_code = m.code INNER JOIN student s ON smg.s_id = s.index_no WHERE s.id = ?');
     $stmt->bind_param("s", $stuId);
     $stmt->execute();
     $stmt->bind_result($id, $sId, $mCode, $title, $sem, $grade);
     while ($stmt->fetch()) {
         $result = new student_module_grade();
         $result->id = $id;
         $result->setSId($sId);
         $result->setMCode($mCode);
         $result->mTitle = $title;
         $result->setSemId($sem);
         $result->setGrade($grade);
         array_push($results, $result);
         //Push one by one
     }
     $stmt->close();
     return $results;
 }