<?php 
/**
 * template: Home
 */
$proqyz_tutorials   = [];
$grow_tutorials     = [];

$tutorials          =  (object) ST_ProQyz_Admin_Page_Home::fetch_tutorials();
$is_error           = isset($tutorials->error)? $tutorials->error : false;
$proqyz_tutorials   = isset($tutorials->proqyz_tutorials)? (array) $tutorials->proqyz_tutorials : [];
$grow_tutorials     = isset($tutorials->grow_tutorials)? (array) $tutorials->grow_tutorials : [];



?>

<style>
.notice.e-notice {display: none !important;}
.mb-3{margin-bottom: 3rem; }
.ml-3{ margin-left: 3rem; }
</style>


<div class="wrap proqyz_home proqyz__root" style="padding: 10px 20px 0 20px;">
    <div class="text-center">
        <h2 style="font-size: 3rem;font-weight;600;">Welcome to ProQyz</h2>
        <h3 style="font-size: 2.25rem;"><b>The Perfect Tool for Teachers & Trainers.</b> </h3>
        <p style="font-size: 1.5rem;" >
            With ProQyz, you can teach virtually anything. Use a variety of question types like multiple choice, checkboxes, labeling diagrams, and more. <br /> Create engaging lessons and tests with text, video, images, and audio. Plus, our feedback features will keep your students motivated and on track.  
        </p>
        <?php if(count($proqyz_tutorials) == 0 && count($grow_tutorials) == 0) { ?>
            <p>
            <div class="notice inline notice-info notice-alt">
                <p>No Tutorials found </p>                   
            </div> 
            </p>
        <?php } ?>
    </div>

    <br /><br />


    <?php if(!$is_error){ ?>
    
    <!--begin::proqyz tutorials-->
    <?php if(count($proqyz_tutorials) > 0){ ?>
    <div class="container-fluid">
            
        <div class="row">
            <div class="col-12 mb-3" style="padding-left:15px;">
                <h3>ProQyz Tutorials</h3>
            </div>
            <?php 
                foreach( $proqyz_tutorials as $pkey => $tutorial ) { 
                    $tutorial   = (object) $tutorial;
                    $is_media   = isset($tutorial->is_media)? true : false;
                    $cover      = isset($tutorial->cover)? $tutorial->cover : ST_PROQYZ_PUBLIC_URL. '/dist/svg/placeholder.svg' ;
                    $media_url  = isset($tutorial->media_url)? $tutorial->media_url : null;
                    $details    = isset($tutorial->details)? $tutorial->details : null;
                    $media_type = isset($tutorial->type)? $tutorial->type : 'mp4';
                    ?>
                    <?php if($media_url !== null){ ?>
                    <div class="col-sm-6 col-md-6 col-lg-3 col-xs-12 mb-3">
                        <?php if($is_media){
                            if($media_type == "mp4"){ ?>
                                <div class="card card-plyr" style="width: 100%;">
                                    <div class="card-body">
                                        <video class="plyr__video" src="<?php echo $media_url; ?>" controls data-poster="<?php echo $cover; ?>"> </video>
                                        <?php if($details !== null){ ?>
                                            <p class="card-text" style="padding: 0 10px;"><?php echo $details; ?></p>
                                        <?php } ?>
                                    </div>
                                </div>
                            <?php } else if($media_type == "youtube"){ ?>
                            <iframe 
                                style="border-radius:10px;"
                                src="<?php echo $media_url; ?>" 
                                title="YouTube video player"
                                width="350"
                                height="200"
                                frameborder="0" 
                                allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" 
                                referrerpolicy="strict-origin-when-cross-origin" 
                                allowfullscreen
                                x-frame-origin=""
                            ></iframe>
                            <?php } ?>
                            
                        <?php } ?>
                    </div>
                <?php } ?>
                    <?php 
               
                } 
            ?>
            
        </div><!--/row -->
        
    </div>
    <?php } ?>
            
    <?php } # no error ?>
    
    <!--end::proqyz tutorials-->

    <br /><br />
    
    <?php if($is_error) { ?>
        <div class="notice inline notice-error notice-alt">
            <p><?php echo $is_error; ?> </p>                   
        </div>
    <?php } ?>




</div>