<?php


     error_reporting(E_ALL);
     ini_set('display_errors', 1);
    
     include('../../../config/config.php');
    
    
    $campus = $_POST['campus'];
    $userID = $_POST['userID'];
    
    $session = "SELECT * FROM `session` WHERE `sessionStatus` = 1";
    
    $ekeneselect = mysqli_query($link, $session);
    $ekene_get_select_details = mysqli_fetch_assoc($ekeneselect);
    $ekene_row_select = mysqli_num_rows($ekeneselect);
    
    $ekene_session_name = $ekene_get_select_details['sessionName'];
    
    
    $term = "SELECT * FROM `termorsemester` WHERE `status` = 1";
    $ekeneterm = mysqli_query($link, $term);
    $ekene_get_term_details = mysqli_fetch_assoc($ekeneterm);
    $ekene_row_term = mysqli_num_rows($ekeneterm);
         
    $ekene_term = $ekene_get_term_details['TermOrSemesterID'];
    
    $ekene_select_fromassignmentsetting = "SELECT * FROM `assignmentsettings` 
    WHERE `CampusID` = '$campus' AND `sessionID` = '$ekene_session_name' AND `TermOrSemesterID`= '$ekene_term' AND deletestatus = '0' ORDER BY AssignmentSettingsID DESC LIMIT 5";
    
    $ekene_setassign = mysqli_query($link, $ekene_select_fromassignmentsetting);
    $ekene_get_import_details = mysqli_fetch_assoc($ekene_setassign);
    $ekene_row_setassignmentt = mysqli_num_rows($ekene_setassign);
    
if ($ekene_row_setassignmentt > 0)
{
    do{

      $SubjectOrCourseID = $ekene_get_import_details['SubjectOrCourseID'];
      $AssignmentTitle = $ekene_get_import_details['AssignmentTitle'];
      $AssignmentSettingsID = $ekene_get_import_details['AssignmentSettingsID'];
      $ClassOrDepartmentID = $ekene_get_import_details['ClassOrDepartmentID'];

        $select_subjectnameii = "SELECT * FROM `subjectorcourse` WHERE `SubjectOrCourseID` = '$SubjectOrCourseID'";
        $ekene_subjectname = mysqli_query($link, $select_subjectnameii);
        $ekene_get_subject_details = mysqli_fetch_assoc($ekene_subjectname);
        $ekene_row_subjectnamementt = mysqli_num_rows($ekene_subjectname);
        
        if ($ekene_row_subjectnamementt > 0)
        {
            $SubjectOrCourseTitle = $ekene_get_subject_details['SubjectOrCourseTitle'];
            
            $select_submitted_value = " SELECT * FROM `assignmentanswer` WHERE AssignmentSettingsID = '$AssignmentSettingsID' AND `StudentID` = '$userID' AND `CampusID` = '$campus' AND `SubjectOrCourseID` = '$SubjectOrCourseID' AND `sessionID` = '$ekene_session_name' AND `TermOrSemesterID` = '$ekene_term' AND submitstatus = 1 ";
            $ekene_answer = mysqli_query($link, $select_submitted_value);
            $ekene_get_answer_details = mysqli_fetch_assoc($ekene_answer);
          $ekene_row_answermentt = mysqli_num_rows($ekene_answer);
            
            if ($ekene_row_answermentt > 0)
            {
                $submitstatus = $ekene_get_answer_details['submitstatus'];

                echo '<div class="card chiPerCardLeft">
                       <div class="card-body">
                           <div class="row g-2">

                               <div class="col-12" style="display: flex;">
                                 
                                   <div style="margin-left: 10px;">
                                       <a href="" style="color: #666666; text-decoration: none;">
                                           <strong style="font-size: 13px;color: #d8d8d8;">'.$SubjectOrCourseTitle.'</strong>
                                           <br>
                                           <small>Assignment title: '.$AssignmentTitle.'</small>
                                           <br>
                                           <small style="color: #d8d8d8; font-weight: 600;"><i class="bx bx-time-five"></i>Submitted</small>
                                       </a>
                                   </div>
                               </div>
                           </div>

                    
                        </div>
                   </div>';
            }
            else{
                
                echo '<div class="card chiPerCardLeft">
                       <div class="card-body">
                           <div class="row g-2">

                               <div class="col-12" style="display: flex;">
                               
                                   <div style="margin-left: 10px;">
                                       <a href="" style="color: #666666; text-decoration: none;">
                                           <strong style="font-size: 13px;">'.$SubjectOrCourseTitle.'</strong>
                                           <br>
                                           <small>Assignment title: '.$AssignmentTitle.'</small>
                                       </a>
                                   </div>
                               </div>
                           </div>

                    
                        </div>
                   </div>';
            }

        }

    }while($ekene_get_import_details = mysqli_fetch_assoc($ekene_setassign));
    
    
    echo '<a href="../my-class/" style="text-decoration: none; float: right; margin-top: 10px; margin-right: 20px; font-size: 15px; font-weight: 600;">View all</a>';
}

?>