<?php
include('../../../config/config.php');

        $tari_get_stored_instituion_id = $_POST['tari_get_stored_instituion_id'];
        $campus_id = $_POST['campus_id'];
         $sectionID = $_POST['sectionID'];

         $UserType = $_POST['UserType'];
         $UserID = $_POST['UserID'];


          if($UserType == 'teacher')
          {


            
                    $check_subject = ("SELECT DISTINCT `classtemplate`.`ClassTemplateID`, `classtemplate`.`ClassTemplateName` FROM `courseorsubjectallocation` INNER JOIN `classordepartment` ON `courseorsubjectallocation`.`ClassOrDepartmentID` = `classordepartment`.`ClassOrDepartmentID` INNER JOIN `classtemplate` ON `classordepartment`.`ClassTemplateID` =  `classtemplate`.`ClassTemplateID` WHERE `courseorsubjectallocation`.`CourseOrSubjectTeacherUserID`='$UserID' AND `classordepartment`.`CampusID`='$campus_id' AND `classordepartment`.`SectionID`='$sectionID'");

          }else
          {


                    $check_subject = (" SELECT * FROM `section` INNER JOIN `classtemplate` ON 
                    `section`.`SectionListID` = `classtemplate`.`SectionListID` 
                    WHERE `section`.`CampusID`='$campus_id' AND `section`.`SectionID`='$sectionID'");

          }
      
     


        $query_subject = mysqli_query($link,$check_subject);
        $fetch_subject = mysqli_fetch_assoc($query_subject);
         $row_subject = mysqli_num_rows($query_subject);

        if($row_subject > 0)
        {
            echo '<h5 class="p-4">Select Class</h5>
                 <form class="selectSubject">';
                
            do{
                $ClassTemplateName = $fetch_subject['ClassTemplateName'];
                $ClassTemplateID = $fetch_subject['ClassTemplateID'];

                echo '<label class="ps-1 py-1 subjectDirect" data-id="'. $ClassTemplateID.'">
                        <input type="radio" class="prosloadclassforcreatequestion" name="radio3" value="'.$ClassTemplateID.'"/>
                        <span>'.$ClassTemplateName.'</span>
                    </label>';   
            }while( $fetch_subject = mysqli_fetch_assoc($query_subject));

            echo '</form>';

        }else{
            echo '<img src="err.png" width="70" class="img-fluid mx-auto d-block" alt="...">
                    <figure class="text-center">
                        <blockquote class="blockquote">
                        <p style="font-size:18px;">Opps, No Class Found.</p>
                        </blockquote>
                    </figure>';
        }
?>
