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/Error.class.php';
27 class SurveyResponse extends Error {
29 * Associative array of data from db.
31 * @var array $data_array.
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 __construct(&$Group, $arr=false) {
52 if (!$Group || !is_object($Group)) {
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
69 * @param string The question
70 * @param int The question type
71 * 1: Radio Buttons 1-5
73 * 3: Radio Buttons Yes/No
77 * @return boolean success.
79 function create($user_id, $survey_id, $question_id, $response) {
80 $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)',
82 $this->Group->GetID(),
85 htmlspecialchars ($response),
88 $this->setError(_('Error').db_error());
95 * getGroup - get the Group object this SurveyResponse is associated with.
97 * @return object The Group object.
99 function &getGroup() {
104 * getUserID - Get the user id of this Survey response
106 * @return int The user_id
108 function getUserID() {
109 return $this->data_array['user_id'];
113 * getGroup - Get the group id of this Survey response
115 * @return int The group_id
117 function getGroupID() {
118 return $this->data_array['group_id'];
122 * getSurveyID - Get the survey id of this Survey response
124 * @return int The survey_id
126 function getSurveyID() {
127 return $this->data_array['survey_id'];
132 * getQuestionID - Get the question id of this Survey response
134 * @return int The question_id
136 function getQuestionID() {
137 return $this->data_array['question_id'];
141 * getUserID - Get the response of this Survey response
143 * @return int The response
145 function getResponse() {
146 return $this->data_array['response'];
151 * getPostDate - Get the post date of this Survey response
153 * @return int The post date
155 function getPostDate() {
156 return $this->data_array['post_date'];
162 // c-file-style: "bsd"