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.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / single / assignment / content.php
tutor / templates / single / assignment Last commit date
content.php 4 years ago
content.php
337 lines
1 <?php
2
3 /**
4 * @package TutorLMS/Templates
5 * @version 1.4.3
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11 global $wpdb;
12 $is_submitted = false;
13 $is_submitting = tutor_utils()->is_assignment_submitting( get_the_ID() );
14 // get the comment
15 $post_id = get_the_ID();
16 $user_id = get_current_user_id();
17 $assignment_comment = tutor_utils()->get_single_comment_user_post_id( $post_id, $user_id );
18
19 if ( $assignment_comment != false ) {
20 $submitted = $assignment_comment->comment_approved;
21 $submitted == 'submitted' ? $is_submitted = true : '';
22 }
23 ?>
24
25 <?php do_action( 'tutor_assignment/single/before/content' ); ?>
26
27 <div class="tutor-single-page-top-bar">
28 <div class="tutor-topbar-item tutor-hide-sidebar-bar">
29 <a href="javascript:;" class="tutor-lesson-sidebar-hide-bar"><i class="tutor-icon-angle-left"></i> </a>
30 <?php $course_id = tutor_utils()->get_course_id_by( 'assignment', get_the_ID() ); ?>
31 <a href="<?php echo esc_url( get_the_permalink( $course_id ) ); ?>" class="tutor-topbar-home-btn">
32 <i class="tutor-icon-home"></i> <?php echo __( 'Go to Course Home', 'tutor' ); ?>
33 </a>
34 </div>
35 <div class="tutor-topbar-item tutor-topbar-content-title-wrap">
36 <?php
37 tutor_utils()->get_lesson_type_icon( get_the_ID(), true, true );
38 the_title();
39 ?>
40 </div>
41 </div>
42
43 <div class="tutor-lesson-content-area">
44 <div class="tutor-assignment-title">
45 <h2><?php the_title(); ?></h2>
46 </div>
47
48 <div class="tutor-assignment-information">
49 <?php
50 $time_duration = tutor_utils()->get_assignment_option(
51 get_the_ID(),
52 'time_duration',
53 array(
54 'time' => '',
55 'value' => 0,
56 )
57 );
58
59 $total_mark = tutor_utils()->get_assignment_option( get_the_ID(), 'total_mark' );
60 $pass_mark = tutor_utils()->get_assignment_option( get_the_ID(), 'pass_mark' );
61
62 global $post;
63 $assignment_created_time = strtotime( $post->post_date_gmt );
64 $time_duration_in_sec = 0;
65 if ( isset( $time_duration['value'] ) and isset( $time_duration['time'] ) ) {
66 switch ( $time_duration['time'] ) {
67 case 'hours':
68 $time_duration_in_sec = 3600;
69 break;
70 case 'days':
71 $time_duration_in_sec = 86400;
72 break;
73 case 'weeks':
74 $time_duration_in_sec = 7 * 86400;
75 break;
76 default:
77 $time_duration_in_sec = 0;
78 break;
79 }
80 }
81 $time_duration_in_sec = $time_duration_in_sec * $time_duration['value'];
82 $remaining_time = $assignment_created_time + $time_duration_in_sec;
83 $now = time();
84
85 ?>
86
87 <ul>
88 <li>
89 <?php _e( 'Time Duration : ', 'tutor' ); ?>
90 <strong><?php echo $time_duration['value'] ? $time_duration['value'] . ' ' . $time_duration['time'] : __( 'No limit', 'tutor' ); ?></strong>
91 </li>
92 <?php
93 /*
94 *time_duration[value]==0 means no limit
95 *if have unlimited time then no msg should
96 *appear
97 */
98 if ( $time_duration['value'] != 0 ) :
99 if ( $now > $remaining_time and $is_submitted == false ) :
100 ?>
101 <li>
102 <?php _e( 'Deadline : ', 'tutor' ); ?>
103 <strong><?php _e( 'Expired', 'tutor' ); ?></strong>
104 </li>
105 <?php
106 endif;
107 endif;
108 ?>
109 <!--<li>
110 <?php /*_e('Time Remaining : ') */ ?>
111 <strong><?php /*echo "7 Days, 12 Hour"; */ ?></strong>
112 </li>-->
113
114 <li>
115 <?php _e( 'Total Points : ', 'tutor' ); ?>
116 <strong><?php echo esc_attr( $total_mark ); ?></strong>
117 </li>
118 <li>
119 <?php _e( 'Minimum Pass Points : ', 'tutor' ); ?>
120 <strong><?php echo esc_attr( $pass_mark ); ?></strong>
121 </li>
122 </ul>
123 </div>
124
125 <hr />
126 <?php
127 /*
128 *time_duration[value]==0 means no limit
129 *if have unlimited time then no msg should
130 *appear
131 */
132 if ( $time_duration['value'] != 0 ) :
133 if ( $now > $remaining_time and $is_submitted == false ) :
134 ?>
135 <div class="tutor-asignment-expire tutor-alert-danger tutor-alert" style="margin:36px 0 46px">
136
137 <?php _e( 'You have missed the submission deadline. Please contact the instructor for more information.', 'tutor' ); ?>
138
139 </div>
140 <?php
141 endif;
142 endif;
143 ?>
144 <div class="tutor-assignment-content">
145 <h2><?php _e( 'Description', 'tutor' ); ?></h2>
146
147 <?php the_content(); ?>
148 </div>
149
150 <?php
151 $assignment_attachments = maybe_unserialize( get_post_meta( get_the_ID(), '_tutor_assignment_attachments', true ) );
152 if ( tutor_utils()->count( $assignment_attachments ) ) {
153 ?>
154 <div class="tutor-assignment-attachments">
155 <h2><?php _e( 'Attachments', 'tutor' ); ?></h2>
156 <?php
157 foreach ( $assignment_attachments as $attachment_id ) {
158 if ( $attachment_id ) {
159
160 $attachment_name = get_post_meta( $attachment_id, '_wp_attached_file', true );
161 $attachment_name = substr( $attachment_name, strrpos( $attachment_name, '/' ) + 1 );
162 ?>
163 <p class="attachment-file-name">
164 <a href="<?php echo esc_url( wp_get_attachment_url( $attachment_id ) ); ?>" target="_blank">
165 <i class="tutor-icon-attach"></i> <?php echo esc_attr( $attachment_name ); ?>
166 </a>
167 </p>
168 <?php
169 }
170 }
171 ?>
172 </div>
173 <?php
174 }
175
176 if ( $is_submitting and ( $remaining_time > $now or $time_duration['value'] == 0 ) ) {
177 ?>
178 <div class="tutor-assignment-submit-form-wrap">
179 <h2><?php _e( 'Assignment answer form', 'tutor' ); ?></h2>
180
181 <form action="" method="post" id="tutor_assignment_submit_form" enctype="multipart/form-data">
182 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
183 <input type="hidden" value="tutor_assignment_submit" name="tutor_action" />
184 <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>">
185
186 <?php $allowd_upload_files = (int) tutor_utils()->get_assignment_option( get_the_ID(), 'upload_files_limit' ); ?>
187
188 <div class="tutor-form-group">
189 <p><?php _e( 'Write your answer briefly', 'tutor' ); ?></p>
190 <textarea name="assignment_answer"></textarea>
191 </div>
192
193 <div id="form_validation_response"></div>
194
195 <?php if ( $allowd_upload_files ) { ?>
196 <p><?php _e( 'Attach assignment files', 'tutor' ); ?></p>
197 <div class="tutor-assignment-attachment-upload-wrap">
198 <?php
199 for ( $item = 1; $item <= $allowd_upload_files; $item++ ) {
200 ?>
201 <div class="tutor-form-group">
202 <label for="tutor-assignment-input-<?php echo esc_attr( $item ); ?>"><i class="tutor-icon-upload-file"></i><span><?php _e( 'Upload file', 'tutor' ); ?></span></label>
203 <input class="tutor-assignment-file-upload" id="tutor-assignment-input-<?php echo esc_attr( $item ); ?>" type="file" name="attached_assignment_files[]">
204 </div>
205 <?php
206 }
207 ?>
208 </div>
209 <?php
210 }
211 ?>
212 <div class="tutor-assignment-submit-btn-wrap">
213 <button type="submit" class="tutor-button tutor-button-primary" id="tutor_assignment_submit_btn">
214 <?php _e( 'Submit Assignment', 'tutor' ); ?> </button>
215 </div>
216 </form>
217
218 </div>
219
220 <?php
221 } else {
222
223 $submitted_assignment = tutor_utils()->is_assignment_submitted( get_the_ID() );
224 if ( $submitted_assignment ) {
225 $is_reviewed_by_instructor = get_comment_meta( $submitted_assignment->comment_ID, 'evaluate_time', true );
226
227 if ( $is_reviewed_by_instructor ) {
228 $assignment_id = $submitted_assignment->comment_post_ID;
229 $submit_id = $submitted_assignment->comment_ID;
230
231 $max_mark = tutor_utils()->get_assignment_option( $submitted_assignment->comment_post_ID, 'total_mark' );
232 $pass_mark = tutor_utils()->get_assignment_option( $submitted_assignment->comment_post_ID, 'pass_mark' );
233 $given_mark = get_comment_meta( $submitted_assignment->comment_ID, 'assignment_mark', true );
234 ?>
235
236 <?php ob_start(); ?>
237
238 <div class="assignment-result-wrap">
239 <h4><?php echo sprintf( __( 'You received %1$s points out of %2$s', 'tutor' ), '<span class="received-marks">' . $given_mark . '</span>', '<span class="out-of-marks">' . $max_mark . '</span>' ); ?></h4>
240 <h4 class="submitted-assignment-grade">
241 <?php _e( 'Your Grade is ', 'tutor' ); ?>
242 <?php
243 if ( $given_mark >= $pass_mark ) {
244 ?>
245 <span class="submitted-assignment-grade-pass">
246 <?php _e( 'Passed', 'tutor' ); ?>
247 </span>
248 <?php
249 } else {
250 ?>
251 <span class="submitted-assignment-grade-failed">
252 <?php _e( 'Failed', 'tutor' ); ?>
253 </span>
254 <?php
255 }
256 ?>
257 </h4>
258 </div>
259
260 <?php echo apply_filters( 'tutor_assignment/single/results/after', ob_get_clean(), $submit_id, $assignment_id ); ?>
261
262 <?php } ?>
263
264 <div class="tutor-assignments-submitted-answers-wrap">
265
266 <h2><?php _e( 'Your Answers', 'tutor' ); ?></h2>
267
268 <?php
269 echo wp_kses_post( nl2br( stripslashes( $submitted_assignment->comment_content ) ) );
270
271 $attached_files = get_comment_meta( $submitted_assignment->comment_ID, 'uploaded_attachments', true );
272 if ( $attached_files ) {
273 $attached_files = json_decode( $attached_files, true );
274
275 if ( tutor_utils()->count( $attached_files ) ) {
276
277 ?>
278 <h2><?php _e( 'Your uploaded file(s)', 'tutor' ); ?></h2>
279
280 <?php
281 $upload_dir = wp_get_upload_dir();
282 $upload_baseurl = trailingslashit( tutor_utils()->array_get( 'baseurl', $upload_dir ) );
283 foreach ( $attached_files as $attached_file ) {
284 ?>
285 <div class="uploaded-files">
286 <a href="<?php echo esc_url( $upload_baseurl . tutor_utils()->array_get( 'uploaded_path', $attached_file ) ); ?>" target="_blank"><?php echo esc_attr( tutor_utils()->array_get( 'name', $attached_file ) ); ?>
287 </a>
288 </div>
289 <?php
290 }
291 }
292 }
293
294 if ( $is_reviewed_by_instructor ) {
295 ?>
296
297 <div class="instructor-note-wrap">
298 <h2><?php _e( 'Instructor Note', 'tutor' ); ?></h2>
299 <p><?php echo nl2br( get_comment_meta( $submitted_assignment->comment_ID, 'instructor_note', true ) ); ?></p>
300 </div>
301 <?php
302 }
303 ?>
304 </div>
305
306 <?php
307 } else {
308 ?>
309 <div class="tutor-assignment-start-btn-wrap">
310 <form action="" method="post" id="tutor_assignment_start_form">
311 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
312 <input type="hidden" value="tutor_assignment_start_submit" name="tutor_action" />
313 <input type="hidden" name="assignment_id" value="<?php echo get_the_ID(); ?>">
314 <button type="submit" class="tutor-button" id="tutor_assignment_start_btn"
315 <?php
316 if ( $time_duration['value'] != 0 ) {
317 if ( $now > $remaining_time ) {
318 echo 'disabled';
319 }
320 }
321 ?>
322 >
323 <?php _e( 'Submit assignment', 'tutor' ); ?>
324 </button>
325 </form>
326 </div>
327 <?php
328 }
329 }
330 ?>
331
332 <?php tutor_next_previous_pagination(); ?>
333
334 </div>
335
336 <?php do_action( 'tutor_assignment/single/after/content' ); ?>
337