當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Test::get_by_id方法代碼示例

本文整理匯總了PHP中Test::get_by_id方法的典型用法代碼示例。如果您正苦於以下問題:PHP Test::get_by_id方法的具體用法?PHP Test::get_by_id怎麽用?PHP Test::get_by_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Test的用法示例。


在下文中一共展示了Test::get_by_id方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getTest

 function getTest()
 {
     $t = new Test();
     foreach ($t->get_by_id(2)->topic->get() as $o) {
         echo $o->to_json();
     }
 }
開發者ID:htom78,項目名稱:peersay,代碼行數:7,代碼來源:ormTest.php

示例2: addBatch

 function addBatch()
 {
     $users = str_getcsv($_POST['users']);
     $saved = TRUE;
     $testid = $this->session->userdata('testid');
     $test = new Test();
     $test->get_by_id($testid);
     $this->load->helper("pinyin");
     foreach ($users as $user) {
         $u = new User();
         $u->uStudId = $user[0];
         $u->uName = str_replace(' ', '', $user[1]);
         //$u->uPassword = $user[0];//密碼等於用戶的學號
         $pinyin = get_pinyin($u->uName);
         $u->uPassword = str_replace('_', '', $pinyin);
         //用拚音作為密碼
         $u->uType = 'student';
         if (!$u->save()) {
             $saved = FALSE;
             break;
         }
         $test->save($u);
     }
     return 'saved';
 }
開發者ID:htom78,項目名稱:peersay,代碼行數:25,代碼來源:users.php

示例3: lists

 function lists($id = 0)
 {
     if (!$id) {
         $id = $this->session->userdata("testid");
     }
     $test = new Test();
     $test->get_by_id((int) $id);
     $t = $test->topic->get();
     $this->session->set_userdata(array('testid' => $id));
     //datamapper的json擴展真是強大
     echo $t->all_to_json();
 }
開發者ID:htom78,項目名稱:peersay,代碼行數:12,代碼來源:topics.php

示例4: initialize

 /**
  * This method will initialize this instance of test object with Test model, or id of test model.
  * @param DataMapper|integer $test_model Test model or id of test record.
  * @throws TestException can be thrown if $test_model is not Test object, test record not exists or test type or subtype is not supported.
  */
 public function initialize($test_model)
 {
     if (is_object($test_model) && !$test_model instanceof Test) {
         throw new TestException($this->CI->lang->line('tests_general_error_cant_initialize_with_non_test_model'), 1000001);
     } elseif (is_integer($test_model)) {
         $test_model_id = $test_model;
         $test_model = new Test();
         $test_model->get_by_id($test_model_id);
     }
     if ($test_model->exists()) {
         if ($test_model->type !== $this->test_type) {
             throw new TestException(sprintf($this->CI->lang->line('tests_general_error_test_type_is_not_supported'), get_class($this)), 1000002);
         } elseif (!array_key_exists($test_model->subtype, $this->test_subtypes)) {
             throw new TestException(sprintf($this->CI->lang->line('tests_general_error_test_subtype_is_not_supported'), get_class($this)), 1000003);
         }
         $current_test = array('subtype' => $test_model->subtype, 'config' => unserialize($test_model->configuration), 'id' => $test_model->id, 'enable_scoring' => (int) $test_model->enable_scoring > 0 ? TRUE : FALSE, 'task_id' => $test_model->task_id, 'timeout' => $test_model->timeout);
         $this->current_test = $current_test;
     } else {
         throw new TestException($this->CI->lang->line('tests_general_error_test_record_not_exists'), 1000004);
     }
 }
開發者ID:andrejjursa,項目名稱:list-lms,代碼行數:26,代碼來源:abstract_test.php

示例5: edit

 public function edit($id = 0)
 {
     $obj = new Test();
     $obj->get_by_id((int) $id);
     if (!$_POST) {
         echo $obj->to_json();
     } else {
         if (isset($_POST['model']) and $model = $_POST['model']) {
             $obj->from_json($model);
             if ($obj->save()) {
                 $this->_user->save($obj);
                 //保存關係
                 echo $obj->to_json();
             } else {
                 echo json_encode(array('error' => $obj->error->string));
             }
         } else {
             if (isset($_POST['_method']) and $_POST['_method'] === 'DELETE') {
                 $this->_user->delete($obj);
                 $obj->delete();
             }
         }
     }
 }
開發者ID:htom78,項目名稱:peersay,代碼行數:24,代碼來源:tests.php

示例6: run_single_test

 public function run_single_test($test_id, $source_file, $evaluation = FALSE, $student_id = NULL, $token = '')
 {
     $output = new stdClass();
     $output->text = '';
     $output->code = 0;
     try {
         $test = new Test();
         $test->get_by_id(intval($test_id));
         if ($test->exists()) {
             $test_object = $this->load->test($test->type);
             $test_object->initialize($test);
             $output->text = $test_object->run(decode_from_url($source_file), (bool) (int) $evaluation && strlen($token) > 0, $student_id, $token);
         }
     } catch (Exception $e) {
         $output->text = $e->getMessage();
         $output->code = $e->getCode();
     }
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
開發者ID:andrejjursa,項目名稱:list-lms,代碼行數:20,代碼來源:tests.php


注:本文中的Test::get_by_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。