Skip to content
Permalink
Browse files

Only export custom choice types for the Survey, and only the ones tha…

…t are used by this Survey.
  • Loading branch information...
perlDreamer committed Nov 22, 2011
1 parent 9d2bcd2 commit 626011a8502dd3e3ab29f8ad8f75932336571494
Showing with 6 additions and 2 deletions.
  1. +4 −2 lib/WebGUI/Asset/Wobject/Survey.pm
  2. +2 −0 t/Asset/Wobject/Survey/package.t
@@ -2466,10 +2466,12 @@ sub exportAssetData {
my $self = shift;
my $asset_data = $self->SUPER::exportAssetData();
my $questions = $self->surveyJSON->questions();
my %question_types = ();
my $get_question = $self->session->db->prepare('select answers from Survey_questionTypes where questionType=?');
my $multiple_choice = $self->surveyJSON->multipleChoiceTypes();
my %question_types = ();
my $get_question = $self->session->db->prepare('select answers from Survey_questionTypes where questionType=?');
foreach my $question (@{ $questions }) {
my $type = $question->{questionType};
next unless $multiple_choice->{$type};
next if $question_types{$type};
$get_question->execute([$type]);
my ($answers) = $get_question->array();
@@ -38,6 +38,7 @@ $sJSON->update([0,0], { variable => 'toes', questionType => 'Multiple Choice' })
$sJSON->update([0,0,0], { text => 'one',});
$sJSON->update([0,0,1], { text => 'two',});
$sJSON->update([0,0,2], { text => 'more than two',});
$sJSON->update([0,1], { variable => 'name', questionType => 'Text' });

$survey->persistSurveyJSON;

@@ -47,6 +48,7 @@ my $asset_data = $survey->exportAssetData();

ok exists $asset_data->{question_types}, 'question_types entry exists in asset data to package';
ok exists $asset_data->{question_types}->{toes}, 'the toes type in a question type';
ok !exists $asset_data->{question_types}->{name}, 'name question not in question types';

$asset_data->{question_types}->{fingers} = clone $asset_data->{question_types}->{toes};

0 comments on commit 626011a

Please sign in to comment.
You can’t perform that action at this time.