Debugging Our Computer Science Trivia Feature

Only a few days after I coded this new feature from scratch, we are seeing over 3000 entries in the database from members (mostly guests) playing CS trivia.

I have spend a lot of time coding this (from scratch) and testing the API. From the logs, it seems to have an API bug which appears about 5 times or less per thousand impressions, but I am not sure.

The bug seems to happen when there is some issue where the answer to a question in the Javascript is blank (on rare occasion) or there is a problem with the AJAX XHR request based on a network issue.

I have written a lot of "error trapping" code today to try to see exactly what causes this small bug.

If anyone sees any CS trivia statement and their T/F answer seems wrong, the issue is more-than-likely related to this rare bug, but then again, it could be a typo in the DB (or some strange HTML entity which was not encoded and decoded properly). So, if you do see anything which seems ODD, please take a screenshot of your screen and post it back here.

If you are a savvy at web dev, you can help out by opening your web dev console and inspecting the Javascript console and the Network XHR request and responses (and take a screen shot of any console errors and the XHR request / response).

Either way, if anyone want to help debug the API during the testing phase, the best way to debug is to answer a lot of questions, push NEXT and answer more. I have done this for the past two days for countless hours and I think I have trapped most network and AJAX issues, but I am sure there are more bugs, as there are always bugs in new code, without exception.

Please note that today one user from the Philippines answered over 100 questions. A lot of people worldwide are finding good value with this new feature so you can help me and help others by helping debug, so I can make sure all errors are trapped.

Thanks for help debugging.

Cheers!

Note: Code and other special chars must be encoded before they are submitted to the DB (for DB integrity) and I have written some special code to decode the HTML entities (in JS) but there are some occasional HTML entities (encodings) which are not decoded properly. If you see any of the HTML entities still encoded, please take a screen shot and post back so I can trap those and decode them as well. If you do not know what an HTML entity is, I have screen shots I can share :slight_smile:

Here is any example (see screenshot) of an encode HTML entity which I trapped and decoded (in a custom JS function I wrote) yesterday:

&ndash

However, I don't think these occasional encoded HTML entities are causing the rare bug where the correct answer to a T/F statement is null, causing some rare problem I have am still debugging.

Cheers.

OBTW,

I am logging every request and response..... and so far, so good.

I would like to remind everyone that I started coding this from SCRATCH on October 27th. Today is November 1st.

If anyone here can code a new feature so quickly in PHP, HTML and Javascript including building the DB, all the XHR calls, debug the APIs, and create over 600 good CS trivia questions, and a the same time insuring the API is secure, please do so now :slight_smile:

Otherwise.... kindly help me debug by answering a lot of questions, click next, answer more, taking screenshots of any issues you might encounter and if you can use the Web Dev console, please do so!

:slight_smile:

Current user interactions (which is much higher than I anticipated when I started coding this a few days ago):

mysql> select count(*) from neo_trivia_scoreboard;
+----------+
| count(*) |
+----------+
|     3048 |
+----------+
1 row in set (0.00 sec)

Size of CS trivia DB as of right now:

mysql> select count(*) from neo_open_trivia;
+----------+
| count(*) |
+----------+
|      625 |
+----------+
1 row in set (0.00 sec)

On a specific question note (318) ....

mysql> select * from neo_open_trivia where id = 318;
+-----+----------+---------+------------+--------------------------+----------------+-------------------+-----------+----------------+------------------+------------------+----------------+--------------------+
| id  | category | type    | difficulty | question                 | correct_answer | incorrect_answers | validated | time_validated | userid_validated | userid_submitted | time_submitted | time_last_modified |
+-----+----------+---------+------------+--------------------------+----------------+-------------------+-----------+----------------+------------------+------------------+----------------+--------------------+
| 318 |       18 | boolean | easy       | MacOS is based on Linux. | False          | True              |         0 |     1572497150 |                0 |                1 |     1572151119 |         1572151119 |
+-----+----------+---------+------------+--------------------------+----------------+-------------------+-----------+----------------+------------------+------------------+----------------+--------------------+
1 row in set (0.00 sec)

A user got a wrong answer and it was not recorded (submitted) to the DB (this error was due to a bug in the browser, not in the DB):

mysql> select uid,results from neo_trivia_scoreboard where trivia_id = 318;
+-----+---------+
| uid | results |
+-----+---------+
|   0 | right   |
|   0 | right   |
|   0 | right   |
|   0 | right   |
|   0 | right   |
|   0 | right   |
|   0 | right   |
|   0 | right   |
+-----+---------+
8 rows in set (0.00 sec)

So, I am pretty sure there is still a small bug somewhere which is causing some rare errors, so I am logging every request at this time, debugging.

Javascript must be enabled in order to work properly. If your browser is blocking JS, you will get wrong answers (errors) because the app needs JS to work properly and I have not written any code yet to check for JS, etc, and block users from trivia who have JS disabled or their browser is blocking JS.

Also regarding id: 318:

 grep 318 *

