5 * Copyright 2004, Sung Kim/GForge, LLC
6 * Copyright 2009, Roland Mas
7 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'include/FFError.class.php';
27 class SurveyResponse extends FFError {
29 * Associative array of data from db.
31 * @var array $data_array.
46 function __construct(&$Group, $arr=false) {
47 parent::__construct();
48 if (!$Group || !is_object($Group)) {
49 $this->setError(_('Invalid Project'));
52 if ($Group->isError()) {
53 $this->setError('Survey: '.$Group->getErrorMessage());
56 $this->Group =& $Group;
58 if ($arr && is_array($arr)) {
59 $this->data_array =& $arr;
64 * create - use this function to create a survey response
70 * @return bool success.
72 function create($user_id, $survey_id, $question_id, $response) {
73 $res = db_query_params ('INSERT INTO survey_responses (user_id,group_id,survey_id,question_id,response,post_date) VALUES ($1,$2,$3,$4,$5,$6)',
75 $this->Group->GetID(),
78 htmlspecialchars ($response),
81 $this->setError(_('Error').db_error());
88 * getGroup - get the Group object this SurveyResponse is associated with.
90 * @return object The Group object.
92 function &getGroup() {
97 * getUserID - Get the user id of this Survey response
99 * @return int The user_id
101 function getUserID() {
102 return $this->data_array['user_id'];
106 * getGroup - Get the group id of this Survey response
108 * @return int The group_id
110 function getGroupID() {
111 return $this->data_array['group_id'];
115 * getSurveyID - Get the survey id of this Survey response
117 * @return int The survey_id
119 function getSurveyID() {
120 return $this->data_array['survey_id'];
124 * getQuestionID - Get the question id of this Survey response
126 * @return int The question_id
128 function getQuestionID() {
129 return $this->data_array['question_id'];
133 * getUserID - Get the response of this Survey response
135 * @return int The response
137 function getResponse() {
138 return $this->data_array['response'];
142 * getPostDate - Get the post date of this Survey response
144 * @return int The post date
146 function getPostDate() {
147 return $this->data_array['post_date'];
153 // c-file-style: "bsd"