content.php
636 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for assignment content. |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Single\Assignment |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 1.4.3 |
| 10 | */ |
| 11 | |
| 12 | use TUTOR\Input; |
| 13 | use \TUTOR_ASSIGNMENTS\Assignments; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | global $post; |
| 20 | global $wpdb; |
| 21 | global $next_id; |
| 22 | global $assignment_submitted_id; |
| 23 | |
| 24 | $is_submitted = false; |
| 25 | $is_submitting = tutor_utils()->is_assignment_submitting( get_the_ID() ); |
| 26 | |
| 27 | // Get the comment. |
| 28 | $post_id = get_the_ID(); //phpcs:ignore |
| 29 | $user_id = get_current_user_id(); |
| 30 | $user_data = get_userdata( $user_id ); |
| 31 | $assignment_comment = tutor_utils()->get_single_comment_user_post_id( $post_id, $user_id ); |
| 32 | $submitted_assignment = tutor_utils()->is_assignment_submitted( get_the_ID() ); |
| 33 | |
| 34 | if ( false != $assignment_comment ) { |
| 35 | $submitted = $assignment_comment->comment_approved; |
| 36 | 'submitted' == $submitted ? $is_submitted = true : ''; |
| 37 | } |
| 38 | |
| 39 | // Get the ID of this content and the corresponding course. |
| 40 | $course_content_id = get_the_ID(); |
| 41 | $course_id = tutor_utils()->get_course_id_by_subcontent( $course_content_id ); |
| 42 | |
| 43 | // Get total content count. |
| 44 | $course_stats = tutor_utils()->get_course_completed_percent( $course_id, 0, true ); |
| 45 | |
| 46 | // Get enrolled data. |
| 47 | $enrolled_info = tutor_utils()->is_enrolled( $course_id, $user_id ); |
| 48 | $enrollment_time = strtotime( $enrolled_info->post_date_gmt ); |
| 49 | |
| 50 | /** |
| 51 | * Convert assignment time |
| 52 | * |
| 53 | * @todo move to utils |
| 54 | * |
| 55 | * @param integer $seconds seconds. |
| 56 | * @return string |
| 57 | */ |
| 58 | function tutor_assignment_convert_seconds( $seconds ) { |
| 59 | $dt1 = new DateTime( '@0' ); |
| 60 | $dt2 = new DateTime( "@$seconds" ); |
| 61 | |
| 62 | $diff = $dt1->diff( $dt2 ); |
| 63 | $days = $diff->days; |
| 64 | $hours = $diff->h; |
| 65 | |
| 66 | return $days . ' ' . __( 'Days', 'tutor' ) . ', ' . $hours . ' ' . __( 'Hours', 'tutor' ); |
| 67 | } |
| 68 | |
| 69 | $next_prev_content_id = tutor_utils()->get_course_prev_next_contents_by_id( $post_id ); |
| 70 | $content = get_the_content(); |
| 71 | $s_content = $content; |
| 72 | $allow_to_upload = (int) tutor_utils()->get_assignment_option( $post_id, 'upload_files_limit' ); |
| 73 | $course_id = tutor_utils()->get_course_id_by( 'lesson', get_the_ID() ); |
| 74 | |
| 75 | $upload_dir = wp_get_upload_dir(); |
| 76 | $upload_baseurl = trailingslashit( $upload_dir['baseurl'] ?? '' ); |
| 77 | $upload_basedir = trailingslashit( $upload_dir['basedir'] ?? '' ); |
| 78 | ?> |
| 79 | |
| 80 | <?php do_action( 'tutor_assignment/single/before/content' ); ?> |
| 81 | |
| 82 | <?php tutor_load_template( 'single.common.header', array( 'course_id' => $course_id ) ); ?> |
| 83 | |
| 84 | <div class="tutor-course-topic-single-body"> |
| 85 | <div class="tutor-quiz-wrapper tutor-d-flex tutor-justify-center tutor-mt-36 tutor-pb-80"> |
| 86 | <div id="tutor-assignment-wrap" class="tutor-quiz-wrap tutor-course-assignment-details tutor-submit-assignment tutor-assignment-result-pending"> |
| 87 | <div class="tutor-assignment-title tutor-fs-4 tutor-fw-medium tutor-color-black"> |
| 88 | <?php the_title(); ?> |
| 89 | </div> |
| 90 | |
| 91 | <?php |
| 92 | $time_duration = tutor_utils()->get_assignment_option( |
| 93 | get_the_ID(), |
| 94 | 'time_duration', |
| 95 | array( |
| 96 | 'time' => '', |
| 97 | 'value' => 0, |
| 98 | ) |
| 99 | ); |
| 100 | |
| 101 | $total_mark = tutor_utils()->get_assignment_option( get_the_ID(), 'total_mark' ); |
| 102 | $pass_mark = tutor_utils()->get_assignment_option( get_the_ID(), 'pass_mark' ); |
| 103 | $file_upload_limit = tutor_utils()->get_assignment_option( get_the_ID(), 'upload_file_size_limit' ); |
| 104 | |
| 105 | global $post; |
| 106 | $assignment_created_time = strtotime( $post->post_date_gmt ); |
| 107 | $deadline_time = $enrollment_time < $assignment_created_time ? $assignment_created_time : $enrollment_time; |
| 108 | $time_duration_in_sec = 0; |
| 109 | |
| 110 | if ( isset( $time_duration['value'] ) && isset( $time_duration['time'] ) ) { |
| 111 | switch ( $time_duration['time'] ) { |
| 112 | case 'hours': |
| 113 | $time_duration_in_sec = 3600; |
| 114 | break; |
| 115 | case 'days': |
| 116 | $time_duration_in_sec = 86400; |
| 117 | break; |
| 118 | case 'weeks': |
| 119 | $time_duration_in_sec = 7 * 86400; |
| 120 | break; |
| 121 | default: |
| 122 | $time_duration_in_sec = 0; |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | $time_duration_in_sec = $time_duration_in_sec * (int) $time_duration['value']; |
| 128 | $remaining_time = $deadline_time + $time_duration_in_sec; |
| 129 | $now = time(); |
| 130 | $remaining = $now - $remaining_time; |
| 131 | ?> |
| 132 | |
| 133 | <?php if ( ! $submitted_assignment ) : ?> |
| 134 | <div class="tutor-assignment-meta-info tutor-d-flex tutor-justify-between tutor-mt-24 tutor-mt-sm-32 tutor-py-16 tutor-py-sm-24"> |
| 135 | <div class="tutor-assignment-detail-info tutor-d-flex"> |
| 136 | <div class="tutor-assignment-duration"> |
| 137 | <span class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Duration:', 'tutor' ); ?></span> |
| 138 | <span class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 139 | <?php echo esc_html( $time_duration['value'] ? $time_duration['value'] . ' ' . __( $time_duration['time'], 'tutor' ) : __( 'No limit', 'tutor' ) ); //phpcs:ignore ?> |
| 140 | </span> |
| 141 | </div> |
| 142 | <div class="tutor-assignmetn-deadline"> |
| 143 | <span class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Deadline:', 'tutor' ); ?></span> |
| 144 | <span class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 145 | <?php |
| 146 | if ( 0 != $time_duration['value'] ) { |
| 147 | if ( $now > $remaining_time && false == $is_submitted ) { |
| 148 | esc_html_e( 'Expired', 'tutor' ); |
| 149 | } else { |
| 150 | echo esc_html( tutor_assignment_convert_seconds( $remaining ) ); |
| 151 | } |
| 152 | } else { |
| 153 | esc_html_e( 'N\\A', 'tutor' ); |
| 154 | } |
| 155 | ?> |
| 156 | </span> |
| 157 | </div> |
| 158 | </div> |
| 159 | <div class="tutor-assignment-detail-info tutor-d-flex"> |
| 160 | <div class="tutor-assignment-marks"> |
| 161 | <span class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Total Marks:', 'tutor' ); ?></span> |
| 162 | <span class="tutor-fs-6 tutor-fw-medium tutor-color-black"><?php echo esc_html( $total_mark ); ?></span> |
| 163 | </div> |
| 164 | <div class="tutor-assignmetn-pass-mark"> |
| 165 | <span class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Passing Mark:', 'tutor' ); ?></span> |
| 166 | <span class="tutor-fs-6 tutor-fw-medium tutor-color-black"><?php echo esc_html( $pass_mark ); ?></span> |
| 167 | </div> |
| 168 | </div> |
| 169 | </div> |
| 170 | <?php endif; ?> |
| 171 | |
| 172 | <?php |
| 173 | /** |
| 174 | * Time_duration[value]==0 means no limit |
| 175 | * if have unlimited time then no msg should appear |
| 176 | */ |
| 177 | if ( ( 0 != $time_duration['value'] ) && ( $now > $remaining_time && false == $is_submitted ) ) : |
| 178 | ?> |
| 179 | <div class="quiz-flash-message tutor-mt-24 tutor-mt-sm-32"> |
| 180 | <div class="tutor-quiz-warning-box time-over tutor-d-flex tutor-align-center tutor-justify-between"> |
| 181 | <div class="flash-info tutor-d-flex tutor-align-center"> |
| 182 | <span class="tutor-icon-circle-times-bold tutor-color-danger tutor-mr-8"></span> |
| 183 | <span class="tutor-fs-7 tutor-color-danger-100"> |
| 184 | <?php esc_html_e( 'You have missed the submission deadline. Please contact the instructor for more information.', 'tutor' ); ?> |
| 185 | </span> |
| 186 | </div> |
| 187 | </div> |
| 188 | </div> |
| 189 | <?php endif; ?> |
| 190 | |
| 191 | <?php if ( ! $is_submitting && ! $submitted_assignment && get_the_content() ) : ?> |
| 192 | <div class="tutor-time-out-assignment-details tutor-assignment-border-bottom tutor-pb-48 tutor-pb-sm-72"> |
| 193 | <div class="tutor-to-assignment tutor-pt-32 tutor-pt-sm-40"> |
| 194 | <div class="tutor-to-title tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 195 | <?php esc_html_e( 'Description', 'tutor' ); ?> |
| 196 | </div> |
| 197 | <div class="tutor-to-body tutor-fs-6 tutor-color-secondary tutor-pt-12 tutor-entry-content"> |
| 198 | <?php the_content(); ?> |
| 199 | </div> |
| 200 | </div> |
| 201 | </div> |
| 202 | <?php endif; ?> |
| 203 | |
| 204 | <?php |
| 205 | $assignment_attachments = maybe_unserialize( get_post_meta( get_the_ID(), '_tutor_assignment_attachments', true ) ); |
| 206 | if ( tutor_utils()->count( $assignment_attachments ) ) : |
| 207 | ?> |
| 208 | <div class="tutor-assignment-attachments tutor-pt-40"> |
| 209 | <span class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 210 | <?php esc_html_e( 'Attachments', 'tutor' ); ?> |
| 211 | </span> |
| 212 | <div class="tutor-assignment-attachments-list tutor-pt-16"> |
| 213 | <?php if ( is_array( $assignment_attachments ) && count( $assignment_attachments ) ) : ?> |
| 214 | <?php foreach ( $assignment_attachments as $attachment_id ) : ?> |
| 215 | <?php |
| 216 | $attachment_name = get_post_meta( $attachment_id, '_wp_attached_file', true ); |
| 217 | $attachment_name = substr( $attachment_name, strrpos( $attachment_name, '/' ) + 1 ); |
| 218 | $file_size = tutor_utils()->get_readable_filesize( get_attached_file( $attachment_id ) ); |
| 219 | ?> |
| 220 | <div class="tutor-instructor-card tutor-col-sm-5 tutor-py-16 tutor-mr-12 tutor-ml-3"> |
| 221 | <div class="tutor-icard-content"> |
| 222 | <div class="tutor-fs-6 tutor-color-secondary"> |
| 223 | <a href="<?php echo esc_url( wp_get_attachment_url( $attachment_id ) ); ?>" target="_blank" |
| 224 | download> |
| 225 | <?php echo esc_html( $attachment_name ); ?> |
| 226 | </a> |
| 227 | </div> |
| 228 | <div class="tutor-fs-7"> |
| 229 | <?php esc_html_e( 'Size: ', 'tutor' ); ?> |
| 230 | <?php echo esc_html( $file_size ); ?> |
| 231 | </div> |
| 232 | </div> |
| 233 | <div class="tutor-d-flex tutor-align-center"> |
| 234 | <a class="tutor-iconic-btn tutor-iconic-btn-outline" href="<?php echo esc_url( wp_get_attachment_url( $attachment_id ) ); ?>" target="_blank"> |
| 235 | <span class="tutor-icon-download" area-hidden="true"></span> |
| 236 | </a> |
| 237 | </div> |
| 238 | </div> |
| 239 | <?php endforeach; ?> |
| 240 | <?php endif; ?> |
| 241 | </div> |
| 242 | </div> |
| 243 | <?php endif; ?> |
| 244 | |
| 245 | <?php if ( ( $is_submitting || isset( $_GET['update-assignment'] ) ) && ( $remaining_time > $now || 0 == $time_duration['value'] ) ) : ?> |
| 246 | <div class="tutor-assignment-submission tutor-assignment-border-bottom tutor-pb-48 tutor-pb-sm-72"> |
| 247 | <form action="" method="post" id="tutor_assignment_submit_form" enctype="multipart/form-data"> |
| 248 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce, false ); ?> |
| 249 | <input type="hidden" value="tutor_assignment_submit" name="tutor_action" /> |
| 250 | <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>"> |
| 251 | |
| 252 | <?php $allowed_upload_files = (int) tutor_utils()->get_assignment_option( get_the_ID(), 'upload_files_limit' ); ?> |
| 253 | <div class="tutor-assignment-body tutor-pt-32 tutor-pt-sm-40"> |
| 254 | <div class="tutor-to-title tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 255 | <?php esc_html_e( 'Assignment Submission', 'tutor' ); ?> |
| 256 | </div> |
| 257 | |
| 258 | <div class="tutor-fs-7 tutor-color-secondary tutor-pt-16 tutor-pt-sm-32"> |
| 259 | <?php esc_html_e( 'Assignment answer form', 'tutor' ); ?> |
| 260 | </div> |
| 261 | |
| 262 | <div class="tutor-assignment-text-area tutor-pt-20"> |
| 263 | <?php |
| 264 | $assignment_comment_id = Input::has( 'update-assignment' ) ? Input::get( 'update-assignment' ) : 0; |
| 265 | $content = $assignment_comment_id ? get_comment( $assignment_comment_id ) : ''; |
| 266 | $args = tutor_utils()->text_editor_config(); |
| 267 | $args['tinymce'] = array( |
| 268 | 'toolbar1' => 'formatselect,bold,italic,underline,forecolor,bullist,numlist,alignleft,aligncenter,alignright,alignjustify,undo,redo', |
| 269 | ); |
| 270 | $args['editor_height'] = '140'; |
| 271 | $editor_args = array( |
| 272 | 'content' => isset( $content->comment_content ) ? $content->comment_content : '', |
| 273 | 'args' => $args, |
| 274 | ); |
| 275 | $text_editor_template = tutor()->path . 'templates/global/tutor-text-editor.php'; |
| 276 | tutor_load_template_from_custom_path( $text_editor_template, $editor_args ); |
| 277 | ?> |
| 278 | </div> |
| 279 | |
| 280 | <?php if ( $allowed_upload_files ) : ?> |
| 281 | <div class="tutor-assignment-attachment tutor-mt-32 tutor-py-20 tutor-px-16 tutor-py-sm-32 tutor-px-sm-32"> |
| 282 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 283 | <?php |
| 284 | $attachment_text = _x( 'Attach assignment files (Max: ', 'Assignment attachment', 'tutor' ); |
| 285 | $attachment_text .= $allow_to_upload . _x( ' file)', 'Assignment attachment', 'tutor' ); |
| 286 | echo esc_html( $attachment_text ); |
| 287 | ?> |
| 288 | </div> |
| 289 | <div class="tutor-attachment-files tutor-mt-12"> |
| 290 | <div class="tutor-assignment-upload-btn tutor-mt-12 tutor-mt-md-0"> |
| 291 | <form> |
| 292 | <label for="tutor-assignment-file-upload"> |
| 293 | <input type="file" id="tutor-assignment-file-upload" |
| 294 | name="attached_assignment_files[]" multiple> |
| 295 | <a class="tutor-btn tutor-btn-primary tutor-btn-md"> |
| 296 | <?php esc_html_e( 'Choose file', 'tutor' ); ?> |
| 297 | </a> |
| 298 | </label> |
| 299 | <input type="hidden" name="tutor_assignment_upload_limit" |
| 300 | value="<?php echo esc_attr( $file_upload_limit * 1000000 ); ?>"> |
| 301 | </form> |
| 302 | </div> |
| 303 | <div class="tutor-input-type-size"> |
| 304 | <p class="tutor-fs-7 tutor-color-secondary"> |
| 305 | <?php esc_html_e( 'File Support: ', 'tutor' ); ?> |
| 306 | <span class="tutor-color-black"> |
| 307 | <?php esc_html_e( 'Any standard Image, Document, Presentation, Sheet, PDF or Text file is allowed', 'tutor' ); ?> |
| 308 | </span> |
| 309 | </p> |
| 310 | <p class="tutor-fs-7 tutor-color-secondary tutor-mt-7"> |
| 311 | <?php esc_html_e( 'Total File Size: Max', 'tutor' ); ?> |
| 312 | <span class="tutor-color-black"> |
| 313 | <?php echo esc_html( $file_upload_limit ); ?> |
| 314 | <?php esc_html_e( 'MB', 'tutor' ); ?> |
| 315 | </span> |
| 316 | </p> |
| 317 | </div> |
| 318 | </div> |
| 319 | |
| 320 | <div class="tutor-container tutor-pt-16 tutor-update-assignment-attachments"> |
| 321 | <div class="tutor-row tutor-gy-3" id="tutor-student-assignment-edit-file-preview"> |
| 322 | <?php |
| 323 | $submitted_attachments = get_comment_meta( $assignment_comment_id, 'uploaded_attachments' ); |
| 324 | if ( is_array( $submitted_attachments ) && count( $submitted_attachments ) ) : |
| 325 | ?> |
| 326 | <?php |
| 327 | foreach ( $submitted_attachments as $attach ) : |
| 328 | $attachments = json_decode( $attach ); |
| 329 | ?> |
| 330 | <?php foreach ( $attachments as $attachment ) : ?> |
| 331 | <div class="tutor-instructor-card tutor-col-sm-5 tutor-py-16 tutor-mr-16"> |
| 332 | <div class="tutor-icard-content"> |
| 333 | <div class="tutor-fs-6 tutor-color-secondary"> |
| 334 | <?php echo esc_html( $attachment->name ); ?> |
| 335 | </div> |
| 336 | <div class="tutor-fs-7"> |
| 337 | <?php echo esc_html( tutor_utils()->get_readable_filesize( $upload_basedir . $attachment->uploaded_path ) ); ?> |
| 338 | </div> |
| 339 | </div> |
| 340 | <div |
| 341 | class="tutor-attachment-file-close tutor-d-flex tutor-align-center"> |
| 342 | <a class="tutor-iconic-btn tutor-iconic-btn-outline" href="<?php echo esc_url( $attachment->url ); ?>" |
| 343 | data-id="<?php echo esc_attr( $assignment_comment_id ); ?>" |
| 344 | data-name="<?php echo esc_attr( $attachment->name ); ?>" target="_blank"> |
| 345 | <span class="tutor-icon-times"></span> |
| 346 | </a> |
| 347 | </div> |
| 348 | </div> |
| 349 | <?php endforeach; ?> |
| 350 | <?php endforeach; ?> |
| 351 | <?php endif; ?> |
| 352 | </div> |
| 353 | </div> |
| 354 | </div> |
| 355 | <?php endif; ?> |
| 356 | |
| 357 | <div class="tutor-assignment-submit-btn tutor-mt-60"> |
| 358 | <button type="submit" id="tutor_assignment_submit_btn" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-static-loader"> |
| 359 | <?php esc_html_e( 'Submit Assignment', 'tutor' ); ?> |
| 360 | </button> |
| 361 | </div> |
| 362 | </div> |
| 363 | </form> |
| 364 | </div> |
| 365 | |
| 366 | <?php $has_show_more = strlen( $s_content ) > 500 ? true : false; ?> |
| 367 | |
| 368 | <?php if ( $s_content ) : ?> |
| 369 | <div class="tutor-assignment-description-details tutor-assignment-border-bottom tutor-pb-32 tutor-pb-sm-44"> |
| 370 | <div id="content-section" class="tutor-pt-40 tutor-pt-sm-60<?php echo esc_attr( $has_show_more ? ' tutor-toggle-more-content tutor-toggle-more-collapsed' : '' ); ?>"<?php echo $has_show_more ? ' data-tutor-toggle-more-content data-toggle-height="300" style="height: 300px;"' : ''; ?>> |
| 371 | <div class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 372 | <?php esc_html_e( 'Description', 'tutor' ); ?> |
| 373 | </div> |
| 374 | <div class="tutor-entry-content tutor-fs-6 tutor-color-secondary tutor-pt-12"> |
| 375 | <?php echo apply_filters( 'the_content', $s_content );//phpcs:ignore ?> |
| 376 | </div> |
| 377 | </div> |
| 378 | |
| 379 | <?php if ( $has_show_more ) : ?> |
| 380 | <a href="#" class="tutor-btn-show-more tutor-btn tutor-btn-ghost tutor-mt-32" data-tutor-toggle-more=".tutor-toggle-more-content"> |
| 381 | <span class="tutor-toggle-btn-icon tutor-icon tutor-icon-plus tutor-mr-8" area-hidden="true"></span> |
| 382 | <span class="tutor-toggle-btn-text"><?php esc_html_e( 'Show More', 'tutor' ); ?></span> |
| 383 | </a> |
| 384 | <?php endif; ?> |
| 385 | </div> |
| 386 | <?php endif; ?> |
| 387 | |
| 388 | <?php if ( $next_prev_content_id->next_id ) : ?> |
| 389 | <div class="tutor-assignment-footer tutor-d-flex tutor-justify-end tutor-pt-32 tutor-pt-sm-44"> |
| 390 | <a href="<?php echo esc_url( get_permalink( $next_prev_content_id->next_id ) ); ?>" class="tuttor-assignment-skip-button tutor-btn tutor-btn-ghost tutor-mt-md-0 tutor-mt-12"> |
| 391 | <?php esc_html_e( 'Skip To Next', 'tutor' ); ?> |
| 392 | </a> |
| 393 | </div> |
| 394 | <?php endif; ?> |
| 395 | <?php else : ?> |
| 396 | |
| 397 | <?php if ( $submitted_assignment ) : ?> |
| 398 | <?php |
| 399 | $is_reviewed_by_instructor = get_comment_meta( $submitted_assignment->comment_ID, 'evaluate_time', true ); |
| 400 | |
| 401 | $assignment_id = $submitted_assignment->comment_post_ID; |
| 402 | $submit_id = $submitted_assignment->comment_ID; |
| 403 | |
| 404 | $max_mark = tutor_utils()->get_assignment_option( $submitted_assignment->comment_post_ID, 'total_mark' ); |
| 405 | $pass_mark = tutor_utils()->get_assignment_option( $submitted_assignment->comment_post_ID, 'pass_mark' ); |
| 406 | $given_mark = get_comment_meta( $submitted_assignment->comment_ID, 'assignment_mark', true ); |
| 407 | ?> |
| 408 | <div class="tutor-assignment-result-table tutor-mt-32 tutor-mb-40"> |
| 409 | <div class="tutor-table-responsive"> |
| 410 | <table class="tutor-table my-quiz-attempts"> |
| 411 | <thead> |
| 412 | <tr> |
| 413 | <th> |
| 414 | <?php esc_html_e( 'Date', 'tutor' ); ?> |
| 415 | </th> |
| 416 | <th> |
| 417 | <?php esc_html_e( 'Total Marks', 'tutor' ); ?> |
| 418 | </th> |
| 419 | <th> |
| 420 | <?php esc_html_e( 'Pass Marks', 'tutor' ); ?> |
| 421 | </th> |
| 422 | <th> |
| 423 | <?php esc_html_e( 'Earned Marks', 'tutor' ); ?> |
| 424 | </th> |
| 425 | <th> |
| 426 | <?php esc_html_e( 'Result', 'tutor' ); ?> |
| 427 | </th> |
| 428 | </tr> |
| 429 | </thead> |
| 430 | |
| 431 | <tbody> |
| 432 | <tr> |
| 433 | <td> |
| 434 | <?php echo esc_html( tutor_utils()->convert_date_into_wp_timezone( $submitted_assignment->comment_date ) ); ?> |
| 435 | </td> |
| 436 | |
| 437 | <td> |
| 438 | <?php esc_html_e( $max_mark, 'tutor' );//phpcs:ignore ?> |
| 439 | </td> |
| 440 | |
| 441 | <td> |
| 442 | <?php esc_html_e( $pass_mark, 'tutor' );//phpcs:ignore ?> |
| 443 | </td> |
| 444 | |
| 445 | <td> |
| 446 | <?php esc_html_e( $given_mark, 'tutor' );//phpcs:ignore ?> |
| 447 | </td> |
| 448 | |
| 449 | <td> |
| 450 | <?php if ( $is_reviewed_by_instructor ) : ?> |
| 451 | <?php if ( $given_mark >= $pass_mark ) : ?> |
| 452 | <span class="tutor-badge-label label-success"> |
| 453 | <?php esc_html_e( 'Passed', 'tutor' ); ?> |
| 454 | </span> |
| 455 | <?php else : ?> |
| 456 | <span class="tutor-badge-label label-danger"> |
| 457 | <?php esc_html_e( 'Failed', 'tutor' ); ?> |
| 458 | </span> |
| 459 | <?php endif; ?> |
| 460 | <?php endif; ?> |
| 461 | |
| 462 | <?php if ( ! $is_reviewed_by_instructor ) : ?> |
| 463 | <span class="tutor-badge-label label-warning"> |
| 464 | <?php esc_html_e( 'Pending', 'tutor' ); ?> |
| 465 | </span> |
| 466 | <?php endif; ?> |
| 467 | </td> |
| 468 | </tr> |
| 469 | </tbody> |
| 470 | </table> |
| 471 | </div> |
| 472 | </div> |
| 473 | |
| 474 | <?php |
| 475 | $instructor_note = get_comment_meta( $submitted_assignment->comment_ID, 'instructor_note', true ); |
| 476 | if ( ! empty( $instructor_note ) && $is_reviewed_by_instructor ) : |
| 477 | ?> |
| 478 | <div class="tutor-instructor-note tutor-my-32 tutor-py-20 tutor-px-24 tutor-py-sm-32 tutor-px-sm-36"> |
| 479 | <div class="tutor-in-title tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 480 | <?php esc_html_e( 'Instructor Note', 'tutor' ); ?> |
| 481 | </div> |
| 482 | <div class="tutor-in-body tutor-fs-6 tutor-color-secondary tutor-pt-12 tutor-pt-sm-16"> |
| 483 | <?php echo wp_kses_post( nl2br( get_comment_meta( $submitted_assignment->comment_ID, 'instructor_note', true ) ) ); ?> |
| 484 | </div> |
| 485 | </div> |
| 486 | <?php endif; ?> |
| 487 | |
| 488 | <?php |
| 489 | /** |
| 490 | * If user not submitted assignment and assignment expired |
| 491 | * then show expire message |
| 492 | * |
| 493 | * @since 2.0.0 |
| 494 | */ |
| 495 | if ( ! $is_submitted && 0 != $time_duration['value'] && ( $now > $remaining_time ) ) : |
| 496 | ?> |
| 497 | <div class="tutor-mb-40"> |
| 498 | <?php |
| 499 | $alert_template = tutor()->path . 'templates/global/alert.php'; |
| 500 | if ( file_exists( $alert_template ) ) { |
| 501 | tutor_load_template_from_custom_path( |
| 502 | $alert_template, |
| 503 | array( |
| 504 | 'alert_class' => 'tutor-alert tutor-danger', |
| 505 | 'message' => __( 'You have missed the submission deadline. Please contact the instructor for more information.', 'tutor' ), |
| 506 | 'icon' => ' tutor-icon-circle-times-line', |
| 507 | ) |
| 508 | ); |
| 509 | } |
| 510 | ?> |
| 511 | </div> |
| 512 | <?php endif; ?> |
| 513 | |
| 514 | <div class="tutor-assignment-details tutor-assignment-border-bottom tutor-pb-48 tutor-pb-sm-72"> |
| 515 | <div class="tutor-ar-body tutor-pt-24 tutor-pb-40 tutor-px-16 tutor-px-md-32"> |
| 516 | <div class="tutor-ar-header tutor-d-flex tutor-justify-between tutor-align-center"> |
| 517 | <div class="tutor-ar-title tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 518 | <?php esc_html_e( 'Your Assignment', 'tutor' ); ?> |
| 519 | </div> |
| 520 | |
| 521 | <?php |
| 522 | $result = Assignments::get_assignment_result( $post_id, $user_id ); |
| 523 | if ( in_array( $result, array( 'pending', 'fail' ), true ) && ( $remaining_time > $now || 0 == $time_duration['value'] ) ) : |
| 524 | ?> |
| 525 | <div class="tutor-ar-btn"> |
| 526 | <a href="<?php echo esc_url( add_query_arg( 'update-assignment', $submitted_assignment->comment_ID ) ); ?>" |
| 527 | class="tutor-btn tutor-btn-outline-primary tutor-btn-sm"> |
| 528 | <?php esc_html_e( 'Edit', 'tutor' ); ?> |
| 529 | </a> |
| 530 | </div> |
| 531 | <?php endif; ?> |
| 532 | </div> |
| 533 | |
| 534 | <div class="tutor-fs-6 tutor-color-secondary tutor-pt-16 tutor-entry-content"> |
| 535 | <?php echo wp_kses_post( nl2br( stripslashes( $submitted_assignment->comment_content ) ) ); ?> |
| 536 | </div> |
| 537 | |
| 538 | <?php |
| 539 | $attached_files = get_comment_meta( $submitted_assignment->comment_ID, 'uploaded_attachments', true ); |
| 540 | if ( $attached_files ) : |
| 541 | ?> |
| 542 | <?php |
| 543 | $attached_files = json_decode( $attached_files, true ); |
| 544 | if ( tutor_utils()->count( $attached_files ) ) : |
| 545 | ?> |
| 546 | <div class="tutor-attachment-files submited-files tutor-d-flex tutor-flex-column tutor-mt-20 tutor-mt-sm-40"> |
| 547 | <?php |
| 548 | foreach ( $attached_files as $attached_file ) : |
| 549 | ?> |
| 550 | <div class="tutor-instructor-card tutor-mt-12"> |
| 551 | <div class="tutor-icard-content"> |
| 552 | <div class="tutor-fs-6 tutor-color-secondary"> |
| 553 | <?php echo esc_html( tutor_utils()->array_get( 'name', $attached_file ) ); ?> |
| 554 | </div> |
| 555 | <div class="tutor-fs-7"><?php esc_html_e( 'Size', 'tutor' ); ?>: |
| 556 | <?php |
| 557 | echo esc_html( |
| 558 | tutor_utils()->get_readable_filesize( $upload_basedir . $attached_file['uploaded_path'] ) |
| 559 | ); |
| 560 | ?> |
| 561 | </div> |
| 562 | </div> |
| 563 | <div class="tutor-d-flex tutor-align-center"> |
| 564 | <a class="tutor-iconic-btn tutor-iconic-btn-outline" download |
| 565 | href="<?php echo esc_url( $upload_baseurl . tutor_utils()->array_get( 'uploaded_path', $attached_file ) ); ?>" |
| 566 | target="_blank"> |
| 567 | <span class="tutor-icon-download"></span> |
| 568 | </a> |
| 569 | </div> |
| 570 | </div> |
| 571 | <?php endforeach; ?> |
| 572 | </div> |
| 573 | <?php endif; ?> |
| 574 | <?php endif; ?> |
| 575 | </div> |
| 576 | </div> |
| 577 | |
| 578 | <?php $has_show_more = strlen( $s_content ) > 500 ? true : false; ?> |
| 579 | |
| 580 | <?php if ( $s_content ) : ?> |
| 581 | <div class="tutor-assignment-description-details tutor-assignment-border-bottom tutor-pb-32 tutor-pb-sm-44"> |
| 582 | <div id="content-section" class="tutor-pt-40 tutor-pt-sm-60<?php echo $has_show_more ? ' tutor-toggle-more-content tutor-toggle-more-collapsed' : ''; ?>"<?php echo $has_show_more ? ' data-tutor-toggle-more-content data-toggle-height="300" style="height: 300px;"' : ''; ?>> |
| 583 | <div class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 584 | <?php esc_html_e( 'Description', 'tutor' ); ?> |
| 585 | </div> |
| 586 | <div class="tutor-entry-content tutor-fs-6 tutor-color-secondary tutor-pt-12"> |
| 587 | <?php echo apply_filters( 'the_content', $s_content ); //phpcs:ignore ?> |
| 588 | </div> |
| 589 | </div> |
| 590 | <?php if ( $has_show_more ) : ?> |
| 591 | <a href="#" class="tutor-btn-show-more tutor-btn tutor-btn-ghost tutor-mt-32" data-tutor-toggle-more=".tutor-toggle-more-content"> |
| 592 | <span class="tutor-toggle-btn-icon tutor-icon tutor-icon-plus tutor-mr-8" area-hidden="true"></span> |
| 593 | <span class="tutor-toggle-btn-text"><?php esc_html_e( 'Show More', 'tutor' ); ?></span> |
| 594 | </a> |
| 595 | <?php endif; ?> |
| 596 | </div> |
| 597 | <?php endif; ?> |
| 598 | |
| 599 | |
| 600 | <?php if ( $next_prev_content_id->next_id ) : ?> |
| 601 | <div class="tutor-assignment-footer tutor-pt-32 tutor-pt-sm-44"> |
| 602 | <a class="tutor-btn tutor-btn-primary tutor-static-loader" |
| 603 | href="<?php echo esc_url( get_the_permalink( $next_prev_content_id->next_id ) ); ?>"> |
| 604 | <?php esc_html_e( 'Continue Lesson', 'tutor' ); ?> |
| 605 | </a> |
| 606 | </div> |
| 607 | <?php endif; ?> |
| 608 | <?php else : ?> |
| 609 | <div class="tutor-assignment-footer tutor-pt-32 tutor-pt-sm-44"> |
| 610 | <div class="tutor-assignment-footer-btn tutor-d-flex tutor-justify-between"> |
| 611 | <form action="" method="post" id="tutor_assignment_start_form"> |
| 612 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 613 | <input type="hidden" value="tutor_assignment_start_submit" name="tutor_action" /> |
| 614 | <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>"> |
| 615 | <button type="submit" id="tutor_assignment_start_btn" class="tutor-btn tutor-btn-primary"<?php echo ( ( 0 != $time_duration['value'] ) && ( $now > $remaining_time ) ) ? ' disabled' : ''; ?>> |
| 616 | <?php esc_html_e( 'Start Assignment Submit', 'tutor' ); ?> |
| 617 | </button> |
| 618 | </form> |
| 619 | |
| 620 | <?php if ( $next_prev_content_id->next_id ) : ?> |
| 621 | <a href="<?php echo esc_url( get_permalink( $next_prev_content_id->next_id ) ); ?>" class="tutor-btn tutor-btn-ghost tutor-mt-md-0 tutor-mt-12"> |
| 622 | <?php esc_html_e( 'Skip To Next', 'tutor' ); ?> |
| 623 | </a> |
| 624 | <?php endif; ?> |
| 625 | </div> |
| 626 | </div> |
| 627 | <?php endif; ?> |
| 628 | <?php endif; ?> |
| 629 | </div> |
| 630 | </div> |
| 631 | </div> |
| 632 | |
| 633 | <?php tutor_load_template( 'single.common.footer', array( 'course_id' => $course_id ) ); ?> |
| 634 | |
| 635 | <?php do_action( 'tutor_assignment/single/after/content' ); ?> |
| 636 |