submitted.php
169 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Assignment Submitted Page |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Dashboard\Assignments |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @version 1.4.3 |
| 10 | */ |
| 11 | |
| 12 | if ( ! defined( 'TUTOR_PRO_VERSION' ) ) { |
| 13 | return; |
| 14 | } |
| 15 | |
| 16 | use Tutor\Helpers\DateTimeHelper; |
| 17 | use TUTOR\Input; |
| 18 | use TUTOR_ASSIGNMENTS\Assignments_List; |
| 19 | |
| 20 | $order_filter = Input::get( 'order', 'desc' ); |
| 21 | $assignment_id = Input::get( 'assignment', 0, Input::TYPE_INT ); |
| 22 | $format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); |
| 23 | $course_id = tutor_utils()->get_course_id_by( 'assignment', $assignment_id ); |
| 24 | $assignment_info = tutor_utils()->get_assignment_option( $assignment_id ); |
| 25 | |
| 26 | if ( ! $assignment_info || ! tutor_utils()->can_user_edit_course( get_current_user_id(), $course_id ) ) { |
| 27 | tutor_utils()->tutor_empty_state(); |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | $submission_time = $assignment_info['time_duration']['value'] > 1 ? $assignment_info['time_duration']['time'] : str_replace( 's', '', $assignment_info['time_duration']['time'] ); |
| 32 | $submission_period = ! $assignment_info['time_duration']['value'] ? __( 'No Limit', 'tutor' ) : $assignment_info['time_duration']['value'] . ' ' . $submission_time; |
| 33 | $assignments_submitted = Assignments_List::get_submitted_assignments( $assignment_id, $order_filter ); |
| 34 | |
| 35 | $max_mark = tutor_utils()->get_assignment_option( $assignment_id, 'total_mark' ); |
| 36 | $pass_mark = tutor_utils()->get_assignment_option( $assignment_id, 'pass_mark' ); |
| 37 | $comment_parent = ! empty( $assignments_submitted ) ? $assignments_submitted[0]->comment_parent : null; |
| 38 | ?> |
| 39 | |
| 40 | <div class="tutor-dashboard-content-inner tutor-dashboard-assignment-submits"> |
| 41 | <div class="tutor-mb-24"> |
| 42 | <a class="tutor-btn tutor-btn-ghost" href="<?php echo esc_url( tutor_utils()->get_tutor_dashboard_page_permalink( 'assignments' ) ); ?>"> |
| 43 | <span class="tutor-icon-previous tutor-mr-8" area-hidden="true"></span> |
| 44 | <?php esc_html_e( 'Back', 'tutor' ); ?> |
| 45 | </a> |
| 46 | </div> |
| 47 | |
| 48 | <div class="tutor-assignment-review-header tutor-assignment-submitted-page"> |
| 49 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 50 | <?php esc_html_e( 'Course', 'tutor' ); ?> : <?php echo esc_html( get_the_title( $comment_parent ) ); ?> |
| 51 | </div> |
| 52 | <div class="tutor-fs-6 tutor-fw-medium tutor-mt-8"> |
| 53 | <?php echo esc_html( get_the_title( $assignment_id ) ); ?> |
| 54 | </div> |
| 55 | <div class="assignment-info tutor-mt-12 tutor-d-flex"> |
| 56 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 57 | <?php esc_html_e( 'Assignment Submission Period', 'tutor' ); ?>: |
| 58 | <span class="tutor-fs-7 tutor-fw-medium"><?php echo esc_html( $submission_period ); ?></span> |
| 59 | </div> |
| 60 | <div class="tutor-fs-7 tutor-color-secondary tutor-ml-24"> |
| 61 | <?php esc_html_e( 'Total Points', 'tutor' ); ?>: |
| 62 | <span class="tutor-fs-7 tutor-fw-medium"><?php echo esc_html( $max_mark ); ?></span> |
| 63 | </div> |
| 64 | <div class="tutor-fs-7 tutor-color-secondary tutor-ml-24"> |
| 65 | <?php esc_html_e( 'Pass Points', 'tutor' ); ?>: |
| 66 | <span class="tutor-fs-7 tutor-fw-medium"><?php echo esc_html( $pass_mark ); ?></span> |
| 67 | </div> |
| 68 | </div> |
| 69 | </div> |
| 70 | |
| 71 | <div class="tutor-dashboard-announcement-sorting-wrap submitted-assignments-sorting-wrap"> |
| 72 | <div class="tutor-dashboard-announcement-sorting-input"> |
| 73 | <label class="tutor-fs-7 tutor-color-secondary"><?php esc_html_e( 'Sort By:', 'tutor' ); ?></label> |
| 74 | <select class="tutor-announcement-order-sorting tutor-form-control"> |
| 75 | <option value="desc" <?php selected( $order_filter, 'desc' ); ?>><?php esc_html_e( 'Latest', 'tutor' ); ?></option> |
| 76 | <option value="asc" <?php selected( $order_filter, 'asc' ); ?>><?php esc_html_e( 'Oldest', 'tutor' ); ?></option> |
| 77 | </select> |
| 78 | </div> |
| 79 | </div> |
| 80 | |
| 81 | <?php if ( tutor_utils()->count( $assignments_submitted ) ) : ?> |
| 82 | <div class="tutor-table-responsive"> |
| 83 | <table class="tutor-table tutor-table-middle"> |
| 84 | <thead> |
| 85 | <tr> |
| 86 | <th width="30%"> |
| 87 | <?php esc_html_e( 'Student', 'tutor' ); ?> |
| 88 | </th> |
| 89 | <th width="20%"> |
| 90 | <?php esc_html_e( 'Submission Date', 'tutor' ); ?> |
| 91 | </th> |
| 92 | <th width="18%"> |
| 93 | <?php esc_html_e( 'Submission Deadline', 'tutor' ); ?> |
| 94 | </th> |
| 95 | <th> |
| 96 | <?php esc_html_e( 'Total Points', 'tutor' ); ?> |
| 97 | </th> |
| 98 | <th> |
| 99 | <?php esc_html_e( 'Result', 'tutor' ); ?> |
| 100 | </th> |
| 101 | <th></th> |
| 102 | </tr> |
| 103 | </thead> |
| 104 | <tbody> |
| 105 | <?php |
| 106 | foreach ( $assignments_submitted as $assignment ) : |
| 107 | $review_url = tutor_utils()->get_tutor_dashboard_page_permalink( 'assignments/review' ); |
| 108 | $comment_author = get_user_by( 'login', $assignment->comment_author ); // login=username. |
| 109 | $is_reviewed_by_instructor = get_comment_meta( $assignment->comment_ID, 'evaluate_time', true ); |
| 110 | $given_mark = get_comment_meta( $assignment->comment_ID, 'assignment_mark', true ); |
| 111 | $not_evaluated = '' === $given_mark; |
| 112 | $status = 'pending'; |
| 113 | $button_text = __( 'Evaluate', 'tutor' ); |
| 114 | $deadline_date = tutor_utils()->get_assignment_deadline_date_in_gmt( $assignment->comment_post_ID, null, $assignment->user_id, $assignment->comment_parent ); |
| 115 | |
| 116 | if ( ! empty( $given_mark ) || ! $not_evaluated ) { |
| 117 | $status = (int) $given_mark >= (int) $pass_mark ? 'pass' : 'fail'; |
| 118 | $button_text = __( 'Details', 'tutor' ); |
| 119 | } |
| 120 | ?> |
| 121 | <tr> |
| 122 | <td> |
| 123 | <div class="tutor-d-flex tutor-align-center tutor-gap-2"> |
| 124 | <?php echo wp_kses( tutor_utils()->get_tutor_avatar( $comment_author->ID ), tutor_utils()->allowed_avatar_tags() ); ?> |
| 125 | <div> |
| 126 | <?php echo esc_html( $comment_author->display_name ); ?><br/> |
| 127 | <span class="tutor-fs-7 tutor-fw-normal tutor-color-muted"> |
| 128 | <?php echo esc_html( $comment_author->user_email ); ?> |
| 129 | </span> |
| 130 | </div> |
| 131 | </div> |
| 132 | </td> |
| 133 | <td> |
| 134 | <?php echo wp_kses_post( DateTimeHelper::get_gmt_to_user_timezone_date( $assignment->comment_date_gmt ) ); ?> |
| 135 | </td> |
| 136 | <td> |
| 137 | <?php echo esc_html( is_null( $deadline_date ) ? __( 'No Limit', 'tutor' ) : DateTimeHelper::get_gmt_to_user_timezone_date( $deadline_date ) ); ?> |
| 138 | </td> |
| 139 | <td> |
| 140 | <span class="tutor-color-black tutor-fs-7 tutor-fw-medium"> |
| 141 | <?php echo ! empty( $given_mark ) ? esc_html( $given_mark ) . '/' . esc_html( $max_mark ) : ' '; ?> |
| 142 | </span> |
| 143 | </td> |
| 144 | <td> |
| 145 | <?php |
| 146 | // $status contains HTML |
| 147 | echo wp_kses( |
| 148 | tutor_utils()->translate_dynamic_text( $status, true ), |
| 149 | array( |
| 150 | 'span' => array( 'class' => true ), |
| 151 | ) |
| 152 | ); |
| 153 | ?> |
| 154 | </td> |
| 155 | <td> |
| 156 | <a href="<?php echo esc_url( $review_url . '?view_assignment=' . $assignment->comment_ID ) . '&assignment=' . esc_attr( $assignment_id ); ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm"> |
| 157 | <?php echo esc_html( $button_text ); ?> |
| 158 | </a> |
| 159 | </td> |
| 160 | </tr> |
| 161 | <?php endforeach; ?> |
| 162 | </tbody> |
| 163 | </table> |
| 164 | </div> |
| 165 | <?php else : ?> |
| 166 | <?php tutor_utils()->tutor_empty_state( 'No assignment', 'tutor' ); ?> |
| 167 | <?php endif; ?> |
| 168 | </div> |
| 169 |