Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 15    Views: 93

AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
08/14/14 04:33 AM (10 years ago)

Quiz Script Help please

I'm looking at implementing the David Book script http://www.buzztouch.com/docs/v1.5/sample-scoreboard.txt for an Android/Apple quiz I am working on. I trawled the forum looking for how this should be done but I am struggling, so I wanted to reach out to anyone who has worked this out for themselves - I need a pointer or two please. I understand the general steps are : 1) To get the script working, create the database table described in the script on a server that supports mysql, add the passwords, user name etc and then load the script onto a server. 2) Add a URL under "Quiz Send Results to URL" such as : http://www.myserver.com/appdb/rcscores.php?command=getQuizScoreboardData&appGuid=[buzztouchAppId]&apiKey=[buzztouchAPIKey]&screenId=[screenId]&deviceModel=[deviceModel]&deviceLatitude=[deviceLatitude]&deviceLongitude=[deviceLongitude]&totalPoints=[totalPoints]&totalSeconds=[totalSeconds]&numberOfQuestions=[numberOfQuestions]&numberCorrect=[numberCorrect]&numberIncorrect=[numberIncorrect] 3) Create a screen of type customurl called something like 'results' and in "Quiz Scoring, Finish Options" add that screen as the "Finished Screen Nickname". I have assigned the same URL as above to this plugin. So, my questions are Am I on the right path? Has anone had it working? My problems so far I don't seem to be able to get any results into the database. As a test, I am pasting http://www.myserver.com/appdb/rcscores.php?command=getQuizScoreboardData&appGuid=12345&apiKey=12345&screenId=12345&deviceModel=iphone&deviceLatitude=50.000&deviceLongitude=-6.000 to try and get a value into the database. No errors, but also no rows added. I can't visualise how the results would look or if my approach is correct. If anyone has anything I could use as an example, or any suggestions, I would be very grateful. Thanks in advance, Alan
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
08/14/14 04:57 AM (10 years ago)
Did you try doing a PHP echo to see if your script is receiving and parsing the values properly? print_r is another good command for investigating values of PHP arrays. -- Niraj
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/14/14 05:04 AM (10 years ago)
Hi @Niraj, on a scale of one to 10, my php skills are close to zero. I'll do some research, unless you know what I need to do?
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
08/14/14 05:25 AM (10 years ago)
Try this tutorial http://myphpform.com/validating-forms.php Instead of "yourname", "likeit", and "comments" you would use your variable names such as "totalPoints", "totalSeconds", etc. That will help you gain insight into the question of "What information am I passing from the app to the server?" -- Niraj
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/14/14 07:28 AM (10 years ago)
Hi Niraj, I modified my test send url to be http://www.myscore.com/appdb/rcscores.php?command=getQuizScoreboardData&appGuid=12345&apiKey=12345&screenId=12345&deviceModel=iphone&deviceLatitude=50.000&deviceLongitude=6.000&totalPoints=[9]&totalSeconds=[60]&numberOfQuestions=[10]&numberCorrect=[9]&numberIncorrect=[1]&screenId=[QuizScreen]&deviceModel=[iPhone]&userDisplayName=[Alan] And I used Echo in the php file to reflect that these values are being passed in. A baby step. I thenn used myphp to browse the database and I still see "MySQL returned an empty result set (i.e. zero rows). (Query took 0.0098 sec)"
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
08/14/14 07:51 AM (10 years ago)
In the PHP script, put echo statements to see the SQL statement in these functions: - fnExecuteNonQuery - fnDbGetResult More baby steps! :-) -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
08/14/14 07:51 AM (10 years ago)
In the PHP script, put echo statements to see the SQL statement in these functions: - fnExecuteNonQuery - fnDbGetResult More baby steps! :-) -- Niraj
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/14/14 10:06 AM (10 years ago)
Hmm, made the changes and my script stopped echoing altogether. Undid the changes, still no echo. Started again. went back to what I thought worked before, but it doesn't work now. Its been a long day...
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/14/14 08:50 PM (10 years ago)
Keep in mind that those functions Niraj mentions, are "BT" functions; functions that David coded into the BT Backend of the self hosted server to do common tasks. It's easier to use what's already there (if you know what's there) but... you also have to include a BT authentication code so that everything works together. Not a big deal, but something to remember. If you need a sample to look at, check out the 'SmugCopy' script that Mr. David and I created a while back... Specifically, the 'index.php' file which incorporates all of the BT stuff, and then includes our script from within. You'll find your testing will go smoother if you 'encapsulate' it within the 'BT environment'. http://www.smugwimp.com/btMods/smugcopy.zip Yell if you have specific questions. Cheers! -- Smug
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/15/14 01:45 AM (10 years ago)
Hi Smug, I looked at the file, thank you. I am really struggling with this one and I can't find documentation, so any examples are gratefully received. I had difficulty understanding the code, and I could not see how this is connected to the quiz plugin. My understanding of the quiz scoreboard php script is that it runs stand-alone and is not connected to the self hosted setup. Am I wrong?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/15/14 01:50 AM (10 years ago)
I have no idea, let me take a look at the quiz script. I may have spoken prematurely. Cheers! -- Smug
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/15/14 02:00 AM (10 years ago)
Nifty script. So, for the moment, you probably have everything installed correctly, and as long as you plugged in the DB authentication credentials. The only thing I noticed is in your query, you're trying to use the command 'getQuizScoreBoardData', but in the script, it doesn't account for upper or lower case; it *must* be GETQUIZSCOREBOARDDATA. Try that and see if it works better. Cheers! -- Smug
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/15/14 02:33 AM (10 years ago)
Hi Smug, appreciate the help. The nifty script was authored by David Book, I'm just trying to figure out how to use it. Yesterday I had echo working, today, nothing echo's at all. I started to use GETQUIZSCOREBOARDDATA. My initial test is to simply pass the test string in a browser. My example test string http://www.mydomain.com/appdb/scores_echo.php?command=GETQUIZSCOREBOARDDATA&appGuid=12345&apiKey=12345&screenId=12345 gives me a blank screen. If I send http://wwwm.mydomain.com/appdb/scores_echo.php with no parameters, I do see the error {"invalid":"request"} which means the php is loaded. My echo statements don't seem to work in the script no matter where I put them. They did yesterday, then I broke something. They are as follows: echo "Values Passed in : "; echo " Total Points: "; echo $appVars["totalPoints"]; echo " Total Seconds: "; echo $appVars["totalSeconds"]; echo " Total Questions: "; echo $appVars["numberQuestions"]; echo " Incorrect: ";
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/15/14 03:52 AM (10 years ago)
Usually, when the screen returns blank, there's a problem with PHP, usually syntax. A missing or extra quote, semi-colon, who knows... Try running the script through a php validator (such as can be found at http://phpcodechecker.com) and it might discover what part of your code might be tripping. If that doesn't work, send me copy of your script and I'll see what's not working right. Cheers! -- Smug
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/15/14 04:16 AM (10 years ago)
Thanks Smug, did that, script seems OK. Then I moved the echo statements around, now they show in some places. I'll happily send you the script and I really appreciate the help. Cheers, Alan
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/15/14 04:22 AM (10 years ago)
smugwimp at smugwimp dot com, make sure the subject line has something distinct in it. Cheers! -- Smug
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.