From 626011a8502dd3e3ab29f8ad8f75932336571494 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 22 Nov 2011 09:02:10 -0800 Subject: [PATCH] Only export custom choice types for the Survey, and only the ones that are used by this Survey. --- lib/WebGUI/Asset/Wobject/Survey.pm | 6 ++++-- t/Asset/Wobject/Survey/package.t | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index aa32d3371..438f8f067 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -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(); diff --git a/t/Asset/Wobject/Survey/package.t b/t/Asset/Wobject/Survey/package.t index 40b79232a..be86d9c2f 100644 --- a/t/Asset/Wobject/Survey/package.t +++ b/t/Asset/Wobject/Survey/package.t @@ -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};