submitted.php
134 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package TutorLMS/Templates |
| 5 | * @version 1.4.3 |
| 6 | */ |
| 7 | |
| 8 | global $wpdb; |
| 9 | |
| 10 | $order_filter = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'desc'; |
| 11 | $assignment_id = sanitize_text_field($_GET['assignment']); |
| 12 | $assignments_submitted = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_type = 'tutor_assignment' AND comment_post_ID = %d ORDER BY comment_ID $order_filter", $assignment_id)); |
| 13 | |
| 14 | $max_mark = tutor_utils()->get_assignment_option($assignment_id, 'total_mark'); |
| 15 | $pass_mark = tutor_utils()->get_assignment_option($assignment_id, 'pass_mark'); |
| 16 | $format = get_option('date_format').' '.get_option('time_format'); |
| 17 | $deadline = tutor_utils()->get_assignment_deadline_date($assignment_id, $format, __('No Limit', 'tutor')); |
| 18 | ?> |
| 19 | |
| 20 | <div class="submitted-assignment-title"> |
| 21 | <a class="prev-btn" href="<?php echo tutor_utils()->get_tutor_dashboard_page_permalink('assignments'); ?>"><span>←</span><?php _e('Back', 'tutor'); ?></a> |
| 22 | </div> |
| 23 | |
| 24 | <?php |
| 25 | if (tutor_utils()->count($assignments_submitted)) { |
| 26 | ?> |
| 27 | |
| 28 | <div class="tutor-assignment-review-header tutor-assignment-submitted-page"> |
| 29 | <p> |
| 30 | <?php _e('Course', 'tutor'); ?> : |
| 31 | <a href="<?php echo get_the_permalink($assignments_submitted[0]->comment_parent); ?>" target="_blank"> |
| 32 | <?php echo get_the_title($assignments_submitted[0]->comment_parent); ?> |
| 33 | </a> |
| 34 | </p> |
| 35 | <h3> |
| 36 | <a href="<?php echo get_the_permalink($assignment_id); ?>" target="_blank"> |
| 37 | <?php echo get_the_title($assignment_id); ?> |
| 38 | </a> |
| 39 | </h3> |
| 40 | <div class="assignment-info"> |
| 41 | <p> |
| 42 | <?php _e('Submission Deadline', 'tutor'); ?>: |
| 43 | <span><?php echo $deadline; ?></span> |
| 44 | </p> |
| 45 | <p> |
| 46 | <?php _e('Total Points', 'tutor'); ?>: |
| 47 | <span><?php echo $max_mark; ?></span> |
| 48 | </p> |
| 49 | <p> |
| 50 | <?php _e('Pass Points', 'tutor'); ?>: |
| 51 | <span><?php echo $pass_mark; ?></span> |
| 52 | </p> |
| 53 | </div> |
| 54 | </div> |
| 55 | |
| 56 | <div class="tutor-announcement-table-wrap"> |
| 57 | |
| 58 | <div class="tutor-dashboard-announcement-sorting-wrap submitted-assignments-sorting-wrap"> |
| 59 | <div class="tutor-form-group"> |
| 60 | <label><?php _e('Sort By:', 'tutor'); ?></label> |
| 61 | <select class="tutor-announcement-order-sorting ignore-nice-select"> |
| 62 | <option value="desc" <?php selected($order_filter, 'desc'); ?>><?php _e('Latest', 'tutor'); ?></option> |
| 63 | <option value="asc" <?php selected($order_filter, 'asc'); ?>><?php _e('Oldest', 'tutor'); ?></option> |
| 64 | </select> |
| 65 | </div> |
| 66 | </div> |
| 67 | |
| 68 | <table class="tutor-dashboard-announcement-table tutor-dashboard-assignment-table" width="100%"> |
| 69 | <thead> |
| 70 | <tr> |
| 71 | <th style="width:25%;"><?php esc_attr_e('Date', 'tutor'); ?></td> |
| 72 | <th><?php esc_attr_e('Student', 'tutor'); ?></td> |
| 73 | <th style="width:15%;"><?php esc_attr_e('Total Points', 'tutor'); ?></td> |
| 74 | <th style="width:12%;"><?php esc_attr_e('Result', 'tutor'); ?></td> |
| 75 | <th style="width:10%;"> </td> |
| 76 | </tr> |
| 77 | </thead> |
| 78 | |
| 79 | <tbody> |
| 80 | <?php |
| 81 | |
| 82 | foreach ($assignments_submitted as $assignment) { |
| 83 | $comment_author = get_user_by('login', $assignment->comment_author); // login=username |
| 84 | $is_reviewed_by_instructor = get_comment_meta($assignment->comment_ID, 'evaluate_time', true); |
| 85 | $given_mark = get_comment_meta($assignment->comment_ID, 'assignment_mark', true); |
| 86 | $not_evaluated = $given_mark === ''; |
| 87 | $status = sprintf(__('%s Pending %s', 'tutor'), '<span class="review-required">', '</span>'); |
| 88 | $button_text = __('Evaluate', 'tutor'); |
| 89 | if (!empty($given_mark) || !$not_evaluated) { |
| 90 | $status = (int) $given_mark >= (int) $pass_mark ? sprintf(__('%s Pass %s', 'tutor'), '<span class="result-pass">', '</span>') : sprintf(__('%s Fail %s', 'tutor'), '<span class="result-fail">', '</span>'); |
| 91 | $button_text = __('Details', 'tutor'); |
| 92 | } |
| 93 | |
| 94 | $review_url = tutor_utils()->get_tutor_dashboard_page_permalink('assignments/review'); |
| 95 | |
| 96 | ?> |
| 97 | <tr> |
| 98 | <td><?php echo date('j M, Y,<\b\r>h:i a', strtotime($assignment->comment_date)); ?></td> |
| 99 | <td> |
| 100 | <div class="student-column"> |
| 101 | <div class="student-avatar"> |
| 102 | <?php echo tutils()->get_tutor_avatar($comment_author->ID); ?> |
| 103 | </div> |
| 104 | <div class="student-details"> |
| 105 | <h4><?php echo $comment_author->display_name; ?></h4> |
| 106 | <p><?php echo $comment_author->user_email; ?></p> |
| 107 | </div> |
| 108 | </div> |
| 109 | </td> |
| 110 | <td><?php echo !empty($given_mark) ? $given_mark . '/' . $max_mark : $max_mark; ?></td> |
| 111 | <td><?php echo $status; ?></td> |
| 112 | <td> |
| 113 | <a href="<?php echo esc_url($review_url . '?view_assignment=' . $assignment->comment_ID) . '&assignment=' . $assignment_id; ?>" class="tutor-btn bordered-btn tutor-announcement-details"> |
| 114 | <?php echo $button_text; ?> |
| 115 | </a> |
| 116 | </tr> |
| 117 | <?php |
| 118 | } |
| 119 | |
| 120 | ?> |
| 121 | |
| 122 | </tbody> |
| 123 | </table> |
| 124 | </div> |
| 125 | |
| 126 | <?php |
| 127 | } else { |
| 128 | ?> |
| 129 | <p><?php _e('No assignment has been submitted yet', 'tutor'); ?></p> |
| 130 | <?php |
| 131 | } |
| 132 | ?> |
| 133 | |
| 134 | </div> |