function test_model_without_factory() { $Test = new Model_Test(); $result = $Test->find_one(); $this->assertArrayHasKey('id', $result->as_array()); echo json_encode(array('result' => $result->as_array(), 'query' => $result->get_query()), JSON_NUMERIC_CHECK); }
/** * * Building tree */ public function action_index() { if ($_POST) { $val = \Validation::forge(); $val->add_field('id', 'node id', 'required|min_length[1]|max_length[20]'); $val->add_field('rel', 'node type', 'required|min_length[1]|max_length[20]'); if ($val->run()) { switch ($this->gettype($val->validated('rel'))) { //room case 0: $data['groups'] = Model_Group::find()->where('meta_update_user', $this->user)->get(); return \Response::forge(\View::forge('tree/group', $data)); break; //group //group case 1: $tests = Model_Test::find()->where('group_id', $val->validated('id'))->get(); $data['tests'] = $tests; return \Response::forge(\View::forge('tree/test', $data)); break; //test //test case 2: $records = Model_Record::find()->where('test_id', $val->validated('id'))->get(); $data['records'] = $records; return \Response::forge(\View::forge('tree/record', $data)); break; //record //record case 3: echo '{:P}'; break; } //echo $val->validated('id'); } } }
public function action_ajax_load_list() { $test = Model_Test::create(); $tests = $test->getAll(); $list = array(); foreach ($tests as $t) { $list[$t->test_id] = $t->theme; } echo json_encode($list); }
/** * 取回所有结果行的第一个字段名 */ public function listColAction() { $data = array(); $data['title'] = '列表页面'; $condition = array('fields' => array('id')); $data['story_list'] = Model_Test::_model('story')->fetchCol($condition); $this->setInvokeArg('layout', 'mainLayout'); var_dump($data); }
/** * Отображение доступных учебных материалов. */ public function action_show(array $params = array()) { $a = Model_Test::create(); $a->test(); $links = Resources::getInstance()->links; if (!isset($params['discipline_id']) || is_int($params['discipline_id'])) { $this->flash('Не указан идентификатор дисциплины', $links->get('student.programs')); } $discipline_id = intval($params['discipline_id']); $user = Model_User::create(); $udata = (object) $user->getAuth(); $session = Resources_Abstract::getInstance()->session; // если данных о доступных дисциплинах нет - вычислить if (!isset($session->availDisciplines)) { $student = Model_Education_Students::create(); $avail_programs = $student->getAvailDisciplinesForPrograms($udata->user_id); $avail_disciplines = $student->getAvailDisciplinesSeparate($udata->user_id); } $discipline_open = in_array($discipline_id, $session->availDisciplines); if ($discipline_open) { // дисциплина доступна $disc = Model_Discipline::create(); $discipline_data = $disc->get($discipline_id); $section = Model_Section::create(); $sections = $section->getAllByDiscipline($discipline_id); $modelApps = Model_Application::create(); $statuses = $modelApps->getAppsStatus($discipline_id, $udata->user_id); //== Model_Application::STATUS_FINISHED; $statusFinished = array_key_exists(Model_Application::STATUS_FINISHED, $statuses); $material = Model_Educational_Materials::create(); $materials = $material->getAllByDiscipline($discipline_id, $statusFinished); $control_work = Model_ControlWork::create(); $tests = $control_work->getTestsByDiscipline($discipline_id); $this->set('discipline', $discipline_data); $this->set('sections', $sections); $this->set('materials', $materials); $this->set('tests', $tests); $this->set('user_id', $udata->user_id); //print_r($materials); $this->render(); } else { $this->flash('Данная дисциплина на данный Вам недоступна. Возможно Вы не полностью оплатили заявку по данной дисциплине или программе, содержащей данную дисциплину, либо вообще не подавали заявку на ее изучение.', $links->get('student.programs'), 5); } }