neo_trivia_api_debug.log:source: unix {"response_code":0,"id":318,"results":[{"category":"Science: Computers","type":"boolean","difficulty":"easy","question":"MacOS is based on Linux.","correct_answer":"False","incorrect_answers":["True"]}]}: {"response_code":0,"id":318,"results":[{"category":"Science: Computers","type":"boolean","difficulty":"easy","question":"MacOS is based on Linux.","correct_answer":"False","incorrect_answers":["True"]}]} api: https://www.unix.com/trivia/api.php
neo_trivia_api_debug.log:source: unix {"response_code":0,"id":318,"results":[{"category":"Science: Computers","type":"boolean","difficulty":"easy","question":"MacOS is based on Linux.","correct_answer":"False","incorrect_answers":["True"]}]}: {"response_code":0,"id":318,"results":[{"category":"Science: Computers","type":"boolean","difficulty":"easy","question":"MacOS is based on Linux.","correct_answer":"False","incorrect_answers":["True"]}]} api: https://www.unix.com/trivia/api.php
neo_trivia_api_debug.log:source: unix trivia: {"response_code":0,"id":318,"results":[{"category":"Science: Computers","type":"boolean","difficulty":"easy","question":"MacOS is based on Linux.","correct_answer":"False","incorrect_answers":["True"]}]} api: https://www.unix.com/trivia/api.php
neo_trivia_api_debug.log:source: unix trivia: {"response_code":0,"id":318,"results":[{"category":"Science: Computers","type":"boolean","difficulty":"easy","question":"MacOS is based on Linux.","correct_answer":"False","incorrect_answers":["True"]}]} api: https://www.unix.com/trivia/api.php
neo_trivia_user_neo.log:Thu, 31 Oct 2019 05:04:57 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: FR Name: Unregistered
neo_trivia_user_neo.log:Thu, 31 Oct 2019 05:27:37 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: RU Name: Unregistered
neo_trivia_user_neo.log:Thu, 31 Oct 2019 06:30:20 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: US Name: Unregistered
neo_trivia_user_neo.log:Thu, 31 Oct 2019 09:52:51 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: CZ Name: Unregistered
neo_trivia_user_neo.log:Thu, 31 Oct 2019 09:52:55 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: AR Name: Unregistered
neo_trivia_user_neo.log:Thu, 31 Oct 2019 18:44:52 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: US Name: Unregistered
neo_trivia_user_neo.log:Thu, 31 Oct 2019 22:58:31 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: AU Name: Unregistered
neo_trivia_user_neo.log:Fri, 01 Nov 2019 06:21:31 -0400: userid: 0 site: unix id: 318 answer: right Category: 18 IP: masked Country: IN Name: Unregistered

Regarding this question, there is no recorded "wrong answer" (True) in the DB.... all the answers so far, recorded in the DB and logs, were "False" (which is "right")

Looking at the log files and inside the DB this morning, I have added some additional string filtering for questions, for example:

<?php
$question =  filter_var($question, FILTER_SANITIZE_STRING,FILTER_FLAG_STRIP_HIGH);

because I was seeing some unprintable chars in the JSON response to the AJAX request, so hopefully, stripping out these symbols will help.

Status Update:

Total Interactions in DB (questions answered so far):

mysql> select count(*) from neo_trivia_scoreboard;
+----------+
| count(*) |
+----------+
|     3540 |
+----------+
1 row in set (0.00 sec)

Total question in DB:

mysql> select count(*) from neo_open_trivia;
+----------+
| count(*) |
+----------+
|      629 |
+----------+
1 row in set (0.00 sec)

If anyone sees any "strangeness" please take a screen shot and post it, and if possible please look into your web dev console and post any the XHR response to the API query and any JS errors in the JS console (if you know how to do it, if not just post the screen shots). I hope filtering the string will solve this tiny, occasional bug.

Top 20 interactions by country:

mysql> select country, count(country) from neo_trivia_scoreboard  group by country order by count(country) desc limit 20;
+---------+----------------+
| country | count(country) |
+---------+----------------+
| US      |            874 |
| IN      |            418 |
| TH      |            411 |  <---- my testing
| GB      |            185 |
| DE      |            131 |
| NL      |            115 |
| IT      |            111 |
| PH      |            109 |
| BR      |            105 |
| FR      |             93 |
| AU      |             82 |
| BG      |             81 |
| CA      |             79 |
| RU      |             73 |
| ES      |             60 |
| PL      |             58 |
| SE      |             48 |
| XX      |             47 |
| CH      |             44 |
| MX      |             33 |
+---------+----------------+
20 rows in set (0.00 sec)

I also just noticed that line breaks in question string in the JSON response will cause a problem so, for now, I am stripping out line breaks, like this:

$question = str_replace(array("\n", "\r"), '', $question );

I hope I have trapped all the issues which cause bugs when processing the JSON AJAX response, but I doubt it..... :slight_smile:

In addition, I have added the database id to the text box so if there are any questions or issues, we have the id to reference, for example:

Here is a quick look at the top 40 users by ip address (not included in the report) and their country, so far (excluding me):

