/** * This tests Sensei_Courses::get_all_course * * @since 1.8.0 */ public function testGetAllCourses() { // check if the function is there $this->assertTrue(method_exists('WooThemes_Sensei_Course', 'get_all_courses'), 'The course class get_all_courses function does not exist.'); //setup the assertion $retrieved_courses = get_posts(array('post_type' => 'course', 'posts_per_page' => 10000)); //make sure the same course were retrieved as what we just created $this->assertEquals(count($retrieved_courses), count(WooThemes_Sensei_Course::get_all_courses()), 'The number of course returned is not equal to what is actually available'); }
/** * Add the admin all lessons screen edit options. * * The fields in this function work for both quick and bulk edit. The ID attributes is used * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then * name attribute is will be used by the quick edit and submitted via standard POST. This * will use this classes save_post_meta function to save the new field data. * * @hooked quick_edit_custom_box * @hooked bulk_edit_custom_box * * @since 1.8.0 * * @param string $column_name * @param string $post_type * @return void */ public function all_lessons_edit_fields($column_name, $post_type) { // only show these options ont he lesson post type edit screen if ('lesson' != $post_type || 'lesson-course' != $column_name || !current_user_can('edit_lessons')) { return; } ?> <fieldset class="sensei-edit-field-set inline-edit-lesson"> <div class="sensei-inline-edit-col column-<?php echo $column_name; ?> "> <?php echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>'; // create a nonce field to be used as a security measure when saving the data wp_nonce_field('bulk-edit-lessons', '_edit_lessons_nonce'); wp_nonce_field('sensei-save-post-meta', 'woo_' . $this->token . '_nonce'); // unchanged option - we need this in because // the default option in bulk edit should not be empty. If it is // the user will erase data they didn't want to touch. $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --'; // //course selection // $courses = WooThemes_Sensei_Course::get_all_courses(); $course_options = array(); if (count($courses) > 0) { foreach ($courses as $course) { $course_options[$course->ID] = get_the_title($course->ID); } } //pre-append the no change option $course_options['-1'] = $no_change_text; $course_attributes = array('name' => 'lesson_course', 'id' => 'sensei-edit-lesson-course', 'class' => ' '); $course_field = Sensei_Utils::generate_drop_down('-1', $course_options, $course_attributes); echo $this->generate_all_lessons_edit_field(__('Lesson Course', 'woothemes-sensei'), $course_field); // // lesson complexity selection // $lesson_complexities = $this->lesson_complexities(); //pre-append the no change option $lesson_complexities['-1'] = $no_change_text; $complexity_dropdown_attributes = array('name' => 'lesson_complexity', 'id' => 'sensei-edit-lesson-complexity', 'class' => ' '); $complexity_filed = Sensei_Utils::generate_drop_down('-1', $lesson_complexities, $complexity_dropdown_attributes); echo $this->generate_all_lessons_edit_field(__('Lesson Complexity', 'woothemes-sensei'), $complexity_filed); ?> <h4><?php _e('Quiz Settings', 'woothemes-sensei'); ?> </h4> <?php // // Lesson require pass to complete // $pass_required_options = array('-1' => $no_change_text, '0' => __('No', 'woothemes'), '1' => __('Yes', 'woothemes')); $pass_required_select_attributes = array('name' => 'pass_required', 'id' => 'sensei-edit-lesson-pass-required', 'class' => ' '); $require_pass_field = Sensei_Utils::generate_drop_down('-1', $pass_required_options, $pass_required_select_attributes, false); echo $this->generate_all_lessons_edit_field(__('Pass required', 'woothemes-sensei'), $require_pass_field); // // Quiz pass percentage // $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />'; echo $this->generate_all_lessons_edit_field(__('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field); // // Enable quiz reset button // $quiz_reset_select__options = array('-1' => $no_change_text, '0' => __('No', 'woothemes'), '1' => __('Yes', 'woothemes')); $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset'; $quiz_reset_select_attributes = array('name' => 'enable_quiz_reset', 'id' => $quiz_reset_name_id, 'class' => ' '); $quiz_reset_field = Sensei_Utils::generate_drop_down('-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false); echo $this->generate_all_lessons_edit_field(__('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field); ?> </div> </fieldset> <?php }
/** * The Template for displaying the learner profile page data. * * Override this template by copying it to yourtheme/sensei/learner-profile/learner-info.php * * @author WooThemes * @package Sensei/Templates * @version 1.0.0 */ if (!defined('ABSPATH')) { exit; } global $woothemes_sensei, $post, $current_user, $wp_query, $learner_user; // Get User Meta get_currentuserinfo(); do_action('sensei_complete_course'); ?> <article class="post"> <section id="learner-info" class="learner-info entry fix"> <?php do_action('sensei_frontend_messages'); do_action('sensei_learner_profile_info', $learner_user); if (isset($woothemes_sensei->settings->settings['learner_profile_show_courses']) && $woothemes_sensei->settings->settings['learner_profile_show_courses']) { $manage = $learner_user->ID == $current_user->ID ? true : false; do_action('sensei_before_learner_course_content', $learner_user); echo WooThemes_Sensei_Course::load_user_courses_content($learner_user, $manage); do_action('sensei_after_learner_course_content', $learner_user); } ?> </section> </article>
/** * sensei_course_archive_header function. * * @access public * @since 1.2.0 * @deprecated since 1.9.0 use WooThemes_Sensei_Course::archive_header * @return void */ function sensei_course_archive_header() { trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header '); WooThemes_Sensei_Course::archive_header('', '<header class="archive-header"><h1>', '</h1></header>'); }
/** * Content-course.php template file * * responsible for content on archive like pages. Only shows the course excerpt. * * For single course content please see single-course.php * * @author Automattic * @package Sensei * @category Templates * @version 1.9.0 */ ?> <li <?php post_class(WooThemes_Sensei_Course::get_course_loop_content_class()); ?> > <?php /** * This action runs before the sensei course content. It runs inside the sensei * content-course.php template. * * @since 1.9 * * @param integer $course_id */ do_action('sensei_course_content_before', get_the_ID()); ?>
public function add_new_learners() { $result = false; if (!isset($_POST['add_learner_submit'])) { return $result; } if (!isset($_POST['add_learner_nonce']) || !wp_verify_nonce($_POST['add_learner_nonce'], 'add_learner_to_sensei')) { return $result; } if (!isset($_POST['add_user_id']) || '' == $_POST['add_user_id'] || !isset($_POST['add_post_type']) || !isset($_POST['add_course_id']) || !isset($_POST['add_lesson_id'])) { return $result; } $post_type = $_POST['add_post_type']; $user_id = absint($_POST['add_user_id']); $course_id = absint($_POST['add_course_id']); $lesson_id = absint($_POST['add_lesson_id']); switch ($post_type) { case 'course': $result = WooThemes_Sensei_Utils::user_start_course($user_id, $course_id); // Complete each lesson if course is set to be completed if (isset($_POST['add_complete_course']) && 'yes' == $_POST['add_complete_course']) { $lesson_ids = WooThemes_Sensei_Course::course_lessons($course_id, 'any', 'ids'); foreach ($lesson_ids as $lesson_id) { WooThemes_Sensei_Utils::sensei_start_lesson($lesson_id, $user_id, true); } // Updates the Course status and it's meta data WooThemes_Sensei_Utils::user_complete_course($course_id, $user_id); do_action('sensei_user_course_end', $user_id, $course_id); } break; case 'lesson': $complete = false; if (isset($_POST['add_complete_lesson']) && 'yes' == $_POST['add_complete_lesson']) { $complete = true; } $result = WooThemes_Sensei_Utils::sensei_start_lesson($lesson_id, $user_id, $complete); // Updates the Course status and it's meta data WooThemes_Sensei_Utils::user_complete_course($course_id, $user_id); break; } // Set redirect URL after adding user to course/lesson $query_args = array('page' => $this->page_slug, 'view' => 'learners'); if ($result) { if ($course_id) { $query_args['course_id'] = $course_id; } if ($lesson_id) { $query_args['lesson_id'] = $lesson_id; } $query_args['message'] = 'success'; } else { $query_args['message'] = 'error'; } $redirect_url = apply_filters('sensei_learners_add_learner_redirect_url', add_query_arg($query_args, admin_url('admin.php'))); wp_safe_redirect($redirect_url); exit; }