Skip to content

peterddod/lvl3-team-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SETUP

Prerequisites

  1. A Linux distro - we have been using Ubuntu.
  2. An up-to-date installation of Docker. More information here: https://docs.docker.com/engine/install/

You will need to run docker without having to use sudo. To do this, run the following in the terminal:

sudo groupadd docker
sudo usermod -aG docker $USER

You will likely need to log out and log back in so your user membership is reevaluated.

  1. A version of Python that is between 3.5 and 3.9.

  • Step 1
    Clone the repo using:
    git clone <link>

  • Step 2
    Run the setup script in the cs14-main/ directory:
    python setup.py If you do this, you can skip to Step 5. Alternatively, or if this script fails, do the following steps.

  • Step 3
    Install the requirements.
    In the cs14-main/ directory, run:
    pip install -r requirements.txt

  • Step 4
    Create the database.
    In the cs14-main/main/ directory, run the following commands:
    python manage.py makemigrations
    python manage.py makemigrations cs14
    python manage.py migrate

  • Step 5 (optional)
    Populate the database.
    We have provided two database dumps, admindb.json and exampledb.json in the cs14-main/main directory. The first one simply contains a superuser, which does not yet have any site privileges assigned, they simply have access to the Django admin interface.
    The second contains a superuser with site admin and reviewer privileges (can generate users, tasks and review tasks), a candidate and two tasks, both assigned to the candidate.
    You can populate the database by running:
    python manage.py loaddata <selected json file>
    The password for all users is PASSWORD!!! and the usernames are admin and user1.

NOTE: If using the database with the example tasks, we have written a script, populate_tests.py in the cs14-main/main directory, which will create (and remove) the necessary folders for the tasks to work.
To create the necessary directories and files, run:
python populate_tests.py create_tests
To remove these, run:
python populate_tests.py remove_tests

  • Step 6
    If you used one of the database dumps from step 5, a superuser should already be created, with the credentials:
    user: admin
    password: PASSWORD!!!
    If you are not using one of the database dumps, you can create a superuser with the following command:
    python manage.py createsuperuser

  • Step 7
    Build the docker image.
    In the directory cs14-main/main/static/python/, run the following command:
    docker build -t coding-image .

Note: The docker image may take a few minutes to build, and the building process may not succeed on the first try.

  • Step 8
    You can now run the site locally using the following command in the cs14-main/main/ directory:
    python manage.py runserver

ADMIN (adding users and other objects to the database)

  • Firstly, you will need to add a superuser. You should have already done this in the setup, either by using one of the provided database dumps, or by running:
    python manage.py createsuperuser

  • You can now log into the Django admin interface using this user. You will need to run the server first:
    python manage.py runserver
    Open the link that appears in the terminal, and navigate to http://127.0.0.1:8000/admin.

  • From here, sign in as the created superuser. You can now add values to the database.

Note: The site admins are different to the superusers. You will have to give a superuser admin privileges so they can generate user accounts.
Alternatively, you can create a new admin user. This can be done via the Django admin interface.

ADDING CODING TASKS

Coding task objects are added via the Django admin interface. However, the expected output and sample input need to be added manually. To do so:

  • Create a directory in cs14-main/main/media/tests/ with the name test followed by the the task id. For example, if the task id is 1, the folder should be named "test1", thus creating the directory cs14-main/main/media/tests/test1.

  • Within this new directory, create two directories: input and output.

  • In the "input" directory, create a file containing the input to the code. If no input is required, create an empty file, as this is required for the compilation to work.

  • In the "output" directory, create a file containing the expected output of the code, which will be used for the testing.

An example of sample input and output would be the following:

Task description: "Write some code which takes input values from the command line and outputs their squares."

The input and output files should contain the following:

Input:
1
2
3
4

Output:
1
4
9
16

ADDING MORE LANGUAGES

If you would like to add more languages, you will need to:

  • Add installation instructions for the compiler/language in the Dockerfile, which can be found in cs14-main/main/static/python/
  • Add code for compilation and/or running in runcontainer.py, found in cs14-main/main/static/python/
  • Rebuild the Docker image
  • Add the necessary file extension in the add_language_extension function found in compile.py (cs14-main/main/static/python)
  • You will also need to add the required buttons in the selection menu of the coding page.

About

The repository for my 3rd year team project working for Avaloq, in which we achieved a grade of A2.

Resources

License

Stars

Watchers

Forks

Packages

No packages published