question_and_answer.php
39 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Question and answer in single course details tab |
| 4 | * |
| 5 | * @since v.1.0.0 |
| 6 | * @author themeum |
| 7 | * @url https://themeum.com |
| 8 | * |
| 9 | * @package TutorLMS/Templates |
| 10 | * @version 1.4.3 |
| 11 | */ |
| 12 | global $post; |
| 13 | $disable_qa_for_this_course = get_post_meta($post->ID, '_tutor_enable_qa', true)!='yes'; |
| 14 | $enable_q_and_a_on_course = tutor_utils()->get_option('enable_q_and_a_on_course'); |
| 15 | if ( !$enable_q_and_a_on_course || $disable_qa_for_this_course == 'yes') { |
| 16 | tutor_load_template( 'single.course.q_and_a_turned_off' ); |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | do_action('tutor_course/question_and_answer/before'); |
| 21 | |
| 22 | echo '<h3 class="tutor-fs-5 tutor-fw-bold tutor-color-black tutor-mb-20">'.__('Question & Answer', 'tutor').'</h3>'; |
| 23 | |
| 24 | // New qna form |
| 25 | tutor_load_template_from_custom_path(tutor()->path . '/views/qna/qna-new.php', array( |
| 26 | 'course_id' => get_the_ID(), |
| 27 | 'context' => 'course-single-qna-single' |
| 28 | ), false); |
| 29 | |
| 30 | // Previous qna list |
| 31 | $questions = tutor_utils()->get_qa_questions(0, 20, $search_term = '', $question_id = null, $meta_query = null, $asker_id = null, $question_status = null, $count_only = false, $args = array('course_id' => get_the_ID())); |
| 32 | foreach ($questions as $question) { |
| 33 | tutor_load_template_from_custom_path(tutor()->path . '/views/qna/qna-single.php', array( |
| 34 | 'question_id' => $question->comment_ID, |
| 35 | 'context' => 'course-single-qna-single' |
| 36 | ), false); |
| 37 | } |
| 38 | |
| 39 | do_action('tutor_course/question_and_answer/after'); |