mysql> select  count(ipaddress),uid, country from neo_trivia_scoreboard  where uid != 1 group by ipaddress,uid,country  order by count(ipaddress) desc limit 40;
+------------------+-----------+---------+
| count(ipaddress) | uid       | country |
+------------------+-----------+---------+
|              103 |         0 | PH      |
|               91 |         0 | IT      |
|               60 |         0 | NL      |
|               55 | 302183346 | BG      |
|               53 |         0 | BR      |
|               45 |         0 | US      |
|               44 |         0 | DE      |
|               34 |         0 | US      |
|               31 |         0 | BR      |
|               31 |         0 | US      |
|               30 |         0 | AU      |
|               29 |         0 | US      |
|               28 |         0 | IN      |
|               28 |         0 | NL      |
|               27 |         0 | US      |
|               27 |         0 | IN      |
|               26 |     21292 | US      |
|               26 |         0 | GB      |
|               25 |         0 | FR      |
|               24 |         0 | UA      |
|               23 |         0 | US      |
|               23 |         0 | PL      |
|               23 |         0 | SE      |
|               23 |         0 | GB      |
|               22 |         0 | US      |
|               22 |         0 | AR      |
|               21 | 302093876 | HR      |
|               20 |         0 | US      |
|               20 |         0 | ES      |
|               19 |         0 | US      |
|               18 |         0 | CH      |
|               18 |         0 | XX      |
|               17 |         0 | US      |
|               15 |         0 | HU      |
|               15 |         0 | DE      |
|               14 |         0 | IN      |
|               14 |         0 | TH      |
|               14 |         0 | IN      |
|               13 |         0 | BG      |
|               13 |         0 | MX      |
+------------------+-----------+---------+
40 rows in set (0.00 sec)

Some from the Philippines answered 103 questions yesterday. Which is the current record, here is their score:

mysql> select count(results), results from neo_trivia_scoreboard where ipaddress ="MASKED" group by results;
+----------------+---------+
| count(results) | results |
+----------------+---------+
|             71 | right   |
|             32 | wrong   |
+----------------+---------+
2 rows in set (0.00 sec)

Score: 68%

For the site in general, to date:

mysql> select count(results), results from neo_trivia_scoreboard group by results;
+----------------+---------+
| count(results) | results |
+----------------+---------+
|           2465 | right   |
|           1089 | wrong   |
+----------------+---------+
2 rows in set (0.01 sec)

Overall site score (all users): 69%

Ran this against the DB and manually edited any of these "non JSON friendly" chars:

SELECT * FROM neo_open_trivia WHERE question REGEXP '[^a-zA-Z0-9@:. \'\-`,\&#%$\\\"\!\|]';

I think the bug is in my submission script and I need to add better filters. Just using the PHP encode HTML entities function does not work perfectly.

SO, the DB should be clean now and the errors in display effect T/F etc, I think, solved.

Lot's of people playing trivia... I will need to code some scoreboards / leaderboards / stats soon:

Top 40 players by questions submitted:

mysql> select left(MD5(ipaddress),12) as hash, count(ipaddress),uid, country from neo_trivia_scoreboard  where uid != 1 group by ipaddress,uid,country  order by count(ipaddress) desc limit 40;
+--------------+------------------+-----------+---------+
| hash         | count(ipaddress) | uid       | country |
+--------------+------------------+-----------+---------+
| 2308b749ee0c |              187 | 302126107 | US      |
| 9beb7eda3ada |              103 |         0 | PH      |
| 4769267eed25 |               91 |         0 | IT      |
| 0c8adcc201b2 |               60 |         0 | NL      |
| 857d22f278f2 |               55 | 302183346 | BG      |
| 145322cf921e |               53 |         0 | BR      |
| 9c6892813c0f |               45 |         0 | US      |
| 50796d179daf |               44 |         0 | DE      |
| 496c1ebb49bb |               37 |         0 | AR      |
| 26b37bb15612 |               34 |         0 | US      |
| 8bfc0fbb7d31 |               31 |         0 | IN      |
| 2c676bfbff0e |               31 |         0 | US      |
| 4e628f3442d1 |               31 |         0 | BR      |
| 73aaa345d005 |               30 |         0 | AU      |
| 13b4d6b7b692 |               29 |         0 | US      |
| 91cb2d037eee |               28 |         0 | NL      |
| e40c9db86f87 |               28 |         0 | IN      |
| 96bd912beb5d |               27 |         0 | IN      |
| 11330bb5bd01 |               27 |         0 | US      |
| 299767cc5bf2 |               27 |         0 | ID      |
| 18a9b4c29552 |               26 |     21292 | US      |
| 47a14a853303 |               26 |         0 | GB      |
| 8a98f1985c12 |               25 |         0 | FR      |
| 99f15d8b770f |               24 |         0 | UA      |
| ed3af5326e07 |               23 |         0 | US      |
| a4798823ea4d |               23 |         0 | GB      |
| ef1e0f8ec62a |               23 |         0 | PL      |
| 67b4b3c0a97e |               23 |         0 | SE      |
| 401f4643e20c |               22 |         0 | AR      |
| e75e8d5e2004 |               22 |         0 | US      |
| a7a86f27afe5 |               22 |         0 | DE      |
| 8593591e2cdb |               21 | 302093876 | HR      |
| 76ff897ab4c8 |               20 |         0 | US      |
| 9d6bb91258b6 |               20 |         0 | ES      |
| dd5a37107aac |               19 |         0 | UA      |
| 1cab2e056a09 |               19 |         0 | US      |
| f1f17934834a |               18 |         0 | XX      |
| 91fb4740973e |               18 |         0 | CH      |
| 3d1eb0ae6247 |               17 |         0 | US      |
| 9cbac71180ef |               17 |         0 | IN      |
+--------------+------------------+-----------+---------+
40 rows in set (0.01 sec)

