<?php
/**
 * Class CourseCountQuizDynamicElementor
 *
 * Dynamic course count quiz elementor.
 *
 * @since 4.2.3.5
 * @version 1.0.0
 */
namespace LearnPress\ExternalPlugin\Elementor\Widgets\Course\Dynamic;
use Elementor\Core\DynamicTags\Tag;
use LearnPress\ExternalPlugin\Elementor\LPDynamicElementor;
use LearnPress\TemplateHooks\Course\SingleCourseTemplate;

defined( 'ABSPATH' ) || exit;

class CourseCountQuizDynamicElementor extends Tag {
	use LPDynamicElementor;

	public function __construct( array $data = [] ) {
		$this->lp_dynamic_title = 'Course Count Quiz';
		$this->lp_dynamic_name  = 'course-count-quiz';
		parent::__construct( $data );
	}

	public function render() {
		$singleCourseTemplate = SingleCourseTemplate::instance();

		try {
			$course = $this->get_course_model();
			if ( ! $course ) {
				return;
			}

			echo $singleCourseTemplate->html_count_item( $course, LP_QUIZ_CPT );
		} catch ( \Throwable $e ) {
			error_log( $e->getMessage() );
		}
	}
}
