public function add_to_task_set() { $this->_add_mathjax(); $url = $this->uri->ruri_to_assoc(3); $task_id = isset($url['task_id']) ? intval($url['task_id']) : intval($this->input->post('task_id')); $task = new Task(); $task->get_by_id($task_id); $task_set = new Task_set(); $task_set_id = intval($this->input->post('task_set_id')); if ($task_set_id == 0) { $task_set->get_as_open(); } else { $task_set->get_by_id($task_set_id); } $this->_add_prettify(); $this->parser->add_js_file('admin_tasks/add_to_task_set.js'); $this->parser->parse('backend/tasks/add_to_task_set.tpl', array('task' => $task, 'task_set' => $task_set)); }
/** * Loads and inject open task set to template. * Smarty template variable $list_open_task_set will be created. */ protected function _initialize_open_task_set() { $task_set = new Task_set(); $task_set->get_as_open(); $this->parser->assign('list_open_task_set', $task_set); }
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)); }