webgui/lib/WebGUI/Asset/Wobject/Survey/AnswerJSON.pm

55 lines
1.2 KiB
Perl

package WebGUI::Asset::Wobject::Survey::AnswerJSON;
use strict;
use Data::Structure::Util qw/unbless/;
sub new{
my $class = shift;
my $parent = shift;
my $self = shift || {};
$self->{answers} = $self->{answers} || [];
$self->{text};
$self->{index};
$self->{parentIndex};
$self->{parent} = $parent;
$self->{verbatim};
$self->{textCols};
$self->{textRows};
$self->{gotoQuestion};
$self->{recordedAnswer};
$self->{isCorrect};
$self->{min};
$self->{max};
$self->{step};
$self->{value};
$self->{terminal};
$self->{terminalUrl};
bless($self,$class);
return $self;
}
sub update{
my ($self,$ref) = @_;
while(my ($key,$value) = keys %{$ref->{object}}){
$self->{$key} = $value;
}
}
sub remove{
my $self = shift;
$self->{parent} = undef;
}
sub freeze{
my $self = shift;
my %temp = %{$self};
$temp{parent} = undef;
# unbless $self;
return \%temp;
}
#address is the array of objects currently selected in the edit screen
#data is the array of hash items for displaying
sub getDragDropList{
my ($self,$data,$address,$selected) = @_;
push(@$data, { "type","answer","text",$self->{"text"}, "recorded", $self->{'recordedAnswer'} });
}
1;