Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 626011a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/WebGUI/Asset/Wobject/Survey.pm
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions t/Asset/Wobject/Survey/package.t
Expand Up @@ -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;

Expand All @@ -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};

Expand Down

0 comments on commit 626011a

Please sign in to comment.