review.php
127 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for displaying Assignments Review Form |
| 4 | * |
| 5 | * @since v.1.3.4 |
| 6 | * |
| 7 | * @author Themeum |
| 8 | * @url https://themeum.com |
| 9 | * |
| 10 | * @package TutorLMS/Templates |
| 11 | * @version 1.4.3 |
| 12 | */ |
| 13 | |
| 14 | $assignment_id = (int) tutor_utils()->array_get( 'assignment', $_GET ); |
| 15 | $assignment_submitted_id = (int) tutor_utils()->array_get( 'view_assignment', $_GET ); |
| 16 | $submitted_url = tutor_utils()->get_tutor_dashboard_page_permalink( 'assignments/submitted' ); |
| 17 | |
| 18 | if ( ! $assignment_submitted_id ) { |
| 19 | _e( "Sorry, but you are looking for something that isn't here.", 'tutor' ); |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | $submitted_assignment = tutor_utils()->get_assignment_submit_info( $assignment_submitted_id ); |
| 24 | if ( $submitted_assignment ) { |
| 25 | |
| 26 | $max_mark = tutor_utils()->get_assignment_option( $submitted_assignment->comment_post_ID, 'total_mark' ); |
| 27 | |
| 28 | $given_mark = get_comment_meta( $assignment_submitted_id, 'assignment_mark', true ); |
| 29 | $instructor_note = get_comment_meta( $assignment_submitted_id, 'instructor_note', true ); |
| 30 | $comment_author = get_user_by( 'login', $submitted_assignment->comment_author ) |
| 31 | ?> |
| 32 | |
| 33 | <div class="submitted-assignment-title"> |
| 34 | <a class="prev-btn" href="<?php echo esc_url( $submitted_url . '?assignment=' . $assignment_id ); ?>"><span>←</span><?php esc_html_e( 'Back', 'tutor' ); ?></a> |
| 35 | </div> |
| 36 | |
| 37 | <div class="tutor-assignment-review-header"> |
| 38 | <h3> |
| 39 | <a href="<?php echo esc_url( get_the_permalink( $submitted_assignment->comment_post_ID ) ); ?>" target="_blank"> |
| 40 | <?php echo esc_html( get_the_title( $submitted_assignment->comment_post_ID ) ); ?> |
| 41 | </a> |
| 42 | </h3> |
| 43 | <p> |
| 44 | <?php esc_html_e( 'Course', 'tutor' ); ?>: |
| 45 | <a href="<?php echo esc_url( get_the_permalink( $submitted_assignment->comment_parent ) ); ?>" target="_blank"> |
| 46 | <?php echo esc_html( get_the_title( $submitted_assignment->comment_parent ) ); ?> |
| 47 | </a> |
| 48 | </p> |
| 49 | <p> |
| 50 | <?php esc_html_e( 'Student', 'tutor' ); ?>: |
| 51 | <span><?php echo esc_html( $comment_author->display_name ) . ' (' . esc_html( $comment_author->user_email ) . ')'; ?></span> |
| 52 | </p> |
| 53 | <p> |
| 54 | <?php esc_html_e( 'Submitted Date', 'tutor' ); ?>: |
| 55 | <span><?php echo date( 'j M, Y, h:i a', strtotime( $submitted_assignment->comment_date ) ); ?></span> |
| 56 | </p> |
| 57 | </div> |
| 58 | |
| 59 | <hr> |
| 60 | |
| 61 | <div class="tutor-dashboard-assignment-submitted-content"> |
| 62 | <h4><?php esc_html_e( 'Assignment Description:', 'tutor' ); ?></h4> |
| 63 | <p><?php echo wp_kses_post( nl2br( stripslashes( $submitted_assignment->comment_content ) ) ); ?></p> |
| 64 | |
| 65 | <?php |
| 66 | $attached_files = get_comment_meta( $submitted_assignment->comment_ID, 'uploaded_attachments', true ); |
| 67 | if ( $attached_files ) { |
| 68 | ?> |
| 69 | <h5><?php esc_html_e( 'Attach assignment file(s)', 'tutor' ); ?></h5> |
| 70 | <div class="tutor-dashboard-assignment-files"> |
| 71 | <?php |
| 72 | $attached_files = json_decode( $attached_files, true ); |
| 73 | if ( tutor_utils()->count( $attached_files ) ) { |
| 74 | $upload_dir = wp_get_upload_dir(); |
| 75 | $upload_baseurl = trailingslashit( tutor_utils()->array_get( 'baseurl', $upload_dir ) ); |
| 76 | foreach ( $attached_files as $attached_file ) { |
| 77 | ?> |
| 78 | <div class="uploaded-files"> |
| 79 | <a href="<?php echo esc_url( $upload_baseurl . tutor_utils()->array_get( 'uploaded_path', $attached_file ) ); ?>" target="_blank"> <i class="tutor-icon-upload-file"></i> <?php echo esc_html( tutor_utils()->array_get( 'name', $attached_file ) ); ?></a> |
| 80 | </div> |
| 81 | <?php |
| 82 | } |
| 83 | } |
| 84 | ?> |
| 85 | </div> |
| 86 | <?php |
| 87 | } |
| 88 | ?> |
| 89 | </div> |
| 90 | |
| 91 | <div class="tutor-dashboard-assignment-review"> |
| 92 | <h3><?php esc_html_e( 'Evaluation', 'tutor' ); ?></h3> |
| 93 | <form action="" method="post" class="tutor-form-submit-through-ajax" data-toast_success_message="<?php esc_attr_e( 'Assignment evaluated', 'tutor' ); ?>"> |
| 94 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 95 | <input type="hidden" value="tutor_evaluate_assignment_submission" name="tutor_action"/> |
| 96 | <input type="hidden" value="<?php echo esc_attr( $assignment_submitted_id ); ?>" name="assignment_submitted_id"/> |
| 97 | <div class="tutor-assignment-evaluate-row"> |
| 98 | <div class="tutor-option-field-label"> |
| 99 | <label for=""><?php esc_html_e( 'Your Points', 'tutor' ); ?></label> |
| 100 | </div> |
| 101 | <div class="tutor-option-field input-mark"> |
| 102 | <input type="number" name="evaluate_assignment[assignment_mark]" value="<?php echo $given_mark ? esc_attr( $given_mark ) : 0; ?>"> |
| 103 | <p class="desc"><?php echo wp_sprintf( __( 'Evaluate this assignment out of %s', 'tutor' ), '<code>' . $max_mark . '</code>' ); ?></p> |
| 104 | </div> |
| 105 | </div> |
| 106 | <div class="tutor-assignment-evaluate-row"> |
| 107 | <div class="tutor-option-field-label"> |
| 108 | <label for=""><?php esc_html_e( 'Write a note', 'tutor' ); ?></label> |
| 109 | </div> |
| 110 | <div class="tutor-option-field"> |
| 111 | <textarea name="evaluate_assignment[instructor_note]"><?php echo esc_html( $instructor_note ); ?></textarea> |
| 112 | <p class="desc"><?php esc_html_e( 'Write a note to students about this submission', 'tutor' ); ?></p> |
| 113 | </div> |
| 114 | </div> |
| 115 | <div class="tutor-assignment-evaluate-row"> |
| 116 | <div class="tutor-option-field-label"></div> |
| 117 | <div class="tutor-option-field"> |
| 118 | <button type="submit" class="tutor-button tutor-button-primary"><?php esc_html_e( 'Evaluate this submission', 'tutor' ); ?></button> |
| 119 | </div> |
| 120 | </div> |
| 121 | </form> |
| 122 | </div> |
| 123 | |
| 124 | <?php } else { |
| 125 | _e( 'Assignments submission not found or not completed', 'tutor' ); |
| 126 | } ?> |
| 127 |