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 $gfcommon.'survey/Survey.class.php';
30 require_once $gfcommon.'survey/SurveyResponse.class.php';
31 require_once $gfwww.'survey/include/SurveyHTML.class.php';
33 $group_id = getIntFromRequest('group_id');
34 $survey_id = getIntFromRequest('survey_id');
36 $g =& group_get_object($group_id);
37 if (!$g || !is_object($g) || $g->isError()) {
41 $sh = new SurveyHtml();
42 $sh->header(array('title'=>_('Survey Complete')));
46 Quit if params are not provided
48 echo "<h1>"._('Error - For some reason group_id and/or survey_id did not make it he')."</h1>";
53 if (!session_loggedin()) {
55 Tell them they need to be logged in
57 echo "<h1>"._('You need to be logged in')."</h1>";
58 echo "<p>"._('Unfortunately, you have to be logged in to participate in surveys.')."</p>";
65 <p><?php echo _('Thank you for taking time to complete this survey.'); ?></p>
67 <?php echo _('Regards'); ?>,
69 <strong><?php printf(_('The %1$s Crew'), forge_get_config ('forge_name')); ?></strong>
73 Delete this customer's responses in case they had back-arrowed
75 $result = db_query_params ('DELETE FROM survey_responses WHERE survey_id=$1 AND group_id=$2 AND user_id=$3',
76 array(addslashes($survey_id) ,
77 addslashes($group_id) ,
80 Select this survey from the database
82 $s = new Survey($g, $survey_id);
83 $quest_array= & $s->getQuestionArray();
85 $count=count($quest_array);
88 /* Make a dummy SurveyResponses for creating */
89 $sr = new SurveyResponse($g);
91 for ($i=0; $i<$count; $i++) {
92 /* Insert each form value into the responses table */
94 $val="_" . $quest_array[$i];
95 $response = getStringFromRequest($val);;
97 $sr->create(user_getid(), $survey_id, $quest_array[$i], $response);
99 echo $sr->getErrorMessage();
103 $sh->footer(array());