public function attendanceAction()
 {
     $department_id = $this->_getParam('department_id');
     $programme_id = $this->_getParam('programme_id');
     $semester_id = $this->_getParam('semester_id');
     $faculty_id = $this->_getParam('faculty_id');
     $dateFrom = $this->_getParam('date_from');
     $dateUpto = $this->_getParam('date_upto');
     $format = $this->_getParam('format', 'html');
     $faculty = new Acad_Model_Member_Faculty();
     if (true) {
         $faculty->setFacultyId($faculty_id);
     }
     $faculty->setDepartment($department_id);
     $objLevel = null;
     if ($department_id) {
         $objLevel = new Acad_Model_Department();
         $objLevel->setDepartment($department_id);
     }
     if ($department_id and $programme_id and $semester_id) {
         $objLevel = new Acad_Model_Class();
         $objLevel->setDepartment($department_id)->setProgramme_id($programme_id)->setSemester($semester_id);
     }
     $subjects = $faculty->getInHandSubjects($objLevel, TRUE);
     foreach ($subjects as $subject_code => $subjectClasses) {
         $subject = new Acad_Model_Course_Subject(array('subject_code' => $subject_code));
         $subjectName = $subject->getSubject_name();
         foreach ($subjectClasses as $key => $subjectClass) {
             $subjects[$subject_code][$key]['subject_name'] = $subjectName;
         }
     }
     switch (strtolower($format)) {
         case 'test':
             $this->_helper->logger($subjects);
             return;
         case 'html':
             $this->_helper->logger($subjects);
             $this->_helper->viewRenderer->setNoRender(false);
             $this->_helper->layout()->enableLayout();
             $this->view->assign('department_id', $this->view->escape($department_id));
             $urlSubjectDetail = $this->_helper->url('attendance', 'subject');
             $this->view->assign('urlSubjetDetail', $this->view->escape($urlSubjectDetail));
             $this->view->assign('subjects', $subjects);
             $this->view->assign('date_from', $this->view->escape($dateFrom));
             $this->view->assign('date_upto', $this->view->escape($dateUpto));
             $this->view->assign('faculty', $faculty);
             $this->view->assign('viewLevel', $objLevel);
             return;
         case 'json':
             echo $this->_helper->json($subjects, false);
             return;
         case 'jsonp':
             $callback = $this->_getParam('callback');
             echo $callback . '(' . $this->_helper->json($subjects, false) . ')';
             return;
     }
 }
 public function getsubjectAction()
 {
     $request = $this->getRequest();
     //$faculty_id = $request->getParam('faculty_id');
     $department = $request->getParam('department_id');
     $degree = $request->getParam('degree_id');
     $semester = $request->getParam('semester_id');
     $showModes = $request->getParam('modes');
     $format = $this->getRequest()->getParam('format', 'json');
     $faculty = new Acad_Model_Member_Faculty();
     $class = null;
     if (isset($department) and isset($degree) and isset($semester)) {
         $class = new Acad_Model_Class();
         $class->setDepartment($department)->setDegree($degree)->setSemester($semester);
     }
     $result = $faculty->getSubjects($class, $showModes);
     switch (strtolower($format)) {
         case 'json':
             echo $this->_helper->json($result, false);
             return;
         case 'jsonp':
             $callback = $request->getParam('callback');
             echo $callback . '(' . $this->_helper->json($result, false) . ')';
             return;
         case 'select':
             echo '<select id="facultySubject">';
             echo '<option value="">Select one</option>';
             foreach ($result as $subjectCode => $subjectInfo) {
                 foreach ($subjectInfo as $key => $subject) {
                     $mode = isset($subject['subject_mode_id']) ? $subject['subject_mode_id'] : null;
                     $modeValStr = isset($mode) ? '_' . $mode : null;
                     $modeTxtStr = isset($mode) ? ' - ' . $mode : null;
                     echo '<option value="' . $subjectCode . $modeValStr . '">' . ucwords(strtolower($subject['subject_name'])) . $modeTxtStr . '</option>';
                 }
             }
             echo '</select>';
             return;
     }
     header("HTTP/1.1 400 Bad Request");
 }
 public function tempAction()
 {
     $class = new Acad_Model_Class();
     $class->setDepartment('CSE')->setDegree('BTECH')->setSemester('4');
     $faculty = new Acad_Model_Member_Faculty();
     $result = $faculty->getSubjects($class);
     echo '<pre>';
     print_r($result);
     //$this->_helper->logger($result);
 }
