-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathajax.php
More file actions
69 lines (59 loc) · 2.34 KB
/
Copy pathajax.php
File metadata and controls
69 lines (59 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*=========================================================
// File: ajax.php
// Description: AJAX exchange for EvalSMSI
// Created: 2009-01-01
// Licence: GPL-3.0-or-later
// Copyright 2009-2019 Michel Dubois
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
=========================================================*/
include("functions.php");
startSession();
$authorizedRole = array('2');
isSessionValid($authorizedRole);
header("Content-type: text/html; charset=utf-8");
$id_etab = intval($_GET['query']);
if (isRegroupEtabbyId($id_etab)) {
$base = dbConnect();
$request = sprintf("SELECT * FROM quiz");
$result = mysqli_query($base, $request);
dbDisconnect($base);
if (mysqli_num_rows($result)) {
$return = "Choisissez un questionnaire: <select name='id_quiz' id='id_quiz' required><option value=''> </option>";
while ($row = mysqli_fetch_object($result)) {
$return .= sprintf("<option value='%s'>%s</option>", $row->id, $row->nom);
}
$return .= "</select>";
}else {
$return = "Pas de questionnaire";
}
} else {
$annee = $_SESSION['annee'];
$base = dbConnect();
$request = sprintf("SELECT * FROM assess WHERE etablissement='%d' AND annee='%d' ", $id_etab, $annee);
$result = mysqli_query($base, $request);
if (mysqli_num_rows($result)) {
$return = "Questionnaire: <select name='id_quiz' id='id_quiz' required><option value=''> </option>";
while ($row = mysqli_fetch_object($result)) {
$req_quiz = sprintf("SELECT * FROM quiz WHERE id='%d' LIMIT 1", $row->quiz);
$res_quiz = mysqli_query($base, $req_quiz);
$row_quiz = mysqli_fetch_object($res_quiz);
$return .= sprintf("<option value='%s'>%s</option>", $row_quiz->id, $row_quiz->nom);
}
$return .= "</select>";
} else {
$return = "Pas de questionnaire";
}
dbDisconnect($base);
}
echo $return;
?>