public function render() { $course = new Course(); $course->include_related('period'); $course->get_by_id((int) @$this->config['course_id']); $this->parser->assign('course', $course); if ($course->exists()) { $solutions = new Solution(); $solutions->select_func('COUNT', '@id', 'count'); $solutions->where('revalidate', 1); $solutions->where_related('task_set', 'id', '${parent}.id'); $solutions->where_related('student/participant/course', 'id', $course->id); $solutions->where_related('student/participant', 'allowed', 1); $task_sets = new Task_set(); $task_sets->select('*'); $task_sets->select_subquery($solutions, 'solutions_count'); $task_sets->where_related($course); $task_sets->where_related('solution', 'revalidate', 1); $task_sets->where_related('solution/student/participant/course', 'id', $course->id); $task_sets->where_related('solution/student/participant', 'allowed', 1); $task_sets->group_by('id'); $task_sets->order_by_with_overlay('name', 'ASC'); $task_sets->get_iterated(); $this->parser->assign('task_sets', $task_sets); } $this->parser->parse('widgets/admin/unevaluated_solutions/main.tpl'); }
private function inject_all_task_sets() { $task_sets = new Task_set(); $task_set_permissions = $task_sets->task_set_permission; $task_set_permissions->select_func('COUNT', '*', 'count'); $task_set_permissions->where('enabled', 1); $task_set_permissions->where_related('task_set', 'id', '${parent}.id'); $task_sets->select('*'); $task_sets->include_related('group', 'name'); $task_sets->select_subquery($task_set_permissions, 'task_set_permissions_count'); $task_sets->order_by_with_overlay('name'); $task_sets->get_iterated(); $data = array(); $this->lang->init_all_overlays('task_sets'); foreach ($task_sets as $task_set) { $text_groups = ''; if ((int) $task_set->task_set_permissions_count > 0) { $task_set_permissions = new Task_set_permission(); $task_set_permissions->include_related('group', 'name'); $task_set_permissions->where('enabled', 1); $task_set_permissions->where_related_task_set($task_set); $task_set_permissions->order_by_related_with_constant('group', 'name', 'asc'); $task_set_permissions->get_iterated(); $groups = array(); foreach ($task_set_permissions as $task_set_permission) { $groups[] = $this->lang->text($task_set_permission->group_name); } if (count($groups) > 0) { $text_groups = ' ... (' . implode(', ', $groups) . ')'; } } elseif (!is_null($task_set->group_id) && (int) $task_set->group_id > 0) { $text_groups = ' ... (' . $this->lang->text($task_set->group_name) . ')'; } $data[$task_set->course_id][] = array('value' => $task_set->id, 'text' => $this->lang->get_overlay_with_default('task_sets', $task_set->id, 'name', $task_set->name) . $text_groups); } $this->parser->assign('task_sets', $data); }
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)); }
private function get_task_set_by_id(&$course, &$group, &$student, $task_set_id) { $student = new Student(); $student->get_by_id($this->usermanager->get_student_id()); $course = new Course(); $course->where_related('active_for_student', 'id', $student->id); $course->where_related('participant', 'student_id', $student->id); $course->where_related('participant', 'allowed', 1); $course->include_related('period', 'name'); $course->get(); $task_set = new Task_set(); $task_set2 = new Task_set(); $group = new Group(); if ($course->exists()) { $group->where_related_participant('student_id', $student->id); $group->where_related_participant('course_id', $course->id); $group->get(); $task_set->select('`task_sets`.*, `rooms`.`time_day` AS `pb_time_day`, `rooms`.`time_begin` AS `pb_time_begin`, `rooms`.`id` AS `pb_room_id`, `task_sets`.`publish_start_time` AS `pb_publish_start_time`, `task_sets`.`upload_end_time` AS `pb_upload_end_time`'); $task_set->where('published', 1); $task_set->where_related_course($course); $task_set->include_related('solution'); $task_set->add_join_condition('`solutions`.`student_id` = ?', array($student->id)); $task_set->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_set->group_start(); $task_set->or_where('group_id', NULL); $task_set->or_where('group_id', $group->id); $task_set->group_end(); $task_set->include_related('room', '*', TRUE, TRUE); $task_set->include_related_count('task', 'total_tasks'); $task_set->include_related('task_set_type'); $task_set->select_subquery('(SELECT SUM(`points_total`) AS `points` FROM `task_task_set_rel` WHERE `task_set_id` = `${parent}`.`id` AND `task_task_set_rel`.`bonus_task` = 0)', 'total_points'); $task_set->where('id', $task_set_id); $task_set->include_related('course', 'test_scoring_deadline'); $task_set->where('content_type', 'task_set'); $task_set2->select('`task_sets`.*, `task_set_permission_rooms`.`time_day` AS `pb_time_day`, `task_set_permission_rooms`.`time_begin` AS `pb_time_begin`, `task_set_permission_rooms`.`id` AS `pb_room_id`, `task_set_permissions`.`publish_start_time` AS `pb_publish_start_time`, `task_set_permissions`.`upload_end_time` AS `pb_upload_end_time`'); $task_set2->where('published', 1); $task_set2->where_related_course($course); $task_set2->where_related('task_set_permission', 'group_id', $group->id); $task_set2->where_related('task_set_permission', 'enabled', 1); $task_set2->include_related('solution'); $task_set2->add_join_condition('`solutions`.`student_id` = ?', array($student->id)); $task_set2->include_related('task_set_permission/room', '*', 'room', TRUE); $task_set2->include_related_count('task', 'total_tasks'); $task_set2->include_related('task_set_type'); $task_set2->select_subquery('(SELECT SUM(`points_total`) AS `points` FROM `task_task_set_rel` WHERE `task_set_id` = `${parent}`.`id` AND `task_task_set_rel`.`bonus_task` = 0)', 'total_points'); $task_set2->where('id', $task_set_id); $task_set2->include_related('course', 'test_scoring_deadline'); $task_set2->where('content_type', 'task_set'); $task_set3 = new Task_set(); $task_set3->select('`task_sets`.*, NULL AS `pb_time_day`, NULL AS `pb_time_begin`, NULL AS `pb_room_id`, NULL AS `pb_publish_start_time`, "0000-00-00 00:00:00" AS `pb_upload_end_time`', FALSE); $task_set3->where('published', 1); $task_set3->where_related_course($course); $task_set3->include_related('solution'); $task_set3->add_join_condition('`solutions`.`student_id` = ?', array($student->id)); $task_set3->where_related('solution', 'student_id', $student->id); $task_set3->include_related('room', '*', TRUE, TRUE); $task_set3->include_related_count('task', 'total_tasks'); $task_set3->include_related('task_set_type'); $task_set3->select_subquery('(SELECT SUM(`points_total`) AS `points` FROM `task_task_set_rel` WHERE `task_set_id` = `${parent}`.`id` AND `task_task_set_rel`.`bonus_task` = 0)', 'total_points'); $task_set3->where('id', $task_set_id); $task_set3->include_related('course', 'test_scoring_deadline'); $task_set3->where('content_type', 'task_set'); $task_set2->union(array($task_set, $task_set3), FALSE, '', 1, 0, 'id'); } return $task_set2; }