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 '
'; if(isset($_POST['Valider'])) { $chack_libelle=getExamenInformations($_POST['libelle']); if( $chack_libelle[0]['forme'] == 'ENONCE') { echo'
'; } echo'
'; //vérifier si déjà passé cet examen $comm=getPassageInformations($_POST['libelle'],$userId); // Si un passage n'existe pas, créez-le if(sizeof($comm) == 0){ $query = "INSERT INTO `passage_qcm_ent`(`code_ent_qcm` , `libelle_passage_qcm`, `date_passage`, `heure_passage_debut`, `heure_passage_fin`,`candidat` ,`total`,`total_examen`,`termine`) VALUES ('".$_POST['libelle']."',(SELECT libelle_qcm FROM ent_qcm where code_qcm='".$_POST['libelle']."' ),'".$_POST['date']."','".$heure."','".$_POST['heure_passage_fin']."','".$userId."',0,(SELECT sum(note) as note FROM `lignes_qcm` where code_ent_qcm='".$_POST['libelle']."'),0);"; $adb->query($query); $chack_libelle=getExamenInformations($_POST['libelle']); /////////////timer() $start = strtotime($heure); $end = strtotime($chack_libelle[0]['heure_fin']); $mins = ($end - $start); $mins2 = ($end - $start) * 1000; echo''; ///////////////timer() getIdPassage($_POST['libelle'],$userId); $questions =getAllLignesEaxmen($_POST['libelle']); foreach ($questions as $question) { result($question); } } // Si un passage déja existe if(sizeof($comm) > 0 && $comm[0]['termine'] == 0){ $chack_libelle=getExamenInformations($_POST['libelle']); /////////////timer() $start = strtotime($heure); $end = strtotime($chack_libelle[0]['heure_fin']); $mins = ($end - $start); $mins2 = ($end - $start) * 1000; echo''; ///////////////timer() if($chack_libelle[0]['date_debut'] <= $tomorrow && $chack_libelle[0]['date_fin'] >= $tomorrow && $chack_libelle[0]['heure_debut'] <= $heure && $chack_libelle[0]['heure_fin'] > $heure ){ getIdPassage($_POST['libelle'],$userId); $questions =getAllLignesEaxmen($_POST['libelle']); foreach ($questions as $question) { result($question); } } } } echo '
Ordre Question Choix
'; echo''; $viewer->view('CustomDashboardFooter.tpl'); ?>