/text-editor-tournament

Backend code for judging submissions.

Primary LanguagePython

Text Editor Tournament

Client-server system connecting together multiple tournament participants, a Manager (administrator), and a web-based display frontend system through a central server.

The server handles distributing challenges submitted by the Manager and submissions of answers by the participants. The server and client programs are written in Python 3. The web-based frontend displays information about the tournament in real-time using the HTML5 canvas and WebSockets.

Table of Contents

Terminology

Submission server server/submission_server.py

The most important piece of running a tournament. Clients of every type (e.g. Manager, Participant, Display must register with the Submission server. Simply put, the Submission server is the brain of the tournament.

Display server display/ws.py

Relays tournament statistics from the Submission Server to the Display web client.

Display web client display/index.html

Uses WebSockets to establish a connection with the Display server to display tournament statistics it recieves. The HTML5 canvas element is used for displaying graphics.

Manager manager/manager.py

Interface by which Challenges are managed (loaded, initiated, cancelled). The Manager has the following command set:

  • load challenge_id challenge_name
    • Sets the current Challenge to challenge_name with a challenge ID of challenge_id.
  • init
  • ls
  • quit

Participant participant/participant.py

Recieves information about Challenges and can accept or reject Challenges that are presented. If a Participant accepts a challenge, then they must proceed to work toward completing the Challenge. Once the Participant is confident they have completed the Challenge correctly, the Participant can then submit the Challenge to the Submission server. If the Participant answered the Challenge incorrectly, the Participant will recieve a diff of their work against what the correct solution.

Challenge

A directory that resides in the same directory as the Manager. Within this directory must be several types of files:

  • Description File
    • A file named description.info. The format of this file is as follows:
      • The first line is the name of the challenge
      • The second line is blank
      • The rest of the file contains a description of the challenge
  • Challenge Files
    • Files that will be sent over to Participants at the beginning of a challenge
  • Solution Files
    • These files have a .sol extension. Challenge Files will be diffed against these. There must exist a bijection amongst Challenge Files and Solution Files (e.g. If foo is a Challenge File, then there must exist a Solution File by the name of foo.sol)

Normal Tournament sequence

Start Submission Server

Open a terminal, traverse into server/, and issuing the following command:

$ python3 submission_server.py

The Submission server by default runs on port 6900.

Start Display Server

Open a terminal, traverse into display/, and issue the following command:

$ python3 ws.py

This Display server runs on port 9999 and assumes the Submission server is running on port 6900.

Start Display web client

Traverse into display/ and open index.html with your favorite web browser.

Note: The Display web client assumes the Display server is running on the same machine. In order to run the Display server on another machine, change the SERVER_ADDR value line in main.js to the IP address of the machine the Display server is running on.

Start Manager

Open a terminal, traverse into manager/, and issue the following command:

$ python3 manager.py

Have Participants connect

For every Participant, supply them with participant.py and have them issue the following:

$ python3 participant.py [submission_server_ip]

where submission_server_id is the IP address of the machine that the Submission server is running on. If submission_server_ip is omitted, localhost is used.

The Participants are then prompted to enter their name and editor. They must then wait for the Manager to Load up a Challenge.

Load up a Challenge

Issue the load command from the Manager's prompt with a legal Challenge.

Start the Challenge

The Manager can then issue the init command and every Participant will be sent the challenge description and will be prompted to accept it. Once all Participants have responded, the Manager can then start the challenge or cancel it. If the Manager starts the challenge, the challenge will continue until every Participant has either successfully completed it or forfeited.

Other

Videos

Text Editor Tournament

Screenshots

Text Editor Tournament in Action