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


PHP Test::where_in方法代码示例

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


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

示例1: 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

示例2: enqueue_test

 public function enqueue_test()
 {
     $post_test = $this->input->post('test');
     $post_select_test_type = $this->input->post('select_test_type');
     $output = new stdClass();
     $output->status = FALSE;
     $output->message = '';
     if ($post_select_test_type !== '') {
         if (isset($post_test['version']) && (int) $post_test['version'] > 0) {
             if (isset($post_test['id']) && is_array($post_test['id']) && count($post_test['id']) > 0) {
                 if (isset($post_test['task_set_id']) && (int) $post_test['task_set_id'] > 0 && isset($post_test['student_id']) && (int) $post_test['student_id'] > 0) {
                     $this->_transaction_isolation();
                     $this->db->trans_begin();
                     $maximum_eqnueued_tests_allowed = (int) $this->config->item('test_maximum_enqueued_pe_student');
                     if ($maximum_eqnueued_tests_allowed <= 0) {
                         $maximum_eqnueued_tests_allowed = 1;
                     }
                     $enqueued = new Test_queue();
                     $enqueued->where('status', 0);
                     $enqueued->where_related('student', 'id', (int) $post_test['student_id']);
                     $enqueued_for_this_student = $enqueued->count();
                     if ($enqueued_for_this_student < $maximum_eqnueued_tests_allowed) {
                         $tests = new Test();
                         $tests->where_in('id', $post_test['id']);
                         $tests->where('type', $post_select_test_type);
                         $tests->get_iterated();
                         if ($tests->exists()) {
                             $task_set = new Task_set();
                             $task_set->get_by_id((int) $post_test['task_set_id']);
                             $student = new Student();
                             $student->get_by_id((int) $post_test['student_id']);
                             if ($task_set->exists() && $student->exists()) {
                                 $test_queue = new Test_queue();
                                 $test_queue->priority = $task_set->test_priority;
                                 $test_queue->original_priority = $task_set->test_priority;
                                 $test_queue->test_type = $post_select_test_type;
                                 $test_queue->version = (int) $post_test['version'];
                                 $test_queue->start = date('Y-m-d H:i:s');
                                 $test_queue->points = 0;
                                 $test_queue->bonus = 0;
                                 $test_queue->status = 0;
                                 $test_queue->system_language = $this->lang->get_current_idiom();
                                 if ($test_queue->save(array('student' => $student, 'task_set' => $task_set))) {
                                     $errors = 0;
                                     foreach ($tests as $test) {
                                         if (!$test_queue->save($test)) {
                                             $errors++;
                                         }
                                     }
                                     if ($errors == 0) {
                                         $this->db->trans_commit();
                                         $output->status = TRUE;
                                         $output->message = $this->lang->line('admin_tests_enqueue_test_success');
                                     } else {
                                         $this->db->trans_rollback();
                                         $output->message = $this->lang->line('admin_tests_enqueue_test_error_cant_add_to_queue');
                                     }
                                 } else {
                                     $this->db->trans_rollback();
                                     $output->message = $this->lang->line('admin_tests_enqueue_test_error_cant_add_to_queue');
                                 }
                             } else {
                                 $this->db->trans_rollback();
                                 $output->message = $this->lang->line('admin_tests_enqueue_test_error_task_set_or_student_not_found');
                             }
                         } else {
                             $this->db->trans_rollback();
                             $output->message = $this->lang->line('admin_tests_enqueue_test_error_no_tests_selected');
                         }
                     } else {
                         $this->db->trans_rollback();
                         $output->message = sprintf($this->lang->line('admin_tests_enqueue_test_error_maximum_enqueues_reached'), $maximum_eqnueued_tests_allowed);
                     }
                 } else {
                     $output->message = $this->lang->line('admin_tests_enqueue_test_error_task_set_or_student_not_found');
                 }
             } else {
                 $output->message = $this->lang->line('admin_tests_enqueue_test_error_no_tests_selected');
             }
         } else {
             $output->message = $this->lang->line('admin_tests_enqueue_test_error_no_version_selected');
         }
     } else {
         $output->message = $this->lang->line('admin_tests_enqueue_test_error_not_test_type_selected');
     }
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:88,代码来源:tests.php


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