content.php
296 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 | |
| 38 | $total_mark = tutor_utils()->get_assignment_option(get_the_ID(), 'total_mark'); |
| 39 | $pass_mark = tutor_utils()->get_assignment_option(get_the_ID(), 'pass_mark'); |
| 40 | |
| 41 | |
| 42 | global $post; |
| 43 | $assignment_created_time = strtotime($post->post_date); |
| 44 | $time_duration_in_sec; |
| 45 | if(!empty($time_duration['value']) AND !empty($time_duration['time'])) |
| 46 | { |
| 47 | switch ($time_duration['time']) { |
| 48 | case 'hours': |
| 49 | $time_duration_in_sec = 3600; |
| 50 | break; |
| 51 | case 'days': |
| 52 | $time_duration_in_sec = 86400; |
| 53 | break; |
| 54 | case 'weeks': |
| 55 | $time_duration_in_sec = 7*86400; |
| 56 | break; |
| 57 | default: |
| 58 | $time_duration_in_sec = 0; |
| 59 | break; |
| 60 | } |
| 61 | } |
| 62 | $time_duration_in_sec = $time_duration_in_sec * $time_duration['value']; |
| 63 | $remaining_time = $assignment_created_time + $time_duration_in_sec; |
| 64 | $now = time(); |
| 65 | |
| 66 | ?> |
| 67 | |
| 68 | <ul> |
| 69 | <li> |
| 70 | <?php _e('Time Duration : ', 'tutor') ?> |
| 71 | <strong><?php echo $time_duration["value"] ? $time_duration["value"] . ' ' .$time_duration["time"] : __('No limit', 'tutor'); ?></strong> |
| 72 | </li> |
| 73 | <?php if($now>$remaining_time):?> |
| 74 | <li> |
| 75 | <?php _e('Deadline : ', 'tutor') ?> |
| 76 | <strong><?php _e('Expired', 'tutor'); ?></strong> |
| 77 | </li> |
| 78 | <?php endif;?> |
| 79 | <!--<li> |
| 80 | <?php /*_e('Time Remaining : ') */?> |
| 81 | <strong><?php /*echo "7 Days, 12 Hour"; */?></strong> |
| 82 | </li>--> |
| 83 | |
| 84 | <li> |
| 85 | <?php _e('Total Points : ', 'tutor') ?> |
| 86 | <strong><?php echo $total_mark; ?></strong> |
| 87 | </li> |
| 88 | <li> |
| 89 | <?php _e('Minimum Pass Points : ', 'tutor') ?> |
| 90 | <strong><?php echo $pass_mark; ?></strong> |
| 91 | </li> |
| 92 | </ul> |
| 93 | </div> |
| 94 | |
| 95 | <hr /> |
| 96 | <?php if($now>$remaining_time):?> |
| 97 | <div class="tutor-asignment-expire tutor-alert-danger tutor-alert" style="margin:36px 0 46px"> |
| 98 | |
| 99 | <?php _e('You have missed the submission deadline. Please contact the instructor for more information.','tutor');?> |
| 100 | |
| 101 | </div> |
| 102 | <?php endif;?> |
| 103 | <div class="tutor-assignment-content"> |
| 104 | <h2><?php _e('Description', 'tutor'); ?></h2> |
| 105 | |
| 106 | <?php the_content(); ?> |
| 107 | </div> |
| 108 | |
| 109 | <?php |
| 110 | $assignment_attachments = maybe_unserialize(get_post_meta(get_the_ID(),'_tutor_assignment_attachments', true)); |
| 111 | if (tutor_utils()->count($assignment_attachments)){ |
| 112 | ?> |
| 113 | <div class="tutor-assignment-attachments"> |
| 114 | <h2><?php _e('Attachments', 'tutor'); ?></h2> |
| 115 | <?php |
| 116 | foreach ($assignment_attachments as $attachment_id){ |
| 117 | if ($attachment_id) { |
| 118 | |
| 119 | $attachment_name = get_post_meta( $attachment_id, '_wp_attached_file', true ); |
| 120 | $attachment_name = substr($attachment_name, strrpos($attachment_name, '/')+1); |
| 121 | ?> |
| 122 | <p class="attachment-file-name"> |
| 123 | <a href="<?php echo wp_get_attachment_url($attachment_id); ?>" target="_blank"> |
| 124 | <i class="tutor-icon-attach"></i> <?php echo $attachment_name; ?> |
| 125 | </a> |
| 126 | </p> |
| 127 | <?php |
| 128 | } |
| 129 | } |
| 130 | ?> |
| 131 | </div> |
| 132 | <?php |
| 133 | } |
| 134 | |
| 135 | $is_submitting = tutor_utils()->is_assignment_submitting(get_the_ID()); |
| 136 | if ($is_submitting){ |
| 137 | ?> |
| 138 | |
| 139 | <div class="tutor-assignment-submit-form-wrap"> |
| 140 | <h2><?php _e('Assignment answer form', 'tutor'); ?></h2> |
| 141 | |
| 142 | <form action="" method="post" id="tutor_assignment_submit_form" enctype="multipart/form-data"> |
| 143 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 144 | <input type="hidden" value="tutor_assignment_submit" name="tutor_action"/> |
| 145 | <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>"> |
| 146 | |
| 147 | <?php $allowd_upload_files = (int) tutor_utils()->get_assignment_option(get_the_ID(), 'upload_files_limit'); ?> |
| 148 | |
| 149 | <div class="tutor-form-group"> |
| 150 | <p><?php _e('Write your answer briefly', 'tutor'); ?></p> |
| 151 | <textarea name="assignment_answer"></textarea> |
| 152 | </div> |
| 153 | |
| 154 | <div id="form_validation_response"></div> |
| 155 | |
| 156 | <?php if ($allowd_upload_files){ ?> |
| 157 | <p><?php _e('Attach assignment files', 'tutor'); ?></p> |
| 158 | <div class="tutor-assignment-attachment-upload-wrap"> |
| 159 | <?php |
| 160 | for ($item = 1; $item <= $allowd_upload_files; $item++){ |
| 161 | ?> |
| 162 | <div class="tutor-form-group"> |
| 163 | <label for="tutor-assignment-input-<?php echo $item; ?>"><i class="tutor-icon-upload-file"></i><span><?php _e('Upload file', 'tutor'); ?></span></label> |
| 164 | <input class="tutor-assignment-file-upload" id="tutor-assignment-input-<?php echo $item; ?>" type="file" name="attached_assignment_files[]"> |
| 165 | </div> |
| 166 | <?php |
| 167 | } |
| 168 | ?> |
| 169 | </div> |
| 170 | <?php |
| 171 | } |
| 172 | ?> |
| 173 | <div class="tutor-assignment-submit-btn-wrap"> |
| 174 | <button type="submit" class="tutor-button tutor-success" id="tutor_assignment_submit_btn"> <?php _e('Submit Assignment', 'tutor'); |
| 175 | ?> </button> |
| 176 | </div> |
| 177 | </form> |
| 178 | |
| 179 | </div> |
| 180 | |
| 181 | <?php |
| 182 | }else{ |
| 183 | |
| 184 | $submitted_assignment = tutor_utils()->is_assignment_submitted(get_the_ID()); |
| 185 | if ($submitted_assignment){ |
| 186 | $is_reviewed_by_instructor = get_comment_meta($submitted_assignment->comment_ID, 'evaluate_time', true); |
| 187 | |
| 188 | if ($is_reviewed_by_instructor){ |
| 189 | $assignment_id = $submitted_assignment->comment_post_ID; |
| 190 | $submit_id = $submitted_assignment->comment_ID; |
| 191 | |
| 192 | $max_mark = tutor_utils()->get_assignment_option($submitted_assignment->comment_post_ID, 'total_mark'); |
| 193 | $pass_mark = tutor_utils()->get_assignment_option($submitted_assignment->comment_post_ID, 'pass_mark'); |
| 194 | $given_mark = get_comment_meta($submitted_assignment->comment_ID, 'assignment_mark', true); |
| 195 | ?> |
| 196 | |
| 197 | <?php ob_start(); ?> |
| 198 | |
| 199 | <div class="assignment-result-wrap"> |
| 200 | <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> |
| 201 | <h4 class="submitted-assignment-grade"> |
| 202 | <?php _e('Your Grade is ', 'tutor'); ?> |
| 203 | <?php if ($given_mark >= $pass_mark){ |
| 204 | ?> |
| 205 | <span class="submitted-assignment-grade-pass"> |
| 206 | <?php _e('Passed', 'tutor'); ?> |
| 207 | </span> |
| 208 | <?php |
| 209 | }else{ |
| 210 | ?> |
| 211 | <span class="submitted-assignment-grade-failed"> |
| 212 | <?php _e('Failed', 'tutor'); ?> |
| 213 | </span> |
| 214 | <?php |
| 215 | } ?> |
| 216 | </h4> |
| 217 | </div> |
| 218 | |
| 219 | <?php echo apply_filters('tutor_assignment/single/results/after', ob_get_clean(), $submit_id, $assignment_id ); ?> |
| 220 | |
| 221 | <?php } ?> |
| 222 | |
| 223 | |
| 224 | <div class="tutor-assignments-submitted-answers-wrap"> |
| 225 | |
| 226 | <h2><?php _e('Your Answers', 'tutor'); ?></h2> |
| 227 | |
| 228 | <?php echo nl2br(stripslashes($submitted_assignment->comment_content)); |
| 229 | |
| 230 | $attached_files = get_comment_meta($submitted_assignment->comment_ID, 'uploaded_attachments', true); |
| 231 | if ($attached_files){ |
| 232 | $attached_files = json_decode($attached_files, true); |
| 233 | |
| 234 | if (tutor_utils()->count($attached_files)){ |
| 235 | |
| 236 | ?> |
| 237 | <h2><?php _e('Your uploaded file(s)', 'tutor'); ?></h2> |
| 238 | |
| 239 | <?php |
| 240 | |
| 241 | $upload_dir = wp_get_upload_dir(); |
| 242 | $upload_baseurl = trailingslashit(tutor_utils()->array_get('baseurl', $upload_dir)); |
| 243 | |
| 244 | foreach ($attached_files as $attached_file){ |
| 245 | ?> |
| 246 | <div class="uploaded-files"> |
| 247 | <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); ?> |
| 248 | </a> |
| 249 | </div> |
| 250 | <?php |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | if ($is_reviewed_by_instructor){ |
| 256 | ?> |
| 257 | |
| 258 | <div class="instructor-note-wrap"> |
| 259 | <h2><?php _e('Instructor Note', 'tutor'); ?></h2> |
| 260 | <p><?php echo nl2br(get_comment_meta($submitted_assignment->comment_ID,'instructor_note', true)) ?></p> |
| 261 | </div> |
| 262 | <?php |
| 263 | } |
| 264 | ?> |
| 265 | </div> |
| 266 | |
| 267 | <?php |
| 268 | }else { |
| 269 | ?> |
| 270 | |
| 271 | <div class="tutor-assignment-start-btn-wrap"> |
| 272 | <form action="" method="post" id="tutor_assignment_start_form"> |
| 273 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 274 | <input type="hidden" value="tutor_assignment_start_submit" name="tutor_action"/> |
| 275 | <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>"> |
| 276 | |
| 277 | <?php if($now > $remaining_time):?> |
| 278 | |
| 279 | <button type="submit" class="tutor-button" id="tutor_assignment_start_btn" disabled=""> <?php _e( 'Start assignment submit', 'tutor' ); ?> </button> |
| 280 | <?php else:?> |
| 281 | <button type="submit" class="tutor-button" id="tutor_assignment_start_btn"> <?php _e( 'Start assignment submit', 'tutor' ); ?> </button> |
| 282 | <?php endif;?> |
| 283 | </form> |
| 284 | </div> |
| 285 | <?php |
| 286 | } |
| 287 | } |
| 288 | ?> |
| 289 | |
| 290 | <?php tutor_next_previous_pagination(); ?> |
| 291 | |
| 292 | </div> |
| 293 | |
| 294 | |
| 295 | |
| 296 | <?php do_action('tutor_assignment/single/after/content'); ?> |