Default Survey Question settings now save 100% of the answer configuration data. This will not affect previous Surveys, but allow new defaults to be more complex if desired.
This commit is contained in:
parent
7ea43faa3a
commit
99a1418714
4 changed files with 81 additions and 48 deletions
|
|
@ -1,4 +1,5 @@
|
|||
7.7.4
|
||||
- Default Survey Question bundles now store full answer information in json. Everything configured in an answer will be saved in a default configuration.
|
||||
|
||||
7.7.3
|
||||
- fixed #10094: double explanation in thread help
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use Getopt::Long;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
|
||||
use JSON;
|
||||
|
||||
my $toVersion = '7.7.4';
|
||||
my $quiet; # this line required
|
||||
|
|
@ -31,7 +31,7 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
|
||||
updateSurveyQuestionTypes($session);
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
|
|
@ -43,6 +43,65 @@ finish($session); # this line required
|
|||
# # and here's our code
|
||||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
sub updateSurveyQuestionTypes{
|
||||
my $session = shift;
|
||||
my $refs = $session->db->buildArrayRefOfHashRefs("SELECT * FROM Survey_questionTypes");
|
||||
for my $ref(@$refs){
|
||||
my $name = $ref->{questionType};
|
||||
my $params;
|
||||
my @texts = split/,/,$ref->{answers};
|
||||
#next if(@texts == 0);
|
||||
my $count = 0;
|
||||
for my $text(@texts){
|
||||
my $verbatim = 0;
|
||||
$verbatim = 1 if($text =~ /verbatim/);
|
||||
push(@$params,[$text,$count++,$verbatim]);
|
||||
}
|
||||
_loadValues($name,$params,$session);
|
||||
}
|
||||
}
|
||||
|
||||
sub _loadValues{
|
||||
my $name = shift;
|
||||
my $values = shift;
|
||||
my $session = shift;
|
||||
my $answers = [];
|
||||
for my $value(@$values){
|
||||
my $answer = _getAnswer();
|
||||
$answer->{text} = $value->[0];
|
||||
$answer->{recordedAnswer} = $value->[1];
|
||||
$answer->{verbatim} = $value->[2];
|
||||
push @$answers,$answer;
|
||||
}
|
||||
my $json = to_json($answers);
|
||||
$session->db->write("UPDATE Survey_questionTypes SET answers = ? WHERE questionType = ?",[$json,$name]);
|
||||
}
|
||||
|
||||
sub _getAnswer{
|
||||
my $answer = {
|
||||
text => q{},
|
||||
verbatim => 0,
|
||||
textCols => 10,
|
||||
textRows => 5,
|
||||
goto => q{},
|
||||
gotoExpression => q{},
|
||||
recordedAnswer => q{},
|
||||
isCorrect => 1,
|
||||
min => 1,
|
||||
max => 10,
|
||||
step => 1,
|
||||
value => 1,
|
||||
terminal => 0,
|
||||
terminalUrl => q{},
|
||||
type => 'answer'
|
||||
};
|
||||
return $answer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue