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


PHP Student::enroll_in_course方法代码示例

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


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

示例1: listen_for_paid_status_changes_for_courses_2pt0

 public static function listen_for_paid_status_changes_for_courses_2pt0($order)
 {
     global $mp;
     $products = array_keys($order->mp_cart_info);
     $student = new Student($order->post_author);
     foreach ($products as $product_id) {
         $course_id = Course::get_course_id_by_marketpress_product_id($product_id);
         if (!empty($course_id)) {
             $student->enroll_in_course($course_id);
         }
     }
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:12,代码来源:class.marketpress-integration.php

示例2: extract

 /**
  * Shows the course join button.
  *
  * @since 1.0.0
  */
 function course_join_button($atts)
 {
     global $coursepress;
     extract(shortcode_atts(array('course_id' => in_the_loop() ? get_the_ID() : '', 'course' => false, 'course_full_text' => __('Course Full', 'cp'), 'course_expired_text' => __('Not available', 'cp'), 'enrollment_finished_text' => __('Enrollments Finished', 'cp'), 'enrollment_closed_text' => __('Enrollments Closed', 'cp'), 'enroll_text' => __('Enroll now', 'cp'), 'signup_text' => __('Signup!', 'cp'), 'details_text' => __('Details', 'cp'), 'prerequisite_text' => __('Pre-requisite Required', 'cp'), 'passcode_text' => __('Passcode Required', 'cp'), 'not_started_text' => __('Not Available', 'cp'), 'access_text' => __('Start Learning', 'cp'), 'continue_learning_text' => __('Continue Learning', 'cp'), 'list_page' => false, 'class' => ''), $atts, 'course_join_button'));
     $course_id = (int) $course_id;
     $list_page = sanitize_text_field($list_page);
     $list_page = "true" == $list_page || 1 == (int) $list_page ? true : false;
     $class = sanitize_html_class($class);
     global $enrollment_process_url, $signup_url;
     // Saves some overhead by not loading the post again if we don't need to.
     $course = empty($course) ? new Course($course_id) : object_decode($course, 'Course');
     $student = false;
     $course->enrollment_details();
     $button = '';
     $button_option = '';
     $button_url = $enrollment_process_url;
     $is_form = false;
     $buttons = apply_filters('coursepress_course_enrollment_button_options', array('full' => array('label' => sanitize_text_field($course_full_text), 'attr' => array('class' => 'apply-button apply-button-full ' . $class), 'type' => 'label'), 'expired' => array('label' => sanitize_text_field($course_expired_text), 'attr' => array('class' => 'apply-button apply-button-finished ' . $class), 'type' => 'label'), 'enrollment_finished' => array('label' => sanitize_text_field($enrollment_finished_text), 'attr' => array('class' => 'apply-button apply-button-enrollment-finished ' . $class), 'type' => 'label'), 'enrollment_closed' => array('label' => sanitize_text_field($enrollment_closed_text), 'attr' => array('class' => 'apply-button apply-button-enrollment-closed ' . $class), 'type' => 'label'), 'enroll' => array('label' => sanitize_text_field($enroll_text), 'attr' => array('class' => 'apply-button enroll ' . $class, 'data-link-old' => esc_url($signup_url . '?course_id=' . $course_id), 'data-course-id' => $course_id), 'type' => 'form_button'), 'signup' => array('label' => sanitize_text_field($signup_text), 'attr' => array('class' => 'apply-button signup ' . $class, 'data-link-old' => esc_url($signup_url . '?course_id=' . $course_id), 'data-course-id' => $course_id), 'type' => 'form_button'), 'details' => array('label' => sanitize_text_field($details_text), 'attr' => array('class' => 'apply-button apply-button-details ' . $class, 'data-link' => esc_url(get_permalink($course_id))), 'type' => 'button'), 'prerequisite' => array('label' => sanitize_text_field($prerequisite_text), 'attr' => array('class' => 'apply-button apply-button-prerequisite ' . $class), 'type' => 'label'), 'passcode' => array('label' => sanitize_text_field($passcode_text), 'button_pre' => '<div class="passcode-box"><label>' . esc_html($passcode_text) . ' <input type="password" name="passcode" /></label></div>', 'attr' => array('class' => 'apply-button apply-button-passcode ' . $class), 'type' => 'form_submit'), 'not_started' => array('label' => sanitize_text_field($not_started_text), 'attr' => array('class' => 'apply-button apply-button-not-started  ' . $class), 'type' => 'label'), 'access' => array('label' => sanitize_text_field($access_text), 'attr' => array('class' => 'apply-button apply-button-enrolled apply-button-first-time ' . $class, 'data-link' => esc_url(trailingslashit(get_permalink($course_id)) . trailingslashit(CoursePress::instance()->get_units_slug()))), 'type' => 'button'), 'continue' => array('label' => sanitize_text_field($continue_learning_text), 'attr' => array('class' => 'apply-button apply-button-enrolled ' . $class, 'data-link' => esc_url(trailingslashit(get_permalink($course_id)) . trailingslashit(CoursePress::instance()->get_units_slug()))), 'type' => 'button')));
     if (is_user_logged_in()) {
         $student = new Student(get_current_user_id());
         $student->enrolled = $student->user_enrolled_in_course($course_id);
     }
     // Determine the button option
     if (empty($student) || !$student->enrolled) {
         // For vistors and non-enrolled students
         if ($course->full) {
             // COURSE FULL
             $button_option = 'full';
         } elseif ($course->course_expired && !$course->open_ended_course) {
             // COURSE EXPIRED
             $button_option = 'expired';
         } elseif (!$course->enrollment_started && !$course->open_ended_enrollment && !$course->enrollment_expired) {
             // ENROLMENTS NOT STARTED (CLOSED)
             $button_option = 'enrollment_closed';
         } elseif ($course->enrollment_expired && !$course->open_ended_enrollment) {
             // ENROLMENTS FINISHED
             $button_option = 'enrollment_finished';
         } elseif ('prerequisite' == $course->enroll_type) {
             // PREREQUISITE REQUIRED
             if (!empty($student)) {
                 $pre_course = !empty($course->prerequisite) ? $course->prerequisite : false;
                 $enrolled_pre = false;
                 if ($student->enroll_in_course($course->prerequisite)) {
                     $enrolled_pre = true;
                 }
                 if ($enrolled_pre && !empty($pre_course) && Student_Completion::is_course_complete(get_current_user_id(), (int) $pre_course)) {
                     $button_option = 'enroll';
                 } else {
                     $button_option = 'prerequisite';
                 }
             } else {
                 $button_option = 'prerequisite';
             }
         }
         $user_can_register = cp_user_can_register();
         if (empty($student) && $user_can_register && empty($button_option)) {
             // If the user is allowed to signup, let them sign up
             $button_option = 'signup';
         } elseif (!empty($student) && empty($button_option)) {
             // If the user is not enrolled, then see if they can enroll
             switch ($course->enroll_type) {
                 case 'anyone':
                 case 'registered':
                     $button_option = 'enroll';
                     break;
                 case 'passcode':
                     $button_option = 'passcode';
                     break;
                 case 'prerequisite':
                     $pre_course = !empty($course->prerequisite) ? $course->prerequisite : false;
                     $enrolled_pre = false;
                     if ($student->enroll_in_course($course->prerequisite)) {
                         //								$pre_course = new Course_Completion( $course->prerequisite );
                         //								$pre_course->init_student_status();
                         $enrolled_pre = true;
                     }
                     if ($enrolled_pre && !empty($pre_course) && Student_Completion::is_course_complete(get_current_user_id(), (int) $pre_course)) {
                         //							if ( !empty( $pre_course ) && $pre_course->is_course_complete() ) {
                         $button_option = 'enroll';
                     } else {
                         $button_option = 'prerequisite';
                     }
                     break;
             }
         }
     } else {
         // For already enrolled students.
         $progress = Student_Completion::calculate_course_completion(get_current_user_id(), $course_id, false);
         if ($course->course_expired && !$course->open_ended_course) {
             // COURSE EXPIRED
             $button_option = 'expired';
         } elseif (!$course->course_started && !$course->open_ended_course) {
             // COURSE HASN'T STARTED
             $button_option = 'not_started';
         } elseif (!is_single() && false === strpos($_SERVER['REQUEST_URI'], CoursePress::instance()->get_student_dashboard_slug())) {
//.........这里部分代码省略.........
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:101,代码来源:class.shortcodes.php

示例3: Student

 function woo_listen_for_paid_status_for_courses($order_id)
 {
     $wc_order = wc_get_order($order_id);
     $items = $wc_order->get_items();
     $post_customer_id = get_post_meta($order_id, '_customer_user', true);
     $student = new Student($post_customer_id);
     foreach ($items as $item) {
         $course_id = get_post_meta($item['product_id'], 'cp_course_id', true);
         if (!empty($course_id)) {
             $student->enroll_in_course($course_id);
         }
     }
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:13,代码来源:coursepress.php

示例4: enroll_for_all

function enroll_for_all($user_id)
{
    $student = new Student($user_id);
    $courses = new WP_Query(array('post_type' => 'course', 'nopaging' => true, 'status' => 'publish'));
    foreach ($courses->get_posts() as $course) {
        $student->enroll_in_course($course->ID);
    }
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:8,代码来源:functions.php

示例5: Student

            //ob_start();
            wp_redirect(admin_url('admin.php?page=course_details&tab=students&course_id=' . $course_id . '&ms=is'));
            exit;
        } else {
            //ob_start();
            wp_redirect(admin_url('admin.php?page=course_details&tab=students&course_id=' . $course_id . '&ems=wrong_email'));
            exit;
        }
    }
}
/* Enroll student or move to a different class */
if (isset($_POST['students']) && is_numeric($_POST['students'])) {
    // if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
    check_admin_referer('student_details');
    $student = new Student($_POST['students']);
    $student->enroll_in_course($course_id, $_POST['class_name']);
    wp_redirect(admin_url('admin.php?page=course_details&tab=students&course_id=' . $course_id . '&ms=as'));
    exit;
}
/* Add new course class */
if (isset($_POST['add_student_class'])) {
    check_admin_referer('add_student_class');
    if (current_user_can('manage_options') || current_user_can('coursepress_add_new_classes_cap') || current_user_can('coursepress_add_new_my_classes_cap') && $course->details->post_author == get_current_user_id()) {
        sort($_POST['course_classes']);
        $groups = $_POST['course_classes'];
        update_post_meta($course_id, 'course_classes', $groups);
    }
}
/* Delete a Class and Change student's group to Default */
if (isset($_GET['delete_class'])) {
    if (current_user_can('manage_options') || current_user_can('coursepress_delete_classes_cap') || current_user_can('coursepress_delete_my_classes_cap') && $course->details->post_author == get_current_user_id()) {
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:31,代码来源:courses-details-students.php

示例6: printf

 if ($is_paid && isset($course->details->marketpress_product) && $course->details->marketpress_product != '' && $coursepress->marketpress_active) {
     $course_price = 1;
     //forces user to purchase course / show purchase form
     $course->is_user_purchased_course($course->details->marketpress_product, get_current_user_ID());
 }
 if ($course->details->enroll_type == 'passcode') {
     if ($_POST['passcode'] != $course->details->passcode) {
         $pass_errors++;
     }
 }
 if (!$student->user_enrolled_in_course($course_id)) {
     if ($pass_errors == 0) {
         if ($course_price == 0) {
             //Course is FREE
             //Enroll student in
             if ($student->enroll_in_course($course_id)) {
                 printf(__('Congratulations, you have successfully enrolled in "%s" course! Check your %s for more info.', 'cp'), '<strong>' . $course->details->post_title . '</strong>', '<a href="' . $this->get_student_dashboard_slug(true) . '">' . __('Dashboard', 'cp') . '</a>');
             } else {
                 _e('Something went wrong during the enrollment process. Please try again later.', 'cp');
             }
         } else {
             if ($course->is_user_purchased_course($course->details->marketpress_product, get_current_user_ID())) {
                 //Enroll student in
                 if ($student->enroll_in_course($course_id)) {
                     printf(__('Congratulations, you have successfully enrolled in "%s" course! Check your %s for more info.', 'cp'), '<strong>' . $course->details->post_title . '</strong>', '<a href="' . $this->get_student_dashboard_slug(true) . '">' . __('Dashboard', 'cp') . '</a>');
                 } else {
                     _e('Something went wrong during the enrollment process. Please try again later.', 'cp');
                 }
             } else {
                 $course->show_purchase_form($course->details->marketpress_product);
             }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:31,代码来源:enrollment-process.php


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