I'm closing in on 1000 trivia questions (my goal):

mysql> select count(*) from neo_open_trivia;
+----------+
| count(*) |
+----------+
|      682 |
+----------+
1 row in set (0.00 sec)

My plan was to create some scoreboards when we reached 2000 interactions, but I think I will hold off until 10,000... since we are already nearly 1/2 way there:

mysql> select count(*) from neo_trivia_scoreboard;;
+----------+
| count(*) |
+----------+
|     4326 |
+----------+
1 row in set (0.00 sec)

Guests v. Registered users (not including Neo) - almost ten to one, guests over registered users:

mysql> select count(*) from neo_trivia_scoreboard where  uid > 1;
+----------+
| count(*) |
+----------+
|      370 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from neo_trivia_scoreboard where  uid < 1;
+----------+
| count(*) |
+----------+
|     3387 |
+----------+
1 row in set (0.00 sec)

Neo testing and playing:

mysql> select count(*) from neo_trivia_scoreboard where  uid = 1;
+----------+
| count(*) |
+----------+
|      569 |
+----------+
1 row in set (0.00 sec)

Actually, I play this (answer questions) when resting between rounds during fitness training at the gym or when I want to kill some time. It's a great way to kill some time on mobile and test at the same time :slight_smile:

The current "average scores" of all guest users is currently 66%:

The current "average scores" of all registered users (not including Neo) is currently 80%:

I don't include my stats because it would skew the results up, since I submitted all the questions so far. But on the other hand, I often select the "wrong" answer intentionally because I am testing the system for bugs.

Right now, still see some occasional decoding bugs where the answer in the DB is not recorded properly in the Javascript, and so a wrong answer occurs. So, the code is still not 100% bullet proof; and the debugging needs to happen in the web dev console, for the most part.

Also, so far unregistered guests from all over the world (86 to date, actually 85+ since the XX country entry contains the unknown entries) have answered trivia questions, with the US, India, Great Britain, Germany, Brazil, Italy, the Netherlands, and the Philippines all with over 100 DB submissions.

My plan is build some cool scoreboards and leaderboards later this month, when we have over 10,000 submissions.

mysql> select country, count(country) from neo_trivia_scoreboard where uid <1 group by country order by count(country) desc;
+---------+----------------+
| country | count(country) |
+---------+----------------+
| US      |            920 |
| IN      |            496 |
| GB      |            180 |
| DE      |            166 |
| BR      |            129 |
| IT      |            127 |
| NL      |            116 |
| PH      |            109 |
| FR      |             98 |
| AU      |             88 |
| CA      |             79 |
| RU      |             74 |
| AR      |             64 |
| PL      |             62 |
| ES      |             56 |
| UA      |             51 |
| CH      |             44 |
| FI      |             43 |
| MX      |             39 |
| SE      |             39 |
| ID      |             36 |
| HU      |             34 |
| XX      |             28 |
| BG      |             27 |
| TH      |             23 |
| RO      |             22 |
| BE      |             21 |
| AT      |             18 |
| ZA      |             18 |
| PK      |             13 |
| HK      |             13 |
| GR      |             11 |
| VN      |             10 |
| RS      |             10 |
| CL      |             10 |
| DK      |              9 |
| CZ      |              9 |
| VE      |              8 |
| TW      |              8 |
| PY      |              8 |
| MY      |              7 |
| IL      |              7 |
| SG      |              7 |
| IE      |              6 |
| SD      |              6 |
| CO      |              5 |
| SK      |              5 |
| NZ      |              4 |
| NO      |              4 |
| TR      |              4 |
| UY      |              4 |
| CN      |              4 |
| BA      |              3 |
| LU      |              3 |
| CR      |              3 |
| MA      |              3 |
| RW      |              3 |
| AP      |              3 |
| SI      |              2 |
| EU      |              2 |
| KE      |              2 |
| BB      |              2 |
| EE      |              2 |
| EC      |              2 |
| IS      |              2 |
| MD      |              2 |
| PT      |              2 |
| AM      |              1 |
| SA      |              1 |
| PR      |              1 |
| GT      |              1 |
| JP      |              1 |
| GN      |              1 |
| PA      |              1 |
| NA      |              1 |
| IR      |              1 |
| MK      |              1 |
| GE      |              1 |
| CY      |              1 |
| HR      |              1 |
| ET      |              1 |
| AE      |              1 |
| DO      |              1 |
| KZ      |              1 |
| SV      |              1 |
| KR      |              1 |
+---------+----------------+
86 rows in set (0.00 sec)

OK.. there is a problem with Safari and their Cross-Origin Resource Sharing (CORS) implementation, which is causing Javascript errors when ads or videos are served.

This bug is causing an error in the Trivia JS code, so I have am disabling the trivia for guests (not logged in) who are using Safari (for now, in both mobile and desktop):

