Files
CRM/QCMGenerationFunction.php
BACHIR SOULDI 2794e62571 first commit
2025-09-28 08:49:37 +01:00

197 lines
6.8 KiB
PHP

<?php
function TranslateChoixToName($tableau,$idQuestion){
global $adb;
$stack = array();
if(sizeof($tableau) != 0 && $tableau[0] != ""){
$query6="SELECT * FROM lignes_qcm where code_ligne='".$idQuestion."' ";
$sql_get_result6 = $adb->query($query6);
$Correction = array();
while ($recordinfo = $adb->fetch_array($sql_get_result6)) {
$Correction[] = $recordinfo;
}
$nbr=1;
for ($xa = 0; $xa < sizeof($tableau); $xa++) {
$index=$tableau[$xa];
$final=$nbr."- ".html_entity_decode($Correction[0][strtolower($index)]);
array_push($stack,$final);
$nbr=$nbr+1;
}
$result=implode("<br>",$stack);
}else{$result="";}
return $result;
}
function getContenuLibelleQCM($userId,$heure){
global $adb;
//pour affichier la contenu de liste deroulante selon le reseau de candidat et la date debut/fin + heure debut/fin Examen
$query3 ="SELECT res_id FROM `vtiger_users` WHERE id=".$userId." ";
$result3 = $adb->query($query3);
$reseau[] =$adb->fetch_array($result3);
$reseau=$reseau[0]['res_id'];
if($roleid =="H2"){$var="";}else{$var=" and reseau like '%{$reseau}%'";}
$query = "SELECT * FROM `ent_qcm` where date_debut <= ? and date_fin >= ? and heure_debut <= ? and heure_fin > ? ".$var."";
$resultt = $adb->pquery($query, array(date('Y-m-d'),date('Y-m-d'),$heure,$heure));
$libelle = array();
while ($recordinfo = $adb->fetch_array($resultt)) {
$libelles[] = $recordinfo;
}
return $libelles;
}
function getAllLignesEaxmen($idExamen){
global $adb;
$query = "SELECT * FROM `lignes_qcm` where code_ent_qcm= ? ORDER BY ordre ASC;";
$result = $adb->pquery($query, array($idExamen));
$question = array();
while ($recordinfo = $adb->fetch_array($result)) {
$questions[] = $recordinfo;
}
return $questions;
}
function getExamenInformations($idExamen){
global $adb;
//requete pour timer
$query5 = "SELECT * FROM `ent_qcm` where code_qcm = '".$idExamen."'";
$result5 =$adb->query($query5);
while ($recordinfo = $adb->fetch_array($result5)) {
$ExamenInformations[] = $recordinfo;
}
return $ExamenInformations;
}
function result($question){
echo '
<tr>
<td style="display:none;"><input type="hidden" name="code_lignes[]" value='.$question['code_ligne'].'></td>
<td style="width:15px;">'.$question['ordre'].'</td>
<td style="font-size: 14px;"><input type="hidden" name="questions[]" value="'.$question['question'].'">'.html_entity_decode($question['question']).'</td>
<td style="width:30px;">';
if(strlen($question['correction']) == 6){
echo'<select class="js-example-basic-single form-control" style="width:350px;" id="libelleCc" name="Choix'.$question['code_ligne'].'[]" >
<option value=""></option>
';
if ($question['choix1'] != null)
echo '
<option value="Choix1">'.html_entity_decode($question['choix1']).'</option>
';
if ($question['choix2'] != null)
echo '
<option value="Choix2">'.html_entity_decode($question['choix2']).'</option>
';
if ($question['choix3'] != null)
echo '
<option value="Choix3">'.html_entity_decode($question['choix3']).'</option>
';
if ($question['choix4'] != null)
echo '
<option value="Choix4">'.html_entity_decode($question['choix4']).'</option>
';
if ($question['choix5'] != null)
echo '
<option value="Choix5">'.html_entity_decode($question['choix5']).'</option>
';
echo '
</select>';
}else{
echo '
<table style="border-collapse: separate; border-spacing: 10px 10px; ">
<tbody>';
if ($question['choix1'] != null)
echo '
<tr valign="top">
<td style="padding-right:5px; "><input type="checkbox" name="Choix'.$question['code_ligne'].'[]" value="Choix1" id="'.$question['code_ligne'].'1"></td>
<td><label for="'.$question['code_ligne'].'1">'.html_entity_decode($question['choix1']).'</label></td>
</tr>
';
if ($question['choix2'] != null)
echo '
<tr valign="top">
<td style="padding-right:5px;"><input type="checkbox" name="Choix'.$question['code_ligne'].'[]" value="Choix2" id="'.$question['code_ligne'].'2"></td>
<td><label for="'.$question['code_ligne'].'2">'.html_entity_decode($question['choix2']).'</label></td>
</tr>
';
if ($question['choix3'] != null)
echo '
<tr valign="top">
<td style="padding-right:5px;"><input type="checkbox" name="Choix'.$question['code_ligne'].'[]" value="Choix3" id="'.$question['code_ligne'].'3"></td>
<td><label for="'.$question['code_ligne'].'3">'.html_entity_decode($question['choix3']).'</label></td>
</tr>
';
if ($question['choix4'] != null)
echo '
<tr valign="top">
<td style="padding-right:5px;"><input type="checkbox" name="Choix'.$question['code_ligne'].'[]" value="Choix4" id="'.$question['code_ligne'].'4"></td>
<td><label for="'.$question['code_ligne'].'4">'.html_entity_decode($question['choix4']).'</label></td>
</tr>
';
if ($question['choix5'] != null)
echo '
<tr valign="top">
<td style="padding-right:5px;"><input type="checkbox" name="Choix'.$question['code_ligne'].'[]" value="Choix5" id="'.$question['code_ligne'].'5"></td>
<td><label for="'.$question['code_ligne'].'5">'.html_entity_decode($question['choix5']).'</label></td>
</tr>
';
echo '
</tbody>
</table>';
}
echo'</td>
</tr>
';
}
//le candidat passe un examen un seul fois
function getIdPassage($idExamen,$userId){
global $adb;
$queryy = "SELECT * FROM `passage_qcm_ent` where code_ent_qcm= ? and candidat= ?";
$resultt = $adb->pquery($queryy, array($idExamen,$userId));
$ids[] = $adb->fetch_array($resultt);
$_SESSION["id_passage_qcm"] =$ids[0]['code_passage_qcm'];
}
function getPassageInformations($idExamen,$userId){
global $adb;
$queryy = "SELECT * FROM `passage_qcm_ent` where candidat= '".$userId."' and code_ent_qcm='".$idExamen."'";
$sql_get_resultt = $adb->query($queryy);
while ($recordinfo = $adb->fetch_array($sql_get_resultt)) {
$PassageInformations[] = $recordinfo;
}
return $PassageInformations;
}
?>