function learn_press_user_finished_course_send_email($course_id = null, $user_id = null)
{
    $course_id = learn_press_get_course_id($course_id);
    if (!$user_id) {
        $user_id = get_current_user_id();
    }
    $user = get_user_by('id', $user_id);
    if (empty($user->ID) || !$course_id) {
        return false;
    }
    $mail_to = $user->user_email;
    $assessment = get_post_meta($course_id, '_lpr_course_final', true);
    if ('yes' == $assessment) {
        $quiz_id = lpr_get_final_quiz($course_id);
        $quiz_result = learn_press_get_quiz_result($user_id, $quiz_id);
        $course_result = $quiz_result['mark_percent'] * 100;
    } else {
        $course_result = 100;
    }
    $args = apply_filters('learn_press_vars_passed_course', array('user_name' => !empty($user->display_name) ? $user->display_name : $user->user_nicename, 'course_name' => get_the_title($course_id), 'course_link' => get_permalink($course_id), 'course_result' => sprintf(__('%d%% of total', 'learn_press'), intval($course_result))));
    learn_press_send_mail($mail_to, 'passed_course', $args);
}
示例#2
0
<?php

$course_id = learn_press_get_course_by_quiz(get_the_ID());
$passed = learn_press_user_has_passed_course($course_id);
$result = learn_press_get_quiz_result();
?>
<div class="clearfix"></div>
<?php 
if ($passed) {
    ?>
    <?php 
    learn_press_message(sprintf(__('You have passed this course with %.2f%% of total', 'learn_press'), $result['mark_percent'] * 100));
} else {
    ?>
    <?php 
    $passing_condition = learn_press_get_course_passing_condition($course_id);
    ?>
    <?php 
    learn_press_message(sprintf(__('Sorry, you have not passed this course. This course required you pass %.2f%% but your result is only %.2f%%', 'learn_press'), $passing_condition, $result['mark_percent'] * 100), 'error');
}
示例#3
0
<?php

$result = learn_press_get_quiz_result($quiz_id);
?>

<div class="quiz-result">
	<div class="quiz-title">
		<a href="<?php 
echo get_permalink($quiz_id);
?>
"><?php 
echo get_the_title($quiz_id);
?>
</a>
	</div>
	<div class="quiz-result-mark">
		<span class="quiz-mark"><?php 
echo $result['mark'];
?>
			<small>/ <?php 
echo $result['mark_total'];
?>
</small></span>
		<small><?php 
_e('point');
?>
</small>
	</div>
	<div class="quiz-result-summary">
		<div class="quiz-result-field correct">
			<label><?php 
/**
 * Get the results of a quiz
 * @param $quiz_id
 * @param null $user_id
 * @return mixed
 */
function learn_press_quiz_evaluation($quiz_id, $user_id = null)
{
    if (!$user_id) {
        $user_id = get_current_user_id();
    }
    $result = learn_press_get_quiz_result($user_id, $quiz_id);
    return $result['mark_percent'] * 100;
}
示例#5
0
 /**
  * Finish course
  */
 public static function finish_course()
 {
     $user_id = get_current_user_id();
     $course_id = !empty($_POST['course_id']) ? $_POST['course_id'] : 0;
     if (!$user_id || !$course_id) {
         wp_die(__('Access denied!', 'learn_press'));
     }
     $finish = false;
     $json = array('finish' => true);
     $assessment = get_post_meta($course_id, '_lpr_course_final', true);
     $pass = floatval(get_post_meta($course_id, '_lpr_course_condition', true));
     if ($assessment == 'yes') {
         $final_quiz = lpr_get_final_quiz($course_id);
         $final_result = learn_press_get_quiz_result($user_id, $final_quiz);
         // lpr_get_quiz_result( $final_quiz );
         if (!empty($final_result) && !empty($final_result['mark_percent']) && $final_result['mark_percent'] * 100 >= $pass) {
             $finish = true;
         }
     } else {
         $progress = lpr_course_evaluation($course_id);
         if ($progress >= $pass) {
             $finish = true;
         }
     }
     if ($finish) {
         learn_press_finish_course($course_id, $user_id);
         $json['message'] = __('Congratulation ! You have finished this course', 'learn_press');
     } else {
         $json['finish'] = false;
         $json['message'] = __('Sorry! You can not finish this course now', 'learn_press');
     }
     wp_send_json($json);
     die;
 }
