"> <?php if ($quiz_submitted) { ?> <?php $grade = $api->get_quiz_grade($lesson_id, $entry->ID); ?> <section class="ib-edu-quiz-grade"> <h3><?php _e('Quiz Grade', 'ibeducator'); ?> </h3> <p class="grade"> <?php if ('approved' == $grade->status) { printf(__('You scored %s for this quiz.', 'ibeducator'), '<strong>' . ib_edu_format_grade($grade->grade) . '</strong>'); } else { _e('Your grade is pending.', 'ibeducator'); } ?> </p> </section> <?php } ?> <?php if (!$quiz_submitted) { $answers = isset($_POST['answers']) && is_array($_POST['answers']) ? $_POST['answers'] : array(); } else { $answers = $api->get_student_answers($lesson_id, $entry->ID);
/** * Column: grade. * * @param array $item * @return string */ public function column_grade($item) { return ib_edu_format_grade($item['grade']); }
"> <?php if ($quiz_submitted) { ?> <?php $grade = $api->get_quiz_grade($lesson_id, $entry->ID); ?> <section class="ib-edu-quiz-grade"> <h3><?php esc_html_e('Quiz Grade', 'training'); ?> </h3> <p class="grade"> <?php if ('approved' == $grade->status) { printf(esc_html__('You scored %s for this quiz.', 'training'), '<strong>' . ib_edu_format_grade($grade->grade) . '</strong>'); } else { esc_html_e('Your grade is pending.', 'training'); } ?> </p> </section> <?php } ?> <?php if (!$quiz_submitted) { $answers = isset($_POST['answers']) && is_array($_POST['answers']) ? $_POST['answers'] : array(); } else { $answers = $api->get_student_answers($lesson_id, $entry->ID);
foreach ($headings as $th) { echo $th; } echo '</tr></thead>'; echo '<tbody>'; foreach ($courses['entries'] as $entry) { if ('complete' == $entry->entry_status && isset($courses['courses'][$entry->course_id])) { $course = $courses['courses'][$entry->course_id]; /** * This filter can be used to add/remove column values to/from the courses list table. * * @param array $values * @param string $entry_status * @param IB_Educator_Entry $entry */ $values = apply_filters('edr_student_courses_values', array('entry' => '<td>' . (int) $entry->ID . '</td>', 'course' => '<td><a class="title" href="' . esc_url(get_permalink($course->ID)) . '">' . esc_html($course->post_title) . '</a></td>', 'grade' => '<td class="grade">' . ib_edu_format_grade($entry->grade) . '</td>'), 'complete', $entry); echo '<tr>'; foreach ($values as $td) { echo $td; } echo '</tr>'; } } echo '</tbody></table>'; } /** * Paused. */ if (array_key_exists('paused', $courses['statuses'])) { echo '<h3>' . __('Paused', 'ibeducator') . '</h3>'; echo '<table class="ib-edu-courses ib-edu-courses-paused">';
$course = $courses['courses'][$entry->course_id]; ?> <tr> <td><?php echo intval($entry->ID); ?> </td> <td><a class="title" href="<?php echo esc_url(get_permalink($course->ID)); ?> "><?php echo esc_html($course->post_title); ?> </a></td> <td class="grade"><?php echo ib_edu_format_grade($entry->grade); ?> </td> </tr> <?php } } echo '</tbody></table>'; } /** * Paused. */ if (array_key_exists('paused', $courses['statuses'])) { echo '<h3>' . __('Paused', 'ibeducator') . '</h3>'; echo '<table class="ib-edu-courses ib-edu-courses-paused">'; echo '<thead><tr><th style="width:20%;">' . __('Entry ID', 'ibeducator') . '</th><th style="width:50%;">' . __('Course', 'ibeducator') . '</th><th>' . __('Actions', 'ibeducator') . '</th></tr></thead>';
/** * AJAX: add grade for a quiz. */ public static function quiz_grade() { global $wpdb; $api = IB_Educator::get_instance(); $entry_id = isset($_POST['entry_id']) ? absint($_POST['entry_id']) : 0; $lesson_id = isset($_POST['lesson_id']) ? absint($_POST['lesson_id']) : 0; // Verify nonce. if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'ibedu_edit_progress_' . $entry_id)) { exit; } // Verify capabilities. if (!current_user_can('edit_ib_educator_lesson', $lesson_id)) { exit; } $quiz_grade = $api->get_quiz_grade($lesson_id, $entry_id); if (!$quiz_grade) { exit; } $grade = isset($_POST['grade']) ? floatval($_POST['grade']) : 0; $api->update_quiz_grade($quiz_grade->ID, array('grade' => $grade, 'status' => 'approved')); // Send notification email to the student. $entry = IB_Educator_Entry::get_instance($entry_id); $student = get_user_by('id', $entry->user_id); if ($student) { $lesson_title = get_the_title($lesson_id); ib_edu_send_notification($student->user_email, 'quiz_grade', array('lesson_title' => $lesson_title), array('student_name' => $student->display_name, 'lesson_title' => $lesson_title, 'grade' => ib_edu_format_grade($grade))); } echo json_encode(array('status' => 'success')); exit; }