コード例 #1
0
 /**
  * @about Interface.
  */
 public function getstudentsAction()
 {
     $request = $this->getRequest();
     $test_info_id = $request->getParam('test_info_id');
     $format = $request->getParam('format', 'json');
     if ($test_info_id) {
         $options = array('test_info_id' => $test_info_id);
         $test = new Acad_Model_Test_Sessional($options);
         $candidates['students'] = $test->getStudents();
         $candidates['test_info'] = $test->__toArray();
         //$this->_helper->logger($candidates);
         switch (strtolower($format)) {
             case 'json':
                 echo $this->_helper->json($candidates, false);
                 return;
             case 'grid':
                 $valid = $request->getParam('nd');
                 $this->gridparam['page'] = $request->getParam('page', 1);
                 // get the requested page
                 $this->gridparam['limit'] = $request->getParam('rows', 70);
                 // rows limit in Grid
                 $this->_count = count($candidates['students']);
                 $response = new stdClass();
                 $count = 0;
                 foreach ($candidates['students'] as $key => $value) {
                     $response->rows[$count]['id'] = $key;
                     $response->rows[$count++]['cell'] = array($key, $value['marks_scored'], $value['status']);
                 }
                 $response->page = $this->gridparam['page'];
                 $response->total = 1;
                 $response->records = $this->_count;
                 $response->test_info = $candidates['test_info'];
                 echo $this->_helper->json($response, false);
                 return;
             default:
                 $this->getResponse()->setException('Unsupported format request')->setHttpResponseCode(400);
         }
     }
     header("HTTP/1.1 400 Bad Request");
 }
コード例 #2
0
 /**
  * Fetches all the entries for perticular sessional
  * 
  * @param Acad_Model_Test_Sessional
  * @return array Acad_Model_Test_Sessional
  */
 public function fetchAll(Acad_Model_Test_Sessional $sessional)
 {
     //$logger = Zend_Registry::get('logger');
     $sql = $this->getDbTable()->getDefaultAdapter()->select()->from($this->getDbTable()->info('name'))->joinInner('subject', '`test_info`.`subject_code` = `subject`.`subject_code`', 'subject_name')->where('department_id = ?', $sessional->getDepartment_id())->where('test_type_id = ?', $sessional->getTest_type_id());
     //->where('date_of_conduct > CURRENT_DATE');
     if ($sessional->getTest_id()) {
         $sql->where('test_id =?', $sessional->getTest_id());
     }
     if ($sessional->getSemester_id()) {
         $sql->where('semester_id = ?', $sessional->getSemester_id());
     }
     $resultSet = $sql->query()->fetchAll();
     //$logger->debug($resultSet);
     if ($resultSet != NULL) {
         $entries = array();
         foreach ($resultSet as $row) {
             $entry = new Acad_Model_Test_Sessional();
             $entry->setOptions($row)->setMapper($this);
             $entries[] = $entry;
         }
         return $entries;
     } else {
         return null;
     }
 }
コード例 #3
0
 public function getconductedAction()
 {
     $request = $this->getRequest();
     $department = $request->getParam('department_id');
     $degree = $request->getParam('degree_id');
     $semester = $request->getParam('semester_id');
     $format = $this->getRequest()->getParam('format', 'json');
     $sessional = new Acad_Model_Test_Sessional();
     $class = new Acad_Model_Class();
     $class->setDepartment($department)->setDegree($degree)->setSemester($semester);
     $result = $sessional->getConducted($class);
     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>';
             echo '<option>Select one</option>';
             foreach ($result as $key => $row) {
                 echo '<option value="' . $row['department_id'] . '">' . $row['department_id'] . '</option>';
             }
             echo '</select>';
             return;
             break;
     }
     header("HTTP/1.1 400 Bad Request");
 }
コード例 #4
0
 /**
  * 
  * Enter description here ...
  * insert data in database through SessionalMapper 
  */
 public function lockAction()
 {
     $request = $this->getRequest();
     $test_info_id = $request->getParam('test_info_id');
     $sessional = new Acad_Model_Test_Sessional(array('test_info_id' => $test_info_id));
     $result = $sessional->setLock(true);
     if ($result) {
         echo 'Successfully saved!! Affected: ' . $result;
     }
 }