<?php
// exit(urldecode($_POST['SubDir']));
require_once("../../../../general/TaquaLB/Elements/Elements.php");
$configdir = "../../../../../../".urldecode($_POST['SubDir']);
require_once("../../../../general/config.php");
//require("../../../../general/getinfo.php");

/* if(isset($_POST['exid']) && (int)$_POST['exid'] > 0 && isset($_POST['bases'])){

} */

    //get all the student that write exam for this shedule
    $studs = $dbo->SelectFirstRow("cbt_studentquestions_tb","","ID={$_POST['RSTID']}");
    if(is_array($studs)){
        Table("style=width:100%;font-size:0.8em;margin:auto;margin-top:10px;text-align:left,id=coursedet,multiselect=false,data-type=table");
          $arrhed = array("CANDIDATE","CORRECT","TOTAL","PERCENTAGE","STATUS");
          $pec = (int)$studs['TotalQuestion'] > 0?((int)$studs['TotalCorrect'] / (int)$studs['TotalQuestion'])* 100 : 0.0;
          $status = (int)$studs['Finish'] > 0?'Finish' : 'In Progress';
             THeader($arrhed,"style=text-align:left");
             $arrRec = array("<strong>{$studs['Candidate']}</strong>","<strong>{$studs['TotalCorrect']}</strong>","<strong>{$studs['TotalQuestion']}</strong>","<strong>{$pec}%</strong>","<strong>{$status}</strong>");
             TRecord($arrRec,"data-id=paytypesum,style=font-weight:bolder;text-transform:uppercase");
            _Table();
      //get the questions
      $qs = json_decode($studs['Question'],true);
      if(count($qs) > 0){
        $data = [];
        foreach($qs as $qkey => $qdet){
            $ans = isset($qdet['Options']) && isset($qdet['Options'][$qdet['Answer']])?strip_tags($qdet['Options'][$qdet['Answer']]):'--';
            $data[] = [trim($qdet['Question']) == ''?$qdet['Title'].' '.$qkey:strip_tags($qdet['Question']),$ans,$qdet['IsCorrect']?'Correct':'Wrong',1];
        }
        $headers=array("*CBTMQT"=>"QUESTION","*CBTMAns"=>"ANSWER","*CBTMCorrect"=>"CORRECT","*CBTMMrk"=>"MARK");
   SpreadSheet("rowselect=false,style=width:calc(100% - 12px);margin:auto;margin-top:6px;margin-bottom:6px,id=spexamstst,multiselect=false,cellfocus=,cellblur=,cellkeypress=,dynamiccolumn=false,dynamicrow=false,minrow=-1,rowdelete=true,case=none,readonly=CBTMQT;CBTMAns;CBTMCorrect",$headers,$data);
      }else{
        Box("class=defaultTabText");
        Box();Icon("info-circle fa-3x");_Box();
         Box();echo"NO QUESTION";_Box();  
        Box();echo"No question loaded for the selected Candidate";_Box();  
       _Box();
      }
   
    _Table(); 
    } else{
        Box("class=defaultTabText");
        Box();Icon("info-circle fa-3x");_Box();
         Box();echo"INVALID EXAM/TEST";_Box();  
        Box();echo"Invalid Exam/Test Selected";_Box();  
       _Box();
    } 
 /*  
}*/



?>