get('roleid'); $userId = $current_user->get('id'); $viewer = new Vtiger_Viewer(); $viewer->assign('MODULE', 'Home'); $viewer->assign('SELECTED_MENU_CATEGORY', 'MARKETING'); $viewer->assign('COMPANY_LOGO', Vtiger_CompanyDetails_Model::getInstanceById()->getLogo()); $viewer->assign('COMPANY_DETAILS_SETTINGS',new Settings_Vtiger_CompanyDetails_Model()); $viewer->assign('USER_MODEL', $current_user); $viewer->assign('CURRENT_USER_MODEL', $current_user); $viewer->assign('PAGETITLE','QCM'); $viewer->view('CustomDashboard.tpl'); //Prevent Multiple Form Submission function isFinished($passage_qcm_ent){ global $adb; $query6= "SELECT termine FROM `passage_qcm_ent` where code_passage_qcm = '".$passage_qcm_ent."' "; $sql_get_result6 = $adb->query($query6); $termine = array(); while ($recordinfo = $adb->fetch_array($sql_get_result6)) { $termine[] = $recordinfo; } return $termine[0]['termine']; } if(isset($_POST['enregistrer'])) { if(isFinished($_SESSION["id_passage_qcm"]) == 0){ for ($x = 0; $x < sizeof($_POST['code_lignes']); $x++) { $tableCorrection=array(); $tableReponse=array(); $NomTableauReponse="Choix".$_POST['code_lignes'][$x]; $query6="SELECT correction FROM lignes_qcm where code_ligne='".$_POST['code_lignes'][$x]."' "; $sql_get_result6 = $adb->query($query6); $resCorrection = array(); while ($recordinfo = $adb->fetch_array($sql_get_result6)) { $resCorrection[] = $recordinfo; } if(strlen($resCorrection[0]['correction']) == 6){ if( sizeof($_POST[$NomTableauReponse]) != 0){ $tableCorrection=$resCorrection[0]['correction']; $tableReponse=implode("", $_POST[$NomTableauReponse]); if($tableCorrection == $tableReponse){ $result=0; }else{$result=1;} }else{$result=1;} }else{ if(sizeof($_POST[$NomTableauReponse]) != 0){ $tableCorrection=explode("::",$resCorrection[0]['correction']); $tableReponse=$_POST[$NomTableauReponse]; $overlap = array_intersect($tableCorrection, $tableReponse); $counts = array_count_values($overlap); if( sizeof($tableCorrection) == sizeof($counts) && sizeof($tableReponse) == sizeof($counts) && sizeof($counts) != 0){ $result=0; }else{$result=1;} }else{$result=1;} } $tableCorrection=explode("::",$resCorrection[0]['correction']); $reponse=TranslateChoixToName($_POST[$NomTableauReponse],$_POST['code_lignes'][$x]); $correction=TranslateChoixToName($tableCorrection,$_POST['code_lignes'][$x]); $query = "INSERT INTO `lignes_passage_qcm` (`code_ent_passage` , `question`, `reponse`, `correction`, `note_candidat`,`note_question`) VALUES ('".$_SESSION["id_passage_qcm"]."','".$_POST['questions'][$x]."' ,'".$reponse."','".$correction."',IF( '".$result."' = 0, (SELECT note FROM lignes_qcm where code_ligne='".$_POST['code_lignes'][$x]."' ),0),(SELECT note FROM lignes_qcm where code_ligne='".$_POST['code_lignes'][$x]."' ));"; $adb->query($query); } $heure_fin=date('H:i:s', strtotime('1 hour')); $query2 = "UPDATE passage_qcm_ent SET termine = 1 ,heure_passage_fin ='".$heure_fin."' ,total=(SELECT SUM(note_candidat) FROM lignes_passage_qcm where code_ent_passage='".$_SESSION["id_passage_qcm"]."' ) where code_passage_qcm='".$_SESSION["id_passage_qcm"]."' ;"; $adb->query($query2); header("Location: index.php?module=QCMGenerationCorrection&view=QCMGenerationCorrection"); }else{ header("Location: index.php?module=QCMGenerationCorrection&view=QCMGenerationCorrection"); } } $tomorrow = date("Y-m-d", strtotime('today')); $heure_debut=date('H:i:s', strtotime('1 hour')); $heure=date('H:i:s', strtotime('1 hour')); $libelles=getContenuLibelleQCM($userId,$heure); echo '