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


PHP WooThemes_Sensei_Utils::user_completed_lesson方法代码示例

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


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

示例1: savedquest_options


//.........这里部分代码省略.........
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->ID);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->ID);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                //get the user groups
                $useringroup = new Groups_User($user->ID);
                $user_groups = $useringroup->__get('groups');
                $displayed_lessons = array();
                //declare and get module values
                $modules = Sensei()->modules->get_course_modules(intval($courseid));
                $modules_content = Sensei()->modules->course_module_content(intval($courseid));
                //echo "<pre>";
                //echo $user->user_email."<br />";
                //echo "sensei_user_course_status_message: ";
                //print_r($course_status);
                //echo "<br />";
                //echo "started_course: "."<br />";
                $course_status_info['start'][0];
                $datenow = date('Y-m-d h:i:s');
                $date1 = date_create($course_status_info['start'][0]);
                $date2 = date_create($datenow);
                $diff = date_diff($date1, $date2);
                $diftime = $diff->format("%m");
                if ($diftime < 1) {
                    $diftime = 1;
                }
                //echo "</pre>";
                //module loop per user
                foreach ($modules as $module) {
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($courseid), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . $module->term_id, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'suppress_filters' => 0);
                    $lessons = get_posts($args);
                    $num_of_lesson = count($lessons);
                    //lessson loop per user
                    foreach ($lessons as $lesson_item) {
                        $is_lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_item->ID, $user->ID);
                        if ($is_lesson_completed == 1) {
                            $lesson_completed[] = $is_lesson_completed;
                        }
                    }
                    //echo "lesson completed:". count($lesson_completed)."<br />";
                    if (count($lesson_completed) > 0) {
                        if ($num_of_lesson == count($lesson_completed)) {
                            $completed_modules_per_user[] = 1;
                            $total_module_passed[] = 1;
                            //echo "---Module completed <br />";
                        } else {
                            //echo "---Module not completed <br />";
                        }
                    } else {
                        //echo "---Module not completed <br />";
                    }
                    unset($lesson_completed);
                    unset($completed_modules_per_user);
                }
                $overaalltotal_module_passed = count($total_module_passed);
                //echo $overaalltotal_module_passed . " module being passed";
                //loop throughout the user group under a user
                if (is_array($user_groups)) {
                    foreach ($user_groups as $user_group) {
                        if ($user_group->group_id == $_POST['group']) {
                            if (!empty($user_course_status)) {
                                $modules_completed_from_groups = $user_group->description;
                                if ($modules_completed == "") {
                                    $modules_completed = $modules_completed_from_groups;
                                }
                                $num_of_module_x_difftime = $modules_completed * $diftime;
                                //echo "<br />num_of_module_x_difftime:".$num_of_module_x_difftime;
开发者ID:Ezyva2015,项目名称:opendooronline.com.au,代码行数:67,代码来源:fp-sensei-extended-function.php

示例2: course_module_content

    /**
     * Display the single course modules content
     *
     * @since 1.8.0
     * @return void
     */
    public function course_module_content()
    {
        global $post;
        $course_id = $post->ID;
        $modules = $this->get_course_modules($course_id);
        // Display each module
        foreach ($modules as $module) {
            echo '<article class="post module">';
            // module title link
            $module_url = esc_url(add_query_arg('course_id', $course_id, get_term_link($module, $this->taxonomy)));
            echo '<header><h2><a href="' . esc_url($module_url) . '">' . $module->name . '</a></h2></header>';
            echo '<section class="entry">';
            $module_progress = false;
            if (is_user_logged_in()) {
                global $current_user;
                wp_get_current_user();
                $module_progress = $this->get_user_module_progress($module->term_id, $course_id, $current_user->ID);
            }
            if ($module_progress && $module_progress > 0) {
                $status = __('Completed', 'woothemes-sensei');
                $class = 'completed';
                if ($module_progress < 100) {
                    $status = __('In progress', 'woothemes-sensei');
                    $class = 'in-progress';
                }
                echo '<p class="status module-status ' . esc_attr($class) . '">' . $status . '</p>';
            }
            if ('' != $module->description) {
                echo '<p class="module-description">' . $module->description . '</p>';
            }
            $lessons = $this->get_lessons($course_id, $module->term_id);
            if (count($lessons) > 0) {
                $lessons_list = '';
                foreach ($lessons as $lesson) {
                    $status = '';
                    $lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson->ID, get_current_user_id());
                    $title = esc_attr(get_the_title(intval($lesson->ID)));
                    if ($lesson_completed) {
                        $status = 'completed';
                    }
                    $lessons_list .= '<li class="' . $status . '"><a href="' . esc_url(get_permalink(intval($lesson->ID))) . '" title="' . esc_attr(get_the_title(intval($lesson->ID))) . '">' . apply_filters('sensei_module_lesson_list_title', $title, $lesson->ID) . '</a></li>';
                    // Build array of displayed lesson for exclusion later
                    $displayed_lessons[] = $lesson->ID;
                }
                ?>
                <section class="module-lessons">
                    <header>
                        <h3><?php 
                _e('Lessons', 'woothemes-sensei');
                ?>
</h3>
                    </header>
                    <ul>
                        <?php 
                echo $lessons_list;
                ?>
                    </ul>
                </section>

            <?php 
            }
            //end count lessons
            ?>
                </section>
            </article>
        <?php 
        }
        // end each module
    }
开发者ID:drumchannel,项目名称:drumchannel-dev,代码行数:75,代码来源:class-sensei-modules.php

示例3: sensei_has_user_completed_lesson

function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0)
{
    _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()");
    return WooThemes_Sensei_Utils::user_completed_lesson($post_id, $user_id);
}
开发者ID:TravisSperry,项目名称:mpa_website,代码行数:5,代码来源:woothemes-sensei-template.php

示例4: do_action

				<?php 
do_action('sensei_lesson_image', $post->ID);
?>

                <?php 
do_action('sensei_lesson_single_title');
?>

                <?php 
$view_lesson = true;
wp_get_current_user();
$lesson_prerequisite = absint(get_post_meta($post->ID, '_lesson_prerequisite', true));
if ($lesson_prerequisite > 0) {
    // Check for prerequisite lesson completions
    $view_lesson = WooThemes_Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID);
}
$lesson_course_id = get_post_meta($post->ID, '_lesson_course', true);
$user_taking_course = WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID);
if (current_user_can('administrator')) {
    $view_lesson = true;
    $user_taking_course = true;
}
$is_preview = false;
if (WooThemes_Sensei_Utils::is_preview_lesson($post->ID)) {
    $is_preview = true;
    $view_lesson = true;
}
if ($view_lesson) {
    ?>
开发者ID:ragulka,项目名称:sensei,代码行数:29,代码来源:content-single-lesson.php

示例5: get_completed_lesson_ids

 /**
  * Checks how many lessons are completed
  *
  * @since 1.8.0
  *
  * @param int $course_id
  * @param int $user_id
  * @return array $completed_lesson_ids
  */
 public function get_completed_lesson_ids($course_id, $user_id = 0)
 {
     if (!intval($user_id) > 0) {
         $user_id = get_current_user_id();
     }
     $completed_lesson_ids = array();
     $course_lessons = $this->course_lessons($course_id);
     foreach ($course_lessons as $lesson) {
         $is_lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson->ID, $user_id);
         if ($is_lesson_completed) {
             $completed_lesson_ids[] = $lesson->ID;
         }
     }
     return $completed_lesson_ids;
 }
