Debugging Our Computer Science Trivia Feature


 
Thread Tools Search this Thread
The Lounge What is on Your Mind? Debugging Our Computer Science Trivia Feature
# 8  
Old 11-02-2019
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):

Code:
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:

Code:
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:

Code:
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%
# 9  
Old 11-02-2019
Ran this against the DB and manually edited any of these "non JSON friendly" chars:

Code:
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.
# 10  
Old 11-03-2019
Lot's of people playing trivia... I will need to code some scoreboards / leaderboards / stats soon:

Top 40 players by questions submitted:

Code:
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):

Code:
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:

Code:
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:

Code:
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:

Code:
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 Smilie
# 11  
Old 11-03-2019
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.
# 12  
Old 11-03-2019
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.

Code:
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)

# 13  
Old 11-03-2019
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):

Code:
<?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.
# 14  
Old 11-03-2019
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

Computer Trivia Feature Tops 50,000 Questions Answered

Just noticed that our successful computer trivia feature (stats here) has surpassed over 50,000 questions answered by users: https://www.unix.com/trivia_stats.php This was a coding effort worth while and I'm pleased to see so many people enjoying it in such a short time since it was released... (3 Replies)
Discussion started by: Neo
3 Replies

2. What is on Your Mind?

New Member and Country Computer Trivia Leaderboards

Thanks to Akshay, who helped me write the core MySQL queries, we now have two new draft leaderboards, by (1) member and by (2) country: https://www.unix.com/trivia_stats.php Currently milhan leads the members with a high score of 90%: ... (3 Replies)
Discussion started by: Neo
3 Replies

3. What is on Your Mind?

1000+ Computer Science Trivia Questions at UNIX.COM

The UNIX and Linux Forums now has over 1000 TRUE / FALSE computer science and computer related trivia question in our database. These questions are of relatively high quality (compared to similar sites on the web) and are fun (according to feedback by users). In the first week during the... (1 Reply)
Discussion started by: Neo
1 Replies

4. What is on Your Mind?

Forum Trivial Pursuit - New Computer Science and Mathematics Trivia for UNIX.com

I have added a new experimental "Computer Science and Mathematics Trivia - True or False" section in the discussions, currently under the tags box. In the future, I plan to Expand this feature to add more trivia categories from math, science and technology. Keep track of correct and... (20 Replies)
Discussion started by: Neo
20 Replies

5. Web Development

Is Web Development is a part of computer science ?

I am now a student in university in 2nd year. I am studying computer science. But I am not sure what type of jobs computer science provide. I know some of them are software programming or network management. Recently, I hear some about Web Development. I wonder if it is a part of computer... (3 Replies)
Discussion started by: Anna Hussie
3 Replies

6. Programming

Is Web Development is a part of computer science ?

I am now a student in university in 2nd year. I am studying computer science. But I am not sure what type of jobs computer science provide. I know some of them are software programming or network management. Recently, I hear some about Web Development. I wonder if it is a part of computer science.... (1 Reply)
Discussion started by: Anna Hussie
1 Replies

7. What is on Your Mind?

Computer Science and Information Technology

Hi, I haven't posted on the forums for a while now, I tried to find the most appropriate section for this post, but if this is in the wrong section please forgive me. First, let me say I'm a sophomore in HS. I know that job wise I definitely want to do something in computers. A while ago I was... (5 Replies)
Discussion started by: hpicracing
5 Replies
Login or Register to Ask a Question