当前位置: 首页>>代码示例>>PHP>>正文


PHP Participant::count方法代码示例

本文整理汇总了PHP中Participant::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Participant::count方法的具体用法?PHP Participant::count怎么用?PHP Participant::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Participant的用法示例。


在下文中一共展示了Participant::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: select_group

 public function select_group()
 {
     $group_id = $this->input->post('group_id');
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $group = new Group();
     $group->get_by_id($group_id);
     if ($group->exists()) {
         $course = $group->course->get();
         if (is_null($course->groups_change_deadline) || date('U', strtotime($course->groups_change_deadline)) >= time()) {
             $student = new Student();
             $student->get_by_id($this->usermanager->get_student_id());
             if ($student->is_related_to('active_course', $course->id)) {
                 $participant = new Participant();
                 $participant->where_related($student);
                 $participant->where_related($course);
                 $participant->where('allowed', 1);
                 $participant->get();
                 if ($participant->exists()) {
                     if (!$participant->is_related_to($group)) {
                         $participant->save($group);
                         $participant->where_related($course);
                         $participant->where_related($group);
                         $participant->where('allowed', 1);
                         $participants_count = $participant->count();
                         $room = new Room();
                         $room->where_related($group)->order_by('capacity', 'asc')->limit(1)->get();
                         if ($participants_count > intval($room->capacity)) {
                             $this->db->trans_rollback();
                             $this->messages->add_message('lang:groups_message_group_is_full', Messages::MESSAGE_TYPE_ERROR);
                         } else {
                             $this->db->trans_commit();
                             $this->messages->add_message(sprintf($this->lang->line('groups_message_group_changed'), $this->lang->text($group->name)), Messages::MESSAGE_TYPE_SUCCESS);
                             $this->_action_success();
                             $this->output->set_internal_value('course_id', $participant->course_id);
                         }
                     } else {
                         $this->db->trans_rollback();
                         $this->messages->add_message('lang:groups_message_you_are_in_group', Messages::MESSAGE_TYPE_ERROR);
                     }
                 } else {
                     $this->db->trans_rollback();
                     $this->messages->add_message('lang:groups_message_cant_found_participant_record', Messages::MESSAGE_TYPE_ERROR);
                 }
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:groups_message_cant_change_group_of_inactive_course', Messages::MESSAGE_TYPE_ERROR);
             }
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:groups_message_groups_switching_disabled', Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->db->trans_rollback();
         $this->messages->add_message('lang:groups_message_group_not_found', Messages::MESSAGE_TYPE_ERROR);
     }
     redirect(create_internal_url('groups'));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:58,代码来源:groups.php

示例2: participants

 /**
  * @before _secure, changeLayout, _admin
  */
 public function participants()
 {
     $this->seo(array("title" => "Game Participants", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $limit = RequestMethods::get("limit", 10);
     $page = RequestMethods::get("page", 1);
     $participants = Participant::all(array(), array("*"), "created", "desc", $limit, $page);
     $count = Participant::count();
     $view->set("participants", $participants);
     $view->set("count", $count);
     $view->set("limit", $limit);
     $view->set("page", $page);
 }
开发者ID:SwiftDeal,项目名称:fbfunapp,代码行数:16,代码来源:game.php

示例3: signup_to_course

 public function signup_to_course($course_id)
 {
     $this->output->set_content_type('application/json');
     $output = new stdClass();
     $output->status = FALSE;
     $output->message = '';
     $output->content = '';
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $student = new Student();
     $student->get_by_id($this->usermanager->get_student_id());
     $course = new Course();
     $course->where('hide_in_lists', 0);
     $course->get_by_id($course_id);
     if ($course->exists()) {
         if ($course->is_subscription_allowed()) {
             if ($student->participant->where_related($course)->count() == 0) {
                 if ($course->auto_accept_students == 1) {
                     $participants = new Participant();
                     $participants->where_related_course($course);
                     $participants->where('allowed', 1);
                     $participants_count = $participants->count();
                     if ($participants_count >= (int) $course->capacity) {
                         $output->message = $this->lang->line('courses_message_course_is_full');
                         $output->status = FALSE;
                         $this->db->trans_rollback();
                     } else {
                         $participant = new Participant();
                         $participant->allowed = 1;
                         $participant->save(array($student, $course));
                         $this->db->trans_commit();
                         $output->message = sprintf($this->lang->line('courses_message_signed_up_for_course_approved'), $this->lang->text($course->name));
                         $this->parser->assign('course', $course);
                         $output->content = $this->parser->parse('frontend/courses/single_course.tpl', array(), TRUE);
                         $output->status = TRUE;
                         $this->_action_success();
                     }
                 } else {
                     $participant = new Participant();
                     $participant->allowed = 0;
                     $participant->save(array($student, $course));
                     $this->db->trans_commit();
                     $output->message = sprintf($this->lang->line('courses_message_signed_up_for_course'), $this->lang->text($course->name));
                     $this->parser->assign('course', $course);
                     $output->content = $this->parser->parse('frontend/courses/single_course.tpl', array(), TRUE);
                     $output->status = TRUE;
                     $this->_action_success();
                 }
             } else {
                 $output->message = $this->lang->line('courses_message_already_in_course_or_waiting_for_approwal');
                 $this->db->trans_rollback();
             }
         } else {
             $output->message = $this->lang->line('courses_message_subscription_disallowed');
             $this->db->trans_rollback();
         }
     } else {
         $output->message = $this->lang->line('courses_message_course_not_found');
         $this->db->trans_rollback();
     }
     $this->output->set_output(json_encode($output));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:62,代码来源:courses.php

示例4: import_single_line


//.........这里部分代码省略.........
             $this->load->library('form_validation');
             if ($this->form_validation->valid_email(trim($email))) {
                 $student->email = trim($email);
                 $student->fullname = $student_fullname;
                 $password = '';
                 if ($options['password_type'] == 'default') {
                     $password = $this->config->item('student_import_default_password');
                 } elseif ($options['password_type'] == 'random') {
                     $password = md5(base64_encode(rand(0, 99999999999) . time() . $student->fullname . $student->email) . $this->config->item('encryption_key'));
                     $password = substr($password, 0, rand(6, 20));
                 }
                 $student->password = $password != '' ? sha1($password) : '';
                 $student->language = $this->config->item('language');
                 if ($student->save()) {
                     $this->parser->assign('password', $password);
                     $this->db->trans_commit();
                     $this->parser->assign('success_message', 'lang:admin_students_csv_import_successfully_imported');
                     if ((bool) $options['send_mail']) {
                         if ($password == '') {
                             $this->_transaction_isolation();
                             $this->db->trans_begin();
                             $student->generate_random_password_token();
                             $this->db->trans_commit();
                         }
                         $this->_init_language_for_student($student);
                         $this->load->library('email');
                         $this->email->from_system();
                         $this->email->to($student->email);
                         $this->email->subject($this->lang->line('admin_students_csv_import_email_subject'));
                         $this->email->build_message_body('file:emails/backend/students/csv_import_email.tpl', array('student' => $student, 'password' => $password));
                         $sent = $this->email->send();
                         $this->_init_language_for_teacher();
                         if ($sent) {
                             $this->parser->assign('email_success_message', 'lang:admin_students_csv_import_email_sent_successfully');
                         } else {
                             $this->parser->assign('email_error_message', 'lang:admin_students_csv_import_email_sent_failed');
                         }
                     }
                 } else {
                     $this->db->trans_rollback();
                     $this->parser->assign('error_message', 'lang:admin_students_csv_import_error_message_student_save_error');
                 }
             } else {
                 $this->db->trans_rollback();
                 $this->parser->assign('error_message', 'lang:admin_students_csv_import_error_message_student_email_invalid');
             }
         }
         if ($student->exists()) {
             $this->parser->assign('student_id', $student->id);
             if (intval($options['assign_to_course']) > 0) {
                 $this->_transaction_isolation();
                 $this->db->trans_begin();
                 $course = new Course();
                 $course->get_by_id(intval($options['assign_to_course']));
                 if ($course->exists()) {
                     $participant = new Participant();
                     $participant->where_related('student', 'id', $student->id);
                     $participant->where_related('course', 'id', $course->id);
                     $participant->get();
                     if (!$participant->exists()) {
                         $participant->allowed = 0;
                         if ($participant->save(array('student' => $student, 'course' => $course))) {
                             $this->db->trans_commit();
                             $this->parser->assign('course_assignment_success_message', 'lang:admin_students_csv_import_successfully_added_course_participation');
                             $this->db->trans_begin();
                             $course = new Course();
                             $course->get_by_id(intval($options['assign_to_course']));
                             $participant->allowed = 1;
                             $participant->save();
                             $participants = new Participant();
                             $participants->where_related($course);
                             $participants->where('allowed', 1);
                             $participants_count = $participants->count();
                             if ($participants_count <= $course->capacity) {
                                 $this->db->trans_commit();
                                 $this->parser->assign('course_assignment_approwal_success_message', 'lang:admin_students_csv_import_successfully_added_course_participation_approwal');
                             } else {
                                 $this->db->trans_rollback();
                                 $this->parser->assign('course_assignment_approwal_error_message', 'lang:admin_students_csv_import_error_message_added_course_participation_approwal');
                             }
                         } else {
                             $this->db->trans_rollback();
                             $this->parser->assign('course_assignment_error_message', 'lang:admin_students_csv_import_error_message_participation_save_failed');
                         }
                     } else {
                         $this->db->trans_rollback();
                         $this->parser->assign('course_assignment_error_message', 'lang:admin_students_csv_import_error_message_already_in_course');
                     }
                 } else {
                     $this->db->trans_rollback();
                     $this->parser->assign('course_assignment_error_message', 'lang:admin_students_csv_import_error_message_course_not_found');
                 }
             }
         }
     } else {
         $this->parser->assign('error_message', 'lang:admin_students_csv_import_error_message_nothing_to_import');
     }
     $html = $this->parser->parse('backend/students/import_single_line.tpl', array(), TRUE);
     $this->output->set_output(json_encode($html));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:101,代码来源:students.php


注:本文中的Participant::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。