<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if ($vbulletin->userinfo['userid'] < '1') {
    if (stripos($user_agent, 'Chrome') !== false) {
        define('ENABLE_SAFARI_UA', true);
    } else {
        if (stripos($user_agent, 'Safari') !== false) {
            define('ENABLE_SAFARI_UA', false);
            $log = '/var/log/apache2/debug/neo_trivia_global_safari_debug.log';
            error_log(date(DATE_RFC822) . ' UA ' . $user_agent . "\n", 3, $log);
        } else {
            define('ENABLE_SAFARI_UA', true);
        }
    }
} else {
    define('ENABLE_SAFARI_UA', true);
}

I will think about another "fix" for this later.

OK... the Safari CORS issue related to display ads for unregistered users does not seem to direct effect the trivia app as much as I thought, so I have turned it back on for Safari.

Update:

Added a 120 second timeout for each question after it loads.

120 seconds seems like a long time, as I notice most people (like me) click "next" and answer within 10 to 30 seconds, and often faster; so 120 seconds seems fair for everyone; but we can change it of course.

Current stats:

mysql> select count(*) from neo_trivia_scoreboard;
+----------+
| count(*) |
+----------+
|     4674 |
+----------+
1 row in set (0.00 sec)

Top 40 by number of questions per user (hashed for guests):

mysql> select left(MD5(ipaddress),12) as hash, count(ipaddress),username, country from neo_trivia_scoreboard  where uid != 1 group by ipaddress,username,country  order by count(ipaddress) desc limit 40;
+--------------+------------------+--------------+---------+
| hash         | count(ipaddress) | username     | country |
+--------------+------------------+--------------+---------+
| 2308b749ee0c |              279 | rdrtx1       | US      |
| 9beb7eda3ada |              103 | Unregistered | PH      |
| 4769267eed25 |               91 | Unregistered | IT      |
| 0c8adcc201b2 |               60 | Unregistered | NL      |
| 857d22f278f2 |               55 | KD_999       | BG      |
| 145322cf921e |               53 | Unregistered | BR      |
| 9c6892813c0f |               45 | Unregistered | US      |
| 50796d179daf |               44 | Unregistered | DE      |
| 496c1ebb49bb |               37 | Unregistered | AR      |
| 26b37bb15612 |               34 | Unregistered | US      |
| 8bfc0fbb7d31 |               31 | Unregistered | IN      |
| 2c676bfbff0e |               31 | Unregistered | US      |
| 4e628f3442d1 |               31 | Unregistered | BR      |
| 73aaa345d005 |               30 | Unregistered | AU      |
| 13b4d6b7b692 |               29 | Unregistered | US      |
| 91cb2d037eee |               28 | Unregistered | NL      |
| e40c9db86f87 |               28 | Unregistered | IN      |
| 96bd912beb5d |               27 | Unregistered | IN      |
| 299767cc5bf2 |               27 | Unregistered | ID      |
| 11330bb5bd01 |               27 | Unregistered | US      |
| 18a9b4c29552 |               26 | milhan       | US      |
| 47a14a853303 |               26 | Unregistered | GB      |
| 8a98f1985c12 |               25 | Unregistered | FR      |
| 99f15d8b770f |               24 | Unregistered | UA      |
| a4798823ea4d |               23 | Unregistered | GB      |
| ed3af5326e07 |               23 | Unregistered | US      |
| 67b4b3c0a97e |               23 | Unregistered | SE      |
| ef1e0f8ec62a |               23 | Unregistered | PL      |
| 401f4643e20c |               22 | Unregistered | AR      |
| 5fd3ff8783f5 |               22 | Unregistered | US      |
| a7a86f27afe5 |               22 | Unregistered | DE      |
| e75e8d5e2004 |               22 | Unregistered | US      |
| 8593591e2cdb |               21 | Peasant      | HR      |
| 76ff897ab4c8 |               20 | Unregistered | US      |
| 87cf1ccef093 |               20 | Unregistered | DE      |
| 9d6bb91258b6 |               20 | Unregistered | ES      |
| dd5a37107aac |               19 | Unregistered | UA      |
| 1cab2e056a09 |               19 | Unregistered | US      |
| 91fb4740973e |               18 | Unregistered | CH      |
| f1f17934834a |               18 | Guest        | XX      |
+--------------+------------------+--------------+---------+
40 rows in set (0.01 sec)

Total trivia questions in DB:

mysql> select count(*) from neo_open_trivia;
+----------+
| count(*) |
+----------+
|      710 |
+----------+
1 row in set (0.00 sec)

Trivia about trivia:

The current average rate of the new trivia questions being answered since the inception of the my new computer science trivia code (now 5.4 days since launched) is:

One trivia question answered (submitted) every 36 seconds.

Based on:

mysql> select dateline from neo_trivia_scoreboard order by id asc limit 1;
+------------+
| dateline   |
+------------+
| 1572328203 |
+------------+
1 row in set (0.00 sec)

mysql> select dateline from neo_trivia_scoreboard order by id desc limit 1;
+------------+
| dateline   |
+------------+
| 1572794178 |
+------------+
1 row in set (0.00 sec)