开发者ID:mattytemple,项目名称:YTC-Sensei,代码行数:24,代码来源:class-woothemes-sensei-course.php

示例6: sensei_quiz_action_buttons

    public function sensei_quiz_action_buttons()
    {
        global $post, $current_user, $woothemes_sensei;
        $lesson_id = (int) get_post_meta($post->ID, '_quiz_lesson', true);
        $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true);
        $lesson_prerequisite = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
        $show_actions = true;
        $user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_id, $current_user->ID);
        //setup quiz grade
        $user_quiz_grade = '';
        if (!empty($user_lesson_status)) {
            $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
        }
        if (intval($lesson_prerequisite) > 0) {
            // If the user hasn't completed the prereq then hide the current actions
            $show_actions = WooThemes_Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID);
        }
        if ($show_actions && is_user_logged_in() && WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
            // Get Reset Settings
            $reset_quiz_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true);
            ?>

            <!-- Action Nonce's -->
            <input type="hidden" name="woothemes_sensei_complete_quiz_nonce" id="woothemes_sensei_complete_quiz_nonce"
                   value="<?php 
            echo esc_attr(wp_create_nonce('woothemes_sensei_complete_quiz_nonce'));
            ?>
" />
			<input type="hidden" name="woothemes_sensei_reset_quiz_nonce" id="woothemes_sensei_reset_quiz_nonce"
                   value="<?php 
            echo esc_attr(wp_create_nonce('woothemes_sensei_reset_quiz_nonce'));
            ?>
" />
            <input type="hidden" name="woothemes_sensei_save_quiz_nonce" id="woothemes_sensei_save_quiz_nonce"
                   value="<?php 
            echo esc_attr(wp_create_nonce('woothemes_sensei_save_quiz_nonce'));
            ?>
