/** * post_type_custom_column_content function. * * @access public * @since 1.0.0 * @return void */ public function post_type_custom_column_content($column_name, $post_ID) { $user_id = get_post_meta($post_ID, $key = 'learner_id', true); $course_id = get_post_meta($post_ID, $key = 'course_id', true); $user = get_userdata($user_id); $course = get_post($course_id); $course_end_date = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_date')); $certificate_hash = esc_html(substr(md5($course_id . $user_id), -8)); switch ($column_name) { case "learner": echo '<a href="' . add_query_arg(array('page' => 'sensei_analysis', 'user' => intval($user_id), 'course_id' => intval($course_id)), admin_url('edit.php?post_type=lesson')) . '">' . $user->user_login . '</a>'; break; case "course": echo '<a href="' . add_query_arg(array('page' => 'sensei_analysis', 'course_id' => intval($course_id)), admin_url('edit.php?post_type=lesson')) . '">' . $course->post_title . '</a>'; break; case "date_completed": echo $course_end_date; break; case "actions": echo '<a href="' . add_query_arg(array('certificate' => '1', 'hash' => $certificate_hash), site_url()) . '" target="_blank">' . __('View Certificate', 'sensei-certificates') . '</a>'; break; } // End Switch Statement }
/** * Display output to the admin view * * This view is shown when grading a quiz for a single user in admin under grading * * @since 1.3.0 * @return html */ public function display() { // Get data for the user //echo do_shortcode("[i4w_get_contactId]"); //die(); $questions = $this->build_data_array(); global $woothemes_sensei; $count = 0; $graded_count = 0; $user_quiz_grade_total = 0; $quiz_grade_total = 0; $quiz_grade = 0; $lesson_id = $this->lesson_id; $user_id = $this->user_id; ?> <form name="<?php esc_attr_e('quiz_' . $this->quiz_id); ?> " action="" method="post"> <?php wp_nonce_field('sensei_manual_grading', '_wp_sensei_manual_grading_nonce'); ?> <input type="hidden" name="sensei_manual_grade" value="<?php esc_attr_e($this->quiz_id); ?> " /> <input type="hidden" name="sensei_grade_next_learner" value="<?php esc_attr_e($this->user_id); ?> " /> <div class="total_grade_display"> <span><?php esc_attr_e(__('Grade:', 'woothemes-sensei')); ?> </span> <span class="total_grade_total"><?php echo $user_quiz_grade_total; ?> </span> / <span class="quiz_grade_total"><?php echo $quiz_grade_total; ?> </span> (<span class="total_grade_percent"><?php echo $quiz_grade; ?> </span>%) </div> <div class="buttons"> <input type="submit" value="<?php esc_attr_e(__('Save', 'woothemes-sensei')); ?> " class="grade-button button-primary" title="Saves grades as currently marked on this page" /> <input type="button" value="<?php esc_attr_e(__('Auto grade', 'woothemes-sensei')); ?> " class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" /> <input type="reset" value="<?php esc_attr_e(__('Reset', 'woothemes-sensei')); ?> " class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" /> </div> <div class="clear"></div><br/><?php $lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $this->lesson_id, 'user_id' => $this->user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID')); $user_quiz_grade = get_comment_meta($lesson_status_id, 'grade', true); $correct_answers = 0; foreach ($questions as $question) { $question_id = $question->ID; ++$count; $type = false; $type_name = ''; $type = Sensei()->question->get_question_type($question_id); $question_answer_notes = $woothemes_sensei->quiz->get_user_question_feedback($lesson_id, $question_id, $user_id); $question_grade_total = get_post_meta($question_id, '_question_grade', true); if (!$question_grade_total || 0 == intval($question_grade_total)) { $question_grade_total = 1; } $quiz_grade_total += $question_grade_total; $right_answer = get_post_meta($question_id, '_question_right_answer', true); $user_answer_content = $woothemes_sensei->quiz->get_user_question_answer($lesson_id, $question_id, $user_id); $type_name = __('Multiple Choice', 'woothemes-sensei'); $grade_type = 'manual-grade'; switch ($type) { case 'boolean': $type_name = __('True/False', 'woothemes-sensei'); $right_answer = ucfirst($right_answer); $user_answer_content = ucfirst($user_answer_content); $grade_type = 'auto-grade'; break; case 'multiple-choice': $type_name = __('Multiple Choice', 'woothemes-sensei'); $grade_type = 'auto-grade'; break; case 'gap-fill': $type_name = __('Gap Fill', 'woothemes-sensei'); $right_answer_array = explode('||', $right_answer); if (isset($right_answer_array[0])) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; } if (isset($right_answer_array[1])) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; } if (isset($right_answer_array[2])) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; } if (!$user_answer_content) { $user_answer_content = '______'; } $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post; $user_answer_content = $gapfill_pre . ' <span class="highlight">' . $user_answer_content . '</span> ' . $gapfill_post; $grade_type = 'auto-grade'; break; case 'multi-line': $type_name = __('Multi Line', 'woothemes-sensei'); $grade_type = 'manual-grade'; break; case 'single-line': $type_name = __('Single Line', 'woothemes-sensei'); $grade_type = 'manual-grade'; break; case 'file-upload': $type_name = __('File Upload', 'woothemes-sensei'); $grade_type = 'manual-grade'; // Get uploaded file if ($user_answer_content) { $attachment_id = $user_answer_content; $answer_media_url = $answer_media_filename = ''; if (0 < intval($attachment_id)) { $answer_media_url = wp_get_attachment_url($attachment_id); $answer_media_filename = basename($answer_media_url); if ($answer_media_url && $answer_media_filename) { $user_answer_content = sprintf(__('Submitted file: %1$s', 'woothemes-sensei'), '<a href="' . esc_url($answer_media_url) . '" target="_blank">' . esc_html($answer_media_filename) . '</a>'); } } } else { $user_answer_content = ''; } break; default: // Nothing break; } $user_answer_content = (array) $user_answer_content; $right_answer = (array) $right_answer; $question_title = sprintf(__('Question %d: ', 'woothemes-sensei'), $count) . $type_name; $graded_class = ''; $user_question_grade = $woothemes_sensei->quiz->get_user_question_grade($lesson_id, $question_id, $user_id); $graded_class = 'ungraded'; if (intval($user_question_grade) > 0) { $graded_class = 'user_right'; ++$correct_answers; $user_quiz_grade_total += $user_question_grade; ++$graded_count; } else { if (!is_string($user_question_grade) && intval($user_question_grade) == 0) { $graded_class = 'user_wrong'; ++$graded_count; } $user_question_grade = 0; } ?> <div class="postbox question_box <?php esc_attr_e($type); ?> <?php esc_attr_e($grade_type); ?> <?php esc_attr_e($graded_class); ?> " id="<?php esc_attr_e('question_' . $question_id . '_box'); ?> "> <div class="handlediv" title="Click to toggle"><br></div> <h3 class="hndle"><span><?php echo $question_title; ?> </span></h3> <div class="inside"> <div class="sensei-grading-actions"> <div class="actions"> <input type="hidden" class="question_id" value="<?php esc_attr_e($question_id); ?> " /> <input type="hidden" class="question_total_grade" name="question_total_grade" value="<?php echo $question_grade_total; ?> " /> <span class="grading-mark icon_right"><input type="radio" class="<?php esc_attr_e('question_' . $question_id . '_right_option'); ?> " name="<?php esc_attr_e('question_' . $question_id); ?> " value="right" <?php checked($graded_class, 'user_right', true); ?> /></span> <span class="grading-mark icon_wrong"><input type="radio" class="<?php esc_attr_e('question_' . $question_id . '_wrong_option'); ?> " name="<?php esc_attr_e('question_' . $question_id); ?> " value="wrong" <?php checked($graded_class, 'user_wrong', true); ?> /></span> <input type="number" class="question-grade" name="<?php esc_attr_e('question_' . $question_id . '_grade'); ?> " id="<?php esc_attr_e('question_' . $question_id . '_grade'); ?> " value="<?php esc_attr_e($user_question_grade); ?> " min="0" max="<?php esc_attr_e($question_grade_total); ?> " /> <span class="question-grade-total"><?php echo $question_grade_total; ?> </span> </div> </div> <div class="sensei-grading-answer"> <h4><?php echo apply_filters('sensei_question_title', $question->post_title); ?> </h4> <?php echo apply_filters('the_content', $question->post_content); ?> <p class="user-answer"><?php foreach ($user_answer_content as $_user_answer) { if ('multi-line' == Sensei()->question->get_question_type($question->ID)) { $_user_answer = htmlspecialchars_decode(nl2br(esc_html($_user_answer))); } echo apply_filters('sensei_answer_text', $_user_answer) . "<br>"; } ?> </p> <div class="right-answer"> <h5><?php _e('Correct answer', 'woothemes-sensei'); ?> </h5> <span class="correct-answer"><?php foreach ($right_answer as $_right_answer) { echo apply_filters('sensei_answer_text', $_right_answer) . "<br>"; } ?> </span> </div> <div class="answer-notes"> <h5><?php _e('Grading Notes', 'woothemes-sensei'); ?> </h5> <textarea class="correct-answer" name="questions_feedback[<?php esc_attr_e($question_id); ?> ]" placeholder="<?php _e('Add notes here...', 'woothemes-sensei'); ?> "><?php echo $question_answer_notes; ?> </textarea> </div> </div> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <div> <?php //floyd code to get the note history $historynotes = get_user_meta($_GET['user'], '_grading_notes_history', true); $historyanswers = get_user_meta($_GET['user'], '_grading_answer_history', true); //echo "<pre>"; //echo $question_id." ".$lesson_id; //print_r($historyanswers); //echo "</pre>"; if (is_array($historynotes)) { //print_r($historynotes[$question_id]); if (array_key_exists($question_id, $historynotes) || isset($historynotes[$question_id])) { echo "<table class='table striped'>"; echo "<tr><th colspan='3'>Question History</th></tr>"; echo "<tr>"; echo "<th>DATE</th>"; echo "<th>Answer</th>"; echo "<th>Notes</th>"; echo "</tr>"; foreach ($historynotes[$question_id] as $dateTime => $noteentry) { echo "<tr>"; echo "<td>" . $dateTime . "</td>"; echo "<td>" . $historyanswers[$question_id][$dateTime] . "</td>"; echo "<td>" . $noteentry . "</td>"; echo "</tr>"; } echo "</table>"; } } ?> </div> </div> </div><?php } $quiz_grade = intval($user_quiz_grade); $all_graded = 'no'; if (intval($count) == intval($graded_count)) { $all_graded = 'yes'; } ?> <input type="hidden" name="total_grade" id="total_grade" value="<?php esc_attr_e($user_quiz_grade_total); ?> " /> <input type="hidden" name="total_questions" id="total_questions" value="<?php esc_attr_e($count); ?> " /> <input type="hidden" name="quiz_grade_total" id="quiz_grade_total" value="<?php esc_attr_e($quiz_grade_total); ?> " /> <input type="hidden" name="total_graded_questions" id="total_graded_questions" value="<?php esc_attr_e($graded_count); ?> " /> <input type="hidden" name="all_questions_graded" id="all_questions_graded" value="<?php esc_attr_e($all_graded); ?> " /> <div class="total_grade_display"> <span><?php esc_attr_e(__('Grade:', 'woothemes-sensei')); ?> </span> <span class="total_grade_total"><?php echo $user_quiz_grade_total; ?> </span> / <span class="quiz_grade_total"><?php echo $quiz_grade_total; ?> </span> (<span class="total_grade_percent"><?php echo $quiz_grade; ?> </span>%) </div> <div class="buttons"> <input type="submit" value="<?php esc_attr_e('Save'); ?> " class="grade-button button-primary" title="Saves grades as currently marked on this page" /> <input type="button" value="<?php esc_attr_e(__('Auto grade', 'woothemes-sensei')); ?> " class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" /> <input type="reset" value="<?php esc_attr_e(__('Reset', 'woothemes-sensei')); ?> " class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" /> </div> <div class="clear"></div> <script type="text/javascript"> jQuery( window ).load( function() { // Calculate total grade on page load to make sure everything is set up correctly jQuery.fn.autoGrade(); }); </script> </form><?php }
/** * @deprecated use WooThemes_Sensei_Quiz::get_user_answers * @param int $lesson_id * @return array */ public function sensei_get_user_quiz_answers($lesson_id = 0) { global $current_user, $woothemes_sensei; $user_answers = array(); if (0 < intval($lesson_id)) { $lesson_quiz_questions = $woothemes_sensei->post_types->lesson->lesson_quiz_questions($lesson_id); foreach ($lesson_quiz_questions as $question) { $answer = maybe_unserialize(base64_decode(WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content')))); $user_answers[$question->ID] = $answer; } } return $user_answers; }
/** * Check if a user has started a lesson or not * * @since 1.7.0 * @param type $lesson_id * @param type $user_id * @return mixed false or comment_ID */ public static function user_started_lesson($lesson_id = 0, $user_id = 0) { if ($lesson_id) { if (!$user_id) { $user_id = get_current_user_id(); } $user_lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID')); if ($user_lesson_status_id) { return $user_lesson_status_id; } } return false; }
/** * sensei_update_users_certificate_data install user certificate data * @since 1.0.0 * @param int $n number of items to iterate through * @param int $offeset number to offset iteration by * @return boolean */ function sensei_update_users_certificate_data($n = 5, $offset = 0) { $loop_ran = false; // Calculate if this is the last page if (0 == $offset) { $current_page = 1; } else { $current_page = intval($offset / $n); } // End If Statement $args_array = array('number' => $n, 'offset' => $offset, 'orderby' => 'ID', 'order' => 'DESC', 'fields' => 'all_with_meta'); $wp_user_update = new WP_User_Query($args_array); $users = $wp_user_update->get_results(); $user_count = count_users(); $total_items = $user_count['total_users']; $query_total = $wp_user_update->get_total(); $total_pages = intval($total_items / $n); foreach ($users as $user_key => $user_item) { $course_ids = WooThemes_Sensei_Utils::sensei_activity_ids(array('user_id' => $user_item->ID, 'type' => 'sensei_course_start')); $posts_array = array(); if (0 < intval(count($course_ids))) { $posts_array = Sensei()->course->course_query(-1, 'usercourses', $course_ids); } // End If Statement foreach ($posts_array as $course_item) { $course_end_date = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_item->ID, 'user_id' => $user_item->ID, 'type' => 'sensei_course_end', 'field' => 'comment_date')); if (isset($course_end_date) && '' != $course_end_date) { $args = array('post_type' => 'certificate', 'author' => $user_item->ID, 'meta_key' => 'course_id', 'meta_value' => $course_item->ID); $query = new WP_Query($args); if (!$query->have_posts()) { // Insert custom post type $cert_args = array('post_author' => intval($user_item->ID), 'post_title' => esc_html(substr(md5($course_item->ID . $user_item->ID), -8)), 'post_name' => esc_html(substr(md5($course_item->ID . $user_item->ID), -8)), 'post_type' => 'certificate', 'post_status' => 'publish'); $post_id = wp_insert_post($cert_args, $wp_error = false); if (!is_wp_error($post_id)) { add_post_meta($post_id, 'course_id', intval($course_item->ID)); add_post_meta($post_id, 'learner_id', intval($user_item->ID)); add_post_meta($post_id, 'certificate_hash', esc_html(substr(md5($course_item->ID . $user_item->ID), -8))); $loop_ran = true; } // End If Statement } // End If Statement wp_reset_query(); } // End If Statement } // End For Loop } // End For Loop if ($current_page >= $total_pages) { return true; } else { return false; } // End If Statement }
/** * display output to the admin view * @since 1.3.0 * @return html */ public function display() { // Get data for the user $questions = $this->build_data_array(); $count = 0; $graded_count = 0; $user_quiz_grade_total = 0; $quiz_grade_total = 0; $quiz_grade = 0; ?> <form name="<?php esc_attr_e('quiz_' . $this->quiz_id); ?> " action="" method="post"> <?php wp_nonce_field('sensei_manual_grading', '_wp_sensei_manual_grading_nonce'); ?> <input type="hidden" name="sensei_manual_grade" value="<?php esc_attr_e($this->quiz_id); ?> " /> <input type="hidden" name="sensei_grade_next_learner" value="<?php esc_attr_e($this->user_id); ?> " /> <div class="total_grade_display"> <span><?php esc_attr_e(__('Grade:', 'woothemes-sensei')); ?> </span> <span class="total_grade_total"><?php echo $user_quiz_grade_total; ?> </span> / <span class="quiz_grade_total"><?php echo $quiz_grade_total; ?> </span> (<span class="total_grade_percent"><?php echo $quiz_grade; ?> </span>%) </div> <div class="buttons"> <input type="submit" value="<?php esc_attr_e(__('Save', 'woothemes-sensei')); ?> " class="grade-button button-primary" title="Saves grades as currently marked on this page" /> <input type="button" value="<?php esc_attr_e(__('Auto grade', 'woothemes-sensei')); ?> " class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" /> <input type="reset" value="<?php esc_attr_e(__('Reset', 'woothemes-sensei')); ?> " class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" /> </div> <div class="clear"></div><br/><?php $lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $this->lesson_id, 'user_id' => $this->user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID')); $user_quiz_grade = get_comment_meta($lesson_status_id, 'grade', true); $correct_answers = 0; foreach ($questions as $question) { $question_id = $question->ID; ++$count; $type = false; $type_name = ''; $types = wp_get_post_terms($question_id, 'question-type'); foreach ($types as $t) { $type = $t->name; break; } if (!$type) { $type = 'multiple-choice'; } $user_answer = WooThemes_Sensei_Utils::sensei_check_for_activity(array('post_id' => $question_id, 'user_id' => $this->user_id, 'type' => 'sensei_user_answer'), true); $question_answer_notes = WooThemes_Sensei_Utils::sensei_get_user_question_answer_notes($user_answer); $question_grade_total = get_post_meta($question_id, '_question_grade', true); if (!$question_grade_total || 0 == intval($question_grade_total)) { $question_grade_total = 1; } $quiz_grade_total += $question_grade_total; $right_answer = get_post_meta($question_id, '_question_right_answer', true); $user_answer_content = maybe_unserialize(base64_decode($user_answer->comment_content)); $type_name = __('Multiple Choice', 'woothemes-sensei'); $grade_type = 'manual-grade'; switch ($type) { case 'boolean': $type_name = __('True/False', 'woothemes-sensei'); $right_answer = ucfirst($right_answer); $user_answer_content = ucfirst($user_answer_content); $grade_type = 'auto-grade'; break; case 'multiple-choice': $type_name = __('Multiple Choice', 'woothemes-sensei'); $grade_type = 'auto-grade'; break; case 'gap-fill': $type_name = __('Gap Fill', 'woothemes-sensei'); $right_answer_array = explode('||', $right_answer); if (isset($right_answer_array[0])) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; } if (isset($right_answer_array[1])) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; } if (isset($right_answer_array[2])) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; } if (!$user_answer_content) { $user_answer_content = '______'; } $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post; $user_answer_content = $gapfill_pre . ' <span class="highlight">' . $user_answer_content . '</span> ' . $gapfill_post; $grade_type = 'auto-grade'; break; case 'multi-line': $type_name = __('Multi Line', 'woothemes-sensei'); $grade_type = 'manual-grade'; break; case 'single-line': $type_name = __('Single Line', 'woothemes-sensei'); $grade_type = 'manual-grade'; break; case 'file-upload': $type_name = __('File Upload', 'woothemes-sensei'); $grade_type = 'manual-grade'; // Get uploaded file if ($user_answer_content) { $attachment_id = $user_answer_content; $answer_media_url = $answer_media_filename = ''; if (0 < intval($attachment_id)) { $answer_media_url = wp_get_attachment_url($attachment_id); $answer_media_filename = basename($answer_media_url); if ($answer_media_url && $answer_media_filename) { $user_answer_content = sprintf(__('Submitted file: %1$s', 'woothemes-sensei'), '<a href="' . esc_url($answer_media_url) . '" target="_blank">' . esc_html($answer_media_filename) . '</a>'); } } } else { $user_answer_content = ''; } break; default: // Nothing break; } $user_answer_content = (array) $user_answer_content; $right_answer = (array) $right_answer; $question_title = sprintf(__('Question %d: ', 'woothemes-sensei'), $count) . $type_name; $graded_class = ''; $user_question_grade = get_comment_meta($user_answer->comment_ID, 'user_grade', true); $graded_class = 'ungraded'; if (intval($user_question_grade) > 0) { $graded_class = 'user_right'; ++$correct_answers; $user_quiz_grade_total += $user_question_grade; ++$graded_count; } else { if (!is_string($user_question_grade) && intval($user_question_grade) == 0) { $graded_class = 'user_wrong'; ++$graded_count; } $user_question_grade = 0; } ?> <div class="postbox question_box <?php esc_attr_e($type); ?> <?php esc_attr_e($grade_type); ?> <?php esc_attr_e($graded_class); ?> " id="<?php esc_attr_e('question_' . $question_id . '_box'); ?> "> <div class="handlediv" title="Click to toggle"><br></div> <h3 class="hndle"><span><?php echo $question_title; ?> </span></h3> <div class="inside"> <div class="sensei-grading-actions"> <div class="actions"> <input type="hidden" class="question_id" value="<?php esc_attr_e($question_id); ?> " /> <input type="hidden" class="question_total_grade" name="question_total_grade" value="<?php echo $question_grade_total; ?> " /> <span class="grading-mark icon_right"><input type="radio" class="<?php esc_attr_e('question_' . $question_id . '_right_option'); ?> " name="<?php esc_attr_e('question_' . $question_id); ?> " value="right" <?php checked($graded_class, 'user_right', true); ?> /></span> <span class="grading-mark icon_wrong"><input type="radio" class="<?php esc_attr_e('question_' . $question_id . '_wrong_option'); ?> " name="<?php esc_attr_e('question_' . $question_id); ?> " value="wrong" <?php checked($graded_class, 'user_wrong', true); ?> /></span> <input type="number" class="question-grade" name="<?php esc_attr_e('question_' . $question_id . '_grade'); ?> " id="<?php esc_attr_e('question_' . $question_id . '_grade'); ?> " value="<?php esc_attr_e($user_question_grade); ?> " min="0" max="<?php esc_attr_e($question_grade_total); ?> " /> <span class="question-grade-total"><?php echo $question_grade_total; ?> </span> </div> </div> <div class="sensei-grading-answer"> <h4><?php echo apply_filters('sensei_question_title', $question->post_title); ?> </h4> <?php echo apply_filters('the_content', $question->post_content); ?> <p class="user-answer"><?php foreach ($user_answer_content as $_user_answer) { echo apply_filters('sensei_answer_text', $_user_answer) . "<br>"; } ?> </p> <div class="right-answer"> <h5><?php _e('Correct answer', 'woothemes-sensei'); ?> </h5> <span class="correct-answer"><?php foreach ($right_answer as $_right_answer) { echo apply_filters('sensei_answer_text', $_right_answer) . "<br>"; } ?> </span> </div> <div class="answer-notes"> <h5><?php _e('Grading Notes', 'woothemes-sensei'); ?> </h5> <textarea class="correct-answer" name="<?php esc_attr_e('question_' . $question_id . '_notes'); ?> " placeholder="<?php _e('Add notes here...', 'woothemes-sensei'); ?> "><?php echo $question_answer_notes; ?> </textarea> </div> </div> </div> </div><?php } $quiz_grade = intval($user_quiz_grade); $all_graded = 'no'; if (intval($count) == intval($graded_count)) { $all_graded = 'yes'; } ?> <input type="hidden" name="total_grade" id="total_grade" value="<?php esc_attr_e($user_quiz_grade_total); ?> " /> <input type="hidden" name="total_questions" id="total_questions" value="<?php esc_attr_e($count); ?> " /> <input type="hidden" name="quiz_grade_total" id="quiz_grade_total" value="<?php esc_attr_e($quiz_grade_total); ?> " /> <input type="hidden" name="total_graded_questions" id="total_graded_questions" value="<?php esc_attr_e($graded_count); ?> " /> <input type="hidden" name="all_questions_graded" id="all_questions_graded" value="<?php esc_attr_e($all_graded); ?> " /> <div class="total_grade_display"> <span><?php esc_attr_e(__('Grade:', 'woothemes-sensei')); ?> </span> <span class="total_grade_total"><?php echo $user_quiz_grade_total; ?> </span> / <span class="quiz_grade_total"><?php echo $quiz_grade_total; ?> </span> (<span class="total_grade_percent"><?php echo $quiz_grade; ?> </span>%) </div> <div class="buttons"> <input type="submit" value="<?php esc_attr_e('Save'); ?> " class="grade-button button-primary" title="Saves grades as currently marked on this page" /> <input type="button" value="<?php esc_attr_e(__('Auto grade', 'woothemes-sensei')); ?> " class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" /> <input type="reset" value="<?php esc_attr_e(__('Reset', 'woothemes-sensei')); ?> " class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" /> </div> <div class="clear"></div> <script type="text/javascript"> jQuery( window ).load( function() { // Calculate total grade on page load to make sure everything is set up correctly jQuery.fn.autoGrade(); }); </script> </form><?php }