mysql> select count(*) from neo_trivia_scoreboard;
+----------+
| count(*) |
+----------+
|     4722 |
+----------+
1 row in set (0.00 sec)
1 Like

Update:

Removed JS timer (buggy, in certain situations).

Also, 3/4 of the way to 1000:

mysql> select count(*) from neo_open_trivia;
+----------+
| count(*) |
+----------+
|      757 |
+----------+
1 row in set (0.00 sec)

A big THANK YOU to rdrtx1 for stress testing the trivia:

mysql> select left(MD5(ipaddress),12) as hash, count(ipaddress),username, country from neo_trivia_scoreboard  where uid != 1 group by ipaddress,username,country  order by count(ipaddress) desc limit 40;
+--------------+------------------+--------------+---------+
| hash         | count(ipaddress) | username     | country |
+--------------+------------------+--------------+---------+
| 2308b749ee0c |              279 | rdrtx1       | US      |
| 9beb7eda3ada |              103 | Unregistered | PH      |
| 4769267eed25 |               91 | Unregistered | IT      |
| 0c8adcc201b2 |               60 | Unregistered | NL      |
| 857d22f278f2 |               55 | KD_999       | BG      |
| 145322cf921e |               53 | Unregistered | BR      |
| 9c6892813c0f |               45 | Unregistered | US      |
| 50796d179daf |               44 | Unregistered | DE      |
| 496c1ebb49bb |               37 | Unregistered | AR      |
| 26b37bb15612 |               34 | Unregistered | US      |
| 8bfc0fbb7d31 |               31 | Unregistered | IN      |
| 2c676bfbff0e |               31 | Unregistered | US      |
| 4e628f3442d1 |               31 | Unregistered | BR      |
| 73aaa345d005 |               30 | Unregistered | AU      |
| 18a9b4c29552 |               29 | milhan       | US      |
| 13b4d6b7b692 |               29 | Unregistered | US      |
| e40c9db86f87 |               28 | Unregistered | IN      |
| 91cb2d037eee |               28 | Unregistered | NL      |
| 299767cc5bf2 |               27 | Unregistered | ID      |
| 96bd912beb5d |               27 | Unregistered | IN      |
| 11330bb5bd01 |               27 | Unregistered | US      |
| 47a14a853303 |               26 | Unregistered | GB      |
| 8a98f1985c12 |               25 | Unregistered | FR      |
| 99f15d8b770f |               24 | Unregistered | UA      |
| a4798823ea4d |               23 | Unregistered | GB      |
| ed3af5326e07 |               23 | Unregistered | US      |
| ef1e0f8ec62a |               23 | Unregistered | PL      |
| 67b4b3c0a97e |               23 | Unregistered | SE      |
| 401f4643e20c |               22 | Unregistered | AR      |
| 5fd3ff8783f5 |               22 | Unregistered | US      |
| a7a86f27afe5 |               22 | Unregistered | DE      |
| e75e8d5e2004 |               22 | Unregistered | US      |
| 8593591e2cdb |               21 | Peasant      | HR      |
| 87cf1ccef093 |               20 | Unregistered | DE      |
| 76ff897ab4c8 |               20 | Unregistered | US      |
| 9d6bb91258b6 |               20 | Unregistered | ES      |
| dd5a37107aac |               19 | Unregistered | UA      |
| 1cab2e056a09 |               19 | Unregistered | US      |
| 91fb4740973e |               18 | Unregistered | CH      |
| f1f17934834a |               18 | Guest        | XX      |
+--------------+------------------+--------------+---------+
40 rows in set (0.01 sec)

Also some updates:

mysql> select count(*) from neo_open_trivia;
+----------+
| count(*) |
+----------+
|      807 |
+----------+
1 row in set (0.00 sec)
mysql> select count(*) from neo_trivia_scoreboard;;
+----------+
| count(*) |
+----------+
|     4962 |
+----------+
1 row in set (0.00 sec)

Notes:

  1. Anyone who does not like the trivia questions are encouraged to write and submit their own.
  2. Those who do not write and submit trivia questions do not have any standing now, or in the future , to criticize or complain about the questions of those who do the actual work.
  3. To date, 100% of the code was written by Neo and 100% of all the questions were submitted by Neo (most questions are derived from Computer Science textbooks, Wikipedia, etc and come from references.).
  4. If anyone finds any possible error or bug, please report any perceived errors or bugs as I have instructed.
  5. No code or application by anyone is ever developed 100% bug or error free.

As the old saying goes, the only code which is released 100% bug free is the code which is never written; and so far I'm pleased with this new code.

We have received only one bug report so far, which was related I believe to a JSON formatting / Javascript error due to some characters in the database which did not play well with JSON and Javascript. I wrote and testing a lot of code to filter out the potential gotchas when a new question was submitted to the DB and manually cleaned unprintable chars and line breaks from the questions. The results are that the error seems to have gone away and I have not seen it again.

So far so good. Currently, here are the user interactions:

mysql> select count(*) from neo_trivia_scoreboard;
+----------+
| count(*) |
+----------+
|     6305 |
+----------+
1 row in set (0.01 sec)

The first and last entries by users:

