Only export custom choice types for the Survey, and only the ones that are used by this Survey.
This commit is contained in:
parent
9d2bcd282b
commit
626011a850
2 changed files with 6 additions and 2 deletions
|
|
@ -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};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue