<?php
 error_reporting(E_ALL);
 ini_set('display_errors', 1);

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

 
 $campusid = $_POST["campusid"];

 $studentid = $_POST["studentid"];
 $assignmentid = $_POST["assignmentid"];




       $select_fromanswertable = "SELECT * FROM `assignmentanswer` WHERE `AssignmentSettingsID` = '$assignmentid' AND `StudentID`= '$studentid' AND `CampusID` = '$campusid'";
       
        $ekene_mysqli_query = mysqli_query($link, $select_fromanswertable);
        $ekene_get_details = mysqli_fetch_assoc($ekene_mysqli_query);
        $ekene_row_cnt_ekene = mysqli_num_rows($ekene_mysqli_query);
        
        if($ekene_row_cnt_ekene > 0)
        {
         
            do{
                $ObjectiveQuestion = $ekene_get_details['ObjectiveQuestion'];
             $ObjectAnswer = $ekene_get_details['ObjectAnswer'];

                $ObjectiveQuestion = explode(',', $ObjectiveQuestion);
                $ObjectAnswer = explode(',', $ObjectAnswer);


                foreach ($ObjectiveQuestion as $key =>  $question) {
                    $curretnobjective = $ObjectAnswer[$key];

                    
                    $select_fromquestiontable = mysqli_query($link,"SELECT * FROM `assignmentquestion` WHERE `AssignmentQuestionID` = '$question'");
                    $ekene_get_detailsquestiontable = mysqli_fetch_assoc($select_fromquestiontable);
                    $ekene_row_cnt_ekenequestion = mysqli_num_rows($select_fromquestiontable);
                    $cnt= 0;
                    if( $ekene_row_cnt_ekenequestion > 0)
                    {
                        
                          do{
                            $cnt++;
                            $question = $ekene_get_detailsquestiontable['question'];
                            $optionA = $ekene_get_detailsquestiontable['optionA'];
                            $optionB = $ekene_get_detailsquestiontable['optionB'];
                            $optionC = $ekene_get_detailsquestiontable['optionC'];
                            $optionD = $ekene_get_detailsquestiontable['optionD'];
                            $answer = $ekene_get_detailsquestiontable['answer'];

                            echo '
                            <strong style="font-weight: bold;">Q'.$cnt.': '.$question.'</strong>
                              a) '.$optionA.'
                              b) '.$optionB.'
                              c) '.$optionC.'
                              d) '.$optionD.'
               
                             <p class="answer">Student Answer: '.$curretnobjective.'</p>
                             <p class="answer">Correct Answer: '.$answer.'</p>

                       ';
               


                          }while($ekene_get_detailsquestiontable = mysqli_fetch_assoc($select_fromquestiontable));
                                    
                  
                             

                             

                        // if ($curretnobjective == $answer)
                        // {
                        //     $totalstudentscore_obj+=+1;
                        // }

                    }

                }
                



            } while($ekene_get_details = mysqli_fetch_assoc($ekene_mysqli_query));

        
        }

?>