function wplms_custom_unit_header($unit_id, $course_id)
{
    if (get_post_type($unit_id) == 'quiz') {
        in_quiz_timer(array('quiz_id' => $unit_id));
    } else {
        if (get_post_type($unit_id) == 'unit') {
            the_unit_tags($unit_id);
            $id = $unit_id;
        } else {
            $id = $course_id;
        }
        the_unit_instructor($id);
    }
}
Exemple #2
0
        ?>
</span></span>
        </div>
        <div id="unit" class="quiz_title" data-unit="<?php 
        if (isset($unit_id)) {
            echo $unit_id;
        }
        ?>
">
            <?php 
        if (isset($unit_id)) {
            the_unit_tags($unit_id);
            if (is_numeric($unit_id)) {
                the_unit_instructor($unit_id);
            } else {
                the_unit_instructor($course_id);
            }
        }
        $minutes = 0;
        $mins = get_post_meta($unit_id, 'vibe_duration', true);
        $unit_duration_parameter = apply_filters('vibe_unit_duration_parameter', 60);
        $unit_duration = $mins * $unit_duration_parameter;
        do_action('wplms_course_unit_meta');
        echo '<span><i class="icon-clock"></i> ' . tofriendlytime($unit_duration) . '</span>';
        ?>
            <h1><?php 
        if (isset($course_id)) {
            echo get_the_title($unit_id);
        } else {
            the_title();
        }
Exemple #3
0
function unit_traverse1()
{
    $unit_id = $_POST['id'];
    $course_id = $_POST['course_id'];
    if (!isset($_POST['security']) || !wp_verify_nonce($_POST['security'], 'security')) {
        _e('Security check Failed. Contact Administrator.', 'vibe');
        die;
    }
    // Check if user has taken the course
    $user_id = get_current_user_id();
    $coursetaken = get_user_meta($user_id, $course_id, true);
    //if(!isset($_COOKIE['course'])) {
    //   code cũ if($coursetaken>time()){
    if ($coursetaken) {
        setcookie('course', $course_id, $expire, '/');
        $_COOKIE['course'] = $course_id;
    } else {
        $pid = get_post_meta($course_id, 'vibe_product', true);
        $pid = apply_filters('wplms_course_product_id', $pid, $course_id, -1);
        // $id checks for Single Course page or Course page in the my courses section
        if (is_numeric($pid)) {
            $pid = get_permalink($pid);
        }
        echo '<div class="message"><p>' . __('Course Expired.', 'vibe') . '<a href="' . $pid . '" class="link alignright">' . __('Click to renew', 'vibe') . '</a></p></div>';
        die;
    }
    //}
    if (isset($coursetaken) && $coursetaken) {
        $course_curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false));
        $units = array();
        foreach ($course_curriculum as $key => $curriculum) {
            if (is_numeric($curriculum)) {
                $units[] = $curriculum;
            }
        }
        // Drip Feed Check
        $drip_enable = get_post_meta($course_id, 'vibe_course_drip', true);
        if (vibe_validate($drip_enable)) {
            $drip_duration = get_post_meta($course_id, 'vibe_course_drip_duration', true);
            $unitkey = array_search($unit_id, $units);
            if ($unitkey == 0) {
                $pre_unit_time = get_post_meta($units[$unitkey], $user_id, true);
                if (!isset($pre_unit_time) || $pre_unit_time == '') {
                    add_post_meta($units[$unitkey], $user_id, time());
                }
            } else {
                $pre_unit_time = get_post_meta($units[$unitkey - 1], $user_id, true);
                if (isset($pre_unit_time) && $pre_unit_time) {
                    $drip_duration_parameter = apply_filters('vibe_drip_duration_parameter', 86400);
                    $value = $pre_unit_time + $drip_duration * $drip_duration_parameter;
                    $value = apply_filters('wplms_drip_value', $value, $units[$unitkey - 1], $course_id);
                    if ($value > time()) {
                        echo '<div class="message"><p>' . __('Unit will be available in ', 'vibe') . tofriendlytime($pre_unit_time + $drip_duration * $drip_duration_parameter - time()) . '</p></div>';
                        die;
                    } else {
                        $pre_unit_time = get_post_meta($units[$unitkey], $user_id, true);
                        if (!isset($pre_unit_time) || $pre_unit_time == '') {
                            add_post_meta($units[$unitkey], $user_id, time());
                            bp_course_record_activity(array('action' => __('Student started a unit', 'vibe'), 'content' => __('Student started the unit ', 'vibe') . get_the_title($unit_id) . __(' in course ', 'vibe') . get_the_title($course_id), 'type' => 'unit', 'primary_link' => get_permalink($unit_id), 'item_id' => $unit_id, 'secondary_item_id' => $user_id));
                        }
                    }
                } else {
                    echo '<div class="message"><p>' . __('Unit can not be accessed.', 'vibe') . '</p></div>';
                    die;
                }
            }
        }
        // END Drip Feed Check
        echo '<div class="tabheader" style="width:77.7%;">
