コード例 #1
0
function bp_get_course_check_course_complete($args = NULL)
{
    // AUTO EVALUATION FOR COURSE
    global $post;
    $defaults = array('id' => $post->ID, 'user_id' => get_current_user_id());
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $return = '<div class="course_finish">';
    $course_curriculum = bp_course_get_curriculum_units($id);
    //vibe_sanitize(get_post_meta($id,'vibe_course_curriculum',false));
    if (isset($course_curriculum) && count($course_curriculum)) {
        $flag = 0;
        foreach ($course_curriculum as $unit_id) {
            //if(is_numeric($unit_id)){
            $unittaken = get_user_meta($user_id, $unit_id, true);
            if (!isset($unittaken) || !$unittaken) {
                $flag = $unit_id;
                break;
            }
            //}
        }
        $flag = apply_filters('wplms_finish_course_check', $flag, $course_curriculum);
        if (!$flag) {
            $course_id = $id;
            $auto_eval = get_post_meta($id, 'vibe_course_auto_eval', true);
            if (vibe_validate($auto_eval)) {
                // AUTO EVALUATION
                $curriculum = bp_course_get_curriculum_units($id);
                //vibe_sanitize(get_post_meta($id,'vibe_course_curriculum',false));
                $total_marks = $student_marks = 0;
                foreach ($curriculum as $c) {
                    if (is_numeric($c)) {
                        if (get_post_type($c) == 'quiz') {
                            $k = get_post_meta($c, $user_id, true);
                            $student_marks += $k;
                            //Current user is the Student here
                            $questions = vibe_sanitize(get_post_meta($c, 'quiz_questions' . $user_id, false));
                            if (!isset($questions) || !is_array($questions)) {
                                $questions = vibe_sanitize(get_post_meta($c, 'vibe_quiz_questions', false));
                            }
                            $total_marks += array_sum($questions['marks']);
                        }
                    }
                }
                do_action('wplms_submit_course', $post->ID, $user_id);
                // Apply Filters on Auto Evaluation
                $student_marks = apply_filters('wplms_course_student_marks', $student_marks, $id, $user_id);
                $total_marks = apply_filters('wplms_course_maximum_marks', $total_marks, $id, $user_id);
                if (!$total_marks) {
                    $total_marks = $student_marks = 1;
                }
                // Avoid the Division by Zero Error
                $marks = round($student_marks * 100 / $total_marks);
                $return .= '<div class="message" class="updated"><p>' . __('COURSE EVALUATED ', 'vibe') . '</p></div>';
                $badge_per = get_post_meta($id, 'vibe_course_badge_percentage', true);
                $passing_cert = get_post_meta($id, 'vibe_course_certificate', true);
                // Certificate Enable
                $passing_per = get_post_meta($id, 'vibe_course_passing_percentage', true);
                // Certificate Passing Percentage
                //finish bit for student 1.8.4
                update_user_meta($user_id, 'course_status' . $id, 3);
                //end finish bit
                do_action('wplms_evaluate_course', $id, $marks, $user_id, 1);
                $badge_filter = 0;
                if (isset($badge_per) && $badge_per && $marks >= $badge_per) {
                    $badge_filter = 1;
                }
                $badge_filter = apply_filters('wplms_course_student_badge_check', $badge_filter, $course_id, $user_id, $marks, $badge_per);
                if ($badge_filter) {
                    $badges = array();
                    $badges = vibe_sanitize(get_user_meta($user_id, 'badges', false));
                    if (isset($badges) && is_array($badges)) {
                        $badges[] = $id;
                    } else {
                        $badges = array($id);
                    }
                    update_user_meta($user_id, 'badges', $badges);
                    $b = bp_get_course_badge($id);
                    $badge = wp_get_attachment_info($b);
                    $badge_url = wp_get_attachment_image_src($b);
                    if (isset($badge) && is_numeric($b)) {
                        $return .= '<div class="congrats_badge">' . __('Congratulations ! You\'ve earned the ', 'vibe') . ' <strong>' . get_post_meta($id, 'vibe_course_badge_title', true) . '</strong> ' . __('Badge', 'vibe') . '<a class="tip ajax-badge" data-course="' . get_the_title($id) . '" title="' . get_post_meta($id, 'vibe_course_badge_title', true) . '"><img src="' . $badge_url[0] . '" title="' . $badge['title'] . '"/></a></div>';
                    }
                    do_action('wplms_badge_earned', $id, $badges, $user_id, $badge_filter);
                }
                $passing_filter = 0;
                if (vibe_validate($passing_cert) && isset($passing_per) && $passing_per && $marks >= $passing_per) {
                    $passing_filter = 1;
                }
                $passing_filter = apply_filters('wplms_course_student_certificate_check', $passing_filter, $course_id, $user_id, $marks, $passing_per);
                if ($passing_filter) {
                    $pass = array();
                    $pass = vibe_sanitize(get_user_meta($user_id, 'certificates', false));
                    if (isset($pass) && is_array($pass)) {
                        $pass[] = $id;
                    } else {
                        $pass = array($id);
                    }
                    update_user_meta($user_id, 'certificates', $pass);
                    $return .= '<div class="congrats_certificate">' . __('Congratulations ! You\'ve successfully passed the course and earned the Course Completion Certificate !', 'vibe') . '<a href="' . bp_get_course_certificate('user_id=' . $user_id . '&course_id=' . $id) . '" class="ajax-certificate right"><span>' . __('View Certificate', 'vibe') . '</span></a></div>';
                    do_action('wplms_certificate_earned', $id, $pass, $user_id, $passing_filter);
                }
                update_post_meta($id, $user_id, $marks);
                $course_end_status = apply_filters('wplms_course_status', 4);
                update_user_meta($user_id, 'course_status' . $id, $course_end_status);
                //EXCEPTION
                $message = sprintf(__('You\'ve obtained %s in course %s ', 'vibe'), apply_filters('wplms_course_marks', $marks . '/100'), ' <a href="' . get_permalink($id) . '">' . get_the_title($id) . '</a>');
                $return .= '<div class="congrats_message">' . $message . '</div>';
            } else {
                $return .= '<div class="message" class="updated"><p>' . __('COURSE SUBMITTED FOR EVALUATION', 'vibe') . '</p></div>';
                bp_course_update_user_course_status($user_id, $id, 2);
                // 2 determines Course is Complete
                do_action('wplms_submit_course', $post->ID, $user_id);
            }
            // Show the Generic Course Submission
            $content = get_post_meta($id, 'vibe_course_message', true);
            $return .= apply_filters('the_content', $content);
            $return = apply_filters('wplms_course_finished', $return);
        } else {
            $type = get_post_type($flag);
            switch ($type) {
                case 'unit':
                    $type = __('UNIT', 'vibe');
                    break;
                case 'assignment':
                    $type = __('ASSIGNMENT', 'vibe');
                    break;
                case 'quiz':
                    $type = __('QUIZ', 'vibe');
                    break;
            }
            //Default for other customized options
            $message = __('PLEASE COMPLETE THE ', 'vibe') . $type . ' : ' . get_the_title($flag);
            $return .= '<div class="message"><p>' . apply_filters('wplms_unfinished_unit_quiz_message', $message, $flag) . '</p></div>';
        }
    } else {
        $retun .= __('COURSE CURRICULUM NOT SET', 'vibe');
    }
    $return .= '</div>';
    return $return;
}
コード例 #2
0
        switch ($course_complete_status) {
            case 1:
                echo '<strong>' . __('Not Started', 'vibe') . '</strong>';
                break;
            case 2:
                echo '<strong>' . __('In Progress', 'vibe') . '</strong>';
                break;
            case 3:
                echo '<strong>' . __('Under Evaluation', 'vibe') . '</strong>';
                break;
        }
    }
    $badges = get_user_meta($user_id, 'badges', true);
    if (is_array($badges)) {
        if (in_array($course->ID, $badges)) {
            $b = bp_get_course_badge($course->ID);
            $badge = wp_get_attachment_info($b);
            $badge_url = wp_get_attachment_image_src($b);
            echo '<a class="tip ajax-badge" data-course="' . $course->post_title . '" title="' . get_post_meta($course->ID, 'vibe_course_badge_title', true) . '"><img src="' . $badge_url[0] . '" title="' . $badge['title'] . '"/></a>';
        }
    }
    $certificates = get_user_meta($user_id, 'certificates', true);
    if (is_array($certificates)) {
        if (in_array($course->ID, $certificates)) {
            echo '<a href="' . bp_get_course_certificate('user_id=' . $user_id . '&course_id=' . $course->ID) . '" class="ajax-certificate"><span><i class="icon-certificate-file"></i></span></a>';
        }
    }
    do_action('wplms_user_course_stats', $user_id, $course->ID);
    echo '</li>';
}
echo '</ul>';
コード例 #3
0
ファイル: bp-custom.php プロジェクト: inetbiz/wordpress-lms
function show_profile_snapshot()
{
    global $bp;
    $user_id = bp_displayed_user_id();
    $bids = vibe_sanitize(get_user_meta($user_id, 'badges', false));
    if (isset($bids) && is_Array($bids) && count($bids)) {
        echo '<div class="badges"><h6>' . __('Badges', 'vibe') . '</h6>';
        echo '<ul>';
        foreach ($bids as $bid) {
            $b = bp_get_course_badge($bid);
            $badge = wp_get_attachment_info($b);
            $badge_url = wp_get_attachment_image_src($b);
            if (isset($badge) && is_numeric($b)) {
                echo '<li><a class="tip ajax-badge" data-course="' . get_the_title($bid) . '" title="' . get_post_meta($bid, 'vibe_course_badge_title', true) . '">
               <img src="' . $badge_url[0] . '" title="' . $badge['title'] . '"/></a>
               </li>';
            }
        }
        echo '</ul>';
        echo '</div>';
    }
    $certis = vibe_sanitize(get_user_meta($user_id, 'certificates', false));
    if (isset($certis) && is_Array($certis) && count($certis)) {
        echo '<div class="certifications"><h6>' . __('Certifications', 'vibe') . '</h6><ul class="slides">';
        if (isset($certis) && is_Array($certis)) {
            foreach ($certis as $certi) {
                echo '<li><a href="' . bp_get_course_certificate('user_id=' . $user_id . '&course_id=' . $certi) . '" class="ajax-certificate"><i class="icon-certificate-file"></i><span>' . get_the_title($certi) . '</span></a></li>';
            }
        }
        echo '</ul></div>';
    }
    if (user_can($user_id, 'edit_posts')) {
        $instructing_courses = apply_filters('wplms_instructing_courses_endpoint', 'instructing-courses');
        echo '<div class="instructor_line">
      <h3><a href="' . get_author_posts_url($user_id) . $instructing_courses . '/">' . __('Check all Courses created by ', 'vibe') . bp_core_get_user_displayname($user_id) . ' <i class="icon-plus-1"></i></a></h3>
      </div>';
    }
}