" />
            <!--#end Action Nonce's -->

            <?php 
            //if ( '' == $user_quiz_grade) {
            ?>
		 	<span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php 
            echo apply_filters('sensei_complete_quiz_text', __('Complete Quiz', 'woothemes-sensei'));
            ?>
"/></span>
		 	<span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php 
            echo apply_filters('sensei_save_quiz_text', __('Save Quiz', 'woothemes-sensei'));
            ?>
"/></span>
		     <?php 
            php;
            ?>
	          <?php 
            php;
            ?>
		 	   <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php 
            echo apply_filters('sensei_reset_quiz_text', __('Reset Quiz', 'woothemes-sensei'));
            ?>
"/></span>
		     <?php 
            php;
            ?>
        <?php 
        }
    }
开发者ID:Ezyva2015,项目名称:opendooronline.com.au,代码行数:67,代码来源:class-woothemes-sensei-frontend.php

示例7: sensei_user_quiz_status_message

 /**
  * Set the status message displayed to the user for a quiz
  * @param  integer $lesson_id ID of quiz lesson
  * @param  integer $user_id   ID of user
  * @return array              Status code and message
  */
 public static function sensei_user_quiz_status_message($lesson_id = 0, $user_id = 0, $is_lesson = false)
 {
     global $woothemes_sensei, $current_user;
     if (intval($user_id) == 0) {
         $user_id = $current_user->ID;
     }
     $status = 'not_started';
     $box_class = 'info';
     $message = __('You have not taken this lesson\'s quiz yet', 'woothemes-sensei');
     $extra = '';
     if ($lesson_id > 0 && $user_id > 0) {
         // Prerequisite lesson
         $prerequisite = get_post_meta($lesson_id, '_lesson_prerequisite', true);
         // Course ID
         $course_id = absint(get_post_meta($lesson_id, '_lesson_course', true));
         // Has user started course
         $started_course = WooThemes_Sensei_Utils::user_started_course($course_id, $user_id);
         // Has user completed lesson
         $user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_id, $user_id);
         $lesson_complete = WooThemes_Sensei_Utils::user_completed_lesson($user_lesson_status);
         // Quiz ID
         $quiz_id = $woothemes_sensei->post_types->lesson->lesson_quizzes($lesson_id);
         // Quiz grade
         $quiz_grade = false;
         if ($user_lesson_status) {
             $quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
         }
         // Quiz passmark
         $quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true));
         $quiz_passmark_float = (double) $quiz_passmark;
         // Pass required
         $pass_required = get_post_meta($quiz_id, '_pass_required', true);
         // Quiz questions
         $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
         if (!$started_course) {
             $status = 'not_started_course';
             $box_class = 'info';
             $message = sprintf(__('Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei'), '<a href="' . esc_url(get_permalink($course_id)) . '" title="' . esc_attr(__('Sign Up', 'woothemes-sensei')) . '">', '</a>');
         } elseif (!is_user_logged_in()) {
             $status = 'login_required';
             $box_class = 'info';
             $message = __('You must be logged in to take this quiz', 'woothemes-sensei');
         } elseif ($lesson_complete) {
             $status = 'passed';
             $box_class = 'tick';
             // Lesson status will be "complete" (has no Quiz)
             if (!$has_quiz_questions) {
                 $message = sprintf(__('Congratulations! You have passed this lesson.', 'woothemes-sensei'));
             } elseif (empty($quiz_grade)) {
                 $message = sprintf(__('Congratulations! You have completed this lesson.', 'woothemes-sensei'));
             } elseif (!empty($quiz_grade) && abs($quiz_grade) >= 0) {
                 if ($is_lesson) {
                     $message = sprintf(__('Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_grade));
                 } else {
                     $message = sprintf(__('Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_grade));
                 }
             }
         } else {
             // Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete)
             if (isset($user_lesson_status->comment_approved) && 'ungraded' == $user_lesson_status->comment_approved) {
                 $status = 'complete';
                 $box_class = 'info';
                 if ($is_lesson) {
                     $message = sprintf(__('You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei'), '<a href="' . esc_url(get_permalink($quiz_id)) . '" title="' . esc_attr(get_the_title($quiz_id)) . '">', '</a>');
                 } else {
                     $message = sprintf(__('You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark));
                 }
             } elseif (isset($user_lesson_status->comment_approved) && 'failed' == $user_lesson_status->comment_approved) {
                 $status = 'failed';
                 $box_class = 'alert';
                 if ($is_lesson) {
                     $message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark), WooThemes_Sensei_Utils::round($quiz_grade));
                 } else {
                     $message = sprintf(__('You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark), WooThemes_Sensei_Utils::round($quiz_grade));
                 }
             } elseif ($pass_required) {
                 $status = 'not_started';
                 $box_class = 'info';
                 if ($is_lesson) {
                     $message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark));
                 } else {
                     $message = sprintf(__('You require %1$d%% to pass this quiz.', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark));
                 }
             }
         }
     }
     // Legacy filter
     $message = apply_filters('sensei_user_quiz_status_' . $status, $message);
     if ($is_lesson && !in_array($status, array('login_required', 'not_started_course'))) {
         $extra = '<p><a class="button" href="' . esc_url(get_permalink($quiz_id)) . '" title="' . esc_attr(apply_filters('sensei_view_lesson_quiz_text', __('View the lesson quiz', 'woothemes-sensei'))) . '">' . apply_filters('sensei_view_lesson_quiz_text', __('View the lesson quiz', 'woothemes-sensei')) . '</a></p>';
     }
     // Filter of all messages
     return apply_filters('sensei_user_quiz_status', array('status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra), $lesson_id, $user_id, $is_lesson);
 }
开发者ID:grey-rsi,项目名称:sensei,代码行数:100,代码来源:class-woothemes-sensei-utils.php

示例8: sprintf

     $html .= '<span class="course-completion-rate">' . sprintf(__('Currently completed %1$s of %2$s in total', 'woothemes-sensei'), '######', $total_lessons) . '</span>';
     $html .= '<div class="meter+++++"><span style="width: @@@@@%">@@@@@%</span></div>';
 }
 // End If Statement
 $html .= '</header>';
 $lesson_count = 1;
 $lessons_completed = 0;
 $show_lesson_numbers = false;
 foreach ($course_lessons as $lesson_item) {
     $single_lesson_complete = false;
     $post_classes = array('course', 'post');
     $user_lesson_status = false;
     if (is_user_logged_in()) {
         // Check if Lesson is complete
         $user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_item->ID, $current_user->ID);
         $single_lesson_complete = WooThemes_Sensei_Utils::user_completed_lesson($user_lesson_status);
         if ($single_lesson_complete) {
             $lessons_completed++;
             $post_classes[] = 'lesson-completed';
         }
         // End If Statement
     }
     // End If Statement
     // Get Lesson data
     $complexity_array = $woothemes_sensei->post_types->lesson->lesson_complexities();
     $lesson_length = get_post_meta($lesson_item->ID, '_lesson_length', true);
     $lesson_complexity = get_post_meta($lesson_item->ID, '_lesson_complexity', true);
     if ('' != $lesson_complexity) {
         $lesson_complexity = $complexity_array[$lesson_complexity];
     }
     $user_info = get_userdata(absint($lesson_item->post_author));
开发者ID:AlecBeltrami,项目名称:sensei,代码行数:31,代码来源:course-lessons.php

示例9: load_global_quiz_data

 /**
  * This function set's up the data need for the quiz page
  *
  * This function hooks into sensei_complete_quiz and load the global data for the
  * current quiz.
  *
  * @since 1.7.4
  * @access public
  *
  */
 public function load_global_quiz_data()
 {
     global $woothemes_sensei, $post, $current_user;
     $this->data = new stdClass();
     // Default grade
     $grade = 0;
     // Get Quiz Questions
     $lesson_quiz_questions = $woothemes_sensei->post_types->lesson->lesson_quiz_questions($post->ID);
     $quiz_lesson_id = absint(get_post_meta($post->ID, '_quiz_lesson', true));
     // Get quiz grade type
     $quiz_grade_type = get_post_meta($post->ID, '_quiz_grade_type', true);
     // Get quiz pass setting
     $pass_required = get_post_meta($post->ID, '_pass_required', true);
     // Get quiz pass mark
     $quiz_passmark = abs(round(doubleval(get_post_meta($post->ID, '_quiz_passmark', true)), 2));
     // Get latest quiz answers and grades
     $lesson_id = $woothemes_sensei->quiz->get_lesson_id($post->ID);
     $user_quizzes = $woothemes_sensei->quiz->get_user_answers($lesson_id, get_current_user_id());
     $user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($quiz_lesson_id, $current_user->ID);
     $user_quiz_grade = 0;
     if (isset($user_lesson_status->comment_ID)) {
         $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
     }
     if (!is_array($user_quizzes)) {
         $user_quizzes = array();
     }
     // Check again that the lesson is complete
     $user_lesson_end = WooThemes_Sensei_Utils::user_completed_lesson($user_lesson_status);
     $user_lesson_complete = false;
     if ($user_lesson_end) {
         $user_lesson_complete = true;
     }
     // End If Statement
     $reset_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true);
     //backwards compatibility
     if ('on' == $reset_allowed) {
         $reset_allowed = 1;
     }
     // Build frontend data object
     $this->data->user_quiz_grade = $user_quiz_grade;
     $this->data->quiz_passmark = $quiz_passmark;
     $this->data->quiz_lesson = $quiz_lesson_id;
     $this->data->quiz_grade_type = $quiz_grade_type;
     $this->data->user_lesson_end = $user_lesson_end;
     $this->data->user_lesson_complete = $user_lesson_complete;
     $this->data->lesson_quiz_questions = $lesson_quiz_questions;
     $this->data->reset_quiz_allowed = $reset_allowed;
 }
开发者ID:mattytemple,项目名称:YTC-Sensei,代码行数:58,代码来源:class-woothemes-sensei-quiz.php

示例10: course_module_collapse_content

    /**
     * Display the single course modules content with Collapse/Expand Toggle
     *
     * @since 1.8.0
     * @return void
     */
    public function course_module_collapse_content()
    {
        global $post;
        $course_id = $post->ID;
        $modules = Sensei()->modules->get_course_modules($course_id);
        // Display each module
        foreach ($modules as $module) {
            echo '<article class="post module">';
            echo '<section class="entry">';
            $module_progress = false;
            if (is_user_logged_in()) {
                global $current_user;
                wp_get_current_user();
                $module_progress = Sensei()->modules->get_user_module_progress($module->term_id, $course_id, $current_user->ID);
            }
            if ($module_progress && $module_progress > 0) {
                $status = __('Completed', 'woothemes-sensei');
                $class = 'completed';
                if ($module_progress < 100) {
                    $status = __('In progress', 'woothemes-sensei');
                    $class = 'in-progress';
                }
                echo '<p class="status module-status ' . esc_attr($class) . '">' . $status . '</p>';
            }
            if ('' != $module->description) {
                echo '<p class="module-description">' . $module->description . '</p>';
            }
            $lessons = Sensei()->modules->get_lessons($course_id, $module->term_id);
            if (count($lessons) > 0) {
                $lessons_list = '';
                foreach ($lessons as $lesson) {
                    $status = '';
                    $lessons_time = '';
                    $lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson->ID, get_current_user_id());
                    $lesson_length = get_post_meta($lesson->ID, '_lesson_length', true);
                    $title = esc_attr(get_the_title(intval($lesson->ID)));
                    // Get lesson completed status
                    if ($lesson_completed) {
                        $status = 'completed';
                    }
                    // Get lesson time and set variable if it exists
                    if ('' != $lesson_length) {
                        $lessons_time = '<span style="float:right" class="lesson-length"><i class="fa fa-clock-o"></i> ' . $lesson_length . __(' min', 'woothemes-sensei') . '</span>';
                    }
                    $lessons_list .= '<li class="' . $status . '"><a href="' . esc_url(get_permalink(intval($lesson->ID))) . '" title="' . esc_attr(get_the_title(intval($lesson->ID))) . '">' . apply_filters('sensei_module_lesson_list_title', $title, $lesson->ID) . $lessons_time . '</a></li>';
                    // Build array of displayed lesson for exclusion later
                    $displayed_lessons = array();
                    $displayed_lessons[] = $lesson->ID;
                }
                ?>

                <section class="module-lessons">
                    <ul >
                        <header class="expList">
                            <?php 
                // module title header with collapsing toggle
                // Module URL commented out as it is no linger used, uncomment if you want to use it
                // $module_url = esc_url(add_query_arg('course_id', $course_id, get_term_link($module, $this->taxonomy)));
                echo "<img class='expList' src='" . $this->assets_url . "img/collapse.png' ><h2 class='expList'> " . $module->name . "</h2>";
                ?>
                        </header>
                        <li >
                            <ul class="expList2" >
                                <?php 
                echo $lessons_list;
                ?>
                            </ul>
                        </li>
                    </ul>
                </section>

            <?php 
            }
            //end count lessons
            ?>
                </section>
            </article>
        <?php 
        }
        // end each module
    }
开发者ID:jamestrevorlees,项目名称:sensei-module-collapse,代码行数:87,代码来源:class-sensei-module-collapse.php

示例11: load_user_courses_content

    /**
     * load_user_courses_content generates HTML for user's active & completed courses
     * @since  1.4.0
     * @param  object  $user   Queried user object
     * @param  boolean $manage Whether the user has permission to manage the courses
     * @return string          HTML displayng course data
     */
    public function load_user_courses_content($user = false, $manage = false)
    {
        global $woothemes_sensei, $post, $wp_query, $course, $my_courses_page, $my_courses_section;
        // Build Output HTML
        $complete_html = $active_html = '';
        if ($user) {
            $my_courses_page = true;
            // Allow action to be run before My Courses content has loaded
            do_action('sensei_before_my_courses', $user->ID);
            // Logic for Active and Completed Courses
            $per_page = 20;
            if (isset($woothemes_sensei->settings->settings['my_course_amount']) && 0 < absint($woothemes_sensei->settings->settings['my_course_amount'])) {
                $per_page = absint($woothemes_sensei->settings->settings['my_course_amount']);
            }
            $course_statuses = WooThemes_Sensei_Utils::sensei_check_for_activity(array('user_id' => $user->ID, 'type' => 'sensei_course_status'), true);
            // User may only be on 1 Course
            if (!is_array($course_statuses)) {
                $course_statuses = array($course_statuses);
            }
            $completed_ids = $active_ids = array();
            foreach ($course_statuses as $course_status) {
                if (WooThemes_Sensei_Utils::user_completed_course($course_status, $user->ID)) {
                    $completed_ids[] = $course_status->comment_post_ID;
                } else {
                    $active_ids[] = $course_status->comment_post_ID;
                }
            }
            $active_count = $completed_count = 0;
            $active_courses = array();
            if (0 < intval(count($active_ids))) {
                $my_courses_section = 'active';
                $active_courses = $woothemes_sensei->post_types->course->course_query($per_page, 'usercourses', $active_ids);
                $active_count = count($active_ids);
            }
            // End If Statement
            $completed_courses = array();
            if (0 < intval(count($completed_ids))) {
                $my_courses_section = 'completed';
                $completed_courses = $woothemes_sensei->post_types->course->course_query($per_page, 'usercourses', $completed_ids);
                $completed_count = count($completed_ids);
            }
            // End If Statement
            $lesson_count = 1;
            $active_page = 1;
            if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) {
                $active_page = $_GET['active_page'];
            }
            $completed_page = 1;
            if (isset($_GET['completed_page']) && 0 < intval($_GET['completed_page'])) {
                $completed_page = $_GET['completed_page'];
            }
            foreach ($active_courses as $course_item) {
                $course_lessons = $woothemes_sensei->post_types->course->course_lessons($course_item->ID);
                $lessons_completed = 0;
                foreach ($course_lessons as $lesson) {
                    if (WooThemes_Sensei_Utils::user_completed_lesson($lesson->ID, $user->ID)) {
                        ++$lessons_completed;
                    }
                }
                // Get Course Categories
                $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', '');
                $active_html .= '<article class="' . esc_attr(join(' ', get_post_class(array('course', 'post'), $course_item->ID))) . '">';
                // Image
                $active_html .= $woothemes_sensei->post_types->course->course_image(absint($course_item->ID));
                // Title
                $active_html .= '<header>';
                $active_html .= '<h2><a href="' . esc_url(get_permalink(absint($course_item->ID))) . '" title="' . esc_attr($course_item->post_title) . '">' . esc_html($course_item->post_title) . '</a></h2>';
                $active_html .= '</header>';
                $active_html .= '<section class="entry">';
                $active_html .= '<p class="sensei-course-meta">';
                // Author
                $user_info = get_userdata(absint($course_item->post_author));
                if (isset($woothemes_sensei->settings->settings['course_author']) && $woothemes_sensei->settings->settings['course_author']) {
                    $active_html .= '<span class="course-author">' . __('by ', 'woothemes-sensei') . '<a href="' . esc_url(get_author_posts_url(absint($course_item->post_author))) . '" title="' . esc_attr($user_info->display_name) . '">' . esc_html($user_info->display_name) . '</a></span>';
                }
                // End If Statement
                // Lesson count for this author
                $lesson_count = $woothemes_sensei->post_types->course->course_lesson_count(absint($course_item->ID));
                // Handle Division by Zero
                if (0 == $lesson_count) {
                    $lesson_count = 1;
                }
                // End If Statement
                $active_html .= '<span class="course-lesson-count">' . $lesson_count . '&nbsp;' . apply_filters('sensei_lessons_text', __('Lessons', 'woothemes-sensei')) . '</span>';
                // Course Categories
                if ('' != $category_output) {
                    $active_html .= '<span class="course-category">' . sprintf(__('in %s', 'woothemes-sensei'), $category_output) . '</span>';
                }
                // End If Statement
                $active_html .= '<span class="course-lesson-progress">' . sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count) . '</span>';
                $active_html .= '</p>';
                $active_html .= '<p class="course-excerpt">' . apply_filters('get_the_excerpt', $course_item->post_excerpt) . '</p>';
                $progress_percentage = abs(round(doubleval($lessons_completed) * 100 / $lesson_count, 0));
//.........这里部分代码省略.........
开发者ID:AlecBeltrami,项目名称:sensei,代码行数:101,代码来源:class-woothemes-sensei-course.php

示例12: widget


//.........这里部分代码省略.........

		<?php 
        $nav_id_array = sensei_get_prev_next_lessons($current_lesson_id);
        $previous_lesson_id = absint($nav_id_array['prev_lesson']);
        $next_lesson_id = absint($nav_id_array['next_lesson']);
        if (0 < $previous_lesson_id || 0 < $next_lesson_id) {
            ?>

			<ul class="course-progress-navigation">
				<?php 
            if (0 < $previous_lesson_id) {
                ?>
<li class="prev"><a href="<?php 
                echo esc_url(get_permalink($previous_lesson_id));
                ?>
" title="<?php 
                echo get_the_title($previous_lesson_id);
                ?>
"><span><?php 
                _e('Previous', 'sensei-course-progress');
                ?>
</span></a></li><?php 
            }
            ?>
				<?php 
            if (0 < $next_lesson_id) {
                ?>
<li class="next"><a href="<?php 
                echo esc_url(get_permalink($next_lesson_id));
                ?>
" title="<?php 
                echo get_the_title($next_lesson_id);
                ?>
"><span><?php 
                _e('Next', 'sensei-course-progress');
                ?>
</span></a></li><?php 
            }
            ?>
			</ul>

		<?php 
        }
        ?>

		<ul class="course-progress-lessons">

			<?php 
        $old_module = '';
        foreach ($lesson_array as $lesson) {
            $lesson_id = $lesson->ID;
            $lesson_title = htmlspecialchars($lesson->post_title);
            $lesson_url = get_the_permalink($lesson_id);
            // add 'completed' class to completed lessons
            $classes = "not-completed";
            if (WooThemes_Sensei_Utils::user_completed_lesson($lesson->ID, $current_user->ID)) {
                $classes = "completed";
            }
            // Lesson Quiz Meta
            $lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
            // add 'current' class on the current lesson/quiz
            if ($lesson_id == $post->ID || $lesson_quiz_id == $post->ID) {
                $classes .= " current";
            }
            if (isset(Sensei()->modules) && 'on' == $allmodules) {
                $new_module = Sensei()->modules->get_lesson_module($lesson_id);
                if ($old_module != $new_module) {
                    ?>
						<li class="course-progress-module"><h3><?php 
                    echo $new_module->name;
                    ?>
</h3></li>
						<?php 
                    $old_module = $new_module;
                }
            }
            ?>

				<li class="course-progress-lesson <?php 
            echo $classes;
            ?>
">
					<?php 
            if ($lesson->ID == $post->ID || $lesson_quiz_id == $post->ID) {
                echo '<span>' . $lesson_title . '</span>';
            } else {
                echo '<a href="' . $lesson_url . '">' . $lesson_title . '</a>';
            }
            ?>
				</li>

			<?php 
        }
        ?>

		</ul>

		<?php 
        echo $after_widget;
    }
开发者ID:mslinnea,项目名称:sensei-course-progress,代码行数:101,代码来源:class-sensei-course-progress-widget.php

示例13: savedquest_options


//.........这里部分代码省略.........
                $completionpermonth = groups_get_groupmeta($group_id, 'sensei_threshold', true);
            }
            /* echo "<pre>";
            
            			print_r($userincourse);
            
            			echo "</pre>";
            
            			echo "<pre>";
            
            			print_r($user_in_groups);
            
            			echo "</pre>";	 */
            $user_in_groups = $wpdb->get_results($wpdb->prepare("SELECT user_id FROM wp_bp_groups_members WHERE group_id = %d", $group_id));
            //user loop ----- loop user get the groups and course the course they take
            foreach ($user_in_groups as $user) {
                //echo "user_id ".$user->user_id."<br />";
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->user_id);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->user_id);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->user_id);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->user_id);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                $modules = Sensei()->modules->get_course_modules($courseid);
                //$modules_content = Sensei()->modules->course_module_content(  $courseid );
                foreach ($modules as $module) {
                    $module_id = $module->term_id;
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'module', 'field' => 'id', 'terms' => $module_id)), 'meta_query' => array(array('key' => '_lesson_course', 'value' => $courseid)), 'fields' => 'ids');
                    $lessons = get_posts($args);
                    $completed = false;
                    $lesson_count = 0;
                    $completed_count = 0;
                    foreach ($lessons as $lesson_id) {
                        $completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_id, $user->user_id);
                        ++$lesson_count;
                        if ($completed) {
                            ++$completed_count;
                        }
                    }
                    $module_progress = $completed_count / $lesson_count * 100;
                    if ($module_progress == 100) {
                        $module_passed[] = 1;
                        $module_name[] = $module->name;
                    }
                    /* 	echo "<pre>";
                    
                    						echo $module_progress;
                    
                    						echo "---<br />";
                    
                    						//print_r($modules_content);
                    
                    						echo "</pre>"; */
                }
                $course_status_info['start'][0];
                $datenow = date('Y-m-d h:i:s');
                $date1 = date_create($course_status_info['start'][0]);
                $date2 = date_create($datenow);
                $diff = date_diff($date1, $date2);
                $diftime = $diff->format("%m");
                if ($diftime < 1) {
                    $diftime = 1;
                }
                $num_of_module_x_difftime = $completionpermonth * $diftime;
                //echo "<br />num_of_module_x_difftime:".$num_of_module_x_difftime;
                //echo count($module_passed)." module passed<br />";
