Пример #1
0
 function required_lessons($course_id, $student_id)
 {
     global $wpdb;
     $required_lessons_ids = get_post_meta($course_id, 'namaste_required_lessons', true);
     if (!is_array($required_lessons_ids)) {
         return array();
     }
     $required_lessons = $wpdb->get_results("SELECT * FROM {$wpdb->posts} \n\t\t\tWHERE ID IN (" . implode(",", $required_lessons_ids) . ") ORDER BY ID");
     foreach ($required_lessons as $cnt => $lesson) {
         $required_lessons[$cnt]->namaste_completed = 0;
         if (NamasteLMSLessonModel::is_completed($lesson->ID, $student_id)) {
             $required_lessons[$cnt]->namaste_completed = 1;
         }
     }
     return $required_lessons;
 }
Пример #2
0
function namaste_mark()
{
    global $wpdb, $post, $user_ID;
    if (!is_user_logged_in()) {
        return "";
    }
    // ready for completion?
    if (NamasteLMSLessonModel::is_completed($post->ID, $user_ID)) {
        return __('Lesson completed!', 'namaste');
    } elseif (NamasteLMSLessonModel::is_ready($post->ID, $user_ID, false, true)) {
        // display button or mark as completed
        if (!empty($_POST['mark'])) {
            NamasteLMSLessonModel::complete($post->ID, $user_ID);
            return __('Lesson completed!', 'namaste');
        } else {
            return '<form method="post" action="">
				<p><input type="submit" class="namaste-mark" name="mark" value="' . __('Mark as completed', 'namaste') . '"></p>
				</form>';
        }
    } else {
        return '<form method="post" action="">
				<p><input type="submit" class="namaste-mark" name="mark" value="' . __('Mark as completed', 'namaste') . '" disabled="disabled"></p>
				</form>';
    }
}