[otrs-cvs] Survey/Kernel/System Survey.pm,1.68,1.69
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/Survey/Kernel/System
In directory lancelot:/tmp/cvs-serv31465/Kernel/System
Modified Files:
Survey.pm
Log Message:
Added answer required functionality in Survey for 3.1.x.
Author: jh
Index: Survey.pm
===================================================================
RCS file: /home/cvs/Survey/Kernel/System/Survey.pm,v
retrieving revision 1.68
retrieving revision 1.69
diff -2 -u -d -r1.68 -r1.69
--- Survey.pm 13 Nov 2012 16:10:58 -0000 1.68
+++ Survey.pm 20 Nov 2012 15:53:16 -0000 1.69
@@ -590,9 +590,18 @@
# get all questions of a survey
+ # ---
+ # AnswerRequired
+ # ---
+ # $Self->{DBObject}->Prepare(
+ # SQL => "SELECT id, survey_id, question, question_type "
+ # . " FROM survey_question WHERE survey_id = $Param{SurveyID} ORDER BY position",
+ # );
$Self->{DBObject}->Prepare(
- SQL => "SELECT id, survey_id, question, question_type "
+ SQL => "SELECT id, survey_id, question, question_type, answer_required"
. " FROM survey_question WHERE survey_id = $Param{SurveyID} ORDER BY position",
);
+ # ---
+
# fetch the result
my @List;
@@ -604,4 +613,11 @@
$Data{Type} = $Row[3];
+ # ---
+ # AnswerReqruired
+ # ---
+ $Data{AnswerRequired} = $Row[4];
+
+ # ---
+
push @List, \%Data;
}
@@ -618,4 +634,9 @@
SurveyID => 10,
Question => 'The Question',
+# ---
+# AnswerRequired
+# ---
+ AnswerRequired => 1, # or
+# ---
Type => 'Radio',
);
@@ -648,10 +669,36 @@
# insert a new question
+ # ---
+ # AnswerRequired
+ # ---
+ # return $Self->{DBObject}->Do(
+ # SQL => "INSERT INTO survey_question (survey_id, question, question_type, "
+ # . "position, create_time, create_by, change_time, change_by) VALUES ("
+ # . "$Param{SurveyID}, "
+ # . "'$Param{Question}', "
+ # . "'$Param{Type}', 255, "
+ # . "current_timestamp, "
+ # . "$Param{UserID}, "
+ # . "current_timestamp, "
+ # . "$Param{UserID})",
+ # );
+ # if we didn't get an Answer Parameter (e.g. just undefined)
+ # or it was something else than 0 or 1
+ # we assume it's a required answer
+ if (
+ !defined $Param{AnswerRequired}
+ ||
+ ( $Param{AnswerRequired} ne '0' && $Param{AnswerRequired} ne '1' )
+ )
+ {
+ $Param{AnswerRequired} = 1;
+ }
return $Self->{DBObject}->Do(
SQL => "INSERT INTO survey_question (survey_id, question, question_type, "
- . "position, create_time, create_by, change_time, change_by) VALUES ("
+ . "position, answer_required, create_time, create_by, change_time, change_by) VALUES ("
. "$Param{SurveyID}, "
. "'$Param{Question}', "
. "'$Param{Type}', 255, "
+ . "'$Param{AnswerRequired}',"
. "current_timestamp, "
. "$Param{UserID}, "
@@ -659,4 +706,6 @@
. "$Param{UserID})",
);
+
+ # ---
}
@@ -933,6 +982,15 @@
# get question
+ # ---
+ # AnswerRequired
+ # ---
+ # $Self->{DBObject}->Prepare(
+ # SQL => "SELECT id, survey_id, question, question_type, position, "
+ # . "create_time, create_by, change_time, change_by "
+ # . "FROM survey_question WHERE id = $Param{QuestionID}",
+ # Limit => 1,
+ # );
$Self->{DBObject}->Prepare(
- SQL => "SELECT id, survey_id, question, question_type, position, "
+ SQL => "SELECT id, survey_id, question, question_type, position, answer_required, "
. "create_time, create_by, change_time, change_by "
. "FROM survey_question WHERE id = $Param{QuestionID}",
@@ -940,18 +998,38 @@
);
+ # ---
+
# fetch the result
my %Data;
+
+ # ---
+ # AnswerRequired
+ # ---
+ # while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
+ # $Data{QuestionID} = $Row[0];
+ # $Data{SurveyID} = $Row[1];
+ # $Data{Question} = $Row[2];
+ # $Data{Type} = $Row[3];
+ # $Data{Position} = $Row[4];
+ # $Data{CreateTime} = $Row[5];
+ # $Data{CreateBy} = $Row[6];
+ # $Data{ChangeTime} = $Row[7];
+ # $Data{ChangeBy} = $Row[8];
+ # }
while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
- $Data{QuestionID} = $Row[0];
- $Data{SurveyID} = $Row[1];
- $Data{Question} = $Row[2];
- $Data{Type} = $Row[3];
- $Data{Position} = $Row[4];
- $Data{CreateTime} = $Row[5];
- $Data{CreateBy} = $Row[6];
- $Data{ChangeTime} = $Row[7];
- $Data{ChangeBy} = $Row[8];
+ $Data{QuestionID} = $Row[0];
+ $Data{SurveyID} = $Row[1];
+ $Data{Question} = $Row[2];
+ $Data{Type} = $Row[3];
+ $Data{Position} = $Row[4];
+ $Data{AnswerRequired} = $Row[5];
+ $Data{CreateTime} = $Row[6];
+ $Data{CreateBy} = $Row[7];
+ $Data{ChangeTime} = $Row[8];
+ $Data{ChangeBy} = $Row[9];
}
+ # ---
+
return %Data;
}
@@ -965,4 +1043,9 @@
QuestionID => 4,
SurveyID => 3,
+# ---
+# AnswerRequired
+# ---
+ AnswerRequired => '1', # or '0'
+# ---
Question => 'The Question',
);
@@ -984,4 +1067,18 @@
}
+ # ---
+ # AnswerRequired
+ # ---
+ my $AnswerRequired = 1;
+ if (
+ defined $Param{AnswerRequired}
+ && ( $Param{AnswerRequired} eq '1' || $Param{AnswerRequired} eq '0' )
+ )
+ {
+ $AnswerRequired = $Param{AnswerRequired};
+ }
+
+ # ---
+
# quote
for my $Argument (qw(Question)) {
@@ -996,4 +1093,11 @@
SQL => "UPDATE survey_question SET "
. "question = '$Param{Question}', "
+
+ # ---
+ # AnswerRequired
+ # ---
+ . "answer_required = $AnswerRequired, "
+
+ # ---
. "change_time = current_timestamp, "
. "change_by = $Param{UserID} "
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log