Skip to content

Commit 626011a

Browse files
committedNov 22, 2011
Only export custom choice types for the Survey, and only the ones that are used by this Survey.
1 parent 9d2bcd2 commit 626011a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎lib/WebGUI/Asset/Wobject/Survey.pm

+4-2
Original file line numberDiff line numberDiff line change
@@ -2466,10 +2466,12 @@ sub exportAssetData {
24662466
my $self = shift;
24672467
my $asset_data = $self->SUPER::exportAssetData();
24682468
my $questions = $self->surveyJSON->questions();
2469-
my %question_types = ();
2470-
my $get_question = $self->session->db->prepare('select answers from Survey_questionTypes where questionType=?');
2469+
my $multiple_choice = $self->surveyJSON->multipleChoiceTypes();
2470+
my %question_types = ();
2471+
my $get_question = $self->session->db->prepare('select answers from Survey_questionTypes where questionType=?');
24712472
foreach my $question (@{ $questions }) {
24722473
my $type = $question->{questionType};
2474+
next unless $multiple_choice->{$type};
24732475
next if $question_types{$type};
24742476
$get_question->execute([$type]);
24752477
my ($answers) = $get_question->array();

‎t/Asset/Wobject/Survey/package.t

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ $sJSON->update([0,0], { variable => 'toes', questionType => 'Multiple Choice' })
3838
$sJSON->update([0,0,0], { text => 'one',});
3939
$sJSON->update([0,0,1], { text => 'two',});
4040
$sJSON->update([0,0,2], { text => 'more than two',});
41+
$sJSON->update([0,1], { variable => 'name', questionType => 'Text' });
4142

4243
$survey->persistSurveyJSON;
4344

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.