content.php
251 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package TutorLMS/Templates |
| 4 | * @version 1.4.3 |
| 5 | */ |
| 6 | |
| 7 | if ( ! defined( 'ABSPATH' ) ) |
| 8 | exit; |
| 9 | global $wpdb; |
| 10 | ?> |
| 11 | |
| 12 | <?php do_action('tutor_assignment/single/before/content'); ?> |
| 13 | |
| 14 | <div class="tutor-single-page-top-bar"> |
| 15 | <div class="tutor-topbar-item tutor-hide-sidebar-bar"> |
| 16 | <a href="javascript:;" class="tutor-lesson-sidebar-hide-bar"><i class="tutor-icon-angle-left"></i> </a> |
| 17 | <?php $course_id = get_post_meta(get_the_ID(), '_tutor_course_id_for_assignments', true); ?> |
| 18 | <a href="<?php echo get_the_permalink($course_id); ?>" class="tutor-topbar-home-btn"> |
| 19 | <i class="tutor-icon-home"></i> <?php echo __('Go to Course Home', 'tutor') ; ?> |
| 20 | </a> |
| 21 | </div> |
| 22 | <div class="tutor-topbar-item tutor-topbar-content-title-wrap"> |
| 23 | <?php |
| 24 | tutor_utils()->get_lesson_type_icon(get_the_ID(), true, true); |
| 25 | the_title(); ?> |
| 26 | </div> |
| 27 | </div> |
| 28 | |
| 29 | <div class="tutor-lesson-content-area"> |
| 30 | <div class="tutor-assignment-title"> |
| 31 | <h2><?php the_title(); ?></h2> |
| 32 | </div> |
| 33 | |
| 34 | <div class="tutor-assignment-information"> |
| 35 | <?php |
| 36 | $time_duration = tutor_utils()->get_assignment_option(get_the_ID(), 'time_duration'); |
| 37 | $total_mark = tutor_utils()->get_assignment_option(get_the_ID(), 'total_mark'); |
| 38 | $pass_mark = tutor_utils()->get_assignment_option(get_the_ID(), 'pass_mark'); |
| 39 | ?> |
| 40 | |
| 41 | <ul> |
| 42 | <li> |
| 43 | <?php _e('Time Duration : ', 'tutor') ?> |
| 44 | <strong><?php echo $time_duration["value"] ? $time_duration["value"] . ' ' .$time_duration["time"] : __('No limit', 'tutor'); ?></strong> |
| 45 | </li> |
| 46 | <!--<li> |
| 47 | <?php /*_e('Time Remaining : ') */?> |
| 48 | <strong><?php /*echo "7 Days, 12 Hour"; */?></strong> |
| 49 | </li>--> |
| 50 | <li> |
| 51 | <?php _e('Total Points : ', 'tutor') ?> |
| 52 | <strong><?php echo $total_mark; ?></strong> |
| 53 | </li> |
| 54 | <li> |
| 55 | <?php _e('Minimum Pass Points : ', 'tutor') ?> |
| 56 | <strong><?php echo $pass_mark; ?></strong> |
| 57 | </li> |
| 58 | </ul> |
| 59 | </div> |
| 60 | |
| 61 | <hr /> |
| 62 | |
| 63 | <div class="tutor-assignment-content"> |
| 64 | <h2><?php _e('Description', 'tutor'); ?></h2> |
| 65 | |
| 66 | <?php the_content(); ?> |
| 67 | </div> |
| 68 | |
| 69 | <?php |
| 70 | $assignment_attachments = maybe_unserialize(get_post_meta(get_the_ID(),'_tutor_assignment_attachments', true)); |
| 71 | if (tutor_utils()->count($assignment_attachments)){ |
| 72 | ?> |
| 73 | <div class="tutor-assignment-attachments"> |
| 74 | <h2><?php _e('Attachments', 'tutor'); ?></h2> |
| 75 | <?php |
| 76 | foreach ($assignment_attachments as $attachment_id){ |
| 77 | if ($attachment_id) { |
| 78 | |
| 79 | $attachment_name = get_post_meta( $attachment_id, '_wp_attached_file', true ); |
| 80 | $attachment_name = substr($attachment_name, strrpos($attachment_name, '/')+1); |
| 81 | ?> |
| 82 | <p class="attachment-file-name"> |
| 83 | <a href="<?php echo wp_get_attachment_url($attachment_id); ?>" target="_blank"> |
| 84 | <i class="tutor-icon-attach"></i> <?php echo $attachment_name; ?> |
| 85 | </a> |
| 86 | </p> |
| 87 | <?php |
| 88 | } |
| 89 | } |
| 90 | ?> |
| 91 | </div> |
| 92 | <?php |
| 93 | } |
| 94 | |
| 95 | $is_submitting = tutor_utils()->is_assignment_submitting(get_the_ID()); |
| 96 | if ($is_submitting){ |
| 97 | ?> |
| 98 | |
| 99 | <div class="tutor-assignment-submit-form-wrap"> |
| 100 | <h2><?php _e('Assignment answer form', 'tutor'); ?></h2> |
| 101 | |
| 102 | <form action="" method="post" id="tutor_assignment_submit_form" enctype="multipart/form-data"> |
| 103 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 104 | <input type="hidden" value="tutor_assignment_submit" name="tutor_action"/> |
| 105 | <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>"> |
| 106 | |
| 107 | <?php $allowd_upload_files = (int) tutor_utils()->get_assignment_option(get_the_ID(), 'upload_files_limit'); ?> |
| 108 | |
| 109 | <div class="tutor-form-group"> |
| 110 | <p><?php _e('Write your answer briefly', 'tutor'); ?></p> |
| 111 | <textarea name="assignment_answer"></textarea> |
| 112 | </div> |
| 113 | |
| 114 | <div id="form_validation_response"></div> |
| 115 | |
| 116 | <?php if ($allowd_upload_files){ ?> |
| 117 | <p><?php _e('Attach assignment files', 'tutor'); ?></p> |
| 118 | <div class="tutor-assignment-attachment-upload-wrap"> |
| 119 | <?php |
| 120 | for ($item = 1; $item <= $allowd_upload_files; $item++){ |
| 121 | ?> |
| 122 | <div class="tutor-form-group"> |
| 123 | <label for="tutor-assignment-input-<?php echo $item; ?>"><i class="tutor-icon-upload-file"></i><span><?php _e('Upload file', 'tutor'); ?></span></label> |
| 124 | <input class="tutor-assignment-file-upload" id="tutor-assignment-input-<?php echo $item; ?>" type="file" name="attached_assignment_files[]"> |
| 125 | </div> |
| 126 | <?php |
| 127 | } |
| 128 | ?> |
| 129 | </div> |
| 130 | <?php |
| 131 | } |
| 132 | ?> |
| 133 | <div class="tutor-assignment-submit-btn-wrap"> |
| 134 | <button type="submit" class="tutor-button tutor-success" id="tutor_assignment_submit_btn"> <?php _e('Submit Assignment', 'tutor'); |
| 135 | ?> </button> |
| 136 | </div> |
| 137 | </form> |
| 138 | |
| 139 | </div> |
| 140 | |
| 141 | <?php |
| 142 | }else{ |
| 143 | |
| 144 | $submitted_assignment = tutor_utils()->is_assignment_submitted(get_the_ID()); |
| 145 | if ($submitted_assignment){ |
| 146 | $is_reviewed_by_instructor = get_comment_meta($submitted_assignment->comment_ID, 'evaluate_time', true); |
| 147 | |
| 148 | if ($is_reviewed_by_instructor){ |
| 149 | $assignment_id = $submitted_assignment->comment_post_ID; |
| 150 | $submit_id = $submitted_assignment->comment_ID; |
| 151 | |
| 152 | $max_mark = tutor_utils()->get_assignment_option($submitted_assignment->comment_post_ID, 'total_mark'); |
| 153 | $pass_mark = tutor_utils()->get_assignment_option($submitted_assignment->comment_post_ID, 'pass_mark'); |
| 154 | $given_mark = get_comment_meta($submitted_assignment->comment_ID, 'assignment_mark', true); |
| 155 | ?> |
| 156 | |
| 157 | <?php ob_start(); ?> |
| 158 | |
| 159 | <div class="assignment-result-wrap"> |
| 160 | <h4><?php echo sprintf(__('You received %s points out of %s', 'tutor'), "<span class='received-marks'>{$given_mark}</span>", "<span class='out-of-marks'>{$max_mark}</span>") ?></h4> |
| 161 | <h4 class="submitted-assignment-grade"> |
| 162 | <?php _e('Your Grade is ', 'tutor'); ?> |
| 163 | <?php if ($given_mark >= $pass_mark){ |
| 164 | ?> |
| 165 | <span class="submitted-assignment-grade-pass"> |
| 166 | <?php _e('Passed', 'tutor'); ?> |
| 167 | </span> |
| 168 | <?php |
| 169 | }else{ |
| 170 | ?> |
| 171 | <span class="submitted-assignment-grade-failed"> |
| 172 | <?php _e('Failed', 'tutor'); ?> |
| 173 | </span> |
| 174 | <?php |
| 175 | } ?> |
| 176 | </h4> |
| 177 | </div> |
| 178 | |
| 179 | <?php echo apply_filters('tutor_assignment/single/results/after', ob_get_clean(), $submit_id, $assignment_id ); ?> |
| 180 | |
| 181 | <?php } ?> |
| 182 | |
| 183 | |
| 184 | <div class="tutor-assignments-submitted-answers-wrap"> |
| 185 | |
| 186 | <h2><?php _e('Your Answers', 'tutor'); ?></h2> |
| 187 | |
| 188 | <?php echo nl2br(stripslashes($submitted_assignment->comment_content)); |
| 189 | |
| 190 | $attached_files = get_comment_meta($submitted_assignment->comment_ID, 'uploaded_attachments', true); |
| 191 | if ($attached_files){ |
| 192 | $attached_files = json_decode($attached_files, true); |
| 193 | |
| 194 | if (tutor_utils()->count($attached_files)){ |
| 195 | |
| 196 | ?> |
| 197 | <h2><?php _e('Your uploaded file(s)', 'tutor'); ?></h2> |
| 198 | |
| 199 | <?php |
| 200 | |
| 201 | $upload_dir = wp_get_upload_dir(); |
| 202 | $upload_baseurl = trailingslashit(tutor_utils()->array_get('baseurl', $upload_dir)); |
| 203 | |
| 204 | foreach ($attached_files as $attached_file){ |
| 205 | ?> |
| 206 | <div class="uploaded-files"> |
| 207 | <a href="<?php echo $upload_baseurl.tutor_utils()->array_get('uploaded_path', $attached_file) ?>" target="_blank"><?php echo tutor_utils()->array_get('name', $attached_file); ?> |
| 208 | </a> |
| 209 | </div> |
| 210 | <?php |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | if ($is_reviewed_by_instructor){ |
| 216 | ?> |
| 217 | |
| 218 | <div class="instructor-note-wrap"> |
| 219 | <h2><?php _e('Instructor Note', 'tutor'); ?></h2> |
| 220 | <p><?php echo nl2br(get_comment_meta($submitted_assignment->comment_ID,'instructor_note', true)) ?></p> |
| 221 | </div> |
| 222 | <?php |
| 223 | } |
| 224 | ?> |
| 225 | </div> |
| 226 | |
| 227 | <?php |
| 228 | }else { |
| 229 | ?> |
| 230 | |
| 231 | <div class="tutor-assignment-start-btn-wrap"> |
| 232 | <form action="" method="post" id="tutor_assignment_start_form"> |
| 233 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 234 | <input type="hidden" value="tutor_assignment_start_submit" name="tutor_action"/> |
| 235 | <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>"> |
| 236 | |
| 237 | <button type="submit" class="tutor-button" id="tutor_assignment_start_btn"> <?php _e( 'Start assignment submit', 'tutor' ); ?> </button> |
| 238 | </form> |
| 239 | </div> |
| 240 | <?php |
| 241 | } |
| 242 | } |
| 243 | ?> |
| 244 | |
| 245 | <?php tutor_next_previous_pagination(); ?> |
| 246 | |
| 247 | </div> |
| 248 | |
| 249 | |
| 250 | |
| 251 | <?php do_action('tutor_assignment/single/after/content'); ?> |