当前位置: 首页>>代码示例>>PHP>>正文


PHP Test::count方法代码示例

本文整理汇总了PHP中Test::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::count方法的具体用法?PHP Test::count怎么用?PHP Test::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Test的用法示例。


在下文中一共展示了Test::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRowMethods

 function testRowMethods()
 {
     $id = $this->addRow();
     $tr = new Test();
     $loaded = $tr->load($id);
     $this->assert($updatedRow = $loaded, "Test->load() failed: " . var_export($loaded, 1));
     $exp = $tr->export();
     $this->assert($updatedRow = $exp, "Test->export() failed: " . var_export($exp, 1));
     $newname = 'test updated again';
     $tr->name = $newname;
     $save = $tr->save();
     $this->assert($save, "Test->save() failed: " . var_export($tr->getErrorList(), 1));
     $this->assert(Test::count() == 1, "Test::count() failed");
     $tr->name = null;
     $this->assert(!$tr->save(), "Test->save() should have failed (required name rule should fail)!");
     $tr->name = array('123');
     $this->assert(!$tr->save(), "Test->save() should have failed (string name rule should fail)!");
     $tr2 = new Test();
     $tr2->name = '000 second row';
     // three zeroes - to ensure it sorts above the first one
     $this->assert($tr2->save(), 'Test->save() failed: ' . var_export($tr->getErrorList(), 1));
     $s = Test::findAll();
     $s->setOrder('name');
     $s->paginate(1, 1);
     $all = $s->export()->fetchAll();
     $this->assert(1 == count($all), 'Select->count() failed after pagination');
     $this->assert($tr2->name == $all[0]->name, 'Select->export() failed ordering');
 }
开发者ID:nakonechny,项目名称:naf,代码行数:28,代码来源:ActiveRecordTest.php

示例2: all

 /**
  * @before _secure, _admin
  */
 public function all()
 {
     $this->seo(array("title" => "Manage Medical Test", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $page = RequestMethods::get("page", 1);
     $limit = RequestMethods::get("limit", 10);
     $medicaltests = Test::all(array(), array("id", "title", "live"), "created", "desc", $limit, $page);
     $count = Test::count();
     $view->set("medicaltests", $medicaltests);
     $view->set("page", $page);
     $view->set("count", $count);
     $view->set("limit", $limit);
 }
开发者ID:HLitmus,项目名称:WebApp,代码行数:16,代码来源:medicaltest.php

示例3:

<?php

require_once "TestClass.php";
Test::$count = Test::$count + 1;
echo Test::$count;
开发者ID:BassYang1,项目名称:YueXinChina,代码行数:5,代码来源:TestStatic.php

示例4: upload_solution

 public function upload_solution($task_set_id = 0)
 {
     $this->usermanager->student_login_protected_redirect();
     $task_set = $this->get_task_set_by_id($course, $group, $student, $task_set_id);
     $task_sets = $this->filter_valid_task_sets($task_set);
     $filtered_task_set = count($task_sets) == 1 ? $task_sets[0] : new Task_set();
     if ($filtered_task_set->id == intval($task_set_id) && $this->can_upload_file($filtered_task_set, $course)) {
         $allowed_file_types_array = trim($filtered_task_set->allowed_file_types) != '' ? array_map('trim', explode(',', $filtered_task_set->allowed_file_types)) : array();
         $config['upload_path'] = 'private/uploads/solutions/task_set_' . intval($task_set_id) . '/';
         $config['allowed_types'] = 'zip' . (count($allowed_file_types_array) ? '|' . implode('|', $allowed_file_types_array) : '');
         $config['max_size'] = intval($this->config->item('maximum_solition_filesize'));
         $current_version = $filtered_task_set->get_student_file_next_version($student->id);
         $config['file_name'] = $student->id . '_' . $this->normalize_student_name($student) . '_' . substr(md5(time() . rand(-500000, 500000)), 0, 4) . '_' . $current_version . '.zip';
         @mkdir($config['upload_path'], DIR_READ_MODE, TRUE);
         $this->load->library('upload', $config);
         if ($this->upload->do_upload('file')) {
             $upload_data = $this->upload->data();
             $mimes = $this->upload->mimes_types('zip');
             if (is_array($mimes) && !in_array($upload_data['file_type'], $mimes) || is_string($mimes) && $upload_data['file_type'] != $mimes) {
                 if (!$this->zip_plain_file_to_archive($upload_data['full_path'], $upload_data['client_name'], $upload_data['file_path'])) {
                     $this->messages->add_message('lang:tasks_task_error_cant_zip_file', Messages::MESSAGE_TYPE_ERROR);
                     redirect(create_internal_url('tasks/task/' . intval($task_set_id)));
                     die;
                 }
             }
             $this->_transaction_isolation();
             $this->db->trans_begin();
             $solution = new Solution();
             $solution->where('task_set_id', $filtered_task_set->id);
             $solution->where('student_id', $student->id);
             $solution->get();
             $revalidate = 1;
             if ($course->test_scoring_deadline >= date('Y-m-d H:i:s') && $filtered_task_set->enable_tests_scoring == 1 && $filtered_task_set->allowed_test_types != '') {
                 $test_types = explode(',', $filtered_task_set->allowed_test_types);
                 $tests = new Test();
                 $tests->where_related('task/task_set', 'id', $filtered_task_set->id);
                 $tests->where('enabled', 1);
                 $tests->where('enable_scoring', 1);
                 $tests->where_in('type', $test_types);
                 $revalidate = $tests->count() > 0 ? 0 : 1;
             }
             if ($solution->exists()) {
                 $solution->ip_address = $_SERVER["REMOTE_ADDR"];
                 $solution->revalidate = $revalidate;
                 $solution->save();
             } else {
                 $solution = new Solution();
                 $solution->ip_address = $_SERVER["REMOTE_ADDR"];
                 $solution->revalidate = $revalidate;
                 $solution->save(array('student' => $student, 'task_set' => $filtered_task_set));
             }
             $solution_version = new Solution_version();
             $solution_version->ip_address = $_SERVER["REMOTE_ADDR"];
             $solution_version->version = $current_version;
             $solution_version->save($solution);
             if ($this->db->trans_status()) {
                 $log = new Log();
                 $log->add_student_solution_upload_log(sprintf($this->lang->line('tasks_task_solution_upload_log_message'), $config['file_name']), $student, $solution->id);
                 $this->db->trans_commit();
                 $this->messages->add_message('lang:tasks_task_solution_uploaded', Messages::MESSAGE_TYPE_SUCCESS);
                 $this->_action_success();
                 $this->output->set_internal_value('task_set_id', $solution->task_set_id);
             } else {
                 $this->db->trans_rollback();
                 @unlink($config['upload_path'] . $config['file_name']);
                 $this->messages->add_message('lang:tasks_task_solution_canceled_due_db_error', Messages::MESSAGE_TYPE_ERROR);
             }
             redirect(create_internal_url('tasks/task/' . intval($task_set_id)));
         } else {
             $this->parser->assign('file_error_message', $this->upload->display_errors('', ''));
             $this->task($task_set_id);
         }
     } else {
         $this->messages->add_message('lang:tasks_task_error_cant_upload_solution', Messages::MESSAGE_TYPE_ERROR);
         redirect(create_internal_url('tasks/task/' . intval($task_set_id)));
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:77,代码来源:tasks.php


注:本文中的Test::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。