コード例 #1
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");
 }