added Survey Number type. Text number entry that uses slider restrictions as constraints (server and client side). You can also use the arrow keys
to increment or decrement the number enter.
This commit is contained in:
parent
d47f5e1886
commit
9df02396b7
3 changed files with 38 additions and 4 deletions
|
|
@ -29,7 +29,8 @@
|
|||
- Replaced the tax system with a pluggable one. Included are a Generic plugin
|
||||
(which works the same as the old system) and a plugin for EU merchants ( Martin Kamerbeek / Oqapi )
|
||||
- fixed #10213: RssFeed aspect now checks canView and gives HTTP Basic Auth box to login
|
||||
|
||||
- added Survey Number type. Text number entry that uses slider restrictions as constraints (server and client side). You can also use the arrow keys
|
||||
to increment or decrement the number enter.:q
|
||||
7.7.3
|
||||
- fixed #10094: double explanation in thread help
|
||||
- rfe #9612: Carousel Wobject (was Widget Wobject) (SDH Consulting Group)
|
||||
|
|
|
|||
|
|
@ -529,6 +529,15 @@ sub recordResponses {
|
|||
|
||||
# Proceed if we're satisfied that the submitted answer response is valid..
|
||||
if ( defined $submittedAnswerResponse && $submittedAnswerResponse =~ /\S/ ) {
|
||||
|
||||
#Validate answers met question criteria
|
||||
if($question->{questionType} eq 'Number'){
|
||||
if($submittedAnswerResponse > $answer->{max} or $submittedAnswerResponse < $answer->{min} or
|
||||
$submittedAnswerResponse % $answer->{step} != 0){
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
$aAnswered = 1;
|
||||
|
||||
# Now, decide what to record. For multi-choice questions, use recordedAnswer.
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ if (typeof Survey === "undefined") {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (toValidate[i].type === 'Year Month') {
|
||||
answered = 1;//set to true, then let a single failure set it back to false.
|
||||
|
|
@ -191,6 +192,26 @@ if (typeof Survey === "undefined") {
|
|||
}
|
||||
}
|
||||
|
||||
function numberHandler(event, objs){
|
||||
|
||||
var keycode = event.keyCode;
|
||||
var value = parseFloat(this.value);
|
||||
if(!value){this.value = objs.min;}
|
||||
if(value % objs.step > 0){this.value = value*1 + value % objs.step;}
|
||||
|
||||
if(value < objs.min){this.value = objs.min;}
|
||||
else if(value > objs.max){this.value = objs.max;}
|
||||
else if(keycode == 40){//key down
|
||||
if((value - objs.step) >= objs.min){
|
||||
this.value = value - objs.step;
|
||||
}
|
||||
}else if(keycode == 38){//key up
|
||||
if(((value*1) + (objs.step*1)) <= objs.max){
|
||||
this.value = (value*1) + (objs.step*1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sliderTextSet(event, objs){
|
||||
this.value = this.value * 1;
|
||||
this.value = YAHOO.lang.isValue(this.value) ? this.value : 0;
|
||||
|
|
@ -622,12 +643,15 @@ if (typeof Survey === "undefined") {
|
|||
continue;
|
||||
}
|
||||
if (NUMBER_TYPES[q.questionType]) {
|
||||
if (toValidate[q.id]) {
|
||||
toValidate[q.id].answers[q.answers[x].id] = {'min':q.answers[x].min,'max':q.answers[x].max,'step':q.answers[x].step};
|
||||
for (var x in q.answers) {
|
||||
if (toValidate[q.id]) {
|
||||
toValidate[q.id].answers[q.answers[x].id] = {'min':q.answers[x].min,'max':q.answers[x].max,'step':q.answers[x].step};
|
||||
}
|
||||
YAHOO.util.Event.addListener(q.answers[x].id, "keyup", numberHandler, q.answers[x]);
|
||||
document.getElementById(q.answers[x].id).value = q.answers[x].min;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Must be a multi-choice bundle
|
||||
var butts = [];
|
||||
verb = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue