本文整理汇总了PHP中Student::where_related方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::where_related方法的具体用法?PHP Student::where_related怎么用?PHP Student::where_related使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Student
的用法示例。
在下文中一共展示了Student::where_related方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
if (isset($this->config['course_id'])) {
$course = new Course();
$course->include_related('period');
$course->get_by_id((int) $this->config['course_id']);
$this->parser->assign('course', $course);
if ($course->exists()) {
$task_sets = new Task_set();
$task_sets->where_related($course);
$task_sets->where('published', 1);
$task_sets->where('content_type', 'task_set');
$task_sets_count = $task_sets->count();
$this->parser->assign('task_sets_count', $task_sets_count);
$task_sets->where_related($course);
$task_sets->where('published', 1);
$task_sets->where('content_type', 'project');
$projects_count = $task_sets->count();
$this->parser->assign('projects_count', $projects_count);
$groups = new Group();
$groups->where_related($course);
$groups_count = $groups->count();
$this->parser->assign('groups_count', $groups_count);
$students = new Student();
$students->where_related('participant/course', 'id', $course->id);
$students->where_related('participant', 'allowed', 1);
$students_count = $students->count();
$this->parser->assign('students_count', $students_count);
$task_set_permissions = new 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');
$now = date('Y-m-d H:i:s');
$plus_two_weeks = date('Y-m-d H:i:s', strtotime($now . ' + 2 weeks'));
$minus_one_week = date('Y-m-d H:i:s', strtotime($now . ' - 1 week'));
$task_sets->select('id, name, upload_end_time AS min_upload_end_time, upload_end_time AS max_upload_end_time');
$task_sets->where_related($course);
$task_sets->where('published', 1);
$task_sets->where_subquery('0', $task_set_permissions);
$task_sets->where('upload_end_time >=', $minus_one_week);
$task_sets->where('upload_end_time <=', $plus_two_weeks);
$task_sets_2 = new Task_set();
$task_sets_2->select('id, name');
$task_sets_2->where_related($course);
$task_sets_2->where('published', 1);
$task_sets_2->select_min('task_set_permissions.upload_end_time', 'min_upload_end_time');
$task_sets_2->select_max('task_set_permissions.upload_end_time', 'max_upload_end_time');
$task_sets_2->where_related('task_set_permission', 'enabled', 1);
$task_sets_2->having('(MAX(`task_set_permissions`.`upload_end_time`) >= ' . $this->db->escape($minus_one_week) . ' AND MAX(`task_set_permissions`.`upload_end_time`) <= ' . $this->db->escape($plus_two_weeks) . ')');
$task_sets_2->or_having('(MIN(`task_set_permissions`.`upload_end_time`) >= ' . $this->db->escape($minus_one_week) . ' AND MIN(`task_set_permissions`.`upload_end_time`) <= ' . $this->db->escape($plus_two_weeks) . ')');
$task_sets_2->group_by('id');
$task_sets->union_iterated($task_sets_2, FALSE, 'min_upload_end_time DESC, max_upload_end_time DESC', isset($this->config['number_of_task_sets']) ? (int) $this->config['number_of_task_sets'] : 5);
$this->parser->assign('task_sets', $task_sets);
}
}
$this->parser->parse('widgets/admin/course_overview/main.tpl');
}
示例2: table_content
public function table_content()
{
$filter = $this->input->post('filter');
$this->store_filter($filter);
$students = new Student();
if (isset($filter['fullname']) && trim($filter['fullname']) != '') {
$students->like('fullname', trim($filter['fullname']));
}
if (isset($filter['email']) && trim($filter['email']) != '') {
$students->like('email', trim($filter['email']));
}
if (isset($filter['course']) && $filter['course'] !== '') {
$students->where_related('participant/course', 'id', (int) $filter['course']);
$students->where_related('participant', 'allowed', 1);
}
$order_by_direction = $filter['order_by_direction'] == 'desc' ? 'desc' : 'asc';
if ($filter['order_by_field'] == 'fullname') {
$students->order_by_as_fullname('fullname', $order_by_direction);
} elseif ($filter['order_by_field'] == 'email') {
$students->order_by('email', $order_by_direction);
}
$students->get_paged_iterated(isset($filter['page']) ? intval($filter['page']) : 1, isset($filter['rows_per_page']) ? intval($filter['rows_per_page']) : 25);
$this->parser->parse('backend/students/table_content.tpl', array('students' => $students));
}
示例3: add_files_to_zip_archive
/**
* Add files to open zip archive.
* @param ZipArchive $zip_archive open zip archive.
* @param Course $course course object with loaded course.
* @param string|NULL $subdirectory subdirectory where to add files.
*/
public function add_files_to_zip_archive(ZipArchive $zip_archive, Course $course, $subdirectory = NULL)
{
if (!is_null($this->id)) {
ini_set('max_execution_time', 300);
$path_to_task_set_files = 'private/uploads/solutions/task_set_' . $this->id . '/';
if (file_exists($path_to_task_set_files)) {
$groups = $course->groups->get_iterated();
$group_names = array(0 => 'unassigned');
foreach ($groups as $group) {
$group_names[$group->id] = normalizeForFilesystem($this->lang->text($group->name));
}
$students = new Student();
$students->include_related('participant');
$students->where_related('participant/course', $course);
$students->get_iterated();
$student_groups = array();
foreach ($students as $studnet) {
$student_groups[$studnet->id] = intval($studnet->participant_group_id);
}
$files = scandir($path_to_task_set_files);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
if (preg_match(self::STUDENT_FILE_NAME_REGEXP, $file, $matches)) {
$student_id = intval($matches['student_id']);
$path = ($subdirectory !== NULL && trim($subdirectory) != '' ? $subdirectory . '/' : '') . $group_names[$student_groups[$student_id]] . '/' . $file;
$zip_archive->addFile($path_to_task_set_files . $file, $path);
}
}
}
}
}
}
示例4: send_group_mail
public function send_group_mail($group_id)
{
$group = new Group();
$group->get_by_id($group_id);
if ($group->exists()) {
$this->load->library('form_validation');
$this->form_validation->set_rules('group_mail[subject]', 'lang:admin_groups_group_email_form_field_subject', 'required');
$this->form_validation->set_rules('group_mail[body]', 'lang:admin_groups_group_email_form_field_body', 'required_no_html');
$this->form_validation->set_rules('group_mail[from]', 'lang:admin_groups_group_email_form_field_from', 'required');
$this->form_validation->set_rules('group_mail[student][]', 'lang:admin_groups_group_email_form_field_students', 'required');
if ($this->form_validation->run()) {
$data = $this->input->post('group_mail');
$students = new Student();
$students->where_related('participant/group', 'id', $group->id);
$students->where_related('participant/course', 'id', $group->course_id);
$students->where_related('participant', 'allowed', 1);
$students->where_in('id', $data['student']);
$students->get();
if ($students->exists()) {
$from = NULL;
$from_name = '';
$teacher = new Teacher();
$teacher->get_by_id($this->usermanager->get_teacher_id());
if ($data['from'] == 'me') {
$from = $teacher->email;
$from_name = $teacher->fullname;
}
$sender_copy = isset($data['sender_copy']) && $data['sender_copy'] == 1 ? TRUE : FALSE;
$sender_email = $teacher->email;
if ($this->_send_multiple_emails($students, $data['subject'], '{$data.body|add_base_url}', array('data' => $data), $from, $from_name, $sender_copy, $sender_email)) {
$this->messages->add_message('lang:admin_groups_group_email_success_sent', Messages::MESSAGE_TYPE_SUCCESS);
} else {
$this->messages->add_message('lang:admin_groups_group_email_error_send_failed', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->messages->add_message('lang:admin_groups_group_email_error_no_students_selected', Messages::MESSAGE_TYPE_ERROR);
}
redirect(create_internal_url('admin_groups/group_mail/' . $group_id));
} else {
$this->group_mail($group_id);
}
} else {
$this->messages->add_message('lang:admin_groups_group_email_error_group_not_found', Messages::MESSAGE_TYPE_ERROR);
redirect(create_internal_url('admin_groups/group_mail/' . $group_id));
}
}
示例5: add_participant
public function add_participant()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('participant[course]', 'lang:admin_participants_form_field_course', 'required');
$this->form_validation->set_rules('participant[students][]', 'lang:admin_participants_form_field_students', 'required');
if ($this->form_validation->run()) {
$this->_transaction_isolation();
$this->db->trans_begin();
$process_ok = TRUE;
$participant_data = $this->input->post('participant');
$course = new Course();
$course->get_by_id(intval($participant_data['course']));
$group = new Group();
$group->get_by_id(intval(@$participant_data['group']));
if (!$course->exists()) {
$this->db->trans_rollback();
$this->messages->add_message('lang:admin_participants_message_course_not_exists', Messages::MESSAGE_TYPE_ERROR);
$process_ok = FALSE;
}
if ($process_ok && $course->exists()) {
if ($group->exists() && !$group->is_related_to($course)) {
$this->db->trans_rollback();
$this->messages->add_message('lang:admin_participants_message_group_not_belongs_to_course', Messages::MESSAGE_TYPE_ERROR);
$process_ok = FALSE;
}
}
$disapproved = 0;
$added = 0;
if ($process_ok) {
foreach ($participant_data['students'] as $student_id) {
$student = new Student();
$student->where_related('participant/course', 'id', $course->id);
$student->get_by_id($student_id);
if ($student->exists()) {
continue;
}
$student->get_by_id($student_id);
$participant = new Participant();
$participant->allowed = intval(@$participant_data['allowed']);
$participant->save(array($student, $course, $group));
$added++;
if ($participant->allowed == 1) {
$disallowe_participant = FALSE;
if ($course->participant->where('allowed', 1)->count() > intval($course->capacity)) {
$disallowe_participant = TRUE;
}
if ($group->exists()) {
$group_for_test = new Group();
$rooms = $group_for_test->room;
$rooms->select_min('capacity');
$rooms->where('group_id', '${parent}.id', FALSE);
$group_for_test->select_subquery($rooms, 'group_capacity');
$group_for_test->include_related_count('participant');
$group_for_test->where_related_participant('allowed', 1);
$group_for_test->get_by_id(intval($group->id));
if ($group_for_test->exists()) {
if (intval($group_for_test->participant_count) > intval($group_for_test->group_capacity)) {
$disallowe_participant = TRUE;
}
}
}
if ($disallowe_participant) {
$participant->allowed = 0;
$participant->save();
$disapproved++;
}
}
}
}
if ($this->db->trans_status() && $process_ok) {
$this->db->trans_commit();
$info_approved = intval(@$participant_data['allowed']) == 1 ? $added - $disapproved : 0;
$info_disappoved = intval(@$participant_data['allowed']) == 1 ? $disapproved : $added;
$message = sprintf($this->lang->line('admin_participants_message_addition_successfull'), $info_approved, $info_disappoved);
$this->messages->add_message($message, Messages::MESSAGE_TYPE_SUCCESS);
$this->_action_success();
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:admin_participants_messages_error_in_addition_transaction', Messages::MESSAGE_TYPE_ERROR);
}
redirect(create_internal_url('admin_participants/add_participant_form'));
} else {
$this->add_participant_form();
}
}
示例6: get_valuation_table_data
private function get_valuation_table_data($course_id, $group_id = NULL, $condensed = FALSE)
{
$table_data = array('header' => array(), 'content' => array());
$course = new Course();
$course->get_by_id(intval($course_id));
$group = new Group();
$group->get_by_id((int) $group_id);
if ($course->exists()) {
$students = new Student();
$students->select('id, fullname, email');
$students->include_related('participant/group', array('id', 'name'));
$students->where_related('participant/course', 'id', $course->id);
$students->where_related('participant', 'allowed', 1);
$students->order_by_as_fullname('fullname');
if ($group->exists()) {
$students->where_related('participant/group', 'id', (int) $group_id);
}
$students->get_iterated();
$task_sets_out_of_group_ids = array(0);
$task_sets_data = array();
$task_sets_ids = array();
$projects_ids = array();
if ($group->exists()) {
$students_filter = new Student();
$students_filter->select('id');
$students_filter->where_related('participant/course', 'id', $course->id);
$students_filter->where_related('participant', 'allowed', 1);
$students_filter->where_related('participant/group', 'id', (int) $group->id);
$solutions_filter = new Solution();
$solutions_filter->select('id');
$solutions_filter->where_in_subquery('student_id', $students_filter);
$task_sets_out_of_group = new Task_set();
$task_sets_out_of_group->select('id');
$task_sets_out_of_group->where_in_subquery('id', $solutions_filter);
$task_sets_out_of_group->where('published', 1);
$task_sets_out_of_group->get();
$task_sets_out_of_group_ids = $task_sets_out_of_group->all_to_single_array('id');
$task_sets_out_of_group_ids[] = 0;
}
$content_type_task_set = new Task_set();
$content_type_task_set->select('id, name, content_type, group_id, task_set_type_id');
$content_type_task_set->include_related('task_set_type', 'name');
$content_type_task_set->include_related('group', 'name');
$content_type_task_set->where('content_type', 'task_set');
$content_type_task_set->where('published', 1);
$content_type_task_set->where_related_course($course);
$content_type_task_set->order_by_related_with_constant('task_set_type', 'name', 'asc');
$content_type_task_set->order_by('task_set_type_id', 'asc');
$content_type_task_set->order_by('publish_start_time', 'asc');
if ($group->exists()) {
$content_type_task_set->group_start();
$content_type_task_set->group_start('', 'OR ');
$content_type_task_set->group_start();
$content_type_task_set->or_where('group_id', NULL);
$content_type_task_set->or_where('group_id', (int) $group_id);
$content_type_task_set->group_end();
$content_type_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)');
$content_type_task_set->group_end();
$content_type_task_set->group_start('', 'OR ');
$content_type_task_set->where_related('task_set_permission', 'group_id', (int) $group_id);
$content_type_task_set->where_related('task_set_permission', 'enabled', 1);
$content_type_task_set->group_end();
$content_type_task_set->or_where_in('id', $task_sets_out_of_group_ids);
$content_type_task_set->group_end();
}
$content_type_task_set->get();
$header_items = array();
if ($content_type_task_set->result_count() > 0) {
$last_task_set_type_id = NULL;
foreach ($content_type_task_set->all as $task_set) {
$permissions = new Task_set_permission();
$permissions->select('id, group_id');
$permissions->include_related('group', 'name');
$permissions->where_related_task_set($task_set);
$permissions->where('enabled', 1);
$permissions->get_iterated();
if ($permissions->result_count() > 0) {
$group_ids = array();
$group_names = array();
foreach ($permissions as $permission) {
$group_ids[] = $permission->group_id;
$group_names[] = $this->lang->text($permission->group_name);
}
$task_sets_data[$task_set->id] = array('group_id' => $group_ids, 'group_name' => $group_names);
} else {
$task_sets_data[$task_set->id] = array('group_id' => array($task_set->group_id), 'group_name' => $this->lang->text($task_set->group_name));
}
if ($task_set->task_set_type_id !== $last_task_set_type_id) {
$last_task_set_type_id = $task_set->task_set_type_id;
$header_items[] = array('type' => 'task_set_type', 'id' => $task_set->task_set_type_id, 'name' => $this->lang->text($task_set->task_set_type_name), 'title' => '');
}
if (!$condensed) {
$header_items[] = array('type' => 'task_set', 'id' => $task_set->id, 'name' => $this->lang->get_overlay_with_default('task_sets', $task_set->id, 'name', $task_set->name), 'title' => is_array($task_sets_data[$task_set->id]['group_name']) ? implode(', ', $task_sets_data[$task_set->id]['group_name']) : $task_sets_data[$task_set->id]['group_name']);
}
$task_sets_ids[] = $task_set->id;
}
}
$table_data['header']['content_type_task_set'] = array('content_type_name' => $this->lang->line('admin_solutions_valuation_tables_header_content_type_task_sets'), 'items' => $header_items);
$content_type_project = new Task_set();
$content_type_project->where('content_type', 'project');
//.........这里部分代码省略.........
示例7: edit
public function edit()
{
$this->_select_teacher_menu_pagetag('task_sets');
$url = $this->uri->ruri_to_assoc(3);
$task_set_id = isset($url['task_set_id']) ? intval($url['task_set_id']) : intval($this->input->post('task_set_id'));
$task_set = new Task_set();
$task_set->get_by_id($task_set_id);
$ps_data = array();
$nps_data = array();
if ($task_set->exists() && $task_set->content_type == 'project') {
$project_selections = new Project_selection();
$project_selections->select('*');
$project_selections->include_related('student', array('fullname', 'email'));
$project_selections->where_related($task_set);
$project_selections->include_related('task', 'name');
$project_selections->include_related('task/task_set', 'id');
$project_selections->where_related('task/task_set', 'id', $task_set->id);
$project_selections->order_by('task_task_task_set_rel.sorting', 'ASC');
$project_selections->order_by_related_as_fullname('student', 'fullname', 'asc');
$project_selections->get();
if ($project_selections->exists()) {
foreach ($project_selections->all as $project_selection) {
$ps_data[$project_selection->task_id][] = $project_selection;
}
}
$project_selections->select_func('COUNT', '@id', 'count');
$project_selections->where('task_set_id', 'participant_course_task_sets.id', false);
$project_selections->where_related('student', 'id', '${parent}.id');
$students = new Student();
$students->where_related('participant/course/task_set', $task_set);
$students->where_related('participant', 'allowed', 1);
$students->where_subquery(0, $project_selections);
$students->order_by_as_fullname('fullname', 'asc');
$students->get();
if ($students->exists()) {
$nps_data = $students->all;
}
}
$this->_add_tinymce4();
$this->parser->add_js_file('jquery.activeform.js');
$this->parser->add_js_file('admin_task_sets/edit.js');
$this->parser->add_js_file('admin_task_sets/form.js');
$this->parser->add_css_file('admin_task_sets.css');
$this->inject_courses();
$this->inject_languages();
$this->inject_test_types();
$this->inject_course_groups();
$this->inject_course_group_rooms();
$this->inject_course_task_set_types();
$this->parser->parse('backend/task_sets/edit.tpl', array('task_set' => $task_set, 'project_selections' => $ps_data, 'not_project_selections' => $nps_data));
}
示例8: task
public function task($task_set_id_url = NULL, $task_id_url = NULL)
{
$this->_add_mathjax();
$task_set_id = url_get_id($task_set_id_url);
$task_id = url_get_id($task_id_url);
$this->_initialize_student_menu();
$this->_select_student_menu_pagetag('projects');
$this->parser->add_css_file('frontend_projects.css');
$this->parser->add_js_file('projects/task.js');
$this->_add_prettify();
$this->_add_jquery_countdown();
$this->parser->assign('max_filesize', compute_size_with_unit(intval($this->config->item('maximum_solition_filesize') * 1024)));
$cache_id = $this->usermanager->get_student_cache_id('task_set_' . $task_set_id . '|task_' . $task_id);
if (!$this->_is_cache_enabled() || !$this->parser->isCached($this->parser->find_view('frontend/projects/task.tpl'), $cache_id)) {
$project_all = $this->get_task_set($task_set_id, $course, $student);
$project = $this->filter_valid_task_sets($project_all);
if ($course->exists()) {
$this->lang->init_overlays('task_sets', $project, array('name'));
$project = count($project) == 1 ? $project[0] : new Task_set();
$this->parser->assign('project', $project);
$task = $project->task;
$task->include_join_fields()->order_by('`task_task_set_rel`.`sorting`', 'asc');
$task->get_by_id($task_id);
$project_selection = new Project_selection();
$project_selection->where('task_set_id', $project->id);
$project_selection->where('student_id', $this->usermanager->get_student_id());
$project_selection->where('task_id', $task->id);
$project_selection->get();
$students = new Student();
$students->where_related('project_selection', 'task_set_id', $project->id);
$students->where_related('project_selection', 'task_id', $task->id);
$students->get_iterated();
$solution_versions = new Solution_version();
$solution_versions->where_related('solution/task_set', 'id', $task_set_id);
$solution_versions->where_related('solution', 'student_id', $this->usermanager->get_student_id());
$query = $solution_versions->get_raw();
$versions_metadata = array();
if ($query->num_rows()) {
foreach ($query->result() as $row) {
$versions_metadata[$row->version] = clone $row;
}
}
$query->free_result();
$this->parser->assign('task', $task);
$this->parser->assign('students', $students);
$this->parser->assign('project_selection', $project_selection);
$this->parser->assign('solution_files', $project->get_student_files($student->id));
$this->parser->assign('versions_metadata', $versions_metadata);
}
$this->parser->assign(array('course' => $course));
}
$this->parser->parse('frontend/projects/task.tpl', array(), FALSE, $this->_is_cache_enabled(), $cache_id);
}