Beispiel #4
0
 /**
  * Get Faculty Subjects in hand
  * @param Acad_Model_Member_Faculty $faculty
  * @param Acad_Model_Class|Acad_Model_Department $viewLevel = null
  * @param bool $showModes = null
  * @return array
  */
 public function fetchInHandSubjects(Acad_Model_Member_Faculty $faculty, $viewLevel = NULL, $showModes = NULL)
 {
     $select = $this->getDbTable()->getAdapter()->select();
     $select->distinct()->from('period_attendance2', array('subject_code', 'department_id', 'programme_id', 'semester_id'))->where('faculty_id = ?', $faculty->getMemberId());
     if (isset($showModes)) {
         $select->columns('subject_mode_id');
     }
     if ($viewLevel instanceof Acad_Model_Class) {
         $select->where('department_id = ?', $viewLevel->getDepartment())->where('programme_id = ?', $viewLevel->getProgramme_id())->where('semester_id = ?', $viewLevel->getSemester());
     } elseif ($viewLevel instanceof Acad_Model_Department) {
         $select->where('department_id = ?', $viewLevel->getDepartment());
     }
     return $select->query()->fetchAll(Zend_Db::FETCH_GROUP);
 }
Beispiel #5
0
 /**
  * Get Faculty Subjects
  * @param Acad_Model_Member_Faculty $faculty
  * @return array
  */
 public function fetchSubjects(Acad_Model_Member_Faculty $faculty, Acad_Model_Class $class = NULL, $showModes = NULL)
 {
     $select = $this->getDbTable()->getAdapter()->select();
     $select->distinct()->from('subject_faculty', array('subject_code'))->join('subject', 'subject_faculty.subject_code = subject.subject_code', array('subject_name'))->join('subject_department', 'subject_department.subject_code = subject.subject_code', array())->where('subject_faculty.staff_id = ?', $faculty->getMemberId());
     if (isset($showModes)) {
         $select->columns('subject_mode_id');
     }
     if (isset($class)) {
         $select->where('subject_department.department_id = ?', $class->getDepartment())->where('subject_department.degree_id = ?', $class->getDegree())->where('subject_department.semester_id = ?', $class->getSemester());
     }
     return $select->query()->fetchAll(Zend_Db::FETCH_GROUP);
 }
 public function getunmarkedattAction()
 {
     $faculty = new Acad_Model_Member_Faculty();
     $staff_id = $this->getRequest()->getParam('staff_id') ? $this->getRequest()->getParam('staff_id') : $this->identity;
     $faculty->setMemberId($staff_id);
     $result = $faculty->listUnMarkedAttendance();
     echo $this->_helper->json($result, false);
 }
