function wplms_edd_completed_purchase($payment_id, $new_status, $old_status) { if ($old_status == 'publish' || $old_status == 'complete') { return; } // Make sure that payments are only completed once // Make sure the payment completion is only processed when new status is complete if ($new_status != 'publish' && $new_status != 'complete') { return; } $user_id = get_current_user_id(); $cart_items = edd_get_payment_meta_cart_details($payment_id); foreach ($cart_items as $key => $cart_item) { $item_id = isset($cart_item['id']) ? $cart_item['id'] : $cart_item; if (is_numeric($item_id) && get_post_type($item_id) == 'download') { $courses = vibe_sanitize(get_post_meta($item_id, 'vibe_courses', false)); $subscribed = get_post_meta($product_id, 'vibe_subscription', true); if (vibe_validate($subscribed)) { $duration = get_post_meta($product_id, 'vibe_duration', true); $product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400); // Product duration for subscription based $t = time() + $duration * $product_duration_parameter; foreach ($courses as $course) { update_post_meta($course, $user_id, 0); update_user_meta($user_id, $course, $t); $group_id = get_post_meta($course, 'vibe_group', true); if (isset($group_id) && $group_id != '') { groups_join_group($group_id, $user_id); } bp_course_record_activity(array('action' => __('Student subscribed for course ', 'vibe') . get_the_title($course), 'content' => __('Student ', 'vibe') . bp_core_get_userlink($user_id) . __(' subscribed for course ', 'vibe') . get_the_title($course) . __(' for ', 'vibe') . $duration . __(' days', 'vibe'), 'type' => 'subscribe_course', 'item_id' => $course, 'primary_link' => get_permalink($course), 'secondary_item_id' => $user_id)); } } else { if (isset($courses) && is_array($courses)) { foreach ($courses as $course) { $duration = get_post_meta($course, 'vibe_duration', true); $course_duration_parameter = apply_filters('vibe_course_duration_parameter', 86400); // Course duration for subscription based $t = time() + $duration * $course_duration_parameter; update_post_meta($course, $user_id, 0); update_user_meta($user_id, $course, $t); $group_id = get_post_meta($course, 'vibe_group', true); if (isset($group_id) && $group_id != '') { groups_join_group($group_id, $user_id); } bp_course_record_activity(array('action' => __('Student subscribed for course ', 'vibe') . get_the_title($course), 'content' => __('Student ', 'vibe') . bp_core_get_userlink($user_id) . __(' subscribed for course ', 'vibe') . get_the_title($course) . __(' for ', 'vibe') . $duration . __(' days', 'vibe'), 'type' => 'subscribe_course', 'item_id' => $course, 'primary_link' => get_permalink($course), 'secondary_item_id' => $user_id)); } } } } } }
function total_drip_duration($value, $course_id, $unit_id) { $course_drip_duration_type = get_post_meta($course_id, 'vibe_course_drip_duration_type', true); if (vibe_validate($course_drip_duration_type)) { $unit_duration = get_post_meta($unit_id, 'vibe_duration', true); $unit_duration_parameter = apply_filters('vibe_drip_duration_parameter', 60, $unit_id); $value = $unit_duration * $unit_duration_parameter; } return $value; }
echo '<li>'; if (isset($next_post)) { echo '<a href="' . get_permalink($next_post->ID) . '" class="next"><span>' . $next_post->post_title . '</span>' . get_the_post_thumbnail($next_post->ID, 'thumbnail') . '</a>'; } echo '</li>'; ?> </ul> </div> <?php } ?> </div> <?php $author = getPostMeta($post->ID, 'vibe_author', true); if (vibe_validate($author)) { ?> <div class="postauthor"> <div class="auth_image"> <?php echo get_avatar(get_the_author_meta('email'), '160'); $instructing_courses = apply_filters('wplms_instructing_courses_endpoint', 'instructing-courses'); ?> </div> <div class="author_info"> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " class="readmore link"><?php _e('Posts', 'vibe'); ?>
?> <div class="extra_buttons"> <?php do_action('wplms_event_extra_buttons'); if (vibe_validate($print)) { echo '<a href="#" class="certificate_print"><i class="icon-printer-1"></i></a>'; } ?> </div> <?php if (apply_filters('wplms_event_access_flag', $access_flag)) { the_content(); ?> <?php if (vibe_validate($show_location)) { $map_zoom = vibe_get_option('map_zoom'); echo '<h3 class="heading">' . __('Event Location', 'vibe') . '</h3>'; echo '<div class="vibe_gmap"><script> function initialize() { var myLatlng = new google.maps.LatLng(' . $location['latitude'] . ',' . $location['longitude'] . '); var mapOptions = { zoom: ' . (isset($map_zoom) ? $map_zoom : 15) . ', center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map,
<?php do_action('wplms_course_curriculum_section', $id); $course_curriculum = vibe_sanitize(get_post_meta($id, 'vibe_course_curriculum', false)); if (isset($course_curriculum)) { foreach ($course_curriculum as $lesson) { if (is_numeric($lesson)) { $icon = get_post_meta($lesson, 'vibe_type', true); if (get_post_type($lesson) == 'quiz') { $icon = 'task'; } $href = get_the_title($lesson); $free = ''; $free = get_post_meta($lesson, 'vibe_free', true); $curriculum_course_link = apply_filters('wplms_curriculum_course_link', 0); if (vibe_validate($free) || $post->post_author == get_current_user_id() || current_user_can('manage_options') || $curriculum_course_link) { $href = apply_filters('wplms_course_curriculum_free_access', '<a href="' . get_permalink($lesson) . '?id=' . get_the_ID() . '">' . get_the_title($lesson) . (vibe_validate($free) ? '<span>' . __('FREE', 'vibe') . '</span>' : '') . '</a>', $lesson, $free); } echo '<div class="course_lesson"> <i class="icon-' . $icon . '"></i><h6>' . apply_filters('wplms_curriculum_course_lesson', $href, $lesson) . '</h6>'; $minutes = 0; $hours = 0; $min = get_post_meta($lesson, 'vibe_duration', true); $minutes = $min; if ($minutes) { if ($minutes > 60) { $hours = intval($minutes / 60); $minutes = $minutes - $hours * 60; } echo apply_filters('wplms_curriculum_time_filter', '<span><i class="icon-clock"></i> ' . (isset($hours) ? $hours . __(' Hours', 'vibe') : '') . ' ' . $minutes . ' ' . __('minutes', 'vibe') . '</span><b>' . (isset($hours) && $hours ? sprintf('%02d', $hours) : "00") . ':' . sprintf('%02d', $minutes) . '</b>', $min, $lesson); } echo '</div>';
foreach ($admin_query->results as $user) { $instructors[] = $user->ID; } } if (!empty($user_query->results)) { foreach ($user_query->results as $user) { $instructors[] = $user->ID; } } $instructors = array_unique($instructors); $ifield = vibe_get_option('instructor_field'); if (!isset($ifield) || $ifield == '') { $ifield = 'Expertise'; } $title = get_post_meta(get_the_ID(), 'vibe_title', true); if (vibe_validate($title)) { ?> <section class="title-area"> <?php if (has_post_thumbnail()) { $url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); } else { $vibe = Wplms_Modern_Init::init(); $url = $vibe->option('hero_img'); } ?> <div class="title-content" style="background:url(<?php echo is_Array($url) ? $url[0] : $url; ?> ) no-repeat 50% 50%; "> <div class="container">
?> </strong> </li> <?php } ?> </ul> <div class="clear"></div> <?php $items = $order->get_items(); foreach ($items as $item) { $product_name = $item['name']; $product_id = $item['product_id']; $subs = ''; $subscribed = get_post_meta($product_id, 'vibe_subscription', true); if (vibe_validate($subscribed)) { $duration = get_post_meta($product_id, 'vibe_duration', true); $product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400); $date = tofriendlytime($duration * $product_duration_parameter); $subs = '<strong>' . __('COURSE SUBSCRIBED FOR ', 'vibe') . ' : <span>' . $date . '</span></strong>'; } else { $subs = '<strong>' . __('SUSBSCRIBED FOR FULL COURSE', 'vibe') . '</strong>'; } $vcourses = vibe_sanitize(get_post_meta($product_id, 'vibe_courses', false)); if (count($vcourses)) { echo '<h3 class="heading">' . __('Courses Subscribed', 'vibe') . '</h3> <ul class="order_details"> <li><a>' . __('COURSE', 'vibe') . '</a> <strong>' . __('SUBSCRIPTION', 'vibe') . '</strong></li>'; if ($order->status == 'completed' || $order->status == 'complete') { $ostatus = __('START COURSE', 'vibe');
function bp_course_quiz_auto_submit($quiz_id, $user_id) { $quiz_auto_evaluate = get_post_meta($quiz_id, 'vibe_quiz_auto_evaluate', true); if (vibe_validate($quiz_auto_evaluate)) { // Auto Evaluate for Quiz Enabled, Quiz auto evaluate, autoevaluate $total_marks = 0; $questions = vibe_sanitize(get_post_meta($quiz_id, 'quiz_questions' . $user_id, false)); if (!isset($questions) || !is_array($questions)) { // Fallback for Older versions $questions = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_questions', false)); } if (count($questions)) { $sum = $max_sum = 0; foreach ($questions['ques'] as $key => $question) { // Grab all the Questions $marks = 0; if (isset($question) && $question) { $type = get_post_meta($question, 'vibe_question_type', true); $auto_evaluate_question_types = vibe_get_option('auto_eval_question_type'); if (isset($auto_evaluate_question_types) && is_Array($auto_evaluate_question_types) && count($auto_evaluate_question_types)) { // Validated } else { $auto_evaluate_question_types = array('single'); } if (isset($type) && in_array($type, $auto_evaluate_question_types)) { $correct_answer = get_post_meta($question, 'vibe_question_answer', true); $comments_query = new WP_Comment_Query(); $comments = $comments_query->query(array('post_id' => $question, 'user_id' => $user_id, 'number' => 1, 'status' => 'approve')); foreach ($comments as $comment) { $comment->comment_content = trim($comment->comment_content, ','); if ($comment->comment_content == $correct_answer) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; } else { // Use cases for No exact match for answer if ($type == 'multiple') { if (!strlen($comment->comment_content)) { $marks = 0; } else { $marked_answers = explode(',', $comment->comment_content); if (!is_array($marks_answers)) { // Force Array Form $marks_answers = array($marks_answers); } $correct_answers = explode(',', $correct_answer); if (!is_array($correct_answers)) { // Force Array Form $correct_answers = array($correct_answers); } sort($marked_answers); sort($correct_answers); if (array_diff($marked_answers, $correct_answers) == array_diff($correct_answers, $marked_answers)) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; } else { $marks = apply_filters('wplms_incorrect_quiz_answer', 0, $quiz_id, $comment->comment_content, $question); $total_marks = $total_marks + $marks; } } } else { if ($type == 'smalltext' || $type == 'fillblank') { if (strpos($correct_answer, ',')) { $correct_answers_array = explode(',', $correct_answer); foreach ($correct_answers_array as $c_answer) { if (strtolower($c_answer) == strtolower($comment->comment_content)) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; break; } else { $marks = apply_filters('wplms_incorrect_quiz_answer', 0, $quiz_id, $comment->comment_content, $question); $total_marks = $total_marks + $marks; } } } } } // If user does not marks in any of above use cases if ($marks == 0) { $marks = apply_filters('wplms_incorrect_quiz_answer', 0, $quiz_id, $comment->comment_content, $question); } } update_comment_meta($comment->comment_ID, 'marks', $marks); } //END-For } } } update_post_meta($quiz_id, $user_id, $total_marks); $max_marks = array_sum($questions['marks']); do_action('wplms_evaluate_quiz', $quiz_id, $total_marks, $user_id, $max_marks); } } else { // End Auto evaluate and Send notification to instructor do_action('wplms_submit_quiz', $quiz_id, $course_id, $user_id); } }
function display_time($time, $seconds, $course_id) { $button_access = get_post_meta($course_id, 'vibe_course_button', true); if (vibe_validate($button_access)) { if (empty($seconds)) { $time = __('COURSE FINISHED', 'vibe'); } } return $time; }
} ?> </ul> </div> </div> <div class="show_course_reviews"> <?php if (get_comments_number() == 0) { echo '<div id="message" class="notice"><p>'; _e('No Reviews found for this course.', 'vibe'); echo '</p></div>'; } else { ?> <ol class="reviewlist commentlist"> <?php wp_list_comments(array('type' => 'comment', 'reverse_top_level' => false, 'avatar_size' => 120, 'callback' => 'wplms_course_reviews')); paginate_comments_links(array('prev_text' => '«', 'next_text' => '»')); ?> </ol> <?php } ?> </div> <?php $course_review = get_post_meta(get_the_ID(), 'vibe_course_review', true); if (is_user_logged_in() && vibe_validate($course_review) && bp_course_is_member($post->ID, $user_id)) { comment_form(array('fields' => $fields, 'comment_field' => $comment_field, 'label_submit' => __('Post Review', 'vibe'), 'title_reply' => '<span>' . __('Post Review', 'vibe') . '</span>', 'logged_in_as' => '', 'comment_notes_after' => '')); } }
function wplms_redirect_to_course($order_id) { if (!class_exists('WC_Order')) { return; } $order = new WC_Order($order_id); $items = $order->get_items(); $order_courses = array(); foreach ($items as $item) { $product_name = $item['name']; $product_id = $item['product_id']; $vcourses = vibe_sanitize(get_post_meta($product_id, 'vibe_courses', false)); if (isset($vcourses) && is_array($vcourses) && count($vcourses) && $vcourses != '') { $order_courses[$product_id]['courses'] = $vcourses; $subscribed = get_post_meta($product_id, 'vibe_subscription', true); if (vibe_validate($subscribed)) { $duration = get_post_meta($product_id, 'vibe_duration', true); $product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400); $date = tofriendlytime($duration * $product_duration_parameter); $order_courses[$product_id]['subs'] = '<strong>' . __('COURSE SUBSCRIBED FOR ', 'vibe') . ' : <span>' . $date . '</span></strong>'; } else { $order_courses[$product_id]['subs'] = '<strong>' . __('SUSBSCRIBED FOR FULL COURSE', 'vibe') . '</strong>'; } } } if (isset($order_courses) && is_array($order_courses) && count($order_courses)) { echo '<h3 class="heading">' . __('Courses Subscribed', 'vibe') . '</h3> <ul class="order_details"> <li><a>' . __('COURSE', 'vibe') . '</a> <strong>' . __('SUBSCRIPTION', 'vibe') . '</strong></li>'; if ($order->status == 'completed' || $order->status == 'complete') { $ostatus = __('START COURSE', 'vibe'); } else { if ($order->status == 'pending') { do_action('wplms_force_woocommerce_order_complete', $order); $ostatus = __('WAITING FOR ORDER CONFIRMATION TO START COURSE', 'vibe'); } else { $ostatus = __('WAITING FOR ADMIN APPROVAL', 'vibe'); } } foreach ($order_courses as $order_course) { foreach ($order_course['courses'] as $course) { echo '<li> <a class="course_name">' . get_the_title($course) . '</a> <a href="' . get_permalink($course) . '" class="button"> ' . $ostatus . '</a>' . $order_course['subs'] . ' </li>'; } } echo '</ul>'; if (count($order_courses) == 1 && count($order_courses[$product_id]['courses']) == 1 && ($order->status == 'completed' || $order->status == 'complete')) { $thankyou_redirect = vibe_get_option('thankyou_redirect'); if (isset($thankyou_redirect) && $thankyou_redirect) { echo '<script> jQuery(location).attr("href","' . get_permalink($course) . '"); </script>'; } } } }
function bp_course_get_full_course_curriculum($course_id = NULL) { $curriculum = array(); global $post; if (empty($course_id) && $post->post_type == 'course') { $course_id = $post->ID; } if (!isset($course_id) || !is_numeric($course_id)) { return $curriculum; } $course_items = bp_course_get_curriculum($course_id); foreach ($course_items as $key => $item) { if (is_numeric($item)) { $type = get_post_type($item); $labels = ''; if ($type == 'unit') { $free_access = get_post_meta($item, 'vibe_free', true); $labels = vibe_validate($free_access) ? '<span class="free">' . __('FREE', 'vibe') . '</span>' : ''; } $duration = get_post_meta($item, 'vibe_duration', true); $duration_parameter = apply_filters("vibe_{$type_duration_parameter}", 60); $duration = '<span class="time"><i class="fa fa-clock-o"></i> ' . gmdate("H:i:s", $duration * $duration_parameter) . '</span>'; //apply_filters('wplms_curriculum_time_filter',//,$duration,$item); $curriculum_course_link = apply_filters('wplms_curriculum_course_link', 0); $curriculum[] = array('id' => $item, 'key' => $key, 'type' => $type, 'icon' => $type == 'unit' ? get_post_meta($item, 'vibe_type', true) : 'task', 'labels' => apply_filters('bp_course_curriculum_item_labels', $labels, $item, $type), 'title' => get_the_title($item), 'link' => vibe_validate($free) || $post->post_author == get_current_user_id() || current_user_can('manage_options') || $curriculum_course_link ? get_permalink($item) . '?id=' . $course_id : '', 'duration' => $duration, 'extras' => apply_filters('course_curriculum_extras', 0, $item)); } else { $curriculum[] = array('type' => 'section', 'key' => $key, 'title' => $item); } } return apply_filters('bp_course_get_full_course_curriculum', $curriculum, $course_id); }
function wplms_renew_free_course() { global $post; if (!is_user_logged_in()) { return; } $course_id = get_the_ID(); $user_id = get_current_user_id(); $expiry = get_user_meta($user_id, $course_id, true); if ($expiry > time()) { return; } $free = get_post_meta($course_id, 'vibe_course_free', true); if (vibe_validate($free) && isset($_REQUEST['renew'])) { $course_duration = get_post_meta($course_id, 'vibe_duration', true); $course_duration_parameter = apply_filters('vibe_course_duration_parameter', 86400); $new_expiry = time() + $course_duration * $course_duration_parameter; update_user_meta($user_id, $course_id, $new_expiry); do_action('wplms_renew_course', $course_id, $user_id); } }
<?php /** * Template Name: Blog 1 */ if (!defined('ABSPATH')) { exit; } get_header(vibe_get_header()); $page_id = get_the_ID(); $title = get_post_meta(get_the_ID(), 'vibe_title', true); if (!isset($title) || !$title || vibe_validate($title)) { ?> <section id="title"> <div class="<?php echo vibe_get_container(); ?> "> <div class="row"> <div class="col-md-9 col-sm-8"> <div class="pagetitle"> <?php vibe_breadcrumbs(); ?> <h1><?php the_title(); ?> </h1> <?php the_sub_title();
function free_label($label, $course_id) { $free = get_post_meta($course_id, 'vibe_course_free', true); if (vibe_validate($free)) { $label = __('Take this Course', 'vibe-customtypes'); } return $label; }
echo '</div>'; the_tags('<ul><li>', '</li><li>', '</li></ul>'); ?> <?php wp_link_pages('before=<div class="page-links"><ul>&link_before=<li>&link_after=</li>&after=</ul></div>'); ?> <div class="social_sharing"> <?php echo social_sharing(); ?> </div> </div> </div> <?php $prenex = get_post_meta(get_the_ID(), 'vibe_prev_next', true); if (vibe_validate($prenex)) { ?> <div class="prev_next_links"> <ul class="prev_next"> <?php echo '<li>'; previous_post_link('<strong class="prev">%link</strong>'); echo '</li><li> | </li><li>'; next_post_link('<strong class="next">%link</strong>'); echo '</li>'; ?> </ul> </div> <?php } ?>
function wplms_assignment_maximum_marks($maximum_marks, $course_id, $user_id) { global $wpdb; $members_assignments = $wpdb->get_results($wpdb->prepare("SELECT post_id as assignment_id FROM {$wpdb->postmeta} WHERE meta_key='vibe_assignment_course' AND meta_value = %d", $course_id), ARRAY_A); if (isset($members_assignments) && is_array($members_assignments) && count($members_assignments)) { foreach ($members_assignments as $members_assignment) { $include_in_course = get_post_meta($members_assignment['assignment_id'], 'vibe_assignment_evaluation', true); if (vibe_validate($include_in_course)) { $newmaximum_marks = get_post_meta($members_assignment['assignment_id'], 'vibe_assignment_marks', true); if (is_numeric($newmaximum_marks)) { $maximum_marks += $newmaximum_marks; } } } } return $maximum_marks; }
function bp_course_enable_access($order_id) { $order = new WC_Order($order_id); $items = $order->get_items(); $user_id = $order->user_id; $order_total = $order->get_total(); $commission_array = array(); foreach ($items as $item_id => $item) { $instructors = array(); $courses = get_post_meta($item['product_id'], 'vibe_courses', true); $product_id = apply_filters('bp_course_product_id', $item['product_id'], $item); $subscribed = get_post_meta($product_id, 'vibe_subscription', true); if (isset($courses) && is_array($courses)) { if (vibe_validate($subscribed)) { $duration = get_post_meta($product_id, 'vibe_duration', true); foreach ($courses as $course) { bp_course_add_user_to_course($user_id, $course, $duration, 1); $instructors[$course] = apply_filters('wplms_course_instructors', get_post_field('post_author', $course), $course); do_action('wplms_course_product_puchased', $course, $user_id, $t, 1); } } else { if (isset($courses) && is_array($courses)) { foreach ($courses as $course) { bp_course_add_user_to_course($user_id, $course, '', 1); $instructors[$course] = apply_filters('wplms_course_instructors', get_post_field('post_author', $course, 'raw'), $course); do_action('wplms_course_product_puchased', $course, $user_id, $t, 0); } } } //End Else $line_total = $item['line_total']; //Commission Calculation $commission_array[$item_id] = array('instructor' => $instructors, 'course' => $courses, 'total' => $line_total); } //End If courses } // End Item for loop if (function_exists('vibe_get_option')) { $instructor_commission = vibe_get_option('instructor_commission'); } if ($instructor_commission == 0) { return; } if (!isset($instructor_commission) || !$instructor_commission) { $instructor_commission = 70; } $commissions = get_option('instructor_commissions'); foreach ($commission_array as $item_id => $commission_item) { foreach ($commission_item['course'] as $course_id) { if (count($commission_item['instructor'][$course_id]) > 1) { // Multiple instructors $calculated_commission_base = round($commission_item['total'] * ($instructor_commission / 100) / count($commission_item['instructor'][$course_id]), 0); // Default Slit equal propertion foreach ($commission_item['instructor'][$course_id] as $instructor) { if (empty($commissions[$course_id][$instructor])) { $calculated_commission_base = round($commission_item['total'] * $instructor_commission / 100, 2); } else { $calculated_commission_base = round($commission_item['total'] * $commissions[$course_id][$instructor] / 100, 2); } $calculated_commission_base = apply_filters('wplms_calculated_commission_base', $calculated_commission_base, $instructor); woocommerce_update_order_item_meta($item_id, 'commission' . $instructor, $calculated_commission_base); } } else { if (is_array($commission_item['instructor'][$course_id])) { // Single Instructor $instructor = $commission_item['instructor'][$course_id][0]; } else { $instructor = $commission_item['instructor'][$course_id]; } if (isset($commissions[$course_id][$instructor]) && is_numeric($commissions[$course_id][$instructor])) { $calculated_commission_base = round($commission_item['total'] * $commissions[$course_id][$instructor] / 100, 2); } else { $calculated_commission_base = round($commission_item['total'] * $instructor_commission / 100, 2); } $calculated_commission_base = apply_filters('wplms_calculated_commission_base', $calculated_commission_base, $instructor); woocommerce_update_order_item_meta($item_id, 'commission' . $instructor, $calculated_commission_base); } } } // End Commissions_array }
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; }
function instructor_message_quiz_submit($quiz_id, $user_id) { $instructor_ids = $this->get_instructors($quiz_id); $course_id = get_post_meta($quiz_id, 'vibe_course', true); $evaluation = get_post_meta($quiz_id, 'vibe_quiz_auto_evaluate', true); if (isset($course_id) && is_numeric($course_id) && vibe_validate($evaluation)) { $quiz_link = '<a href="' . get_permalink($course_id) . '?action=admin&submissions">' . get_the_title($quiz_id) . '</a>'; } else { $quiz_link = get_the_title($quiz_id); } $message = sprintf(__('Quiz %s submitted by student %s', 'vibe'), $quiz_link, bp_core_get_userlink($user_id)); messages_new_message(array('sender_id' => $user_id, 'subject' => sprintf(__('Quiz %s submitted by Student', 'vibe'), get_the_title($quiz_id)), 'content' => $message, 'recipients' => $instructor_id)); }
<?php get_header(); global $post; $flag = 0; $free = get_post_meta(get_the_ID(), 'vibe_free', true); if (vibe_validate($free)) { $flag = 1; } else { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && is_user_logged_in()) { $flag = 1; } else { if (current_user_can('edit_posts')) { $flag = 1; $instructor_privacy = vibe_get_option('instructor_content_privacy'); $user_id = get_current_user_id(); if (isset($instructor_privacy) && $instructor_privacy) { if ($user_id != $post->post_author) { $flag = 0; } } } } } $flag = apply_filters('wplms_before_unit', $flag); if ($flag || current_user_can('manage_options')) { $unit_comments = vibe_get_option('unit_comments'); if (have_posts()) { while (have_posts()) { the_post(); ?>
function get_unit_content() { $course_id = $_POST['course_id']; $unit_id = $_POST['unit_id']; ?> <div id="unit_load<?php echo $unit_id; ?> "> <?php if (!is_numeric($unit_id) || !is_numeric($course_id)) { _e('Invalid Course or Unit ID'); echo '</div>'; die; } $curriculum = bp_course_get_curriculum_units($course_id); if (!in_Array($unit_id, $curriculum)) { _e('Unit not found in Course'); echo '</div>'; die; } $course_unit_content = get_post_meta($course_id, 'vibe_course_unit_content', true); if (vibe_validate($course_unit_content)) { $post = get_post($unit_id); if ($post->post_type == 'unit') { ?> <div class="content"> <h2><?php echo $post->post_title; ?> </h2> <h5><?php echo get_post_meta($post->ID, 'vibe_subtitle', true); ?> </h5> <?php echo apply_filters('the_content', $post->post_content); ?> </div> <?php } } ?> </div> <?php die; }
<div class="row"> <div class="col-md-9 col-sm-8"> <div class="pagetitle"> <h1><?php the_title(); ?> </h1> <?php the_sub_title(); ?> </div> </div> <div class="col-md-3 col-sm-4"> <?php $breadcrumbs = get_post_meta(get_the_ID(), 'vibe_breadcrumbs', true); if (vibe_validate($breadcrumbs)) { vibe_breadcrumbs(); } ?> </div> </div> </div> </section> <?php } $v_add_content = get_post_meta($post->ID, '_add_content', true); ?> <section id="content"> <div class="container"> <div class="row"> <div class="col-md-9 col-sm-8">
function thumbnail_generator($custom_post, $featured_style, $cols = 'medium', $n = 100, $link = 0, $zoom = 0) { $return = $read_more = $class = ''; global $post; $more = __('Read more', 'vibe-customtypes'); if (strlen($custom_post->post_content) > $n) { $read_more = '<a href="' . get_permalink($custom_post->ID) . '" class="link">' . $more . '</a>'; } $cache_duration = vibe_get_option('cache_duration'); if (!isset($cache_duration)) { $cache_duration = 0; } if ($cache_duration) { $key = $featured_style . '_' . $custom_post->post_type . '_' . $custom_post->ID; if (is_user_logged_in()) { $user_id = get_current_user_id(); $user_meta = get_user_meta($user_id, $custom_post->ID, true); if (isset($user_meta)) { $key .= '_' . $user_id; } } $result = wp_cache_get($key, 'featured_block'); } else { $result = false; } if (false === $result) { switch ($featured_style) { case 'course': $return .= '<div class="block courseitem">'; $return .= '<div class="block_media">'; $return .= apply_filters('vibe_thumb_featured_image', '<a href="' . get_permalink($custom_post->ID) . '">' . featured_component($custom_post->ID, $cols) . '</a>', $featured_style); $return .= '</div>'; $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $category = ''; if (get_post_type($custom_post->ID) == 'course') { $rating = get_post_meta($custom_post->ID, 'average_rating', true); $rating_count = get_post_meta($custom_post->ID, 'rating_count', true); $meta = '<div class="star-rating">'; for ($i = 1; $i <= 5; $i++) { if (isset($rating)) { if ($rating >= 1) { $meta .= '<span class="fill"></span>'; } elseif ($rating < 1 && $rating > 0.4) { $meta .= '<span class="half"></span>'; } else { $meta .= '<span></span>'; } $rating--; } else { $meta .= '<span></span>'; } } $meta = apply_filters('vibe_thumb_rating', $meta, $featured_style, $rating); $meta .= apply_filters('vibe_thumb_reviews', '( ' . (isset($rating_count) ? $rating_count : '0') . ' ' . __('REVIEWS', 'vibe-customtypes') . ' )', $featured_style) . '</div>'; $free_course = get_post_meta($custom_post->ID, 'vibe_course_free', true); $meta .= bp_course_get_course_credits(array('id' => $custom_post->ID)); $meta .= '<span class="clear"></span>'; $instructor_meta = ''; if (function_exists('bp_course_get_instructor')) { $instructor_meta .= bp_course_get_instructor(); } $meta .= apply_filters('vibe_thumb_instructor_meta', $instructor_meta, $featured_style); $st = get_post_meta($custom_post->ID, 'vibe_students', true); if (isset($st) && $st != '') { $meta .= apply_filters('vibe_thumb_student_count', '<strong>' . $st . ' ' . __('Students', 'vibe-customtypes') . '</strong>'); } $return .= $meta; } $return .= apply_filters('wplms_course_thumb_extras', ''); // Use this filter to add Extra HTML to the course featured block $return .= '</div>'; $return .= '</div>'; break; case 'course2': $return .= '<div class="block courseitem course2">'; $return .= '<div class="block_media">'; $return .= apply_filters('vibe_thumb_featured_image', '<a href="' . get_permalink($custom_post->ID) . '">' . featured_component($custom_post->ID, $cols) . '</a>', $featured_style); $return .= '</div>'; $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $category = ''; if (get_post_type($custom_post->ID) == 'course') { $rating = get_post_meta($custom_post->ID, 'average_rating', true); $rating_count = get_post_meta($custom_post->ID, 'rating_count', true); $meta = '<div class="star-rating">'; for ($i = 1; $i <= 5; $i++) { if (isset($rating)) { if ($rating >= 1) { $meta .= '<span class="fill"></span>'; } elseif ($rating < 1 && $rating > 0.4) { $meta .= '<span class="half"></span>'; } else { $meta .= '<span></span>'; } $rating--; } else { $meta .= '<span></span>'; } } $meta = apply_filters('vibe_thumb_rating', $meta, $featured_style, $rating); $meta .= apply_filters('vibe_thumb_reviews', '( ' . (isset($rating_count) ? $rating_count : '0') . ' ' . __('REVIEWS', 'vibe-customtypes') . ' )', $featured_style) . '</div>'; $free_course = get_post_meta($custom_post->ID, 'vibe_course_free', true); $st = get_post_meta($custom_post->ID, 'vibe_students', true); if (isset($st) && $st != '') { $meta .= apply_filters('vibe_thumb_student_count', '<strong><i class="icon-users"></i> ' . $st . '</strong>'); } $meta .= '<span class="clear"></span>'; $instructor_meta = ''; if (function_exists('bp_course_get_instructor')) { $instructor_meta .= bp_course_get_instructor(); } $meta .= apply_filters('vibe_thumb_instructor_meta', $instructor_meta, $featured_style); $meta .= bp_course_get_course_credits(array('id' => $custom_post->ID)); $return .= $meta; } $return .= apply_filters('wplms_course_thumb_extras', ''); // Use this filter to add Extra HTML to the course featured block $return .= '</div>'; $return .= '</div>'; break; case 'side': $return .= '<div class="block side">'; $return .= '<div class="block_media">'; if (isset($link) && $link) { $return .= '<span class="overlay"></span>'; } if (isset($link) && $link) { $return .= '<a href="' . get_permalink($custom_post->ID) . '" class="hover-link hyperlink"><i class="icon-hyperlink"></i></a>'; } $featured = getPostMeta($custom_post->ID, 'vibe_select_featured'); if (isset($zoom) && $zoom && has_post_thumbnail($custom_post->ID)) { $return .= '<a href="' . wp_get_attachment_url(get_post_thumbnail_id($custom_post->ID), $cols) . '" class="hover-link pop"><i class="icon-arrows-out"></i></a>'; } $return .= apply_filters('vibe_thumb_featured_image', featured_component($custom_post->ID, $cols), $featured_style); $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } $return .= '</div>'; $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $return .= apply_filters('vibe_thumb_date', '<div class="date"><small>' . get_the_time('F d,Y') . '' . (strlen($category) > 2 ? ' / ' . $category : '') . ' / ' . get_comments_number('0', '1', '%') . ' ' . __(' Comments', 'vibe-customtypes') . '</small></div>', $featured_style); $return .= apply_filters('vibe_thumb_desc', '<p class="block_desc">' . custom_excerpt($n, $custom_post->ID) . '</p>', $featured_style); $return .= '</div>'; $return .= '</div>'; break; case 'images_only': $return .= '<div class="block">'; $return .= '<div class="block_media images_only">'; if (isset($link) && $link) { $return .= '<span class="overlay"></span>'; } if (isset($link) && $link) { $return .= '<a href="' . get_permalink($custom_post->ID) . '" class="hover-link hyperlink"><i class="icon-hyperlink"></i></a>'; } if (isset($zoom) && has_post_thumbnail($custom_post->ID) && $zoom) { $return .= '<a href="' . wp_get_attachment_url(get_post_thumbnail_id($custom_post->ID), $cols) . '" class="hover-link pop"><i class="icon-arrows-out"></i></a>'; } $return .= apply_filters('vibe_thumb_featured_image', featured_component($custom_post->ID, $cols), $featured_style); $return .= '</div>'; $return .= '</div>'; break; case 'testimonial': $return .= '<div class="block testimonials">'; $author = getPostMeta($custom_post->ID, 'vibe_testimonial_author_name'); $designation = getPostMeta($custom_post->ID, 'vibe_testimonial_author_designation'); if (has_post_thumbnail($custom_post->ID)) { $image = get_the_post_thumbnail($custom_post->ID, 'full'); } else { $image = get_avatar('*****@*****.**', 96); } $return .= '<div class="testimonial_item style2 clearfix"> <div class="testimonial-content"> <p>' . custom_excerpt($n, $custom_post->ID) . ($n < strlen($custom_post->post_content) ? $read_more : '') . '</p> <div class="author"> ' . $image . ' <h4>' . html_entity_decode($author) . '</h4> <small>' . html_entity_decode($designation) . '</small> </div> </div> </div>'; $return .= '</div>'; break; case 'blogpost': $return .= '<div class="block blogpost">'; $return .= '<div class="blog-item"> ' . apply_filters('vibe_thumb_date', '<div class="blog-item-date"> <span class="day">' . get_the_time('d') . '</span> <p class="month">' . get_the_time('M') . '\'' . get_the_time('y') . '</p> </div>', $featured_style) . ' ' . apply_filters('vibe_thumb_heading', '<h4><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style) . ' <p>' . apply_filters('vibe_thumb_desc', custom_excerpt($n, $custom_post->ID), $featured_style) . '</p> </div>'; $return .= '</div>'; break; case 'event_card': $return .= '<div class="event_card">'; $icon_class = get_post_meta($custom_post->ID, 'vibe_icon', true); $color = get_post_meta($custom_post->ID, 'vibe_color', true); $start_date = get_post_meta($custom_post->ID, 'vibe_start_date', true); $end_date = get_post_meta($custom_post->ID, 'vibe_end_date', true); $start_time = get_post_meta($custom_post->ID, 'vibe_start_time', true); $end_time = get_post_meta($custom_post->ID, 'vibe_end_time', true); $show_location = get_post_meta($custom_post->ID, 'vibe_show_location', true); $all_day = get_post_meta($custom_post->ID, 'vibe_all_day', true); $location = vibe_sanitize(get_post_meta($custom_post->ID, 'vibe_location', false)); $repeatable = get_post_meta($custom_post->ID, 'vibe_repeatable', true); $repeat_value = get_post_meta($custom_post->ID, 'vibe_repeat_value', true); $repeat_unit = get_post_meta($custom_post->ID, 'vibe_repeat_unit', true); $repeat_count = get_post_meta($custom_post->ID, 'vibe_repeat_count', true); $return .= ' <span class="event_icon" style="color:' . $color . '"><i class="' . $icon_class . '"></i></span> <h4 style="background:' . $color . '"><i class="' . $icon_class . '"></i> ' . __('Event ', 'vibe-customtypes') . '</label><span><a href="' . get_permalink($custom_post->ID) . '">' . get_the_title($custom_post->ID) . '</a></span></h4> <ul> '; if (isset($start_date) && $start_date != '') { $return .= '<li><label><i class="icon-calendar"></i> ' . __('Start Date ', 'vibe-customtypes') . '</label><span>' . date('F j Y', strtotime($start_date)) . '</span></li>'; } if (isset($end_date) && $end_date != '') { $return .= '<li><label><i class="icon-calendar"></i> ' . __('End Date ', 'vibe-customtypes') . '</label><span>' . date('F j Y', strtotime($end_date)) . '</span>'; } if (isset($start_time) && $start_time != '') { $return .= '<li><label><i class="icon-clock"></i> ' . __('Start Time ', 'vibe-customtypes') . '</label><span>' . $start_time . '</span>'; } if (isset($end_time) && $end_time != '') { $return .= '<li><label><i class="icon-clock"></i> ' . __('End Time ', 'vibe-customtypes') . '</label><span>' . $end_time . '</span>'; } if (vibe_validate($all_day)) { $return .= '<li><label><i class="icon-circle-full"></i> ' . __('All Day ', 'vibe-customtypes') . '</label><span>' . __('Yes', 'vibe-customtypes') . '</span>'; } if (vibe_validate($repeatable)) { $return .= '<li><label><i class="icon-flash"></i> ' . __('Frequency ', 'vibe-customtypes') . '</label><span>' . __('Every ', 'vibe-customtypes') . (isset($repeat_value) && $repeat_value > 1 ? $repeat_value : '') . ' ' . $repeat_unit . ' ' . __('for ', 'vibe-customtypes') . $repeat_count . ' ' . $repeat_unit . '</span>'; } if (vibe_validate($show_location)) { $return .= '<li><label><i class="icon-pin-alt"></i> ' . __('Venue ', 'vibe-customtypes') . '</label><span>' . (isset($location['staddress']) ? $location['staddress'] : '') . (isset($location['city']) ? ', ' . $location['city'] : '') . (isset($location['state']) ? ', ' . $location['state'] : '') . (isset($location['country']) ? ', ' . $location['country'] : '') . (isset($location['pincode']) ? ' - ' . $location['pincode'] : '') . '</span>'; } $return .= '</ul> <a href="' . get_permalink($custom_post->ID) . '" class="event_full_details tip" title="' . __('View full details', 'vibe-customtypes') . '" style="background:' . $color . '"><i class="icon-plus-1"></i></a> </div>'; break; default: $return .= '<div class="block">'; $return .= '<div class="block_media">'; if (isset($link) && $link) { $return .= '<a href="' . get_permalink($custom_post->ID) . '" class="hover-link hyperlink"><i class="icon-hyperlink"></i></a>'; } $featured = getPostMeta($custom_post->ID, 'vibe_select_featured'); if (isset($zoom) && $zoom && has_post_thumbnail($custom_post->ID)) { $return .= '<a href="' . wp_get_attachment_url(get_post_thumbnail_id($custom_post->ID), $cols) . '" class="hover-link pop"><i class="icon-arrows-out"></i></a>'; } $return .= featured_component($custom_post->ID, $cols); $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } $return .= '</div>'; $category = ''; if (get_post_type($custom_post->ID) == 'post') { $cats = get_the_category(); if (is_array($cats)) { foreach ($cats as $cat) { $category .= '<a href="' . get_category_link($cat->term_id) . '">' . $cat->cat_name . '</a> '; } } } if (get_post_type($custom_post->ID) == 'portfolio') { $cats = get_the_category(); if (is_array($cats)) { $category .= '<div class="categories">'; if (!is_wp_error(get_the_term_list($custom_post->ID, 'portfolio-type', ' ', ' ', ''))) { $category .= get_the_term_list($custom_post->ID, 'portfolio-type', ' ', ' ', ''); } $category .= '</div>'; } } $return .= '<div class="block_content">'; $return .= apply_filters('vibe_thumb_heading', '<h4 class="block_title"><a href="' . get_permalink($custom_post->ID) . '" title="' . $custom_post->post_title . '">' . $custom_post->post_title . '</a></h4>', $featured_style); $return .= apply_filters('vibe_thumb_date', '<div class="date"><small>' . get_the_time('F d,Y') . '' . (strlen($category) > 2 ? ' / ' . $category : '') . ' / ' . get_comments_number('0', '1', '%') . ' ' . __('Comments', 'vibe-customtypes') . '</small></div>', $featured_style); $return .= apply_filters('vibe_thumb_desc', '<p class="block_desc">' . custom_excerpt($n, $custom_post->ID) . '</p>', $featured_style); $return .= '</div>'; $return .= '</div>'; break; } if ($cache_duration) { wp_cache_set($course_key, $result, 'featured_block', $cache_duration); } } //end If return apply_filters('vibe_featured_thumbnail_style', $return, $custom_post, $featured_style); }
<div class="row"> <div class="col-md-12"> <div id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <?php do_action('wplms_certificate_before_content'); ?> <div class="extra_buttons"> <?php do_action('wplms_certificate_extra_buttons'); if (vibe_validate($print)) { echo '<a href="#" class="certificate_print"><i class="icon-printer-1"></i></a>'; } ?> </div> <div class="certificate_content <?php echo $class; ?> " style="<?php if (isset($bgimg_id) && $bgimg_id && isset($bgimg['src'])) { echo 'background:url(' . $bgimg['src'] . ');'; } ?> "> <?php echo isset($css) ? '<style>' . $css . '</style>' : '';
function wplms_get_course_unfinished_unit_sau($course_id) { $user_id = get_current_user_id(); if (isset($_COOKIE['course'])) { $coursetaken = 1; } else { $coursetaken = get_user_meta($user_id, $course_id, true); } $course_curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false)); $key = 0; $uid = ''; if (isset($coursetaken) && $coursetaken) { if (isset($course_curriculum) && is_array($course_curriculum) && count($course_curriculum)) { foreach ($course_curriculum as $uid) { if (is_numeric($uid)) { $units[$key] = $uid; $unittaken = get_user_meta($user_id, $uid, true); if (!isset($unittaken) || !$unittaken) { break; } $key++; } } } else { echo '<div class="error"><p>' . __('Course Curriculum Not Set', 'vibe') . '</p></div>'; return; } } $flag = apply_filters('wplms_next_unit_access', true, $units[$key - 1]); $drip_enable = get_post_meta($course_id, 'vibe_course_drip', true); $drip_duration_parameter = apply_filters('vibe_drip_duration_parameter', 86400); if (vibe_validate($drip_enable)) { $drip_duration = get_post_meta($course_id, 'vibe_course_drip_duration', true); if ($key > 0) { $pre_unit_time = get_post_meta($units[$key - 1], $user_id, true); if (isset($pre_unit_time) && $pre_unit_time) { $value = $pre_unit_time + $key * $drip_duration * $drip_duration_parameter; $value = apply_filters('wplms_drip_value', $value, $units[$key - 1], $course_id, $units[$unitkey]); if ($value > time()) { $flag = 0; } } else { $flag = 0; } } } if (isset($uid) && $flag && $key) { // Should Always be set $unit_id = $uid; // Last un finished unit } else { if (isset($key) && $key > 0) { $unit_id = $units[$key - 1]; } else { $unit_id = $units[0]; } } return $unit_id; }
while (have_posts()) { the_post(); $title = get_post_meta(get_the_ID(), 'vibe_title', true); if (vibe_validate($title) || empty($title)) { ?> <section id="title"> <div class="<?php echo vibe_get_container(); ?> "> <div class="row"> <div class="col-md-12"> <div class="pagetitle"> <?php $breadcrumbs = get_post_meta(get_the_ID(), 'vibe_breadcrumbs', true); if (vibe_validate($breadcrumbs) || empty($breadcrumbs)) { vibe_breadcrumbs(); } ?> <h1><?php the_title(); ?> </h1> <?php the_sub_title(); ?> </div> </div> </div> </div> </section>
function wplms_dynamic_quiz_select_questions($quiz_id = NULL) { $user_id = get_current_user_id(); if (!is_numeric($user_id)) { return; } if (!isset($quiz_id)) { global $post; $quiz_id = $post->ID; } $quiz_created = get_post_meta($quiz_id, 'quiz_questions' . $user_id, false); if (isset($quiz_created) && $quiz_created && is_array($quiz_created)) { return; } $quiz_dynamic = get_post_meta($quiz_id, 'vibe_quiz_dynamic', true); $quiz_questions = array('ques' => array(), 'marks' => array()); if (vibe_validate($quiz_dynamic)) { $tags = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_tags', false)); $number = get_post_meta($quiz_id, 'vibe_quiz_number_questions', true); if (!isset($number) || !is_numeric($number)) { $number = 0; } $marks = get_post_meta($quiz_id, 'vibe_quiz_marks_per_question', true); $args = array('post_type' => 'question', 'orderby' => 'rand', 'posts_per_page' => $number, 'tax_query' => array(array('taxonomy' => 'question-tag', 'field' => 'id', 'terms' => $tags))); $the_query = new WP_Query($args); while ($the_query->have_posts()) { $the_query->the_post(); $quiz_questions['ques'][] = get_the_ID(); $quiz_questions['marks'][] = $marks; } wp_reset_postdata(); } else { $quiz_questions = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_questions', false)); $randomize = get_post_meta($quiz_id, 'vibe_quiz_random', true); if (isset($randomize) && $randomize != 'H') { if (isset($quiz_questions['ques']) && is_array($quiz_questions['ques']) && count($quiz_questions['ques']) > 1) { $randomized_keys = array_rand($quiz_questions['ques'], count($quiz_questions['ques'])); shuffle($randomized_keys); foreach ($randomized_keys as $current_key) { $rand_quiz_questions['ques'][] = $quiz_questions['ques'][$current_key]; $rand_quiz_questions['marks'][] = $quiz_questions['marks'][$current_key]; } } $quiz_questions = $rand_quiz_questions; } } add_post_meta($quiz_id, 'quiz_questions' . $user_id, $quiz_questions); }
function bp_course_quiz_auto_submit($quiz_id, $user_id) { $quiz_auto_evaluate = get_post_meta($quiz_id, 'vibe_quiz_auto_evaluate', true); if (vibe_validate($quiz_auto_evaluate)) { // Auto Evaluate for Quiz Enabled, Quiz auto evaluate, autoevaluate $total_marks = 0; $questions = vibe_sanitize(get_post_meta($quiz_id, 'quiz_questions' . $user_id, false)); if (!isset($questions) || !is_array($questions)) { // Fallback for Older versions $questions = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_questions', false)); } if (count($questions)) { $sum = $max_sum = 0; foreach ($questions['ques'] as $key => $question) { // Grab all the Questions if (isset($question) && $question) { $type = get_post_meta($question, 'vibe_question_type', true); $auto_evaluate_question_types = vibe_get_option('auto_eval_question_type'); if (isset($auto_evaluate_question_types) && is_Array($auto_evaluate_question_types) && count($auto_evaluate_question_types)) { // Validated } else { $auto_evaluate_question_types = array('single'); } if (isset($type) && in_array($type, $auto_evaluate_question_types)) { $correct_answer = get_post_meta($question, 'vibe_question_answer', true); $comments_query = new WP_Comment_Query(); $comments = $comments_query->query(array('post_id' => $question, 'user_id' => $user_id, 'number' => 1, 'status' => 'approve')); foreach ($comments as $comment) { $comment->comment_content = trim($comment->comment_content, ','); if ($comment->comment_content == $correct_answer) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; } else { if ($type == 'multiple') { if (!strlen($comment->comment_content)) { $marks = 0; } else { $marked_answers = explode(',', $comment->comment_content); if (!is_array($marks_answers)) { // Force Array Form $marks_answers = array($marks_answers); } $correct_answers = explode(',', $correct_answer); if (!is_array($correct_answers)) { // Force Array Form $correct_answers = array($correct_answers); } sort($marked_answers); sort($correct_answers); if (array_diff($marked_answers, $correct_answers) == array_diff($correct_answers, $marked_answers)) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; } else { $marks = apply_filters('wplms_incorrect_quiz_answer', 0, $comment->comment_content, $question); } } } elseif ($type == 'smalltext' || $type == 'fillblank') { if (strpos($correct_answer, ',')) { $correct_answers_array = explode(',', $correct_answer); foreach ($correct_answers_array as $c_answer) { if (strtolower($c_answer) == strtolower($comment->comment_content)) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; break; } } } } else { $marks = apply_filters('wplms_incorrect_quiz_answer', 0, $comment->comment_content, $question); } } update_comment_meta($comment->comment_ID, 'marks', $marks); } //END-For } } } if (update_post_meta($quiz_id, $user_id, $total_marks)) { $message = __('You\'ve obtained ', 'vibe') . $total_marks . __(' out of ', 'vibe') . array_sum($questions['marks']) . __(' in quiz ', 'vibe') . ' <a href="' . get_permalink($quiz_id) . '">' . get_the_title($quiz_id) . '</a>'; $sender_id = get_post_field('post_author', $quiz_id); if (!is_numeric($sender_id)) { $sender_id = get_current_user_id(); } if (function_exists('messages_new_message')) { messages_new_message(array('sender_id' => $sender_id, 'subject' => __('Quiz results available', 'vibe'), 'content' => $message, 'recipients' => $user_id)); } $max_marks = array_sum($questions['marks']); $activity_id = bp_course_record_activity(array('action' => __('Quiz Auto Evaluated', 'vibe'), 'content' => __('Quiz ', 'vibe') . get_the_title($quiz_id) . __(' auto evaluated for student ', 'vibe') . bp_core_get_userlink($user_id) . __(' with marks ', 'vibe') . ' = ' . $total_marks . __('/', 'vibe') . $max_marks, 'type' => 'evaluate_quiz', 'primary_link' => get_permalink($quiz_id), 'item_id' => $quiz_id, 'secondary_item_id' => $user_id)); bp_course_record_activity_meta(array('id' => $activity_id, 'meta_key' => 'instructor', 'meta_value' => get_post_field('post_author', $quiz_id))); do_action('badgeos_wplms_evaluate_quiz', $quiz_id, $total_marks, $user_id); } } } else { // End Auto evaluate and Send notification to instructor if (function_exists('messages_new_message')) { $instructor_id = get_post_field('post_author', $quiz_id); $course_id = get_post_meta($quiz_id, 'vibe_course', true); if (isset($course_id) && is_numeric($course_id)) { $quiz_link = '<a href="' . get_permalink($course_id) . '?action=admin&submissions">' . get_the_title($quiz_id) . '</a>'; } else { $quiz_link = get_the_title($quiz_id); } $message = sprintf(__('Quiz %s submitted by student %s for evaluation', 'vibe'), $quiz_link, bp_core_get_userlink($user_id)); messages_new_message(array('sender_id' => $user_id, 'subject' => __('Quiz submitted for evaluation', 'vibe'), 'content' => $message, 'recipients' => $instructor_id)); } } }
$id = vibe_get_bp_page_id('course'); $title = get_post_meta($id, 'vibe_title', true); if (!isset($title) || !$title || vibe_validate($title)) { ?> <section id="title"> <div class="<?php echo vibe_get_container(); ?> "> <div class="row"> <div class="col-md-9 col-sm-8"> <div class="pagetitle"> <?php $breadcrumbs = get_post_meta($id, 'vibe_breadcrumbs', true); if (!isset($breadcrumbs) || !$breadcrumbs || vibe_validate($breadcrumbs)) { vibe_breadcrumbs(); } ?> <h1><?php echo vibe_get_title($id); ?> </h1> <?php the_sub_title($id); ?> </div> </div> <div class="col-md-3 col-sm-4"> <?php do_action('wplms_be_instructor_button');