njudge

command module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

README

njudge

Discord Tests Go Reference Go Report Card

Online Judge system written in golang. A running version can be found here.

It consists of two main parts:

  • A group of reusable components, located in pkg/, which can be used in a variety ways related to the conversion, running and modification of algorithmic/olympiad tasks.
  • A web based online judge system, located in internal/.

How to run

Via docker

Build the containers:

make build

Then, run the migrations:

docker-compose run web ./njudge web migrate --up

Modify the environment files web.env and judge.env. Typically only web.env needs to be changed. A quite minimal web.env file for example would be:

NJUDGE_MODE="production"
NJUDGE_HOSTNAME="yourhost.domain"
NJUDGE_URL="https://yourhost.domain"
NJUDGE_COOKIESECRET="somesecretstring"

Probably you would want some of NJUDGE_SENDGRID, NJUDGE_SMTP, NJUDGE_GOOGLEAUTH as well to provide OAuth login and email sending capabilities. For the full list of the configuration options supported by the web component check out config.go.

Then you can start all containers necessary via:

make up

To make problems available to the system you have two options:

  1. Use the automatically created njudge_problems volume, copy the problems there via docker cp.
  2. Modify the docker-compose.yml to use a bind mount pointing to a directory on your host system.

If both the judge and web component sees the problems, you have to use the admin panel (or some sql client) to create the necessary ProblemRels for it to be displayed on the frontend.

Vanilla method

Build everything with go build. Start the services by executing all 3 commands:

./njudge web
./njudge glue
./njudge judge

You most certainly need to configure a thing or two via glue.yaml, judge.yaml and web.yaml.

Example of web.yaml:

problems_dir: /PATH_TO_PROBLEMS
db:
  user: your_user
  password: your_users_password
  host: localhost
  port: 1234567
  name: your_database

Example of judge.yaml:

problems_dir: /PATH_TO_PROBLEMS

Example of glue.yaml:

db:
  user: your_user
  password: your_users_password
  host: localhost
  port: 1234567
  name: your_database

For configuration check out internal/web/config.go and cmd/ directory. All values can be configured via command line arguments and environment variables as well.

You will also need to execute migrations and add admin user.

Demo mode

WIP. It's a mode to run njudge without a database.

Development

Use make to run and/or generate stuff.

  • make gulp generates css and js (requires npm install)
  • make lint runs golangci-lint (requires golangci-lint installed)
  • make translations generates translation files
  • make models generates models (requires sqlboiler installed)
  • make test runs tests
  • make templ generates templates (requires templ installed)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
gotext-update-templates
Command gotext-update-templates merge translations and generates a catalog.
Command gotext-update-templates merge translations and generates a catalog.
internal
web
web/templates
templ: version: v0.2.696
templ: version: v0.2.696
pkg
language
Package language is used to compile and run untrusted code securely.
Package language is used to compile and run untrusted code securely.
language/sandbox
Package sandbox declares the Sandbox interface which can be used to run untrusted code.
Package sandbox declares the Sandbox interface which can be used to run untrusted code.
problems
Package problems contains utilities useful for parsing, displaying, judging (a submission for) problems
Package problems contains utilities useful for parsing, displaying, judging (a submission for) problems
problems/executable/checker
Package checker contains different implementation of the interface defined as github.com/mraron/njudge/pkg/problems.Checker
Package checker contains different implementation of the interface defined as github.com/mraron/njudge/pkg/problems.Checker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL