<?php
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET, POST');
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
    include '../../../config/index.php';
    $data = array();
    $course_lesson_plan_ids=array();
    $GradedAssignments=array();
    $IssuedAssignments=array();
    $sql_clp="SELECT * FROM centerCourse WHERE  centerCourse_id='".$_GET['centerCourse_id']."'";
 
    $result_clp = mysqli_query($conn, $sql_clp);  
    if (mysqli_num_rows($result_clp) > 0) {
        while($row_clp = mysqli_fetch_assoc($result_clp)) {
        
            $sql_10="SELECT * FROM course_lesson_plan WHERE  course_id='".$row_clp['course_id']."'";
            $result_10 = mysqli_query($conn, $sql_10);  
            if (mysqli_num_rows($result_10) > 0) {
                while($row_10 = mysqli_fetch_assoc($result_10)) {
                    array_push($course_lesson_plan_ids, $row_10 );
                }
            }
            $sql_10="SELECT * FROM StudentAssignment WHERE student_id='".$_GET['student_id']."' AND centerCourse_id='".$row_clp['centerCourse_id']."' AND Status='Graded'";
            $result_10 = mysqli_query($conn, $sql_10);  
            if (mysqli_num_rows($result_10) > 0) {
                while($row_10 = mysqli_fetch_assoc($result_10)) {
                    array_push($GradedAssignments, $row_10 );
                }
            }
            $sql_10="SELECT * FROM StudentAssignment WHERE student_id='".$_GET['student_id']."' AND centerCourse_id='".$row_clp['centerCourse_id']."'  AND Status!='Not Issued'";
            $result_10 = mysqli_query($conn, $sql_10);  
            if (mysqli_num_rows($result_10) > 0) {
                while($row_10 = mysqli_fetch_assoc($result_10)) {
                    array_push($IssuedAssignments, $row_10 );
                }
            }
            $mentor_image;  $mentor_name;  $mentor_email;
            // $sql_10="SELECT * FROM mentorLesson WHERE mentorLesson_id='".$_GET['mentorLesson_id']."'  ";
            // $result_10 = mysqli_query($conn, $sql_10);  
            // if (mysqli_num_rows($result_10) > 0) {
            //     while($row_10 = mysqli_fetch_assoc($result_10)) {
            //         $sql_20="SELECT * FROM mentors WHERE mentor_id='".$row_10['mentor_id']."'  ";
            //         $result_20 = mysqli_query($conn, $sql_20);  
            //         if (mysqli_num_rows($result_20) > 0) {
            //             while($row_20 = mysqli_fetch_assoc($result_20)) {
            //                 $mentor_image=$row_20["mentor_image"];
            //                 $mentor_name=$row_20["mentor_name"];
            //                 $mentor_email=$row_20["mentor_email"];
            //             }
            //         }
            //     }
            // }
            $curl_post_data = array(
                'student_id' => $_GET["student_id"],
                'centerCourse_id' => $row_clp["centerCourse_id"],
                'center_id' => $row_clp["center_id"],
                'centerClasses_id' => $row_clp["centerClasses_id"],
                'curriculumSession_id' => $row_clp["curriculumSession_id"],
                'course_lesson_plan_ids' => $course_lesson_plan_ids,
                'GradedAssignments' => $GradedAssignments,
                'IssuedAssignments' => $IssuedAssignments,
                'mentor_image' => $mentor_image,
                'mentor_name' => $mentor_name,
                'mentor_email' => $mentor_email,
            );
            // array_push($data, $curl_post_data );
            echo json_encode($curl_post_data);
        }
    }
    // echo json_encode($data); $TeacherFirstName;  $TeacherLastName;
?>