Moved multiple choice questions to the data base, and they can now be edited globally from the Survey edito
This commit is contained in:
parent
d0c032625a
commit
046dae4f31
5 changed files with 157 additions and 77 deletions
|
|
@ -195,6 +195,10 @@ sub definition {
|
|||
},
|
||||
);
|
||||
|
||||
#my $defaultMC = $session->
|
||||
|
||||
#%properties = ();
|
||||
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'survey.gif',
|
||||
|
|
@ -412,6 +416,10 @@ sub www_submitObjectEdit {
|
|||
}
|
||||
elsif ( $params->{copy} ) {
|
||||
return $self->copyObject( \@address );
|
||||
}elsif( $params->{removetype} ){
|
||||
return $self->removeType(\@address);
|
||||
}elsif( $params->{addtype} ){
|
||||
return $self->addType($params->{addtype},\@address);
|
||||
}
|
||||
|
||||
# Update the addressed object
|
||||
|
|
@ -493,6 +501,27 @@ sub www_jumpTo {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub removeType{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
$self->surveyJSON->removeType($address);
|
||||
return $self->www_loadSurvey( { address => $address } );
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub addType{
|
||||
my $self = shift;
|
||||
my $name = shift;
|
||||
my $address = shift;
|
||||
$self->surveyJSON->addType($name,$address);
|
||||
$self->persistSurveyJSON();
|
||||
return $self->www_loadSurvey( { address => $address } );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 copyObject ( )
|
||||
|
||||
Takes the address of a survey object and creates a copy. The copy is placed at the end of this object's parent's list.
|
||||
|
|
@ -1208,13 +1237,13 @@ Sends the processed template and questions structure to the client
|
|||
|
||||
sub prepareShowSurveyTemplate {
|
||||
my ( $self, $section, $questions ) = @_;
|
||||
my %multipleChoice = (
|
||||
'Multiple Choice', 1, 'Gender', 1, 'Yes/No', 1, 'True/False', 1, 'Ideology', 1,
|
||||
'Race', 1, 'Party', 1, 'Education', 1, 'Scale', 1, 'Agree/Disagree', 1,
|
||||
'Oppose/Support', 1, 'Importance', 1, 'Likelihood', 1, 'Certainty', 1, 'Satisfaction', 1,
|
||||
'Confidence', 1, 'Effectiveness', 1, 'Concern', 1, 'Risk', 1, 'Threat', 1,
|
||||
'Security', 1
|
||||
);
|
||||
# my %multipleChoice = (
|
||||
# 'Multiple Choice', 1, 'Gender', 1, 'Yes/No', 1, 'True/False', 1, 'Ideology', 1,
|
||||
# 'Race', 1, 'Party', 1, 'Education', 1, 'Scale', 1, 'Agree/Disagree', 1,
|
||||
# 'Oppose/Support', 1, 'Importance', 1, 'Likelihood', 1, 'Certainty', 1, 'Satisfaction', 1,
|
||||
# 'Confidence', 1, 'Effectiveness', 1, 'Concern', 1, 'Risk', 1, 'Threat', 1,
|
||||
# 'Security', 1
|
||||
# );
|
||||
my %textArea = ( 'TextArea', 1 );
|
||||
my %text = ( 'Text', 1, 'Email', 1, 'Phone Number', 1, 'Text Date', 1, 'Currency', 1 );
|
||||
my %slider = ( 'Slider', 1, 'Dual Slider - Range', 1, 'Multi Slider - Allocate', 1 );
|
||||
|
|
@ -1222,14 +1251,13 @@ sub prepareShowSurveyTemplate {
|
|||
my %dateShort = ( 'Year Month', 1 );
|
||||
my %fileUpload = ( 'File Upload', 1 );
|
||||
my %hidden = ( 'Hidden', 1 );
|
||||
use Data::Dumper;
|
||||
|
||||
foreach my $q (@$questions) {
|
||||
if ( $fileUpload{ $q->{questionType} } ) { $q->{fileLoader} = 1; }
|
||||
elsif ( $text{ $q->{questionType} } ) { $q->{textType} = 1; }
|
||||
elsif ( $textArea{ $q->{questionType} } ) { $q->{textAreaType} = 1; }
|
||||
elsif ( $hidden{ $q->{questionType} } ) { $q->{hidden} = 1; }
|
||||
elsif ( $multipleChoice{ $q->{questionType} } ) {
|
||||
elsif ( $self->surveyJSON->multipleChoiceTypes->{ $q->{questionType} } ) {
|
||||
$q->{multipleChoice} = 1;
|
||||
if ( $q->{maxAnswers} > 1 ) {
|
||||
$q->{maxMoreOne} = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue