public function gettestAction() { $request = $this->getRequest(); $department = $this->_getParam('department_id'); $subject_code = $this->_getParam('subject_code'); $locked = $this->_getParam('locked'); $format = $this->getRequest()->getParam('format', 'json'); $subject = new Acad_Model_Course_Subject(); $subject->setSubject_code($subject_code)->setDepartment_id($department); $result = $subject->getTest($locked); switch (strtolower($format)) { case 'json': echo $this->_helper->json($result, false); return; case 'jsonp': $callback = $this->_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"); }