Login Form

#129 – Summation issues

Posted in ‘BF Survey’
This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Friday, 14 February 2014 07:56 AEDT
azjoe
(Joomla 3.2.2, BFSurvey 1.1.15, ValidatPlus plugin installed and enabled) The "Total" field does not appear on a Summation type Question Setup screen as shown in the User's manual... where does one enter that info? I have tried re-installing, etc. I don't even see a "Total" field in the BFSurvey_plus table in the database. What am I missing?

...joe
Friday, 14 February 2014 12:08 AEDT
azjoe
Addendum... I guess I found the field I was looking for in the Advanced tab. It makes the counting in the survey work but there doesn't seem to be sufficient validation... ie, if my entries add up to more/less than the specified number I can still submit. This cannot be used for an election of candidates survey if a user can submit a summation series which adds to more than the number of votes specified. How do I fix this?
Friday, 14 February 2014 19:29 AEDT 5'
Tim
Everything Bundle, BF Quiz Plus 3 Years, BF Survey 12 Months
For the benefit of others reading this, here is the documentation for the summation field, and as you found the total field is located on the advanced tab in Joomla 3.
http://www.tamlynsoftware.com/products/bf-survey-plus/bf-survey-plus-user-guide/summation.html

With regards to validation, there isn't currently any validation in BF Validate Plus that handles the summation question type. It would be possible to write some a custom handler that ensures that all points have been distributed:
http://docs.joomla.org/Client-side_form_validation

If I have time over the weekend, I'll give it a go and see what is possible.

regards

Tim
Follow us on twitter http://twitter.com/tamlynsoftware
Saturday, 15 February 2014 01:53 AEDT
azjoe
Thanks for the quick response Tim. At the minimum, if there was a check in the submit button click logic to ignore the click if the 'amount left to distribute' field didn't equal zero would solve my problem.... I could just add verbiage in the instructions ("Help Text" field) to instruct the user that they can't submit their vote if the field doesn't equal zero. In the general case I guess the check should be an option configured as part of the new question logic and a fully robust solution would need verbiage on the form to inform the user why the submit button isn't enabled, etc. ...joe
Friday, 28 February 2014 06:53 AEDT
azjoe
Hi Tim,
Any progress on this yet?
Thursday, 13 March 2014 22:47 AEDT 30'
Tim
Everything Bundle, BF Quiz Plus 3 Years, BF Survey 12 Months
Hi Joe,
Sorry for the delay, I've been very busy and have only just taken another look at this now. Here is one solution that might work for you.

Assuming you are using the default mutlipage view, create the file:
/components/com_bfsurvey_plus/views/bfsurveyplus/tmpl/custom-validation.js

window.addEvent('domready', function()
{
document.formvalidator.setHandler('summation', function(value)
{
//summation must equal zero
regex = /\b0\b/;
return regex.test(value);
});
});


Now edit the view file, in this case:
/components/com_bfsurvey_plus/views/bfsurveyplus/tmpl/default.php

line 1087, add in class='validate-summation'
//change to
echo "<tr><td></td><td><input id='total".$summation_counter."' name='total' value='".$total."' class='validate-summation' size='5' READONLY></td></tr>";


/components/com_bfsurvey_plus/views/bfsurveyplus/tmpl/default.php
//around line 550, add the following (anywhere after the formvalidation loads)

$document = JFactory::getDocument();
$document->addScript(JURI::root() . "/components/com_bfsurvey_plus/views/bfsurveyplus/tmpl/custom-validation.js");



Basically this just adds a custom validation (using JQuery), which checks to make sure the total field equals 0, which means that all the points have been distributed. Try it out and let me know how you go.

regards

Tim
Follow us on twitter http://twitter.com/tamlynsoftware
Wednesday, 19 March 2014 01:26 AEDT
azjoe
Tim... Thank you very much. Your solution solves my immediate problem. ...joe
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.
Go to top