To start a new game, you can just access the cgi script (rg.cgi) and click 'reset', then click 'really reset!!'
See "how to test" below, for different methods of running a standalone local instance of a server that can serve the script.
To run on a machine with an existing web server, put rg.cgi into /usr/lib/cgi-bin, and change the data path to where you put the trivia.py and rps.py files. The data path must be read/writable by the cgi script (which means the web server).
Then point your browser at: http://server.address/cgi-bin/rg.cgi for the CGI version of the script, or use: http://server.address/rg for the WSGI verison of the script
To run on a machine without a web server, run ./start-cgi-server.
Then point your browser at: http://localhost:8000/rg.cgi
To log in as admin, use this url: http://localhost:8000/rg.cgi?user_id=admin_game_admin
I added the following line to /etc/apache2/conf-available/wsgi.conf
WSGIScriptAlias /rg /usr/lib/cgi-bin/rg.cgi
- Remove user registration files in the rgdata directory
- Remove winner files in the rgdata directory
- Remove leftover answer, rps, and still-in data
('make clean' will do all this)
On the admin screen, you will see a menu showing controls for the game.
there are 4 main phases:
- registration
- trivia
- rock-paper-scissors
- end
The game progresses in 2 sets of rounds, for two different games: 1 Red-green trivia game 2 rock-paper-scissors game
Every operation performed (link clicked, or data entry submitted) changes the game's data file. If you click on the wrong thing, or enter the wrong data, you can click 'undo' to revert to a previous game state.
July 14, 2020:
Sorry, but there is very little documentation for the game. However, there is this README.md file with some of the game setup, and hopefully when you log in to the game as administrator (which is described in the README file) it is not too hard to figure out how the moderator drives the game. The administrator has extra game controls that are not visible to the game players.
The main script of the game is 'rg.cgi', and it can be run as either a CGI script or a WSGI program.
The presence or absence of a file: rgdata/suppress_refresh controls whether the client browsers automatically refresh pages as the game progresses. If the file is present, users must be instructed to move to the next page by clicking on a link. If the file is absent (the default), then when the administrator changes the game state, client browsers will automatically refresh and load the next item in the game sequence.
Sample trivia data for the game is in rgdata/trivia.py, and the format is fairly self-explanatory (but there are some comments in that file that describe the data format.) The trivia data used for the ELC 2020 closing session is in the file trivia-2020-elc.py. To use those trivia questions, you would copy that file into rgdata/trivia.py and reset the game using the administrator interface.
As a note, the game was written quite hastily, so it should not be used as an example of my best code. ;-) Also, a number of odd choices were made in terms of data storage, in order to allow the game to scale. It does not use a database, but rather simple text files for the game and user data. The game does seem to function as intended for a multiplayer game.
After the ELC 2020 closing session, I received a few requests to play the trivia as a standalone game (not moderated or controlled by an admin). I started work on this, but didn't have time to finish it. This is described in the source as SINGLE mode, which is an alternative to the regular "group" mode used for multiplayer play. It almost works, but has a few bugs that need to be worked out. However, I didn't want to wait longer to publish the source. The single-player mode is still a work-in-progress.
In the standalone mode, the pages have timeout counters on them, that will force the user forward through the trivia questions. This will prevent someone from using an arbitrary (long) amount of time to research answers. Since there's no score, I'm not sure what the point of this would be (but I might add a score for this mode later).
There are notes for Tim's development machines.
- this runs the script as a single-threaded, single-process CGI using a python web server
- cd ~/work/games/red-green ; ./start_server
- browse as admin:
- browse as user:
- desktop: chrome chrome: http://localhost:8000/rg.cgi?user_id=one
- laptop: chrome: http://desktop:8000/rg.cgi?user_id=two
- edit rg.cgi
- cd ~/work/games/red-green/cgi-bin
- vi rg.cgi
- ./stop-uwsgi
- (in other window) ./start-uwsgi
- browse as admin:
- browse as user:
- desktop: chrome https://server-addr/rg (register as 'one')
- laptop: chrome https://server-addr/rg (register as 'two')
- start server and wsgi gateway
- systemctl start nginx (if not already running)
- cd ~/work/games/red-green
- ./start-uwsgi
- edit rg.cgi
- cd ~/work/games/red-green
- vi rg.cgi
- after an edit, you need to restart the uwsgi server:
- stop-uwsgi (or ctrl-C in the terminal where uwsgi is running)
- start-uwsgi
- browse as admin:
- browse as user:
- timdesk: chrome https://closinggame.net/rg (register as 'one')
- laptop: chrome https://closinggame.net/rg (register as 'two')
- this runs the script as a single-threaded, single-process CGI using a python web server
- cd ~/work/games/red-green ; ./start_old_server
- browse as admin:
- browse as user:
- desktop: chrome chrome: http://localhost:8000/rg.cgi?user_id=one
- laptop: chrome: http://desktop:8000/rg.cgi?user_id=two