3 * GForge Survey Facility
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 require_once('../env.inc.php');
30 require_once('pre.php');
31 require_once('common/survey/Survey.class.php');
32 require_once('common/survey/SurveyResponse.class.php');
33 require_once('www/survey/include/SurveyHTML.class.php');
35 $group_id = getIntFromRequest('group_id');
36 $survey_id = getIntFromRequest('survey_id');
38 $g =& group_get_object($group_id);
39 if (!$g || !is_object($g) || $g->isError()) {
43 $sh = new SurveyHtml();
44 $sh->header(array('title'=>_('Survey Complete')));
48 Quit if params are not provided
50 echo "<h1>"._('Error - For some reason group_id and/or survey_id did not make it he')."</h1>";
55 if (!session_loggedin()) {
57 Tell them they need to be logged in
59 echo "<h1>"._('You need to be logged in')."</h1>";
60 echo "<p>"._('Unfortunately, you have to be logged in to participate in surveys.')."</p>";
67 <p><?php echo _('Thank you for taking time to complete this survey.'); ?></p>
69 <?php echo _('Regards'); ?>,
71 <strong><?php printf(_('The %1$s Crew'), $GLOBALS['sys_name']); ?></strong>
75 Delete this customer's responses in case they had back-arrowed
77 $result=db_query("DELETE FROM survey_responses WHERE survey_id='" . addslashes($survey_id) . "' AND group_id='" . addslashes($group_id) . "' AND user_id='".user_getid()."'");
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());