Ejemplo n.º 1
0
 public function get_task_set_list()
 {
     $filter = $this->input->post('filter');
     $this->store_task_set_selection_filter($filter);
     $this->db->query('CREATE TEMPORARY TABLE course_task_set_type_rel_override AS ( SELECT ctstr.course_id, ctstr.task_set_type_id, ctstr.upload_solution FROM course_task_set_type_rel ctstr ) UNION ( SELECT cs.id as course_id, 0 AS task_set_type_id, 1 AS upload_solution FROM (SELECT id FROM courses) cs )');
     $solutions = new Solution();
     $solutions->select_func('COUNT', 'id', 'cnt');
     $solutions->where_related('student/participant/course', 'id', '${parent}.course_id');
     $solutions->where_related('task_set', 'id', '${parent}.id');
     $task_sets = new Task_set();
     //$task_sets->select('`task_sets`.*, `course_course_task_set_type_rel`.`upload_solution` AS `join_upload_solution`');
     $task_sets->select('`task_sets`.*');
     $task_sets->select_subquery('(SELECT `sq_ctst`.`upload_solution` FROM course_task_set_type_rel_override AS `sq_ctst` WHERE `sq_ctst`.`course_id` = `${parent}`.`course_id` AND `sq_ctst`.`task_set_type_id` = `${parent}`.`task_set_type_id`)', 'join_upload_solution');
     $task_sets->include_related_count('task_set_permission');
     $task_sets->add_join_condition('`task_set_permissions`.`enabled` = 1');
     //$task_sets->include_related_count('solution');
     $task_sets->select_subquery($solutions, 'solution_count');
     $task_sets->include_related_count('task');
     $task_sets->include_related('course', array('name', 'default_points_to_remove', 'id'));
     $task_sets->include_related('course/period', 'name');
     $task_sets->include_related('group', 'name');
     $task_sets->include_related('task_set_type', 'name');
     //$task_sets->where_related('solution/student/participant/course', 'id', 'courses.id');
     /*$task_sets->include_related('course/task_set_type');
       $task_sets->where('(`course_task_set_types`.`id` = `task_sets`.`task_set_type_id`)');*/
     //$task_sets->where('((`course_course_task_set_type_rel`.`task_set_type_id` = `task_sets`.`task_set_type_id` AND `task_sets`.`task_set_type_id` != 0) OR `task_sets`.`task_set_type_id` = 0)');
     $task_sets->where('content_type', isset($filter['content_type']) ? $filter['content_type'] : 'task_set');
     if (isset($filter['course']) && intval($filter['course']) > 0) {
         $task_sets->where_related_course('id', intval($filter['course']));
     }
     if (isset($filter['group']) && $filter['group'] == 'NULL') {
         $task_sets->where_related_group('id', NULL);
         $task_sets->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
     } else {
         if (isset($filter['group']) && intval($filter['group']) > 0) {
             $task_sets->group_start();
             $task_sets->or_group_start();
             $task_sets->where_related_group('id', intval($filter['group']));
             $task_sets->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
             $task_sets->group_end();
             $task_sets->or_group_start();
             $task_sets->where_related('task_set_permission/group', 'id', intval($filter['group']));
             $task_sets->where_related('task_set_permission', 'enabled', 1);
             $task_sets->group_end();
             $task_sets->group_end();
         }
     }
     if (isset($filter['content_type']) && $filter['content_type'] == 'task_set' && isset($filter['task_set_type']) && intval($filter['task_set_type']) > 0) {
         $task_sets->where_related_task_set_type('id', intval($filter['task_set_type']));
     }
     $order_by_direction = $filter['order_by_direction'] == 'desc' ? 'desc' : 'asc';
     if ($filter['order_by_field'] == 'course') {
         $task_sets->order_by_related('course/period', 'sorting', $order_by_direction);
         $task_sets->order_by_related_with_constant('course', 'name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'task_set_name') {
         $task_sets->order_by_with_overlay('name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'course_group') {
         $task_sets->order_by_related_with_constant('group', 'name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'task_set_type') {
         $task_sets->order_by_related_with_constant('task_set_type', 'name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'solution_count') {
         $task_sets->order_by('solution_count', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'task_count') {
         $task_sets->order_by('task_count', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'upload_end_time') {
         $task_sets->order_by('upload_end_time', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'content_type') {
         $task_sets->order_by('content_type', $order_by_direction);
     }
     $task_sets->get_paged_iterated(isset($filter['page']) ? intval($filter['page']) : 1, isset($filter['rows_per_page']) ? intval($filter['rows_per_page']) : 25);
     //$task_sets->check_last_query();
     $this->lang->init_overlays('task_sets', $task_sets->all_to_array(), array('name'));
     $this->parser->parse('backend/solutions/task_set_list.tpl', array('task_sets' => $task_sets));
 }
Ejemplo n.º 2
0
 public function get_all_task_sets()
 {
     $fields_config = array(array('name' => 'created', 'caption' => 'lang:common_table_header_created'), array('name' => 'updated', 'caption' => 'lang:common_table_header_updated'), array('name' => 'name', 'caption' => 'lang:admin_task_sets_table_header_name'), array('name' => 'content_type', 'caption' => 'lang:admin_task_sets_table_header_content_type'), array('name' => 'course', 'caption' => 'lang:admin_task_sets_table_header_course'), array('name' => 'group', 'caption' => 'lang:admin_task_sets_table_header_group'), array('name' => 'task_set_type', 'caption' => 'lang:admin_task_sets_table_header_task_set_type'), array('name' => 'tasks', 'caption' => 'lang:admin_task_sets_table_header_tasks'), array('name' => 'published', 'caption' => 'lang:admin_task_sets_table_header_published'), array('name' => 'publish_start_time', 'caption' => 'lang:admin_task_sets_table_header_publish_start_time'), array('name' => 'upload_end_time', 'caption' => 'lang:admin_task_sets_table_header_upload_end_time'), array('name' => 'project_selection_deadline', 'caption' => 'lang:admin_task_sets_table_header_project_selection_deadline'));
     $filter = $this->input->post('filter');
     $this->store_filter($filter);
     $this->inject_stored_filter();
     $task_sets = new Task_set();
     $task_sets->include_related_count('task_set_permission');
     $task_sets->add_join_condition('`task_set_permissions`.`enabled` = 1');
     $task_sets->include_related('course', 'name', TRUE);
     $task_sets->include_related('course/period', 'name', TRUE);
     $task_sets->include_related('group', 'name', TRUE);
     $task_sets->include_related('task_set_type', 'name', TRUE);
     $task_sets->include_related_count('task');
     $task_sets->include_related_count('comment');
     if (isset($filter['course']) && intval($filter['course']) > 0) {
         $task_sets->where_related_course('id', intval($filter['course']));
         if (isset($filter['group']) && $filter['group'] == 'none') {
             $task_sets->where_related_group('id', NULL);
             $task_sets->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
         } else {
             if (isset($filter['group']) && intval($filter['group']) > 0) {
                 $task_sets->group_start();
                 $task_sets->or_group_start();
                 $task_sets->where_related_group('id', intval($filter['group']));
                 $task_sets->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
                 $task_sets->group_end();
                 $task_sets->or_group_start();
                 $task_sets->where_related('task_set_permission/group', 'id', intval($filter['group']));
                 $task_sets->where_related('task_set_permission', 'enabled', 1);
                 $task_sets->group_end();
                 $task_sets->group_end();
             }
         }
     }
     if (isset($filter['task_set_type']) && intval($filter['task_set_type']) > 0) {
         $task_sets->where_related_task_set_type('id', intval($filter['task_set_type']));
     }
     if (isset($filter['tasks']) && is_numeric($filter['tasks']) && intval($filter['tasks']) == 0) {
         $task_sets->where_has_no_tasks();
     } else {
         if (isset($filter['tasks']) && is_numeric($filter['tasks']) && intval($filter['tasks']) == 1) {
             $task_sets->where_has_tasks();
         }
     }
     if (isset($filter['name']) && trim($filter['name']) != '') {
         $name_value = trim($filter['name']);
         $task_sets->like_with_overlay('name', $name_value);
     }
     $order_by_direction = $filter['order_by_direction'] == 'desc' ? 'desc' : 'asc';
     if ($filter['order_by_field'] == 'created') {
         $task_sets->order_by('created', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'updated') {
         $task_sets->order_by('updated', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'name') {
         $task_sets->order_by_with_overlay('name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'course') {
         $task_sets->order_by_related('course/period', 'sorting', $order_by_direction);
         $task_sets->order_by_related_with_constant('course', 'name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'group') {
         $task_sets->order_by_related_with_constant('group', 'name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'task_set_type') {
         $task_sets->order_by_related_with_constant('task_set_type', 'name', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'tasks') {
         $task_sets->order_by('task_count', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'published') {
         $task_sets->order_by('published', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'upload_end_time') {
         $task_sets->order_by('upload_end_time', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'publish_start_time') {
         $task_sets->order_by('publish_start_time', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'project_selection_deadline') {
         $task_sets->order_by('project_selection_deadline', $order_by_direction);
     } elseif ($filter['order_by_field'] == 'content_type') {
         $task_sets->order_by('content_type', $order_by_direction);
     }
     $task_sets->get_paged_iterated(isset($filter['page']) ? intval($filter['page']) : 1, isset($filter['rows_per_page']) ? intval($filter['rows_per_page']) : 25);
     $this->lang->init_overlays('task_sets', $task_sets->all_to_array(), array('name'));
     $opened_task_set = new Task_set();
     $opened_task_set->get_as_open();
     $this->parser->parse('backend/task_sets/table_content.tpl', array('task_sets' => $task_sets, 'opened_task_set' => $opened_task_set, 'fields_config' => $fields_config));
 }