5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * http://fusionforge.org/
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once('../../env.inc.php');
27 require_once $gfcommon.'include/pre.php';
30 $group_id = getIntFromRequest('group_id');
31 $survey_id = getIntFromRequest('survey_id');
32 $customer_id = getIntFromRequest('customer_id');
33 survey_header(array('title'=>_('Results')));
35 if (!session_loggedin() || !forge_check_perm('project_admin', $group_id)) {
36 echo '<div class="error">'._('Permission denied').'</div>';
37 survey_footer(array());
47 Select this survey from the database
50 $result = db_query_params ('SELECT * FROM surveys WHERE survey_id=$1 AND group_id=$2',
54 echo "\n<h2>".db_result($result, 0, "survey_title")."</h2><p> </p>";
57 Select the questions for this survey
60 $questions=db_result($result, 0, "survey_questions");
61 $questions=str_replace(" ", "", $questions);
62 $quest_array=explode(',', $questions);
64 $count=count($quest_array);
70 for ($i=0; $i<$count; $i++) {
73 Build the questions on the HTML form
75 $result = db_query_params ('SELECT questions.question_type,questions.question,questions.question_id,responses.response FROM questions,responses WHERE questions.question_id=$1 AND questions.question_id=responses.question_id AND responses.customer_id=$2 AND responses.survey_id=$3',
76 array($quest_array[$i],
80 if (!$result || db_numrows($result) < 1) {
81 $result = db_query_params ('SELECT * FROM survey_questions WHERE question_id=$1',
82 array ($quest_array[$i]));
88 //echo "\n\nnotfound: '$not_found'";
90 $question_type=db_result($result, 0, "question_type");
92 if ($question_type == "4") {
94 Don't show question number if it's just a comment
97 echo "\n<tr><td valign=\"top\"> </td>\n<td>";
101 echo "\n<tr><td valign=\"top\"><strong>";
104 If it's a 1-5 question box and first in series, move Quest
108 if (($question_type != $last_question_type) && (($question_type == "1") || ($question_type == "3"))) {
109 echo " <p> </p>";
112 echo $q_num." <br /></td>\n<td>";
117 if ($question_type == "1") {
120 This is a radio-button question. Values 1-5.
124 // Show the 1-5 markers only if this is the first in a series
126 if ($question_type != $last_question_type) {
127 echo "\n<strong>1 5</strong>\n";
132 for ($j=1; $j<=5; $j++) {
133 echo "\n<input type=\"radio\" name=\"_".$quest_array[$i]."\" value=\"$j\"";
135 add the checked statement if this was the response
137 if (($not_found==0) && db_result($result, 0, "response")=="$j") { echo " checked=\"checked\""; }
141 echo " ".db_result($result, 0, "question")."\n";
143 } else if ($question_type == "2") {
146 This is a text-area question.
149 echo db_result($result, 0, "question")."<br />\n";
150 echo "\n<textarea name=\"_".$quest_array[$i]."\" rows=\"5\" cols=\"60\">";
153 Show the person's response if there was one
157 echo db_result($result, 0, "response");
159 echo "</textarea>\n";
161 } else if ($question_type == "3") {
164 This is a Yes/No question.
168 Show the Yes/No only if this is the first in a series
171 if ($question_type != $last_question_type) {
172 echo "<strong>"._('Yes / No')."</strong><br />\n";
175 echo "\n<input type=\"radio\" name=\"_".$quest_array[$i]."\" value=\"1\"";
178 add the checked statement if this was the response
181 if (($not_found==0) && db_result($result, 0, "response")=="1") { echo " checked=\"checked\""; }
183 echo "\n<input type=\"radio\" name=\"_".$quest_array[$i]."\" value=\"5\"";
186 add the checked statement if this was the response
188 if (($not_found==0) && db_result($result, 0, "response")=="5") { echo " checked=\"checked\""; }
192 echo " ".db_result($result, 0, "question")."\n";
194 } else if ($question_type == "4") {
197 This is a comment only.
200 echo "\n <p><strong>".db_result($result, 0, "question")."</strong></p>\n";
201 echo "\n<input type=\"hidden\" name=\"_".$quest_array[$i]."\" value=\"-666\" />";
203 } else if ($question_type == "5") {
206 This is a text-field question.
209 echo db_result($result, 0, "question")."<br />\n";
210 echo "\n<input type=\"text\" name=\"_".$quest_array[$i]."\" size=\"20\" maxlength=\"70\" value=\"";
213 Show the person's response if there was one
216 echo db_result($result, 0, "response");
224 $last_question_type=$question_type;
235 survey_footer(array());
239 // c-file-style: "bsd"