ActionBoxGenerator.php
1 year ago
AnnouncementsGenerator.php
1 year ago
CourseMetaGenerator.php
1 year ago
CourseThumbnailGenerator.php
1 year ago
ElementGenerator.php
1 year ago
GradebookGenerator.php
1 year ago
InstructorGenerator.php
1 year ago
LessonGenerator.php
1 year ago
Preview.php
1 year ago
QnAGenerator.php
1 year ago
RatingGenerator.php
1 year ago
ResourcesGenerator.php
1 year ago
ShareGenerator.php
1 year ago
TopicsGenerator.php
1 year ago
WishListGenerator.php
1 year ago
GradebookGenerator.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Preview script for html markup generator |
| 4 | * |
| 5 | * @package tutor-droip-elements |
| 6 | */ |
| 7 | |
| 8 | namespace TutorLMSDroip\ElementGenerator; |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; // Exit if accessed directly. |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Class GradebookGenerator |
| 16 | * This class is used to define all helper functions. |
| 17 | */ |
| 18 | trait GradebookGenerator { |
| 19 | |
| 20 | /** |
| 21 | * Generate course gradebook markup |
| 22 | * |
| 23 | * @return string |
| 24 | */ |
| 25 | private function generate_course_gradebook_markup() { |
| 26 | switch ( $this->element['name'] ) { |
| 27 | case TDE_APP_PREFIX . '-gradebook': |
| 28 | $course_id = isset( $this->options['post'] ) ? $this->options['post']->ID : get_the_ID(); |
| 29 | $grades = get_generated_gradebook( 'all', $course_id ); |
| 30 | |
| 31 | $child = is_array( $grades ) && count( $grades ) ? |
| 32 | call_user_func( $this->generate_child_element, $this->element['children'][1], $this->options ) : |
| 33 | call_user_func( $this->generate_child_element, $this->element['children'][0], $this->options ); |
| 34 | |
| 35 | return "<div $this->attributes>$child</div>"; |
| 36 | |
| 37 | case TDE_APP_PREFIX . '-has-gradebook': |
| 38 | if ( function_exists( 'TUTOR_GB' ) ) { |
| 39 | $grade_book_template = trailingslashit( TUTOR_GB()->path ) . 'views/gradebook.php'; |
| 40 | if ( file_exists( $grade_book_template ) ) { |
| 41 | $course_id = isset( $this->options['post'] ) ? $this->options['post']->ID : get_the_ID(); |
| 42 | |
| 43 | ob_start(); |
| 44 | require_once $grade_book_template; |
| 45 | |
| 46 | return ob_get_clean(); |
| 47 | } |
| 48 | } |
| 49 | return ''; |
| 50 | case TDE_APP_PREFIX . '-no-gradebook': |
| 51 | return $this->generate_common_element(); |
| 52 | |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 |