<?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();

    $sql1="SELECT * FROM self_paced_teacher_assignment WHERE self_paced_teacher_assignment_id='".$_GET["self_paced_teacher_assignment_id"]."' ";
    $result1 = mysqli_query($conn, $sql1); 
    if (mysqli_num_rows($result1) > 0) {
        while($row1 = mysqli_fetch_assoc($result1)) {
            $totalRating ; 
            $totalRatingValue ;
            $relevance ;
            $working_code ;
            $creativity ;
            $timely_completion ;
            $completion ;
            $mentor_comments ;
            $sql10="SELECT * FROM self_paced_teacher_assignment_rating WHERE self_paced_teacher_assignment_id='".$row1["self_paced_teacher_assignment_id"]."' ";
            $result10 = mysqli_query($conn, $sql10); 
            if (mysqli_num_rows($result10) > 0) {
                while($row10 = mysqli_fetch_assoc($result10)) {
                    $totalRating =  $row10["totalRating"];
                    $totalRatingValue =  $row10["totalRatingValue"];
                    $relevance =  $row10["relevance"];
                    $working_code =  $row10["working_code"];
                    $creativity =  $row10["creativity"];
                    $timely_completion =  $row10["timely_completion"];
                    $completion =  $row10["completion"];
                    $mentor_comments =  $row10["mentor_comments"];
                }
            }
            $sqlcpn="SELECT * FROM course_lesson_plan WHERE course_lesson_plan_id='".$row1["course_lesson_plan_id"]."' ";
            $resultcpn = mysqli_query($conn, $sqlcpn); 
            if (mysqli_num_rows($resultcpn) > 0) {
                while($rowcpn = mysqli_fetch_assoc($resultcpn)) {
                    $assignment ;
                    $sql10="SELECT * FROM course_lesson_assignment WHERE course_lesson_plan_id='".$row1["course_lesson_plan_id"]."' ";
                
                    $result10 = mysqli_query($conn, $sql10); 
                    if (mysqli_num_rows($result10) > 0) {
                        while($row10 = mysqli_fetch_assoc($result10)) {
                            $assignment =  $row10["assignment"];
                            
                        }
                    }
                    $curl_post_data = array(
                        'course_lesson_plan_id' => $rowcpn["course_lesson_plan_id"],
                        'course_id' => $rowcpn["course_id"],
                        'lesson_session' => $rowcpn["lesson_session"],
                        'lesson_topic' => $rowcpn["lesson_topic"],
                        'lesson_sub_topic' => $rowcpn["lesson_sub_topic"],
                        'self_paced_teacher_assignment_id' => $row1["self_paced_teacher_assignment_id"],
                        'self_paced_teachers_id' => $row1["self_paced_teachers_id"],
                        'teacher_id' => $row1["teacher_id"],
                        'course_id' => $row1["course_id"],
                        'course_lesson_plan_id' => $row1["course_lesson_plan_id"],
                        'status' => $row1["status"],
                        'assignment' => $assignment,
                        'uploadedassignment' => $row1["assignment"],
                        'reason' => $row1["reason"],
                        'updated' => $row1["updated"],
                        'totalRating'  => $totalRating,
                        'totalRatingValue'  => $totalRatingValue,
                        'relevance'  => $relevance,
                        'working_code'  => $working_code,
                        'creativity'  => $creativity,
                        'timely_completion'  => $timely_completion,
                        'completion'  => $completion,
                        'mentor_comments'  => $mentor_comments,
                    );
                    
                    array_push($data, $curl_post_data);
                }
            }
        }
    }
     

    echo json_encode($data);
 


?>