Add a basic test for the Poll, adding votes and making a graph.
Add POD to Poll for setVote, and use placeholders in there.
This commit is contained in:
parent
8318ffe9b1
commit
0bf47be7f4
2 changed files with 138 additions and 6 deletions
|
|
@ -382,13 +382,32 @@ sub setGraphConfig {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setVote ($answer, $userId, $ip)
|
||||
|
||||
Accumulates a vote into the database so that it can be counted.
|
||||
|
||||
=head3 $answer
|
||||
|
||||
The answer selected by the user.
|
||||
|
||||
=head3 $userid
|
||||
|
||||
The userId of the person who voted.
|
||||
|
||||
=head3 $ip
|
||||
|
||||
The IP address of the user who voted.
|
||||
|
||||
=cut
|
||||
|
||||
sub setVote {
|
||||
my $self = shift;
|
||||
my $answer = shift;
|
||||
my $userId = shift;
|
||||
my $ip = shift;
|
||||
$self->session->db->write("insert into Poll_answer (assetId, answer, userId, ipAddress) values (".$self->session->db->quote($self->getId).",
|
||||
".$self->session->db->quote($answer).", ".$self->session->db->quote($userId).", '$ip')");
|
||||
my $self = shift;
|
||||
my $answer = shift;
|
||||
my $userId = shift;
|
||||
my $ip = shift;
|
||||
$self->session->db->write("insert into Poll_answer (assetId, answer, userId, ipAddress) values (?,?,?,?)",
|
||||
[$self->getId, $answer, $userId, $ip] );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue