示例#1
0
 public function testStudentCanStudy()
 {
     // Current user cannot study course 1.
     $can_study = ib_edu_student_can_study($this->lessons[0]);
     $this->assertEquals(false, $can_study);
     // Current user can study course 3.
     $can_study = ib_edu_student_can_study($this->lessons[2]);
     $this->assertEquals(true, $can_study);
 }
示例#2
0
/**
 *
 */
function training_wpo_get_course_lessons_index($course_id)
{
    $id = get_the_ID();
    $api = IB_Educator::get_instance();
    $lessons_query = $api->get_lessons($course_id);
    $number = 0;
    if ($lessons_query && $lessons_query->have_posts()) {
        while ($lessons_query->have_posts()) {
            $number++;
            $lessons_query->the_post();
            $student_can_study = ib_edu_student_can_study(get_the_ID());
            $options = get_post_meta(get_the_ID(), 'wpo_postconfig_other', true);
            ?>

			<div class="lesson<?php 
            if (get_the_ID() == $id) {
                ?>
 active<?php 
            }
            ?>
">
				<span class="number"><?php 
            echo esc_attr($number);
            ?>
</span>
				<span class="lesson-icon"><i class="<?php 
            echo training_wpo_related_post();
            ?>
"></i></span>
				<a class="title" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
					<?php 
            if ($student_can_study) {
                ?>
		            <i class="zmdi zmdi-check"></i>
		         <?php 
            } else {
                ?>
		            <span class="zmdi zmdi-lock-outline"></span>
		         <?php 
            }
            ?>
		         <div class="clearfix"></div>
				<?php 
            if (isset($options['duration']) && $options['duration']) {
                ?>
		         <span class="duration"><?php 
                echo esc_attr($options['duration']);
                ?>
</span>
		   	<?php 
            }
            ?>
				</a>
			</div>
		<?php 
        }
        wp_reset_postdata();
    }
}
<?php

$lesson_id = get_the_ID();
$student_can_study = ib_edu_student_can_study(get_the_ID());
$classes = apply_filters('ib_educator_lesson_classes', array('ib-edu-lesson'), $lesson_id);
$options = get_post_meta(get_the_id(), 'wpo_postconfig_other', true);
global $number;
if ($number) {
    $number++;
} else {
    $number = 1;
}
?>
<article id="lesson-<?php 
the_ID();
?>
" class="<?php 
echo esc_attr(implode(' ', $classes));
?>
">
	<div class="lesson-heading">
      <span div class="number"><?php 
echo esc_attr($number);
?>
</span>
      <a href="<?php 
the_permalink();
?>
">
         <?php 
the_title();