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
26 require_once('../../env.inc.php');
27 require_once $gfwww.'include/pre.php';
28 require_once $gfwww.'survey/survey_utils.php';
31 $group_id = getIntFromRequest('group_id');
32 $survey_id = getIntFromRequest('survey_id');
34 survey_header(array('title'=>_('Edit A Question')));
36 if (!session_loggedin() || !user_ismember($group_id,'A')) {
37 echo '<div class="error">' ._('Permission denied'). '</div>';
38 survey_footer(array());
42 if (getStringFromRequest('post_changes')) {
43 $question = getStringFromRequest('question');
44 $question_type = getStringFromRequest('question_type');
45 $question_id = getIntFromRequest('question_id');
47 $result = db_query_params ('UPDATE survey_questions SET question=$1, question_type=$2 where question_id=$3 AND group_id=$4',
48 array (htmlspecialchars($question),
52 if (db_affected_rows($result) < 1) {
53 $feedback .= _('Update Failed');
55 $feedback .= _('Update Successful');
59 $result = db_query_params ('SELECT * FROM survey_questions WHERE question_id=$1 AND group_id=$2',
64 $question=db_result($result, 0, "question");
65 $question_type=db_result($result, 0, "question_type");
67 $feedback .= _('Error finding question');
71 <script type="text/javascript">
75 function show_questions() {
76 newWindow = open("","occursDialog","height=600,width=500,scrollbars=yes,resizable=yes");
77 newWindow.location=('show_questions.php?group_id=<?php echo $group_id; ?>');
83 <h2><?php echo _('Editing Question'); ?> #<?php echo $question_id; ?></h2>
85 <span class="warning"><?php echo _('WARNING! It is a bad idea to change a question after responses to it have been submitted'); ?></span>
87 <p><?php echo _('If you change a question after responses have been posted, your results pages may be misleading'); ?>.</p>
90 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
91 <input type="hidden" name="post_changes" value="Y" />
92 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>"/>
93 <input type="hidden" name="question_id" value="<?php echo $question_id; ?>" />
95 <?php echo _('Question'); ?>:
97 <input type="text" name="question" value="<?php echo $question; ?>" size="60" maxlength="150" />
99 <p><?php echo _('Question type'); ?>:
103 $result = db_query_params ('SELECT * FROM survey_question_types',
105 echo html_build_select_box($result,'question_type',$question_type,false);
110 <p><input type="submit" name="submit" value="<?php echo _('Submit Changes'); ?>" /></p>
114 <input type="button" name="none" value="<?php echo _('Show Existing Questions'); ?>" onclick="show_questions()" />
119 survey_footer(array());
123 // c-file-style: "bsd"