-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestions.php
216 lines (165 loc) · 8.5 KB
/
questions.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
require_once('lib/common.php');
if(user_is_not_logged_in())
header("location:login.php") || die(); //user not logged in
$completed = user_has_completed_the_survey();
$id_user = get_user_id();
?>
<!DOCTYPE html>
<html>
<!-- Page designed by Carlo Varriale http://carlos-way.deviantart.com !-->
<head>
<meta charset="iso-8859-1">
<title> Outlook - Questionario</title>
<link rel='shortcut icon' type='image/x-icon' href='images/world_icon.png' />
<link rel="stylesheet" type="text/css" href="style/questions.css"/>
<link rel="stylesheet" type="text/css" href="style/reveal.css" >
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.reveal.js"></script>
<script type="text/javascript" src="js/questions.js"></script>
</head>
<body>
<div id="myModal" class="reveal-modal small">
<p>Non hai risposto a tutte le domande!</p>
<a class="close-reveal-modal">×</a>
</div>
<div id="up_side">
<div id="dashboard">
<img src="images/logo2.png" id="logo"/>
<span id="des_logo"> questionario </span>
<?php if(!$completed): ?>
<input type="submit" id="submit_button" value="Invia questionario"> </input>
<?php endif ?>
</div>
</div>
<div id="guide">
<div id="guide_content">
<span id="guide_text">
<?php if(!$completed): ?>
Ci siamo! Compila il questionario Outlook, e clicca su "Invia questionario" quando hai finito.
<?php else: ?>
Hai già inviato il questionario Outlook, ma puoi controllare le risposte che hai dato.
<?php endif ?>
</span>
</div>
</div>
<form id="myform" method="POST" action="submit.php">
<div id="questions_body_container">
<div id="user_section">
<div id="left_usersection_side">
<p id="user_section_title"> Questionario progetto Outlook</p>
<span id="user_section_title_sub"> iniziativa dell'ITIS Galilei di Livorno per la raccolta di informazioni sui diplomati della scuola.</span>
</div>
<?php
$data_query = 'SELECT name, surname, sex, graduation_year, specializations.description, grade, laud
FROM users, specializations
WHERE users.id_user=?
AND users.id_specialization=specializations.id_specialization';
$data = exec_query($data_query, 'i', $id_user);
?>
<div id="right_usersection_side">
<span id="user_name"><?php echo "{$data->name} {$data->surname}" ?></span><br><br>
<span class="user_data_span"> anno diploma: </span> </span><span id="user_grade_date"><?php echo $data->graduation_year ?></span><br>
<span id="user_address"><?php echo $data->description ?></span><br>
<span class="user_data_span"> voto maturità:</span>
<span id="user_grade"><?php echo "{$data->grade}{$data->laud}" ?></span>
</div>
</div>
<?php
$sections_query = 'SELECT id_section, title, subtitle
FROM sections
ORDER BY section_order';
$sections = exec_query_many_results($sections_query);
foreach($sections as $section):
?>
<div class="section">
<p class="section_title">
<?php echo mb_strtoupper($section->title, "iso-8859-1"); ?>
</p>
<?php
$questions_query = 'SELECT id_question, text, id_question_type, id_question in (
SELECT DISTINCT answers.id_question
FROM questions, answers, sections
WHERE answers.id_answer = questions.dependency
OR answers.id_answer = sections.dependency
) AS has_dependencies
FROM questions
WHERE questions.id_section=?
ORDER BY question_order';
$questions = exec_query_many_results($questions_query, 'i', $section->id_section);
foreach($questions as $question):
?>
<div id="question<?php echo $question->id_question?>" data-question_id="<?php echo $question->id_question?>" class="question">
<?php if($question->text != null): ?>
<p class="question_title">
<?php echo $question->text ?>
</p>
<?php endif ?>
<div class="answers">
<?php
$answers_query = "SELECT id_answer, text,
id_answer IN (SELECT id_answer FROM given_answers WHERE id_user=?) AS selected
FROM answers
WHERE id_question=?
ORDER BY answer_order";
$answers = exec_query_many_results($answers_query, 'ii', get_user_id(), $question->id_question);
switch($question->id_question_type):
case 1:
foreach($answers as $answer): ?>
<input type="radio" name="<?php echo $question->id_question ?>"
value="<?php echo $answer->id_answer ?>"
<?php if($question->has_dependencies):?> data-side-effects="true" <?php endif?>
<?php if($completed):?> data-disabled="true" disabled <?php endif?>
<?php if($answer->selected):?> checked <?php endif?> >
<?php echo $answer->text; ?>
</input>
<br>
<?php endforeach ?>
<?php break;
case 2: ?>
<select <?php if($question->has_dependencies):?> data-side-effects="true" <?php endif?>
name="<?php echo $question->id_question ?>"
<?php if($completed):?> data-disabled="true" disabled <?php endif?>>
<option value="" disabled selected/>
<?php foreach($answers as $answer): ?>
<option value="<?php echo $answer->id_answer?>"
<?php if($answer->selected):?> selected <?php endif?>>
<?php echo $answer->text?>
</option>
<?php endforeach ?>
</select>
<?php break;
case 3:
foreach($answers as $answer): ?>
<input type="checkbox" name="<?php echo $question->id_question ?>[]"
value="<?php echo $answer->id_answer ?>"
<?php if($question->has_dependencies):?> data-side-effects="true" <?php endif?>
<?php if($completed):?> data-disabled="true" disabled <?php endif?>
<?php if($answer->selected):?> checked <?php endif?> >
<?php echo $answer->text; ?>
</input>
<br>
<?php endforeach ?>
<?php endswitch ?>
</div>
</div>
<?php endforeach ?>
</div>
<?php endforeach ?>
</div>
<input type="submit" id="hidden_submit"/>
</form>
<div id="footer">
<div style="text-align:center width:100%;">
<input type="submit" value="logout" id="logout_button" onclick="location.href='logout.php'"/>
</div>
<div id="footer_content">
<!--p id="links" da scrivere-->
<p id="links"> visita il sito della scuola - <a style="color:white;" href="http://galileilivorno.it">galileilivorno.it</a>
<span id="credits" > realizzato dalla 5A INA AS 2012/2013 </span></p>
</div>
</div>
</body>
</html>