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


PHP Task::exists方法代码示例

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


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

示例1: insert_to_task_set

 public function insert_to_task_set()
 {
     $this->load->library('form_validation');
     $task_set_id = intval($this->input->post('task_set_id'));
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $task_set = new Task_set();
     $task_set->get_by_id($task_set_id);
     $this->form_validation->set_rules('task_id', 'task_id', 'required');
     $this->form_validation->set_rules('task_set_id', 'task_set_id', 'required');
     if ($task_set->exists()) {
         if ($task_set->content_type == 'task_set') {
             $this->form_validation->set_rules('points_total', 'lang:admin_tasks_add_to_task_set_form_field_points_total', 'required|number|greater_than_equal[0]');
             $this->form_validation->set_rules('test_max_points', 'lang:admin_tasks_add_to_task_set_form_field_test_max_points', 'required|number|greater_than_equal[0]');
             $this->form_validation->set_rules('test_min_points', 'lang:admin_tasks_add_to_task_set_form_field_test_min_points', 'required|number|less_than_field_or_equal[test_max_points]');
         } else {
             $this->form_validation->set_rules('max_projects_selections', 'lang:admin_tasks_add_to_task_set_form_field_max_projects_selections', 'required|integer|greater_than[0]');
         }
     }
     if ($this->form_validation->run()) {
         $task_id = intval($this->input->post('task_id'));
         $points_total = floatval($this->input->post('points_total'));
         $test_max_points = floatval($this->input->post('test_max_points'));
         $test_min_points = floatval($this->input->post('test_min_points'));
         $bonus_task = (int) (bool) intval($this->input->post('bonus_task'));
         $max_projects_selections = intval($this->input->post('max_projects_selections'));
         $internal_comment = $this->input->post('internal_comment');
         $task = new Task();
         $task->get_by_id($task_id);
         if (!$task->exists()) {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_tasks_error_message_task_not_found', Messages::MESSAGE_TYPE_ERROR);
         } elseif (!$task_set->exists()) {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_tasks_add_to_task_set_nothing_opened', Messages::MESSAGE_TYPE_ERROR);
         } elseif ($task_set->is_related_to($task)) {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_tasks_add_to_task_set_already_related', Messages::MESSAGE_TYPE_ERROR);
         } else {
             $related_task = $task_set->task->include_join_fields()->order_by('join_sorting', 'desc')->limit(1)->get();
             $new_sorting = $related_task->exists() ? intval($related_task->join_sorting) + 1 : 1;
             $task_set->save($task);
             $task_set->set_join_field($task, 'points_total', $points_total);
             $task_set->set_join_field($task, 'test_max_points', $test_max_points);
             $task_set->set_join_field($task, 'test_min_points', $test_min_points);
             $task_set->set_join_field($task, 'sorting', $new_sorting);
             $task_set->set_join_field($task, 'bonus_task', $bonus_task);
             $task_set->set_join_field($task, 'max_projects_selections', $max_projects_selections);
             $task_set->set_join_field($task, 'internal_comment', $internal_comment);
             if ($this->db->trans_status()) {
                 $this->db->trans_commit();
                 $this->messages->add_message('lang:admin_tasks_add_to_task_set_save_success', Messages::MESSAGE_TYPE_SUCCESS);
                 $this->_action_success();
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:admin_tasks_add_to_task_set_save_failed', Messages::MESSAGE_TYPE_ERROR);
             }
         }
         redirect(create_internal_url('admin_tasks/add_to_task_set/task_id/' . $task_id));
     } else {
         $this->db->trans_rollback();
         $this->add_to_task_set();
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:64,代码来源:tasks.php

示例2: all_tests

 public function all_tests($task_id)
 {
     $this->load->helper('tests');
     $tests_data = get_all_supported_test_types_and_subtypes();
     $task = new Task();
     $task->get_by_id($task_id);
     $tests = new Test();
     if ($task->exists()) {
         $tests->where_related($task);
         $tests->order_by('type', 'asc');
         $tests->order_by('subtype', 'asc');
         $tests->get_iterated();
     }
     $this->parser->parse('backend/tests/all_tests.tpl', array('test_types' => $tests_data['types'], 'test_subtypes' => $tests_data['subtypes'], 'task' => $task, 'tests' => $tests));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:15,代码来源:tests.php

示例3: select_project

 public function select_project($task_set_id, $task_id, $student_id)
 {
     $output = new stdClass();
     $output->message = '';
     $output->status = FALSE;
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $task_set = new Task_set();
     $task_set->where('content_type', 'project');
     $task_set->get_by_id((int) $task_set_id);
     $task = new Task();
     $task->get_by_id((int) $task_id);
     $student = new Student();
     $student->get_by_id((int) $student_id);
     $course = new Course();
     $course->where_related_task_set($task_set);
     $course->get();
     $participant = new Participant();
     $participant->where_related_course($course);
     $participant->where_related($student);
     $participant->where('allowed', 1);
     $participant->get();
     $project_selection = new Project_selection();
     $project_selection->where_related_student($student);
     $project_selection->where_related_task_set($task_set);
     $project_selection->get();
     if ($task_set->exists() && $task->exists() && $task_set->is_related_to($task) && $student->exists() && $course->exists() && $participant->exists()) {
         if ($task_set->get_student_files_count($student->id) == 0) {
             $all_project_selections = new Project_selection();
             $all_project_selections->where_related_task_set($task_set);
             $all_project_selections->where_related_task($task);
             $currently_selected = $all_project_selections->count();
             $jf_task = $task_set->task->include_join_fields()->get_by_id($task_id);
             $maximum_selections = (int) $jf_task->join_max_projects_selections;
             if ($project_selection->exists()) {
                 if (!$project_selection->is_related_to($task)) {
                     if ($currently_selected < $maximum_selections) {
                         $project_selection->save($task);
                         $output->status = TRUE;
                         $output->message = $this->lang->line('admin_task_sets_project_selection_success');
                     } else {
                         $output->message = $this->lang->line('admin_task_sets_project_selection_no_room');
                     }
                 } else {
                     $output->message = $this->lang->line('admin_task_sets_project_selection_already_selected');
                 }
             } else {
                 if ($currently_selected < $maximum_selections) {
                     $project_selection->save(array('student' => $student, 'task_set' => $task_set, 'task' => $task));
                     $output->status = TRUE;
                     $output->message = $this->lang->line('admin_task_sets_project_selection_success');
                 } else {
                     $output->message = $this->lang->line('admin_task_sets_project_selection_no_room');
                 }
             }
         } else {
             $output->message = $this->lang->line('admin_task_sets_project_selection_already_submited_solutions');
         }
     } else {
         $output->message = $this->lang->line('admin_task_sets_project_selection_cant_find_data');
     }
     if ($output->status) {
         $this->db->trans_commit();
         $this->_action_success();
     } else {
         $this->db->trans_rollback();
     }
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:70,代码来源:task_sets.php

示例4: list_import_lamsfet_tasks_in_sets_relation

function list_import_lamsfet_tasks_in_sets_relation($sets, $tasks, $tasks_in_sets)
{
    echo 'Starting task_task_set_rel import (' . count($tasks_in_sets) . ') [';
    if (count($tasks_in_sets)) {
        foreach ($tasks_in_sets as $task_in_set) {
            $task_set_id = $sets[$task_in_set->set_id]->_list_id;
            $task_id = $tasks[$task_in_set->task_id]->_list_id;
            $task_set = new Task_set();
            $task_set->get_by_id(intval($task_set_id));
            $task = new Task();
            $task->get_by_id(intval($task_id));
            if ($task_set->exists() && $task->exists()) {
                $task_set->save($task);
                $task_set->set_join_field($task, 'sorting', $task_in_set->order);
                $task_set->set_join_field($task, 'points_total', floatval($task_in_set->points));
                $task_set->set_join_field($task, 'bonus_task', 0);
            } else {
                echo ' ( TASK SET OR TASK NOT FOUND ' . $task_set_id . '(' . $task_in_set->set_id . ')/' . $task_id . '(' . $task_in_set->task_id . ') ) ';
            }
            echo '.';
        }
    }
    echo '] ... done' . "\n";
}
开发者ID:andrejjursa,项目名称:list-lms,代码行数:24,代码来源:lamsfet_helper.php


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