<?php


            include("../../../config/config.php");
            
            
        $campus = $_POST["campus"];
        $institution = $_POST["institution"];
        $userID = $_POST["userID"];
        $usertype = $_POST["usertype"];
        $classID = $_POST["classID"];
        $subject = $_POST["subject"];
            
          $sqlsecsession_startcount = mysqli_query($link, "SELECT * FROM `session` WHERE `sessionStatus`='1'");
          $querysecsession_startcount = mysqli_fetch_assoc($sqlsecsession_startcount);
          $cntsecsession_startcount = mysqli_num_rows($sqlsecsession_startcount);
        
         $session_startcount = $querysecsession_startcount['sessionName'];
         $sessionID_startcount = $querysecsession_startcount['sessionID'];
         
        $sqlsectermorsemesterdebt = mysqli_query($link, "SELECT * FROM `termorsemester` WHERE `status`='1'");
        $querysectermorsemesterdebt = mysqli_fetch_assoc($sqlsectermorsemesterdebt);
        $cntsectermorsemesterdebt = mysqli_num_rows($sqlsectermorsemesterdebt);
        
        $termorsemesterdebt = $querysectermorsemesterdebt['TermOrSemesterName'];
        $TermOrSemesterID = $querysectermorsemesterdebt['TermOrSemesterID'];
        
        
          // total submitted for assignment 
            $prosselectsubmitedusers = mysqli_query($link, "SELECT * FROM `assignmentanswer` INNER JOIN `assignmentsettings` ON
            `assignmentanswer`.`AssignmentSettingsID` = `assignmentsettings`.`AssignmentSettingsID`
            WHERE `assignmentanswer`.`CampusID`='$campus' AND `assignmentanswer`.`ClassOrDepartmentID`='$classID' 
            AND `assignmentanswer`.`TermOrSemesterID`='$TermOrSemesterID' AND `assignmentanswer`.`SubjectOrCourseID`='$subject' 
            AND `assignmentanswer`.`sessionID`='$session_startcount' AND `assignmentsettings`.deletestatus='0'");
            $prosselectsubmiteduserscnt = mysqli_num_rows($sqlsectermorsemesterdebt);
          // total submitted for assignment 
          
         
          
          
          
            // total not submitted for assignment 
                                    $prosselectsubmitedusersnotsubmited = mysqli_query($link, " SELECT *   
                FROM `classordepartmentstudentallocation` 
                INNER JOIN `student` ON `classordepartmentstudentallocation`.`StudentID` = `student`.`StudentID` 
                INNER JOIN `assignmentsettings` ON `assignmentsettings`.`ClassOrDepartmentID` = `classordepartmentstudentallocation`.`ClassOrDepartmentID`
                WHERE NOT EXISTS (
                    SELECT 1 
                    FROM `assignmentanswer` 
                    WHERE `classordepartmentstudentallocation`.`StudentID` = `assignmentanswer`.`StudentID`
                )
                AND `classordepartmentstudentallocation`.`CampusID` = '$campus' 
                AND `assignmentsettings`.`ClassOrDepartmentID`='$classID' 
                AND `assignmentsettings`.`TermOrSemesterID`='$TermOrSemesterID' 
                AND `assignmentsettings`.`SubjectOrCourseID`='$subject' 
                AND `assignmentsettings`.`sessionID`='$session_startcount'  AND `assignmentsettings`.`deletestatus`='0'
                ");
                
                
                                  $prosselectsubmiteduserscntnotsubmittd = mysqli_num_rows($prosselectsubmitedusersnotsubmited);
           // total  not submitted for assignment 
           
         
           
           
          
            //total assignment here
            
            $prosselectsubmiteduserstotalassignment = mysqli_query($link, "SELECT * FROM `assignmentsettings` WHERE `CampusID`='$campus' AND `sessionID`='$session_startcount' 
            AND `TermOrSemesterID`='$TermOrSemesterID' AND `SubjectOrCourseID`='$subject' AND `ClassOrDepartmentID`='$classID' AND `assignmentsettings`.`deletestatus`='0'");
             $prosselectsubmiteduserscnttotalassignment = mysqli_num_rows($prosselectsubmiteduserstotalassignment);
            
            
            //total assignment here
            
            
             $assignmentcontennt = array(
                    'submitted_assign' => $prosselectsubmiteduserscnt,
                    'notsubmitted_assign' => $prosselectsubmiteduserscntnotsubmittd,
                    'total_assign' => $prosselectsubmiteduserscnttotalassignment
                    
                );
                
                
                $json_data = json_encode($assignmentcontennt, JSON_PRETTY_PRINT);

                // Output the JSON data
                echo $json_data;
              
          
          
          
       
            
            
        
        
        
        
       
        
?>