course
3 years ago
course-add-edd-product-metabox.php
3 years ago
course-add-product-metabox.php
3 years ago
course-additional-data.php
3 years ago
course-contents.php
3 years ago
course-level-metabox.php
3 years ago
course-topics.php
3 years ago
instructors-metabox.php
3 years ago
lesson-attachments-metabox.php
3 years ago
lesson-metabox.php
3 years ago
product-selection.php
3 years ago
settings-tabs.php
3 years ago
user-profile-fields.php
3 years ago
video-metabox.php
3 years ago
course-contents.php
210 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Course contents |
| 4 | * |
| 5 | * @package Tutor\Views |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 1.0.0 |
| 9 | */ |
| 10 | |
| 11 | ?> |
| 12 | <div class="wp_editor_config_example" style="display: none;"> |
| 13 | <?php wp_editor( '', 'tutor_lesson_editor_config' ); ?> |
| 14 | </div> |
| 15 | |
| 16 | <div class="wp_editor_config_example" style="display: none;"> |
| 17 | <?php wp_editor( '', 'tutor_assignment_editor_config' ); ?> |
| 18 | </div> |
| 19 | |
| 20 | <div class="course-contents"> |
| 21 | |
| 22 | <?php |
| 23 | |
| 24 | $query_topics = new WP_Query( |
| 25 | array( |
| 26 | 'post_type' => 'topics', |
| 27 | 'post_parent' => $course_id, |
| 28 | 'orderby' => 'menu_order', |
| 29 | 'order' => 'ASC', |
| 30 | 'posts_per_page' => -1, |
| 31 | ) |
| 32 | ); |
| 33 | |
| 34 | $query_topics = $query_topics->posts; |
| 35 | |
| 36 | // Actually all kind of contents. |
| 37 | // This keyword '_tutor_course_id_for_lesson' used just to support backward compatibility. |
| 38 | global $wpdb; |
| 39 | $unassigned_contents = $wpdb->get_results( |
| 40 | "SELECT content.* FROM {$wpdb->posts} content |
| 41 | INNER JOIN {$wpdb->postmeta} meta ON content.ID=meta.post_id |
| 42 | WHERE content.post_parent=0 |
| 43 | AND meta.meta_key='_tutor_course_id_for_lesson' |
| 44 | AND meta.meta_value=" . $course_id |
| 45 | ); |
| 46 | |
| 47 | if ( is_array( $unassigned_contents ) && count( $unassigned_contents ) ) { |
| 48 | |
| 49 | $query_topics[] = (object) array( |
| 50 | 'ID' => 0, |
| 51 | 'post_title' => __( 'Un-assigned Topic Contents', 'tutor' ), |
| 52 | 'contents' => $unassigned_contents, |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | foreach ( $query_topics as $topic ) { |
| 57 | $is_topic = $topic->ID > 0; |
| 58 | ?> |
| 59 | <div id="tutor-topics-<?php echo esc_attr( $topic->ID ); ?>" class="tutor-topics-wrap" data-topic-id="<?php echo esc_attr( $topic->ID ); ?>"> |
| 60 | <div class="tutor-topics-top"> |
| 61 | <div class="tutor-topic-title"> |
| 62 | <span class="<?php echo $is_topic ? 'tutor-icon-hamburger-menu course-move-handle' : 'tutor-icon-warning'; ?> tutor-px-12"></span> |
| 63 | <span class="topic-inner-title tutor-fs-6 tutor-fw-bold tutor-color-black tutor-d-flex tutor-align-center"> |
| 64 | <?php echo esc_html( stripslashes( $topic->post_title ) ); ?> |
| 65 | </span> |
| 66 | <?php if ( $is_topic ) : ?> |
| 67 | <span class="tutor-iconic-btn" data-tutor-modal-target="tutor-topics-edit-id-<?php echo esc_attr( $topic->ID ); ?>"> |
| 68 | <i class="tutor-icon-edit" area-hidden="true"></i> |
| 69 | </span> |
| 70 | <span class="topic-delete-btn tutor-iconic-btn" action-delete-course-topic> |
| 71 | <i class="tutor-icon-trash-can-line" area-hidden="true"></i> |
| 72 | </span> |
| 73 | <?php endif; ?> |
| 74 | <span class="expand-collapse-wrap"> |
| 75 | <i class="tutor-icon-angle-down" area-hidden="true"></i> |
| 76 | </span> |
| 77 | </div> |
| 78 | <?php |
| 79 | if ( $is_topic ) { |
| 80 | tutor_load_template_from_custom_path( |
| 81 | tutor()->path . '/views/modal/topic-form.php', |
| 82 | array( |
| 83 | 'modal_title' => __( 'Update Topic', 'tutor' ), |
| 84 | 'wrapper_id' => 'tutor-topics-edit-id-' . $topic->ID, |
| 85 | 'topic_id' => $topic->ID, |
| 86 | 'course_id' => $course_id, |
| 87 | 'title' => $topic->post_title, |
| 88 | 'summary' => $topic->post_content, |
| 89 | 'wrapper_class' => 'tutor-topics-edit-form', |
| 90 | 'button_text' => __( 'Update Topic', 'tutor' ), |
| 91 | 'button_class' => 'tutor-save-topic-btn', |
| 92 | ), |
| 93 | false |
| 94 | ); |
| 95 | } |
| 96 | ?> |
| 97 | </div> |
| 98 | <div class="tutor-topics-body" style="display: <?php echo ( isset( $current_topic_id ) && $current_topic_id == $topic->ID ) ? 'block' : 'none'; ?>;"> |
| 99 | <div class="tutor-lessons"> |
| 100 | <?php |
| 101 | $post_type = apply_filters( 'tutor_course_contents_post_types', array( tutor()->lesson_post_type, 'tutor_quiz' ) ); |
| 102 | $course_contents = ! $is_topic ? $topic->contents : get_posts( |
| 103 | array( |
| 104 | 'post_type' => $post_type, |
| 105 | 'post_parent' => $topic->ID, |
| 106 | 'posts_per_page' => -1, |
| 107 | 'orderby' => 'menu_order', |
| 108 | 'order' => 'ASC', |
| 109 | ) |
| 110 | ); |
| 111 | |
| 112 | $counter = array( |
| 113 | 'lesson' => 0, |
| 114 | 'quiz' => 0, |
| 115 | 'assignment' => 0, |
| 116 | ); |
| 117 | |
| 118 | foreach ( $course_contents as $content ) { |
| 119 | |
| 120 | if ( 'tutor_quiz' === $content->post_type ) { |
| 121 | $quiz = $content; |
| 122 | $counter['quiz']++; |
| 123 | tutor_load_template_from_custom_path( |
| 124 | tutor()->path . '/views/fragments/quiz-list-single.php', |
| 125 | array( |
| 126 | 'quiz_id' => $quiz->ID, |
| 127 | 'topic_id' => $topic->ID, |
| 128 | 'quiz_title' => __( 'Quiz', 'tutor' ) . ' ' . $counter['quiz'] . ': ' . $quiz->post_title, |
| 129 | ), |
| 130 | false |
| 131 | ); |
| 132 | |
| 133 | } elseif ( 'tutor_assignments' === $content->post_type ) { |
| 134 | $counter['assignment']++; |
| 135 | ?> |
| 136 | <div data-course_content_id="<?php echo esc_attr( $content->ID ); ?>" id="tutor-assignmentø-<?php echo esc_attr( $content->ID ); ?>" class="course-content-item tutor-assignment tutor-assignment-<?php echo esc_attr( $content->ID ); ?>"> |
| 137 | <div class="tutor-course-content-top tutor-d-flex tutor-align-center"> |
| 138 | <span class="tutor-icon-hamburger-menu tutor-cursor-move tutor-px-12"></span> |
| 139 | <a href="javascript:;" class="<?php echo $is_topic ? 'open-tutor-assignment-modal' : ''; ?>" data-assignment-id="<?php echo esc_attr( $content->ID ); ?>" data-topic-id="<?php echo esc_attr( $topic->ID ); ?>"> |
| 140 | <?php echo esc_html__( 'Assignment', 'tutor' ) . ' ' . esc_html( $counter['assignment'] ) . ': ' . esc_html( $content->post_title ); ?> |
| 141 | </a> |
| 142 | <div class="tutor-course-content-top-right-action"> |
| 143 | <?php if ( $is_topic ) : ?> |
| 144 | <a href="javascript:;" class="open-tutor-assignment-modal tutor-iconic-btn" data-assignment-id="<?php echo esc_attr( $content->ID ); ?>" data-topic-id="<?php echo esc_attr( $topic->ID ); ?>"> |
| 145 | <span class="tutor-icon-edit" area-hidden="true"></span> |
| 146 | </a> |
| 147 | <?php endif; ?> |
| 148 | <a href="javascript:;" class="tutor-delete-lesson-btn tutor-iconic-btn" data-lesson-id="<?php echo esc_attr( $content->ID ); ?>"> |
| 149 | <span class="tutor-icon-trash-can-line" area-hidden="true"></span> |
| 150 | </a> |
| 151 | </div> |
| 152 | </div> |
| 153 | </div> |
| 154 | <?php |
| 155 | } elseif ( 'lesson' == $content->post_type ) { |
| 156 | $counter['lesson']++; |
| 157 | ?> |
| 158 | <div data-course_content_id="<?php echo esc_attr( $content->ID ); ?>" id="tutor-lesson-<?php echo esc_attr( $content->ID ); ?>" class="course-content-item tutor-lesson tutor-lesson-<?php echo esc_attr( $content->ID ); ?>"> |
| 159 | <div class="tutor-course-content-top tutor-d-flex tutor-align-center"> |
| 160 | <span class="tutor-icon-hamburger-menu tutor-cursor-move tutor-px-12"></span> |
| 161 | <a href="javascript:;" class="<?php echo $is_topic ? 'open-tutor-lesson-modal' : ''; ?>" data-lesson-id="<?php echo esc_attr( $content->ID ); ?>" data-topic-id="<?php echo esc_attr( $topic->ID ); ?>"> |
| 162 | <?php echo esc_html__( 'Lesson', 'tutor' ) . ' ' . esc_html( $counter['lesson'] ) . ': ' . esc_html( stripslashes( $content->post_title ) ); ?> |
| 163 | </a> |
| 164 | <div class="tutor-course-content-top-right-action"> |
| 165 | <?php if ( $is_topic ) : ?> |
| 166 | <a href="javascript:;" class="open-tutor-lesson-modal tutor-iconic-btn" data-lesson-id="<?php echo esc_attr( $content->ID ); ?>" data-topic-id="<?php echo esc_attr( $topic->ID ); ?>"> |
| 167 | <span class="tutor-icon-edit" area-hidden="true"></span> |
| 168 | </a> |
| 169 | <?php endif; ?> |
| 170 | <a href="javascript:;" class="tutor-delete-lesson-btn tutor-iconic-btn" data-lesson-id="<?php echo esc_attr( $content->ID ); ?>"> |
| 171 | <span class="tutor-icon-trash-can-line" area-hidden="true"></span> |
| 172 | </a> |
| 173 | </div> |
| 174 | </div> |
| 175 | </div> |
| 176 | <?php |
| 177 | } else { |
| 178 | ! isset( $counter[ $content->post_type ] ) ? $counter[ $content->post_type ] = 0 : 0; |
| 179 | $counter[ $content->post_type ]++; |
| 180 | do_action( 'tutor/course/builder/content/' . $content->post_type, $content, $topic, $course_id, $counter[ $content->post_type ] ); |
| 181 | } |
| 182 | } |
| 183 | ?> |
| 184 | </div> |
| 185 | |
| 186 | <?php if ( $is_topic ) : ?> |
| 187 | <div class="tutor_add_content_wrap tutor_add_content_wrap_btn_sm" data-topic_id="<?php echo esc_attr( $topic->ID ); ?>"> |
| 188 | <?php do_action( 'tutor_course_builder_before_btn_group', $topic->ID ); ?> |
| 189 | |
| 190 | <button class="tutor-btn tutor-btn-outline-primary tutor-btn-sm open-tutor-lesson-modal create-lesson-in-topic-btn" data-topic-id="<?php echo esc_attr( $topic->ID ); ?>" data-lesson-id="0" > |
| 191 | <i class="tutor-icon-plus-square tutor-mr-8"></i> |
| 192 | <?php esc_html_e( 'Lesson', 'tutor' ); ?> |
| 193 | </button> |
| 194 | |
| 195 | <button class="tutor-btn tutor-btn-outline-primary tutor-btn-sm tutor-add-quiz-btn" data-topic-id="<?php echo esc_attr( $topic->ID ); ?>"> |
| 196 | <i class="tutor-icon-plus-square tutor-mr-8"></i> |
| 197 | <?php esc_html_e( 'Quiz', 'tutor' ); ?> |
| 198 | </button> |
| 199 | |
| 200 | <?php do_action( 'tutor_course_builder_after_btn_group', $topic->ID, $course_id ); ?> |
| 201 | </div> |
| 202 | <?php endif; ?> |
| 203 | </div> |
| 204 | </div> |
| 205 | <?php |
| 206 | } |
| 207 | ?> |
| 208 | <input type="hidden" id="tutor_topics_lessons_sorting" name="tutor_topics_lessons_sorting" value="" /> |
| 209 | </div> |
| 210 |