开发者ID:Ezyva2015,项目名称:opendooronline.com.au,代码行数:67,代码来源:functions.php

示例14: apply_filters

$html .= '<h2>' . apply_filters('sensei_lessons_text', __('Lessons', 'woothemes-sensei')) . '</h2>';
$html .= '</header>';
$lesson_count = 1;
$lessons_completed = count(Sensei()->course->get_completed_lesson_ids($post->ID, $current_user->ID));
$show_lesson_numbers = false;
foreach ($course_lessons as $lesson_item) {
    //skip lesson that are already in the modules
    if (false != Sensei()->modules->get_lesson_module($lesson_item->ID)) {
        continue;
    }
    $single_lesson_complete = false;
    $post_classes = array('course', 'post');
    $user_lesson_status = false;
    if (is_user_logged_in()) {
        // Check if Lesson is complete
        $single_lesson_complete = WooThemes_Sensei_Utils::user_completed_lesson($lesson_item->ID, $current_user->ID);
        if ($single_lesson_complete) {
            $post_classes[] = 'lesson-completed';
        }
        // End If Statement
    }
    // End If Statement
    // Get Lesson data
    $complexity_array = $woothemes_sensei->post_types->lesson->lesson_complexities();
    $lesson_length = get_post_meta($lesson_item->ID, '_lesson_length', true);
    $lesson_complexity = get_post_meta($lesson_item->ID, '_lesson_complexity', true);
    if ('' != $lesson_complexity) {
        $lesson_complexity = $complexity_array[$lesson_complexity];
    }
    $user_info = get_userdata(absint($lesson_item->post_author));
    $is_preview = WooThemes_Sensei_Utils::is_preview_lesson($lesson_item->ID);
开发者ID:drumchannel,项目名称:drumchannel-dev,代码行数:31,代码来源:course-lessons.php

示例15: sensei_quiz_action_buttons

    public function sensei_quiz_action_buttons()
    {
        global $post, $current_user, $woothemes_sensei;
        $lesson_id = (int) get_post_meta($post->ID, '_quiz_lesson', true);
        $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true);
        $lesson_prerequisite = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
        $show_actions = true;
        if (intval($lesson_prerequisite) > 0) {
            // If the user hasn't completed the prereq then hide the current actions
            $show_actions = WooThemes_Sensei_Utils::user_completed_lesson($lesson_prerequisite, $user_id);
        }
        if ($show_actions && is_user_logged_in() && WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
            // Get Reset Settings
            $reset_quiz_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true);
            ?>
			<input type="hidden" name="<?php 
            echo esc_attr('woothemes_sensei_complete_quiz_noonce');
            ?>
" id="<?php 
            echo esc_attr('woothemes_sensei_complete_quiz_noonce');
            ?>
" value="<?php 
            echo esc_attr(wp_create_nonce('woothemes_sensei_complete_quiz_noonce'));
            ?>
" />
		    <?php 
            if ('' == $this->data->user_quiz_grade) {
                ?>
		 	<span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php 
                echo apply_filters('sensei_complete_quiz_text', __('Complete Quiz', 'woothemes-sensei'));
                ?>
"/></span>
		 	<span><input type="submit" name="quiz_complete" class="quiz-submit save" value="<?php 
                echo apply_filters('sensei_save_quiz_text', __('Save Quiz', 'woothemes-sensei'));
                ?>
"/></span>
		     <?php 
            }
            // End If Statement
            ?>
	          <?php 
            if (isset($reset_quiz_allowed) && $reset_quiz_allowed) {
                ?>
		 	   <span><input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php 
                echo apply_filters('sensei_reset_quiz_text', __('Reset Quiz', 'woothemes-sensei'));
                ?>
"/></span>
		     <?php 
            }
            ?>
        <?php 
        }
    }
开发者ID:AlecBeltrami,项目名称:sensei,代码行数:53,代码来源:class-woothemes-sensei-frontend.php


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