mysql> select dateline from neo_trivia_scoreboard order by dateline desc limit 1;
+------------+
| dateline   |
+------------+
| 1572919422 |
+------------+
1 row in set (0.00 sec)


mysql> select dateline from neo_trivia_scoreboard order by dateline asc limit 1;
+------------+
| dateline   |
+------------+
| 1572328203 |
+------------+
1 row in set (0.01 sec)

Or 1572919422 - 1572328203 = 59,1219 seconds lifetime so far, or 9854 minutes.

Translating to 9854 / 6305 or about one user answer submitted every 1.4 minutes (minutes/question) since I released this new code was released.

Over the past 24 hours, the number is higher:

mysql> select count(*)/(24*60) as "questions per minute" from neo_trivia_scoreboard where dateline > UNIX_TIMESTAMP() -86000;
+----------------------+
| questions per minute |
+----------------------+
|               0.9938 |
+----------------------+
1 row in set (0.00 sec)

Translating to about 1 question per minute answered on average over the past 24 hours.

The total number of questions in the DB is:

mysql> select count(*) from neo_open_trivia;
+----------+
| count(*) |
+----------+
|      908 |
+----------+
1 row in set (0.00 sec)

The vast majority of these questions (maybe 99%+) were derived from Computer Science textbooks or Wikipedia.

As far as countries, here are the top 40 (Neo, excluded):

mysql> select country, count(country) from neo_trivia_scoreboard  where uid !=1 group by country order by count(country) desc LIMIT 40;
+---------+----------------+
| country | count(country) |
+---------+----------------+
| US      |           1707 |
| IN      |            742 |
| DE      |            278 |
| GB      |            276 |
| IT      |            202 |
| BR      |            149 |
| CA      |            144 |
| FR      |            138 |
| NL      |            125 |
| PH      |            110 |
| RU      |            107 |
| AU      |             97 |
| BG      |             93 |
| ES      |             88 |
| TH      |             81 |
| SE      |             70 |
| AR      |             70 |
| PL      |             65 |
| UA      |             57 |
| CH      |             51 |
| HR      |             49 |
| MX      |             48 |
| HU      |             48 |
| FI      |             44 |
| MA      |             38 |
| AT      |             38 |
| ID      |             37 |
| XX      |             31 |
| RO      |             29 |
| BE      |             28 |
| RS      |             24 |
| PT      |             19 |
| GR      |             19 |
| AE      |             18 |
| SG      |             18 |
| PK      |             18 |
| ZA      |             18 |
| IE      |             15 |
| HK      |             15 |
| KH      |             14 |
+---------+----------------+
40 rows in set (0.01 sec)

and based on hash (masked), IP addresses:

mysql> select left(MD5(ipaddress),12) as hash, count(ipaddress),username, country from neo_trivia_scoreboard  where uid != 1 group by ipaddress,username,country  order by count(ipaddress) desc limit 40;
+--------------+------------------+--------------+---------+
| hash         | count(ipaddress) | username     | country |
+--------------+------------------+--------------+---------+
| 2308b749ee0c |              279 | rdrtx1       | US      |
| da7c5eae2b00 |              126 | Unregistered | US      |
| 9beb7eda3ada |              103 | Unregistered | PH      |
| 4769267eed25 |               91 | Unregistered | IT      |
| 0c8adcc201b2 |               60 | Unregistered | NL      |
| 857d22f278f2 |               55 | KD_999       | BG      |
| 952b0c66e2af |               53 | Unregistered | IN      |
| 145322cf921e |               53 | Unregistered | BR      |
| 9c6892813c0f |               45 | Unregistered | US      |
| 0b122fbf8494 |               45 | Unregistered | US      |
| 50796d179daf |               44 | Unregistered | DE      |
| 7d735e9d9eea |               43 | Unregistered | IN      |
| 496c1ebb49bb |               37 | Unregistered | AR      |
| 7a42d8abcbc6 |               35 | Unregistered | MA      |
| 26b37bb15612 |               34 | Unregistered | US      |
| 67b4b3c0a97e |               33 | Unregistered | SE      |
| 8bfc0fbb7d31 |               31 | Unregistered | IN      |
| 2c676bfbff0e |               31 | Unregistered | US      |
| 4e628f3442d1 |               31 | Unregistered | BR      |
| 73aaa345d005 |               30 | Unregistered | AU      |
| 18a9b4c29552 |               29 | milhan       | US      |
| 13b4d6b7b692 |               29 | Unregistered | US      |
| e40c9db86f87 |               28 | Unregistered | IN      |
| 91cb2d037eee |               28 | Unregistered | NL      |
| 96bd912beb5d |               27 | Unregistered | IN      |
| 299767cc5bf2 |               27 | Unregistered | ID      |
| 11330bb5bd01 |               27 | Unregistered | US      |
| 47a14a853303 |               26 | Unregistered | GB      |
| 8a98f1985c12 |               25 | Unregistered | FR      |
| 11656f2e9795 |               25 | Unregistered | GB      |
| 698190045add |               25 | Unregistered | IT      |
| 99f15d8b770f |               24 | Unregistered | UA      |
| a4798823ea4d |               23 | Unregistered | GB      |
| ed3af5326e07 |               23 | Unregistered | US      |
| ef1e0f8ec62a |               23 | Unregistered | PL      |
| 1977a7cd1d10 |               23 | CyberStems   | CA      |
| f6f617c97919 |               22 | Unregistered | IT      |
| 401f4643e20c |               22 | Unregistered | AR      |
| 5fd3ff8783f5 |               22 | Unregistered | US      |
| a7a86f27afe5 |               22 | Unregistered | DE      |
+--------------+------------------+--------------+---------+
40 rows in set (0.02 sec)

