Login Form

#125 – BF Survey Plus Statistics Page: Error calculating _OTHER_ Stats

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.
Monday, 10 February 2014 16:15 AEDT
Joomla! version: 2.5.16

In the Stats page for my survey I have noticed the numbers for the _other_ option are incorrect (see image).

It looks like the count for the _other_ option is actually the total count.

In this example the count for _other_ should be 9.

I imagine this is just a simple calculation error in the program, could you please advise a fix.

Monday, 10 February 2014 22:41 AEDT 120'
Everything Bundle, BF Quiz Plus 3 Years, BF Survey 12 Months
Hi Dean,
I've been able to reproduce this on my test site and confirm there is a bug. There are actually two issues, firstly the default mutlipage view was storing _OTHER_ in the results table rather than the additional text typed in by the user. Secondly, there was an issue with the query that obtained the stats for the _OTHER_ option. Both issues are hopefully now fixed in v1.1.15, can you please try this new version and let me know if you still have an issue.


Follow us on twitter http://twitter.com/tamlynsoftware
Wednesday, 12 February 2014 11:24 AEDT
Hey Tim,

I have installed the new version on my test site and the calculation has changed but it is still incorrect (see image)

The actual figures are;

News Bulletin = 118 (BF Survey correct)
NSW Dentist = 31 (BF Survey correct)
Online Comms = 55 (BF Survey correct)
Word of mouth = 11 (BF Survey correct)
Other = 11 ((BF Survey incorrect)
TOTAL = 226 (BF Survey incorrect)

Any ideas where the miscalculation is?

Wednesday, 12 February 2014 21:20 AEDT 20'
Everything Bundle, BF Quiz Plus 3 Years, BF Survey 12 Months
Hi Dean,
If you look in the file /components/com_bfsurvey_plus/controller.php in the getStatsOther function, you will see how this is calculated. Since the actual text typed in is stored in the database, each time this is typed it is going to be different, so we can't create a query to match this. We get round the problem by counting all the other options and determine what is left, which must be _OTHER_. There is also the assumption that the question is mandatory so at least one of the options is always selected.

Firstly on line 723, you can see how it is determining the total by counting the rows in your answer table.
$total = count($rows);

Then on line 739, you can see where it loops through the options in the question. The query looks for each option, for example "News Bulletin", and counts how many rows in the answer table contain this value. We then add this to the count variable.
//line 755

Then after all the options, we take the total and subtract the count to get the value of the _OTHER_ option.
$num = $total-$count;

So based on your screenshot, I would have expected the _OTHER_ total would be:
215 - 118 - 31 - 55 - 11 = 0
Which is different again to what you are getting and what you are expecting.

The first thing to determine is why are you getting a total of 215 instead of 226? Is there actually 226 records in your answer table? Then we need to determine why it shows -19 for the total. I'm wondering if blank options are being counted multiple times and being deducted from the total.

You could possibly debug by adding a few lines to the function:
echo "<br>DEBUG: query=".$query;
//add just before
$db->setQuery( $query);

You should then see the query outputted by the software, which you can test on your mySQL database using phpMyAdmin and see if you are getting the result you expected.

I'm wondering if the query needs something to check to make sure that the response is not blank, maybe something like:
$query->where( $db->quote(JString::trim($db->escape( $qn->$tempoption, true ))) );


Follow us on twitter http://twitter.com/tamlynsoftware
Tuesday, 18 February 2014 10:41 AEDT
Ah okay, the assumption made is incorrect - I haven't got this question set up as mandatory so yes there will be blanks in the database.

Yes there are 226 records in the database.

I will pass this over to my php guy to have a look.

Wednesday, 12 March 2014 16:15 AEDT
Hi Tim,

My web developer has been away so I have had no luck fixing this calculation error. Could you possibly suggest a solution where you don't assume the question is mandatory?

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