function wplms_assignments_before_single_assignment() { if (!is_user_logged_in()) { return; } global $post; $user_id = get_current_user_id(); if (wplms_assignment_answer_posted()) { if (update_post_meta($post->ID, $user_id, 0)) { do_action('wplms_submit_assignment', $post->ID, $user_id); return; } } }
<?php if (is_user_logged_in()) { global $post; $user_id = get_current_user_id(); $answers = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'user_id' => $user_id)); if (isset($answers) && is_array($answers) && count($answers)) { $answer = end($answers); $content = $answer->comment_content; } else { $content = ''; } $fields = array('author' => '<p><label class="comment-form-author clearfix">' . __('Name', 'vibe') . ($req ? '<span class="required">*</span>' : '') . '</label> ' . '<input class="form_field" id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" /></p>', 'email' => '<p><label class="comment-form-email clearfix">' . __('Email', 'vibe') . ($req ? '<span class="required">*</span>' : '') . '</label> ' . '<input id="email" class="form_field" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '"/></p>', 'url' => '<p><label class="comment-form-url clearfix">' . __('Website', 'vibe') . '</label>' . '<input id="url" name="url" type="text" class="form_field" value="' . esc_attr($commenter['comment_author_url']) . '"/></p>'); ob_start(); wp_editor($content, 'comment', array('media_buttons' => false, 'textarea_name' => 'comment')); $comment_field = ob_get_clean(); // $comment_field='<p>' . '<textarea id="comment" name="comment" class="form_field" rows="15" ">'.$content.'</textarea></p>'; comment_form(array('fields' => $fields, 'comment_field' => $comment_field, 'label_submit' => __('Answer Assignment', 'vibe'), 'title_reply' => '<span>' . __('Answer', 'vibe') . '</span>', 'logged_in_as' => '', 'comment_notes_after' => '')); if (wplms_assignment_answer_posted()) { echo '<p class="message success">' . __('Assignment submitted !', 'vibe') . '</p>'; } }
function assignment_submit_button() { global $post; if (!is_user_logged_in()) { return; } $user_id = get_current_user_id(); $evaluation = get_post_meta($post->ID, 'vibe_assignment_evaluation', true); if (isset($evaluation)) { $course = get_post_meta($post->ID, 'vibe_assignment_course', true); $coursestarted = get_user_meta($user_id, $course, true); // Check if Connected course is started if (isset($coursestarted) && $coursestarted > time()) { // Course is Still active if (wplms_assignment_answer_posted()) { echo '<form method="post"> <input type="submit" name="submit_assignment" class="submit_assignment button primary" value="' . __('SUBMIT ASSIGNMENT', 'wplms-assignments') . '" />'; wp_nonce_field('assignment' . $post->ID, 'security'); echo '</form>'; } } else { echo '<a href="' . get_permalink($course) . '" class="button primary full">' . __('INACTIVE COURSE ', 'wplms-assignments') . '</a>'; } } else { if (wplms_assignment_answer_posted()) { echo '<form method="post"> <input type="submit" name="submit_assignment" class="button primary full" value="' . __('SUBMIT ASSIGNMENT', 'wplms-assignments') . '" />'; wp_nonce_field('assignment' . $post->ID, 'security'); echo '</form>'; } } }