<span class="title_unit" >' . get_the_title($unit_id) . '</span>
</div>';
        $typequiz = get_post_type($unit_id);
        if ($typequiz == "quiz") {
            do_action('wplms_unit_header', $unit_id, $course_id);
        }
        echo '<div id="unit" class="quiz_title" data-unit="' . $unit_id . '">';
        the_unit_tags($unit_id);
        the_unit_instructor($unit_id);
        $minutes = 0;
        $mins = get_post_meta($unit_id, 'vibe_duration', true);
        $unit_duration_parameter = apply_filters('vibe_unit_duration_parameter', 60);
        if ($mins) {
            if ($mins > $unit_duration_parameter) {
                $hours = floor($mins / $unit_duration_parameter);
                $minutes = $mins - $hours * $unit_duration_parameter;
            } else {
                $minutes = $mins;
            }
            do_action('wplms_course_unit_meta');
            if ($mins < 9999) {
                if ($unit_duration_parameter == 1) {
                    echo '<span><i class="icon-clock"></i> ' . (isset($hours) ? $hours . __(' Minutes', 'vibe') : '') . ' ' . $minutes . __(' seconds', 'vibe') . '</span>';
                } else {
                    if ($unit_duration_parameter == 60) {
                        echo '<span><i class="icon-clock"></i> ' . (isset($hours) ? $hours . __(' Hours', 'vibe') : '') . ' ' . $minutes . __(' minutes', 'vibe') . '</span>';
                    } else {
                        if ($unit_duration_parameter == 3600) {
                            echo '<span><i class="icon-clock"></i> ' . (isset($hours) ? $hours . __(' Days', 'vibe') : '') . ' ' . $minutes . __(' hours', 'vibe') . '</span>';
                        }
                    }
                }
            }
        }
        echo '<div class="clear"></div>';
        echo '<h1>' . get_the_title($unit_id) . '</h1>';
        echo '<h3>';
        the_sub_title($unit_id);
        echo '</h3></div>';
        the_unit($unit_id);
        $unit_class = 'unit_button';
        $hide_unit = 0;
        $nextunit_access = vibe_get_option('nextunit_access');
        $k = array_search($unit_id, $units);
        $done_flag = get_user_meta($user_id, $unit_id, true);
        $next = $k + 1;
        $prev = $k - 1;
        $max = count($units) - 1;
        echo '<div class="unit_prevnext">';
        echo '<div class="col-md-2"> <span class="backtocourse" data-id="' . $course_id . '"><i class="icon-arrow-1-left"></i> Trở về khóa học </span></div>';
        echo '<div class="col-md-2">';
        if ($prev >= 0) {
            if (get_post_type($units[$prev]) == 'quiz') {
                $quiz_status = get_user_meta($user_id, $units[$prev], true);
                if (!empty($quiz_status)) {
                    echo '<a href="#" data-unit="' . $units[$prev] . '" class="' . $unit_class . '">' . __('Back to Quiz', 'vibe') . '</a>';
                } else {
                    echo '<a href="' . get_permalink($units[$prev]) . '" class="unit_button">' . __('Back to Quiz', 'vibe') . '</a>';
                }
            } else {
                echo '<a href="#" id="prev_unit" data-unit="' . $units[$prev] . '" class="unit unit_button">' . __('Previous Unit', 'vibe') . '</a>';
            }
        }
        echo '</div>';
        echo '<div class="col-md-2">';
        if ($next <= $max) {
            if (isset($nextunit_access) && $nextunit_access) {
                $hide_unit = 1;
                if (isset($done_flag) && $done_flag) {
                    $unit_class .= ' ';
                    $hide_unit = 0;
                } else {
                    $unit_class .= ' hide';
                    $hide_unit = 1;
                }
            }
            if (get_post_type($units[$next]) == 'quiz') {
                $quiz_status = get_user_meta($user_id, $units[$next], true);
                if (!empty($quiz_status)) {
                    echo '<a href="#" data-unit="' . $units[$next] . '" class="unit ' . $unit_class . '">' . __('Proceed to Quiz', 'vibe') . '</a>';
                } else {
                    //                    echo '<a href="'.get_permalink($units[$next]).'" class=" unit_button">'.__('Proceed to Quiz','vibe').'</a>';
                    echo '<a href="#" data-unit="' . $units[$next] . '" class="unit ' . $unit_class . '">' . __('Proceed to Quiz', 'vibe') . '</a>';
                }
            } else {
                echo '<a href="#" id="next_unit" ' . ($hide_unit ? '' : 'data-unit="' . $units[$next] . '"') . ' class="unit ' . $unit_class . '">' . __('Next Unit', 'vibe') . '</a>';
            }
        }
        echo '</div>';
        echo '<div class="col-md-4" style="text-align: center">';
        if (get_post_type($units[$k]) == 'quiz') {
            $quiz_status = get_user_meta($user_id, $units[$k], true);
            //            if(!empty($quiz_status)){
            //                echo '<a href="'.bp_loggedin_user_domain().BP_COURSE_SLUG.'/'.BP_COURSE_RESULTS_SLUG.'/?action='.$units[($k)].'" class="quiz_results_popup">'.__('Check Results','vibe').'</a>';
            //            }else{
            //                echo '<a href="'.get_permalink($units[($k)]).'" class=" unit_button start_quiz">'.__('Start Quiz','vibe').'</a>';
            //            }
            if (is_numeric($quiz_status)) {
                if ($quiz_status < time()) {
                    echo '<script>document.getElementsByClassName("quiz_meta")[0].style.display = "none"</script>';
                    echo '<a href="' . bp_loggedin_user_domain() . BP_COURSE_SLUG . '/' . BP_COURSE_RESULTS_SLUG . '/?action=' . $units[$k] . '" class="quiz_results_popup">' . __('Check Results', 'vibe') . '</a>';
                } else {
                    $quiz_class = apply_filters('wplms_in_course_quiz', '');
                    echo '<a href="' . get_permalink($units[$k]) . '" class=" unit_button ' . $quiz_class . ' continue">' . __('Continue Quiz', 'vibe') . '</a>';
                }
            } else {
                $quiz_class = apply_filters('wplms_in_course_quiz', '');
                echo '<a href="' . get_permalink($units[$k]) . '" class=" unit_button ' . $quiz_class . '">' . __('Start Quiz', 'vibe') . '</a>';
            }
        } else {
            echo isset($done_flag) && $done_flag ? '' : apply_filters('wplms_unit_mark_complete', '<a href="#" id="mark-complete" data-unit="' . $units[$k] . '" class="unit_button">' . __('Mark this Unit Complete', 'vibe') . '</a>', $unit_id, $course_id);
        }
        echo '</div>';
        echo '<div class="col-md-2">';
        echo '<span class="auto_complete" data-id="false"> </span>';
        echo '</div>';
        echo '</div></div>';
    }
    die;
}