function learn_press_course_lesson_quiz_before_title($lesson_or_quiz, $enrolled)
{
    global $learn_press_lesson_quiz_tooltips;
    if (!$learn_press_lesson_quiz_tooltips) {
        $learn_press_lesson_quiz_tooltips = array();
    }
    if (!empty($learn_press_lesson_quiz_tooltips[$lesson_or_quiz])) {
        return;
    }
    if (!$enrolled) {
        if ('lpr_quiz' == get_post_type($lesson_or_quiz)) {
            $learn_press_lesson_quiz_tooltips[$lesson_or_quiz] = array('message' => __('This is a quiz. Please enroll to do this quiz', 'learn_press'));
        } else {
            $learn_press_lesson_quiz_tooltips[$lesson_or_quiz] = array('message' => __('This is a lesson. Please enroll to study this lesson', 'learn_press'));
        }
    } else {
        if ('lpr_quiz' == get_post_type($lesson_or_quiz)) {
            if (learn_press_user_has_started_quiz(null, $lesson_or_quiz)) {
                $result = learn_press_get_quiz_result(null, $lesson_or_quiz);
                $tooltip = sprintf(__('%s and answered correctly %d out of %d total questions', 'learn_press'), learn_press_user_has_completed_quiz(null, $lesson_or_quiz) ? __('You have finished this quiz', 'learn_press') : __('You have started this quiz', 'learn_press'), $result['correct'], $result['questions_count']);
            } else {
                $tooltip = __('This is a quiz. Click on link to complete this quiz', 'learn_press');
            }
            $learn_press_lesson_quiz_tooltips[$lesson_or_quiz] = array('message' => $tooltip);
        } else {
            if (learn_press_user_has_completed_lesson($lesson_or_quiz)) {
                $learn_press_lesson_quiz_tooltips[$lesson_or_quiz] = array('completed' => __('Congratulations! You have completed this lesson', 'learn_press'));
            } else {
                $learn_press_lesson_quiz_tooltips[$lesson_or_quiz] = array('current' => __('You are studying this lesson', 'learn_press'), 'message' => __('This is a lesson. Click on link to complete this lesson', 'learn_press'));
            }
        }
    }
    if ('lpr_quiz' == get_post_type($lesson_or_quiz)) {
        echo '<span class="lesson-quiz-icon quiz"></span>';
    } else {
        echo '<span class="lesson-quiz-icon lesson"></span>';
    }
}
示例#7
0
<?php

$result = learn_press_get_quiz_result($user_id, $quiz_id);
?>

<div class="quiz-result">
	<div class="quiz-title">
		<a href="<?php 
echo get_permalink($quiz_id);
?>
"><?php 
echo get_the_title($quiz_id);
?>
</a>
	</div>
	<div class="quiz-result-mark">
		<span class="quiz-mark"><?php 
echo $result['mark'];
?>
			<small>/ <?php 
echo $result['mark_total'];
?>
</small></span>
		<small><?php 
_e('point', 'learn_press');
?>
</small>
	</div>
	<div class="quiz-result-summary">
		<div class="quiz-result-field correct">
			<label><?php 
示例#8
0
<?php

//$course_id = learn_press_get_course_by_quiz( get_the_ID() );
$course_id = get_the_ID();
$passed = learn_press_user_has_passed_course($course_id);
$result = learn_press_get_quiz_result(null, $quiz_id);
$result = learn_press_get_course_result($course_id);
?>
    <div class="clearfix"></div>
<?php 
if ($passed) {
    ?>
    <?php 
    learn_press_message(sprintf(__('You have passed this course with %.2f%% of total', 'learn_press'), $result));
} else {
    ?>
    <?php 
    $passing_condition = learn_press_get_course_passing_condition($course_id);
    ?>
    <?php 
    learn_press_message(sprintf(__('Sorry, you have not passed this course. This course required you pass %.2f%% but your result is only %.2f%%', 'learn_press'), $passing_condition, $result), 'error');
}
/**
 * Get the results of a quiz
 *
 * @param      $quiz_id
 * @param null $user_id
 *
 * @return mixed
 */
function learn_press_quiz_evaluation($quiz_id, $user_id = null)
{
    if (!$user_id) {
        $user_id = get_current_user_id();
    }
    $result = learn_press_get_quiz_result($user_id, $quiz_id);
    $return = $result['mark_percent'] * 100;
    // @since 0.9.6
    return apply_filters('learn_press_quiz_evaluation', $return, $quiz_id, $user_id);
}