Beispiel #7
0
 /**
  * Set Attendance summary and Students attendance list(Mode wise)
  * @param int $lowerThreshold
  * @param int $upperThreshold
  * @return Acad_Model_Course_Subject
  */
 protected function _attendanceSummary($lowerThreshold = 65, $upperThreshold = 75)
 {
     $attendanceSet = $this->_studentAttendance;
     $stat = $this->_attendanceStat;
     $facultySet = $this->getFaculty();
     $summary = array();
     $stuModeWiseAtt = array();
     if (empty($attendanceSet)) {
         throw new Exception('Student attendance is empty. So cannot generate a summary.', Zend_Log::NOTICE);
     }
     if (empty($stat)) {
         throw new Exception('Attendance Stats are empty. So cannot generate a summary.', Zend_Log::NOTICE);
     }
     foreach ($attendanceSet as $subjectMode => $groups) {
         foreach ($groups as $group_id => $students) {
             $totalDelievered = (int) $stat[$subjectMode][$group_id]['delievered'];
             $avgPresent = $totalDelievered - $stat[$subjectMode][$group_id]['AVERAGE']['ABSENT'];
             $avgPercentage = $avgPresent / $totalDelievered * 100;
             $summary[$subjectMode][$group_id]['total_delievered'] = $totalDelievered;
             $summary[$subjectMode][$group_id]['total_duration'] = $stat[$subjectMode][$group_id]['total_duration'];
             $summary[$subjectMode][$group_id]['average_attedance'] = round($avgPercentage);
             $summary[$subjectMode][$group_id][self::PASS] = 0;
             $summary[$subjectMode][$group_id][self::AVERAGE] = 0;
             $summary[$subjectMode][$group_id][self::FAIL] = 0;
             foreach ($students as $rollNo => $student) {
                 $present = $totalDelievered - $student['ABSENT'];
                 $percentage = $present / $totalDelievered * 100;
                 $attendance = round($percentage);
                 $stuModeWiseAtt[$rollNo][$subjectMode] = $attendance;
                 $division = ceil($attendance);
                 switch ($division) {
                     case 0:
                     case $division < $lowerThreshold:
                         $summary[$subjectMode][$group_id][self::FAIL] += 1;
                         break;
                     case $division < $upperThreshold:
                         $summary[$subjectMode][$group_id][self::AVERAGE] += 1;
                         break;
                     default:
                         $summary[$subjectMode][$group_id][self::PASS] += 1;
                         break;
                 }
             }
             foreach ($facultySet[$subjectMode][$group_id] as $facultyId => $facultySubjectInfo) {
                 foreach ($facultySubjectInfo as $key => $info) {
                     $faculty = new Acad_Model_Member_Faculty(array('facultyId' => $facultyId));
                     $facultyInfo['name'] = $faculty->getName();
                     $date_from = date_create_from_format('Y-m-d', $info['date_from']);
                     $facultyInfo['date_from'] = date_format($date_from, 'd/M');
                     $date_upto = date_create_from_format('Y-m-d', $info['date_upto']);
                     $facultyInfo['date_upto'] = date_format($date_upto, 'd/M');
                     $summary[$subjectMode][$group_id]['faculty'][$facultyId] = $facultyInfo;
                 }
             }
         }
     }
     $subjectModes = array_keys($attendanceSet);
     if (count($subjectModes) > 1) {
         $summary['combined'][self::PASS] = 0;
         $summary['combined'][self::AVERAGE] = 0;
         $summary['combined'][self::FAIL] = 0;
         $basicModes = array_flip($subjectModes);
         $maxPercentage = 100;
         /**
          * I am doing it this way due to following reasons:
          * -> WE have only absent students records
          * -> If a student attendance is 100% the raw data dont have its record right now
          * and attendance of a student may be 100% in LEC and less in TUT...
          * So, I set 100% attendance by default, if a student entry is missing then
          * There are two cases, either its attendance not marked or 100% attendance,
          * Here, it is assumed that attendance is 100%
          */
         foreach ($basicModes as $subjectMode => $value) {
             $basicModes[$subjectMode] = $maxPercentage;
         }
         foreach ($stuModeWiseAtt as $rollNo => $modesAttendance) {
             //setting missing modes attendance value to 100%
             $modesAttendance = array_merge($basicModes, $modesAttendance);
             $totalPercentage = 0;
             foreach ($modesAttendance as $subjectMode => $percentage) {
                 $totalPercentage += $percentage;
             }
             $stuModeWiseAtt[$rollNo]['average'] = $totalPercentage / count($modesAttendance);
             $attendance = round($stuModeWiseAtt[$rollNo]['average']);
             $division = ceil($attendance);
             switch ($division) {
                 case 0:
                 case $division < $lowerThreshold:
                     $summary['combined'][self::FAIL] += 1;
                     break;
                 case $division < $upperThreshold:
                     $summary['combined'][self::AVERAGE] += 1;
                     break;
                 default:
                     $summary['combined'][self::PASS] += 1;
                     break;
             }
         }
     }
     $this->_stuModeWiseAtt = $stuModeWiseAtt;
     $this->_summary = $summary;
     return $this;
 }