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.
45 * @internal param \The $object Group object to which this Survey Response is associated.
46 * @internal param \The $int question_id.
47 * @internal param \The $array associative array of data.
49 function __construct(&$Group, $arr=false) {
50 parent::__construct();
51 if (!$Group || !is_object($Group)) {
52 $this->setError(_('No Valid Group Object'));
55 if ($Group->isError()) {
56 $this->setError('Survey: '.$Group->getErrorMessage());
59 $this->Group =& $Group;
61 if ($arr && is_array($arr)) {
62 $this->data_array =& $arr;
67 * create - use this function to create a survey response
73 * @internal param \The $string question
74 * @internal param \The $int question type
75 * 1: Radio Buttons 1-5
77 * 3: Radio Buttons Yes/No
81 * @return boolean success.
83 function create($user_id, $survey_id, $question_id, $response) {
84 $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)',
86 $this->Group->GetID(),
89 htmlspecialchars ($response),
92 $this->setError(_('Error').db_error());
99 * getGroup - get the Group object this SurveyResponse is associated with.
101 * @return object The Group object.
103 function &getGroup() {
108 * getUserID - Get the user id of this Survey response
110 * @return int The user_id
112 function getUserID() {
113 return $this->data_array['user_id'];
117 * getGroup - Get the group id of this Survey response
119 * @return int The group_id
121 function getGroupID() {
122 return $this->data_array['group_id'];
126 * getSurveyID - Get the survey id of this Survey response
128 * @return int The survey_id
130 function getSurveyID() {
131 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'];
153 * getPostDate - Get the post date of this Survey response
155 * @return int The post date
157 function getPostDate() {
158 return $this->data_array['post_date'];
164 // c-file-style: "bsd"