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 $title = _('Survey Complete');
43 $sh->header(array('title'=>$title));
44 echo '<h1>' . $title . '</h1>';
48 Quit if params are not provided
50 echo '<div class="error">'._('For some reason, the Group ID or Survey ID did not make it to this page').'</div>';
55 if (!session_loggedin()) {
57 Tell them they need to be logged in
59 echo '<div class="error">'._('You have to be logged in to participate in surveys.')."</div>";
66 <p><?php echo _('Thank you for taking time to complete this survey.'); ?></p>
68 <?php echo _('Regards'); ?>,
70 <strong><?php printf(_('The %1$s Crew'), forge_get_config ('forge_name')); ?></strong>
74 Delete this customer's responses in case they had back-arrowed
76 $result = db_query_params ('DELETE FROM survey_responses WHERE survey_id=$1 AND group_id=$2 AND user_id=$3',
77 array(addslashes($survey_id) ,
78 addslashes($group_id) ,
81 Select this survey from the database
83 $s = new Survey($g, $survey_id);
84 $quest_array= & $s->getQuestionArray();
86 $count=count($quest_array);
89 /* Make a dummy SurveyResponses for creating */
90 $sr = new SurveyResponse($g);
92 for ($i=0; $i<$count; $i++) {
93 /* Insert each form value into the responses table */
95 $val="_" . $quest_array[$i];
96 $response = getStringFromRequest($val);;
98 $sr->create(user_getid(), $survey_id, $quest_array[$i], $response);
100 echo $sr->getErrorMessage();
104 $sh->footer(array());