5 * Copyright 2004, Sung Kim/GForge, LLC
7 * This file is part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; either version 2 of the License,
12 * or (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FusionForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 require_once $gfcommon.'include/Error.class.php';
27 class SurveyResponse extends Error {
29 * Associative array of data from db.
31 * @var array $data_array.
40 var $Group; //group object
45 * @param object The Group object to which this Survey Response is associated.
46 * @param int The questtion_id.
47 * @param array The associative array of data.
48 * @return boolean success.
50 function SurveyResponse(&$Group, $arr=false) {
52 if (!$Group || !is_object($Group)) {
53 $this->setError(sprintf(_('%1$s:: No Valid Group Object'), 'Survey Question'));
56 if ($Group->isError()) {
57 $this->setError('Survey:: '.$Group->getErrorMessage());
60 $this->Group =& $Group;
62 if ($arr && is_array($arr)) {
63 $this->data_array =& $arr;
69 * create - use this function to create a survey response
71 * @param string The question
72 * @param int The question type
73 * 1: Radio Buttons 1-5
75 * 3: Radio Buttons Yes/No
79 * @return boolean success.
81 function create($user_id, $survey_id, $question_id, $response) {
82 $group_id = $this->Group->GetID();
85 $sql="INSERT INTO survey_responses (user_id,group_id,survey_id,question_id,response,post_date) ".
86 "VALUES ('". $user_id. "','" . addslashes($group_id) . "','" .
87 addslashes($survey_id) . "','" . addslashes($question_id) . "','".
88 htmlspecialchars($response) . "','$now')";
91 $this->setError(_('Error').db_error());
98 * getGroup - get the Group object this SurveyResponse is associated with.
100 * @return object The Group object.
102 function &getGroup() {
107 * getUserID - Get the user id of this Survey response
109 * @return int The user_id
111 function getUserID() {
112 return $this->data_array['user_id'];
116 * getGroup - Get the group id of this Survey response
118 * @return int The group_id
120 function getGroupID() {
121 return $this->data_array['group_id'];
125 * getSurveyID - Get the survey id of this Survey response
127 * @return int The survey_id
129 function getSurveyID() {
130 return $this->data_array['survey_id'];
135 * getQuestionID - Get the question id of this Survey response
137 * @return int The question_id
139 function getQuestionID() {
140 return $this->data_array['question_id'];
144 * getUserID - Get the response of this Survey response
146 * @return int The response
148 function getResponse() {
149 return $this->data_array['response'];
154 * getPostDate - Get the post date of this Survey response
156 * @return int The post date
158 function getPostDate() {
159 return $this->data_array['post_date'];
165 // c-file-style: "bsd"