Basically, this is going very well and seems to be running close to as bug and error free as one could expect after slightly less than one week after coding it and releasing it to the public.

The greatest percentage of those who answer questions are guests, not registered users:

mysql> select count(*) from neo_trivia_scoreboard where uid < 1; select count(*) from neo_trivia_scoreboard where uid != 1;
+----------+
| count(*) |
+----------+
|     4931 |
+----------+
1 row in set (0.00 sec)

+----------+
| count(*) |
+----------+
|     5451 |
+----------+
1 row in set (0.00 sec)

So, 90% of the users who use this new feature are not registered users, which is exactly what I expected and hoped for.

As far as the average score to date for all these users (sans Neo):

mysql> select count(*) from neo_trivia_scoreboard where uid != 1 and results='right'; select count(*) from neo_trivia_scoreboard where uid != 1;
+----------+
| count(*) |
+----------+
|     3625 |
+----------+
1 row in set (0.00 sec)

+----------+
| count(*) |
+----------+
|     5451 |
+----------+
1 row in set (0.00 sec)

Overall CS trivia score: 67%.

For only guests:

mysql> select count(*) from neo_trivia_scoreboard where uid < 1 and results='right'; select count(*) from neo_trivia_scoreboard where uid < 1;
+----------+
| count(*) |
+----------+
|     3258 |
+----------+
1 row in set (0.01 sec)

+----------+
| count(*) |
+----------+
|     4931 |
+----------+
1 row in set (0.00 sec)

Overall CS trivia score guests: 66%.

and for only registered users (sans Neo):

mysql> select count(*) from neo_trivia_scoreboard where uid > 1 and results='right'; select count(*) from neo_trivia_scoreboard where uid > 1;
+----------+
| count(*) |
+----------+
|      367 |
+----------+
1 row in set (0.00 sec)

+----------+
| count(*) |
+----------+
|      520 |
+----------+
1 row in set (0.00 sec)

Overall CS trivia score members: ~71%.

Neo does not count, since I entered all the questions and also click randomly for testing, but just for fun:

mysql> select count(*) from neo_trivia_scoreboard where uid = 1 and results='right'; select count(*) from neo_trivia_scoreboard where uid = 1;
+----------+
| count(*) |
+----------+
|      740 |
+----------+
1 row in set (0.00 sec)

+----------+
| count(*) |
+----------+
|      856 |
+----------+
1 row in set (0.00 sec)

Neo's testing score: 86%

856... that is a lot of testing... but I play our trivia when I am at the gym and resting and just hanging out killing time, LOL... which means I should be playing trivia less and working out more.

So, that's about it. I will use these kinds of mysql queries to create some scoreboards and leadership boards later; but I'm months behind of my annual tax filing paper work due to some problem with my bill paying service back in the US; and need to get back to solving this problem before the tax man gets mad at me for being behind on my annual paperwork!

Believe, me I would much rather prefer to be writing Vue.js code and creating some scoreboards than doing tax paperwork; but alas, life is not always fun and coding!

As far as registered members who submitted answers so far (sans Neo):

mysql> select count(username),username, country from neo_trivia_scoreboard where uid > 1 group by username,country  order by count(username) desc limit 40;
+-----------------+---------------+---------+
| count(username) | username      | country |
+-----------------+---------------+---------+
|             279 | rdrtx1        | US      |
|              55 | KD_999        | BG      |
|              46 | Peasant       | HR      |
|              29 | milhan        | US      |
|              26 | 000vikas      | TH      |
|              23 | CyberStems    | CA      |
|               9 | prvnrk        | SE      |
|               8 | Akshay Hegde  | IN      |
|               6 | gull04        | GB      |
|               6 | mauregato     | ES      |
|               4 | zxmaus        | US      |
|               4 | anbu23        | US      |
|               3 | MadeInGermany | DE      |
|               3 | hicksd8       | GB      |
|               3 | apmcd47       | GB      |
|               2 | NKaede        | DE      |
|               2 | Sagar Singh   | IN      |
|               2 | penchev       | BG      |
|               2 | yirgacheffe   | AU      |
|               1 | MadeInGermany | US      |
|               1 | Guest         | BG      |
|               1 | kshitij       | IN      |
|               1 | deeppal       | IN      |
|               1 | mcgvaer       | RU      |
|               1 | stomp         | DE      |
|               1 | alexcol       | CO      |
|               1 | wisecracker   | GB      |
+-----------------+---------------+---------+
27 rows in set (0.00 sec)

 

Even though I should be working on non-forum things this week, I did put together some quick draft of a stats module for the trivia, which is not complete and currently only visible to Neo: