cubingusa / compscript

MIT License
11 stars 3 forks source link

CompScript

CompScript is a tool for assigning groups and staff assignments for WCA Rubik's Cube competitions. Other similar tools include Groupifier, AGE, and Delegate Dashboard. Those tools are intended to be user-friendly, automated systems that give you a few configuration options, let you click a button to generate all assignments, then allow for fine-tuning. This is a power-user tool -- it is designed for competitions where the organizer would consider spending multiple hours assigning groups, due to complicated constraints like multiple stages, dedicated staff, a live stream, and a desire to have a large amount of control over how groups should be assigned. Competitions with up to ~200 competitors and only one stage are likely served better by another tool.

CompScript is designed primarily for CubingUSA Nationals and other large championships. Requirements for other competitions may not be prioritized.

Running

Node must be installed on your machine.

$ npm install
$ npm run dev-server

Running the development server will use uses a dev WCA environment running on the same machine. If you would like to use the production WCA site, you need to:

  1. Make an OAuth application here. For "Scopes", use public manage_competitions; for "Callback Urls" use http://localhost:3033/auth/oauth_response.
  2. Make a copy of the .env.DEV file, such as .env.PROD. This file should not be committed; .gitignore should automatically ignore it.
  3. Replace WCA_HOST, API_KEY, and API_SECRET with the production values. You should also consider changing the COOKIE_SECRET to a new value, and to change PORT to 3033 to distinguish from the dev version.
  4. Run with $ ENV=PROD node main.js, using the file suffix you used above.

Scripts

You can enter scripts in the script box, using a custom language called CompScript. See docs/scripts.md for full documentation.

Some examples:

The Luke psych sheet

Table(
  Sort(Persons(And(Registered(), (FirstName() == "Luke"))),
       PersonalBest(_333, "average")),
  [Column("Name", Name()),
   Column("WCA ID", WcaId(), WcaLink()),
   Column("Average", PersonalBest(_333)),
   Column("Single", PersonalBest(_333, "single")),
   Column("psych sheet ranking", PsychSheetPosition(_333))])

Defining a custom function

Define(
  "SumOfRankings",
  (PsychSheetPosition({1, Event}, "average") + PsychSheetPosition({1, Event}, "single")))

which can then be called by:

SumOfRankings(_333)

Google Sheets integration

We use the google-spreadsheets NPM package to read from Google Sheets. Please refer to this page for how to create a Service Account with Google Sheets access. Move the generated JSON file to google-credentials.json in the top-level project directory, and make sure to grant the service account access to the spreadsheet you'd like it to read.

Do not share the service account credentials with anyone who should not have access to the spreadsheets you'd like to read.