3 * GForge Survey Facility
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 require_once('../../env.inc.php');
28 require_once $gfwww.'include/pre.php';
29 require_once $gfwww.'survey/survey_utils.php';
32 $group_id = getIntFromRequest('group_id');
33 $survey_id = getIntFromRequest('survey_id');
34 $customer_id = getIntFromRequest('customer_id');
35 survey_header(array('title'=>_('Results')));
37 if (!session_loggedin() || !user_ismember($group_id,'A')) {
38 echo '<div class="error">'._('Permission denied').'</div>';
39 survey_footer(array());
49 Select this survey from the database
52 $result = db_query_params ('SELECT * FROM surveys WHERE survey_id=$1 AND group_id=$2',
56 echo "\n<h2>".db_result($result, 0, "survey_title")."</h2><p> </p>";
59 Select the questions for this survey
62 $questions=db_result($result, 0, "survey_questions");
63 $questions=str_replace(" ", "", $questions);
64 $quest_array=explode(',', $questions);
66 $count=count($quest_array);
72 for ($i=0; $i<$count; $i++) {
75 Build the questions on the HTML form
77 $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',
78 array($quest_array[$i],
82 if (!$result || db_numrows($result) < 1) {
83 $result = db_query_params ('SELECT * FROM survey_questions WHERE question_id=$1',
84 array ($quest_array[$i]));
90 //echo "\n\nnotfound: '$not_found'";
92 $question_type=db_result($result, 0, "question_type");
94 if ($question_type == "4") {
96 Don't show question number if it's just a comment
99 echo "\n<tr><td valign=\"top\"> </td>\n<td>";
103 echo "\n<tr><td valign=\"top\"><strong>";
106 If it's a 1-5 question box and first in series, move Quest
110 if (($question_type != $last_question_type) && (($question_type == "1") || ($question_type == "3"))) {
111 echo " <p> </p>";
114 echo $q_num." <br /></td>\n<td>";
119 if ($question_type == "1") {
122 This is a radio-button question. Values 1-5.
126 // Show the 1-5 markers only if this is the first in a series
128 if ($question_type != $last_question_type) {
129 echo "\n<strong>1 5</strong>\n";
134 for ($j=1; $j<=5; $j++) {
135 echo "\n<input type=\"radio\" name=\"_".$quest_array[$i]."\" value=\"$j\"";
137 add the checked statement if this was the response
139 if (($not_found==0) && db_result($result, 0, "response")=="$j") { echo " checked=\"checked\""; }
143 echo " ".db_result($result, 0, "question")."\n";
145 } else if ($question_type == "2") {
148 This is a text-area question.
151 echo db_result($result, 0, "question")."<br />\n";
152 echo "\n<textarea name=\"_".$quest_array[$i]."\" rows=\"5\" cols=\"60\">";
155 Show the person's response if there was one
159 echo db_result($result, 0, "response");
161 echo "</textarea>\n";
163 } else if ($question_type == "3") {
166 This is a Yes/No question.
170 Show the Yes/No only if this is the first in a series
173 if ($question_type != $last_question_type) {
174 echo "<strong>"._('Yes / No')."</strong><br />\n";
177 echo "\n<input type=\"radio\" name=\"_".$quest_array[$i]."\" value=\"1\"";
180 add the checked statement if this was the response
183 if (($not_found==0) && db_result($result, 0, "response")=="1") { echo " checked=\"checked\""; }
185 echo "\n<input type=\"radio\" name=\"_".$quest_array[$i]."\" value=\"5\"";
188 add the checked statement if this was the response
190 if (($not_found==0) && db_result($result, 0, "response")=="5") { echo " checked=\"checked\""; }
194 echo " ".db_result($result, 0, "question")."\n";
196 } else if ($question_type == "4") {
199 This is a comment only.
202 echo "\n <p><strong>".db_result($result, 0, "question")."</strong></p>\n";
203 echo "\n<input type=\"hidden\" name=\"_".$quest_array[$i]."\" value=\"-666\" />";
205 } else if ($question_type == "5") {
208 This is a text-field question.
211 echo db_result($result, 0, "question")."<br />\n";
212 echo "\n<input type=\"text\" name=\"_".$quest_array[$i]."\" size=\"20\" maxlength=\"70\" value=\"";
215 Show the person's response if there was one
218 echo db_result($result, 0, "response");
226 $last_question_type=$question_type;
237 survey_footer(array());
241 // c-file-style: "bsd"