README.md 1.84 KB
Newer Older
Julien Palard's avatar
Julien Palard committed
1
2
# How to contribute

Antoine Angot's avatar
Antoine Angot committed
3
4
5

## Requirements

6
This project requires Python 3.6 at least.
Antoine Angot's avatar
Antoine Angot committed
7

8
9

## Install
Antoine Angot's avatar
Antoine Angot committed
10

Julien Palard's avatar
Julien Palard committed
11
12
13
```
pip install -r requirements.txt
./manage.py migrate
Julien Palard's avatar
Julien Palard committed
14
./manage.py loaddata initial  # To get some users and exercises
Julien Palard's avatar
Julien Palard committed
15
16
# (Initial data can be updated using:
   ./manage.py dumpdata -e contenttypes -e auth.Permission -e sessions.session > website/fixtures/initial.json)
Julien Palard's avatar
Julien Palard committed
17
./manage.py createsuperuser
Jérôme's avatar
Jérôme committed
18
./manage.py runserver
Julien Palard's avatar
Julien Palard committed
19
20
```

21
To also run the moulinette, you'll need to install `firejail` and `redis` then run:
Julien Palard's avatar
Julien Palard committed
22

23
24
25
```
celery -A hkis worker
```
Julien Palard's avatar
Julien Palard committed
26

Julien Palard's avatar
Julien Palard committed
27

Julien Palard's avatar
Julien Palard committed
28
29
## Translations

Julien Palard's avatar
Julien Palard committed
30
31
Templates are translated using django `makemessages` and `compilemessages` commands:

Julien Palard's avatar
Julien Palard committed
32
```
Julien Palard's avatar
Julien Palard committed
33
$ ./manage.py makemessages --locale fr
34
$ ./manage.py makemessages --locale fr --domain djangojs
Julien Palard's avatar
Julien Palard committed
35
# Edit the .po files
Julien Palard's avatar
Julien Palard committed
36
$ ./manage.py compilemessages
Julien Palard's avatar
Julien Palard committed
37
38
```

Julien Palard's avatar
Julien Palard committed
39
40
Exercises (title and wording) are translated via the admin (or the
API), we use django-modeltranslation.
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63


## How does the checker bot work?

The answers are load-balanced to correction workers using Celery, so
you can have multiple machines dedicated to correct loads of answers.

Once received by a worker the worker runs two things:

- An optional `pre_check.py` script, that sets-up anything specific
  for this answers (required files and directories, translations,
  whatever is needed).

- A `check.py` script is then started in a sandbox (no internet
  connectivity, restricted filesystem, CPU, memory usage, …).  This is
  the script that check the student answer, the protocol is simple: if
  the script prints, then then answer is wrong, and what's been
  printed is displayed, as Markdown, to the student.

Both `pre_check.py` and `check.py` are in Python, but they're not
limited to check for Python answers, if you want to check for shell
script or C, or whatever, the `check.py` can use `subprocess` to run
the answer script, or compile the answer code, or whatever needed.