示例#1
0
 function uncomplete_task()
 {
     $id = $this->input->post('id');
     $user = new User();
     $task = new Task();
     if ($task->where('user_id', $this->dx_auth->get_user_id())->where('id', $id)->count() == 0) {
         return;
     }
     $task->get_by_id($id);
     $task->completed = 0;
     $task->save();
     $docket = new Docket();
     $docket->get_by_id($task->docket_id);
     $task->clear();
     if ($task->where('docket_id', $docket->id)->where('completed', 0)->count() == 0) {
         $docket->completed = 1;
         $docket->save();
     } else {
         $docket->completed = 0;
         $docket->save();
     }
     $gold = $this->treasure->decrease($this->dx_auth->get_user_id());
     $task->clear();
     $task->get_by_id($id);
     $result = array('id' => $task->id, 'name' => $task->name, 'docket_id' => $docket->id, 'due' => $task->due, 'gold' => $gold);
     echo json_encode($result);
 }
示例#2
0
 private function inject_files($task_id, $source = self::FILELIST_PUBLIC)
 {
     $task = new Task();
     $task->get_by_id($task_id);
     $files = array();
     if ($source == self::FILELIST_PUBLIC) {
         $files = $task->get_task_files();
     } elseif ($source == self::FILELIST_HIDDEN) {
         $files = $task->get_task_hidden_files();
     }
     $this->parser->assign('files', $files);
 }
示例#3
0
 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));
 }
示例#4
0
 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));
 }
示例#5
0
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";
}