Survey: more bug fixes
Fixed invalid calendar markup so that Date question type works in IE Minor tweaks to ResponseJSON for more robustness Fixed Number question type javascript
This commit is contained in:
parent
3a25e806c6
commit
0ad26a1921
5 changed files with 69 additions and 48 deletions
Binary file not shown.
BIN
docs/upgrades/packages-7.7.7/survey.css.wgpkg
Normal file
BIN
docs/upgrades/packages-7.7.7/survey.css.wgpkg
Normal file
Binary file not shown.
|
|
@ -102,11 +102,11 @@ sub reset {
|
||||||
startTime => time(),
|
startTime => time(),
|
||||||
surveyOrder => undef,
|
surveyOrder => undef,
|
||||||
tags => {},
|
tags => {},
|
||||||
|
|
||||||
# And then data overrides
|
|
||||||
%{$data},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# And then data overrides (via a hash slice)
|
||||||
|
@{$self->{_response}}{keys %{$data}} = values %{$data};
|
||||||
|
|
||||||
# If first section is logical, process it immediately
|
# If first section is logical, process it immediately
|
||||||
$self->checkForLogicalSection;
|
$self->checkForLogicalSection;
|
||||||
return $self;
|
return $self;
|
||||||
|
|
@ -1141,6 +1141,15 @@ sub nextQuestions {
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# In rare cases where you change the structure of your survey after
|
||||||
|
# someone has already started a response, it's possible for this
|
||||||
|
# to be triggered, in which case the easiest course of action is
|
||||||
|
# to just skip over the question.
|
||||||
|
if (!$self->survey->question( $address )) {
|
||||||
|
$self->session->log->debug("Unable to retrieve question for address $sIndex-$qIndex");
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
# Make a safe copy of the question
|
# Make a safe copy of the question
|
||||||
my %questionCopy = %{$self->survey->question( $address )};
|
my %questionCopy = %{$self->survey->question( $address )};
|
||||||
|
|
||||||
|
|
@ -1190,7 +1199,10 @@ sub nextQuestions {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for my $aIndex ( aIndexes($address) ) {
|
for my $aIndex ( aIndexes($address) ) {
|
||||||
my %answerCopy = %{ $self->survey->answer( [ $sIndex, $qIndex, $aIndex ] ) };
|
my %answerCopy
|
||||||
|
= %{ $self->survey->answer( [ $sIndex, $qIndex, $aIndex ] )
|
||||||
|
|| $self->survey->newAnswer # in case the lookup fails, use a default answer
|
||||||
|
};
|
||||||
|
|
||||||
# Do text replacement
|
# Do text replacement
|
||||||
$answerCopy{text} = $self->getTemplatedText($answerCopy{text}, \%templateValues);
|
$answerCopy{text} = $self->getTemplatedText($answerCopy{text}, \%templateValues);
|
||||||
|
|
|
||||||
|
|
@ -133,9 +133,6 @@ sub run {
|
||||||
$self->session->db->write( 'delete from Survey_response where assetId = ? and userId = ?',
|
$self->session->db->write( 'delete from Survey_response where assetId = ? and userId = ?',
|
||||||
[ $self->getId, $self->session->user->userId() ] );
|
[ $self->getId, $self->session->user->userId() ] );
|
||||||
|
|
||||||
# disable cookies so that test code doesn't die
|
|
||||||
$survey->responseIdCookies(0);
|
|
||||||
|
|
||||||
# Start a response as current user
|
# Start a response as current user
|
||||||
my $responseId = $survey->responseId($self->session->user->userId)
|
my $responseId = $survey->responseId($self->session->user->userId)
|
||||||
or return { tap => "Bail Out! Unable to start survey response" };
|
or return { tap => "Bail Out! Unable to start survey response" };
|
||||||
|
|
@ -144,7 +141,6 @@ sub run {
|
||||||
my $rJSON = $survey->responseJSON
|
my $rJSON = $survey->responseJSON
|
||||||
or return { tap => "Bail Out! Unable to get responseJSON" };
|
or return { tap => "Bail Out! Unable to get responseJSON" };
|
||||||
|
|
||||||
my %validTargets = map { $_ => 1 } @{$survey->surveyJSON->getGotoTargets};
|
|
||||||
my $surveyOrder = $rJSON->surveyOrder;
|
my $surveyOrder = $rJSON->surveyOrder;
|
||||||
my $surveyOrderIndexByVariableName = $rJSON->surveyOrderIndexByVariableName;
|
my $surveyOrderIndexByVariableName = $rJSON->surveyOrderIndexByVariableName;
|
||||||
|
|
||||||
|
|
@ -371,28 +367,24 @@ sub _setup {
|
||||||
|
|
||||||
# Setup any fake data the user wants prior to the test
|
# Setup any fake data the user wants prior to the test
|
||||||
if ($setup && ref $setup eq 'HASH') {
|
if ($setup && ref $setup eq 'HASH') {
|
||||||
my %existingTags = %{$rJSON->tags};
|
|
||||||
|
|
||||||
# Process tags
|
# Process tags
|
||||||
# N.B. Make sure we add to existing tags instead of overwriting
|
my %tags;
|
||||||
if (ref $setup->{tag} eq 'HASH') {
|
if (ref $setup->{tag} eq 'HASH') {
|
||||||
# already a hash, so store it right away
|
%tags = %{$setup->{tag}};
|
||||||
$rJSON->tags( {%existingTags, %{$setup->{tag}} });
|
|
||||||
} elsif (ref $setup->{tag} eq 'ARRAY') {
|
} elsif (ref $setup->{tag} eq 'ARRAY') {
|
||||||
# turn array into hash before storing it
|
|
||||||
my $tags;
|
|
||||||
for my $tag (@{$setup->{tag}}) {
|
for my $tag (@{$setup->{tag}}) {
|
||||||
if (ref $tag eq 'HASH') {
|
if (ref $tag eq 'HASH') {
|
||||||
# Individual item is a single key/value hash
|
# Individual item is a single key/value hash
|
||||||
my ($key, $value) = %$tag;
|
my ($key, $value) = %$tag;
|
||||||
$tags->{$key} = $value;
|
$tags{$key} = $value;
|
||||||
} else {
|
} else {
|
||||||
# Individual item is a string, default to boolean truth flag
|
# Individual item is a string, default to boolean truth flag
|
||||||
$tags->{$tag} = 1; # default to 1
|
$tags{$tag} = 1; # default to 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rJSON->tags( {%existingTags, %$tags });
|
|
||||||
}
|
}
|
||||||
|
# N.B. Make sure we add to existing tags instead of overwriting
|
||||||
|
@{$rJSON->tags}{keys %tags} = values %tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,41 +187,58 @@ if (typeof Survey === "undefined") {
|
||||||
anim.animate();
|
anim.animate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function numberHandler(event, objs){
|
function numberHandler(event, objs){
|
||||||
|
|
||||||
var keycode = event.keyCode;
|
var keycode = event.keyCode;
|
||||||
var value = this.value;
|
var value = parseFloat(this.value, 10);
|
||||||
|
|
||||||
//if starting a negative number, don't do anything
|
// Keep a record of the original value entered
|
||||||
if(value == '' || value == "-"){return;}
|
var originalValue = value;
|
||||||
|
|
||||||
var step = objs.step ? objs.step : 1;
|
// Get the constraints
|
||||||
|
var min = parseFloat(objs.min, 10);
|
||||||
|
var max = parseFloat(objs.max, 10);
|
||||||
|
var step = parseFloat(objs.step, 10);
|
||||||
|
|
||||||
if(!value){this.value = objs.min ? objs.min : 0;}
|
// Response to up/down arrow keys
|
||||||
if(value % step > 0){
|
if (keycode == 38 || keycode == 40) {
|
||||||
this.value = +value + value % step;
|
// start at zero if we don't have a valid number
|
||||||
|
if (!YAHOO.lang.isNumber(value)) {
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default to 1 for increment steps
|
||||||
|
step = step ? step : 1;
|
||||||
|
|
||||||
|
if (keycode == 38){ // up
|
||||||
|
value += step;
|
||||||
|
}
|
||||||
|
if (keycode == 40){ // down
|
||||||
|
value -= step;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Apart from when we respond to up/down requests, if the input
|
||||||
|
// isn't a valid number it's best if we do nothing - the user
|
||||||
|
// might be half-way through entering something, and
|
||||||
|
// besides, validation will take care of it for us later
|
||||||
|
if (!YAHOO.lang.isNumber(value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(objs.min != '' && +value < +objs.min){
|
// Enforce max/min constraints
|
||||||
this.value = objs.min;
|
if (YAHOO.lang.isNumber(min) && value < min){
|
||||||
|
value = min;
|
||||||
|
}
|
||||||
|
if (YAHOO.lang.isNumber(max) && value > max){
|
||||||
|
value = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(objs.max != '' && +value > objs.max){this.value = objs.max;}
|
// Only modify the value if the new numeric value
|
||||||
else if(+keycode == 40){//key down
|
// is different from the original parsed value
|
||||||
if(objs.min == ''){
|
// (so that "0.000" doesn't get turned into "0" etc..)
|
||||||
this.value = value - step;
|
if (value != originalValue) {
|
||||||
}
|
this.value = value;
|
||||||
else if((value - step) >= +objs.min){
|
|
||||||
this.value = value - step;
|
|
||||||
}
|
|
||||||
}else if(+keycode == 38){//key up
|
|
||||||
if(objs.max == ''){
|
|
||||||
this.value = value + step;
|
|
||||||
}
|
|
||||||
if(value + step <= objs.max){
|
|
||||||
this.value = value + step;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -733,7 +750,7 @@ if (typeof Survey === "undefined") {
|
||||||
if (toValidate[q.id]) {
|
if (toValidate[q.id]) {
|
||||||
toValidate[q.id].answers[q.answers[x1].id] = {'min':q.answers[x1].min,'max':q.answers[x1].max,'step':q.answers[x1].step};
|
toValidate[q.id].answers[q.answers[x1].id] = {'min':q.answers[x1].min,'max':q.answers[x1].max,'step':q.answers[x1].step};
|
||||||
}
|
}
|
||||||
YAHOO.util.Event.addListener(q.answers[x1].id, "keyup", numberHandler, q.answers[x1]);
|
YAHOO.util.Event.addListener(q.answers[x1].id, "keydown", numberHandler, q.answers[x1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue