Esempio n. 1
0
function get_question_type($id)
{
    $bd = new mysqlObject(HOST, DB, USER, MDP);
    $rep = $bd->select('select * from reponse where id_question = ' . $id . '');
    if (count($rep) == 1) {
        return $rep[0]->TYPE;
    }
    return TYPE_CHOIX_MULTIPLE;
}
Esempio n. 2
0
function afficher_users()
{
    $bd = new mysqlObject(HOST, DB, USER, MDP);
    $user = $bd->select('select * from compte 
			where status != ' . ADMIN_NUM . ';');
    echo '<div class="panel panel-primary">';
    echo '<div class="panel-heading">';
    echo '<h3> Liste utilisateur </h3>';
    echo '</div>';
    echo '<div class="list-group scrollable-menu">';
    foreach ($user as $u) {
        echo '<div class="list-group-item"> ';
        echo $u->LOGIN;
        echo '<a href="' . ROOT . '?action=' . DELETE_USER . '&id=' . $u->ID_USER . '" class="pull-right need_confirm">
				<button class="badge">Supprimé</button></a>';
        echo '</div>';
    }
    echo '</div>';
    echo '</div>';
}
Esempio n. 3
0
<?php

include_once $_SERVER['DOCUMENT_ROOT'] . '/sondage/Model/mysql.php';
$bd = new mysqlObject(HOST, DB, USER, MDP);
$id_q = $_GET['ID'];
$name = "";
$val = $bd->select('select valeur, count(valeur) as c from statistique 
					where id_question = ' . $id_q . '
					group by valeur;');
$q = $bd->select('select * from 
		question where id_question = ' . $id_q . ';');
$name = $q[0]->LIBELE;
$datas = "";
foreach ($val as $v) {
    if ($datas == "") {
        $datas = '["' . $v->valeur . '", ' . $v->c . ']';
    } else {
        $datas .= ',["' . $v->valeur . '", ' . $v->c . ']';
    }
}
$series = '"series" : [{
	"type": "pie",
	"name": "stat question",
	"data": [' . $datas . '] 
}]';
echo '{
	"title" : {
		"text" : "' . $name . '"
	},
	' . $series . '
}';
Esempio n. 4
0
function afficher_question_for_voter($id_s, $num_q)
{
    $bd = new mysqlObject(HOST, DB, USER, MDP);
    $sondage = $bd->select('select * from sondage where id_sondage = ' . $id_s . ';');
    $question = $bd->select('select * from question where id_sondage = ' . $id_s . ' and num = ' . $num_q . ';');
    if (count($sondage) == 0) {
        $sondage_label = 'Erreur sondage inconnu';
    } else {
        $sondage_label = $sondage[0]->LIBELE;
    }
    if (count($question) == 0) {
        $question_label = 'Erreur question inconnue';
    } else {
        $question_label = $question[0]->LIBELE;
    }
    ?>
    
    <div class="panel panel-primary">
    	<div class="panel-heading">
        	<h4><?php 
    echo $sondage_label;
    ?>
</h4>
        </div>
        <?php 
    if (count($question) == 0) {
        echo '<div class="panel panel-body">
				    ' . $question_label . '
					</div>';
    } else {
        afficher_liste_reponse_for_voter($question[0]);
    }
    ?>
    </div>
	
	<?php 
}
Esempio n. 5
0
function open_close_sondage($id)
{
    if (!isset($_SESSION[CONNECTED])) {
        return ERROR_NOT_CONNECTED;
    }
    if (!is_numeric($id)) {
        return ERROR_CORRUPTED_DATA;
    }
    $bd = new mysqlObject(HOST, DB, USER, MDP);
    $req = 'select * from sondage
			where id_sondage = ' . $id . ' and
			id_user = '******';';
    $s = $bd->select($req);
    if (count($s) != 1) {
        return ERROR_NOT_YOUR_SONDAGE;
    }
    if ($s[0]->STATUS == OPEN) {
        $stat = CLOSE;
    } else {
        $stat = OPEN;
    }
    $req = 'update sondage set status = ' . $stat . ' 
			where id_sondage = ' . $s[0]->ID_SONDAGE . ';';
    return $bd->execQuery($req);
}