Пример #1
0
 public function index()
 {
     $this->_initialize_student_menu();
     $this->_select_student_menu_pagetag('groups');
     $this->parser->add_css_file('frontend_groups.css');
     $cache_id = $this->usermanager->get_student_cache_id();
     if (!$this->_is_cache_enabled() || !$this->parser->isCached($this->parser->find_view('frontend/groups/index.tpl'), $cache_id)) {
         $student = new Student();
         $student->get_by_id($this->usermanager->get_student_id());
         $course = new Course();
         $course->where_related_active_for_student($student);
         $course->where_related('participant/student', $student);
         $course->where_related_participant('allowed', 1);
         $course->get();
         $can_change_group = FALSE;
         if ($course->exists()) {
             if (is_null($course->groups_change_deadline) || date('U', strtotime($course->groups_change_deadline)) >= time()) {
                 $can_change_group = TRUE;
             }
         }
         smarty_inject_days();
         $this->parser->assign(array('course' => $course, 'can_change_group' => $can_change_group));
     }
     $this->parser->parse('frontend/groups/index.tpl', array(), FALSE, $this->_is_cache_enabled(), $cache_id);
 }
Пример #2
0
 /**
  * Loads and injects page navigation for student's frontend.
  * Also loads all courses, in which current student is participating.
  * Smarty template variable $list_pagemenu will be created.
  */
 protected function _initialize_student_menu()
 {
     $this->config->load('pagemenu');
     $this->parser->assign('list_pagemenu', $this->config->item('pagemenu'));
     $this->_load_student_langfile('pagemenu');
     if ($this->usermanager->is_student_session_valid()) {
         $courses = new Course();
         $courses->where_related('participant', 'student_id', $this->usermanager->get_student_id());
         $courses->where_related('participant', 'allowed', 1);
         $courses->include_related('period', 'name');
         $courses->order_by_related_with_constant('period', 'sorting', 'asc');
         $courses->order_by_with_constant('name', 'asc');
         $courses->get_iterated();
         $this->parser->assign('list_student_courses', $courses);
     }
 }
Пример #3
0
 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;
 }
Пример #4
0
 private function get_task_set_overview($task_set_id, &$course)
 {
     $task_set = new Task_set();
     $task_set->where('published', 1);
     $task_set->include_related_count('task', 'total_tasks');
     $task_set->where('content_type', 'project');
     $task_set->order_by('publish_start_time', 'asc');
     $task_set->order_by('upload_end_time', 'asc');
     $task_set->order_by_with_overlay('name', 'asc');
     $task_set->get_by_id((int) $task_set_id);
     $course = new Course();
     $course->where_related('task_set', 'id', (int) $task_set->id);
     $course->include_related('period');
     $course->get();
     return $task_set;
 }