Skip to content

Commit

Permalink
Merge branch 'development' into frontend/enhancement/error_pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Matisse-Sulzer authored Mar 28, 2024
2 parents 9a2b0a5 + f8fee40 commit 20c0d8d
Show file tree
Hide file tree
Showing 82 changed files with 4,235 additions and 1,269 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci-linter-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: UGent-3-backend-linter
run-name: ${{ github.actor }} is running backend linter 🚀
on:
pull_request:
paths:
- 'backend/**'
jobs:
Backend-tests:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'

- name: Run linting
working-directory: ./backend
run: find . -type f -name "*.py" | xargs pylint

30 changes: 30 additions & 0 deletions .github/workflows/ci-linter-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: UGent-3-frontend-linter
run-name: ${{ github.actor }} is running frontend linter 🚀
on:
pull_request:
paths:
- 'frontend/**'
jobs:
Frontend-tests:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Install dependencies
working-directory: ./frontend
run: npm i eslint

- name: Run linting
working-directory: ./frontend
run: npm run lint

27 changes: 27 additions & 0 deletions .github/workflows/ci-test-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: UGent-3-backend-test
run-name: ${{ github.actor }} is running backend tests 🚀
on:
pull_request:
paths:
- 'backend/**'
jobs:
Backend-tests:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'

- name: Install dependencies
working-directory: ./backend
run: pip3 install -r requirements.txt && pip3 install -r dev-requirements.txt

- name: Running tests
working-directory: ./backend
run: bash ./run_tests.sh


38 changes: 38 additions & 0 deletions .github/workflows/ci-test-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: UGent-3-frontend-test
run-name: ${{ github.actor }} is running frontend tests 🚀
on:
pull_request:
paths:
- 'frontend/**'
jobs:
Frontend-tests:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Install dependencies
working-directory: ./frontend
run: npm ci

- name: Build
working-directory: ./frontend
run: npm run build

- name: Preview Web App
working-directory: ./frontend
run: npm run preview &

- name: Running tests
working-directory: ./frontend
run: npm test

62 changes: 0 additions & 62 deletions .github/workflows/ci-tests.yml

This file was deleted.

22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
# UGent-3
# UGent-3 project peristerónas
![tests](https://github.com/SELab-2/UGent-3/actions/workflows/ci-test-frontend.yaml/badge.svg?branch=development)
![linter](https://github.com/SELab-2/UGent-3/actions/workflows/ci-linter-frontend.yaml/badge.svg?branch=development)
![tests](https://github.com/SELab-2/UGent-3/actions/workflows/ci-test-backend.yaml/badge.svg?branch=development)
![linter](https://github.com/SELab-2/UGent-3/actions/workflows/ci-linter-backend.yaml/badge.svg?branch=development)
## Introduction
Project peristerónas was created to aid both teachers and students in achieving a
clear overview of deadlines and projects that need to be submitted.

There's a separate functionality depending on if you're logged in as a teacher or as a student.
For students the main functionality is to have a user-friendly interface to submit projects and check the correctness of their submissions.

When a teacher is logged in they can get an overview of the projects he assigned and check how many students have already
handed in a correct solution for example. It's also possible to edit the project and to grade projects in peristerónas' interface.
## Usage
### Frontend
For the developer instructions of the frontend please refer to the [frontend readme](frontend/README.md)
where clear instructions can be found for usage, test cases, deployment and development.
### Backend
For the developer instructions of the backend please refer to the [backend readme](backend/README.md)
where clear instructions can be found for usage, test cases, deployment and development.
3 changes: 0 additions & 3 deletions backend/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ COPY . /app
RUN apt-get update
RUN apt-get install -y --no-install-recommends python3-pip
RUN pip3 install --no-cache-dir -r requirements.txt -r dev-requirements.txt

# Command to run the tests
CMD ["pytest"]
9 changes: 9 additions & 0 deletions backend/Dockerfile_auth_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.9
RUN mkdir /auth-app
WORKDIR /auth-app
ADD ./test_auth_server /auth-app/
COPY auth_requirements.txt /auth-app/requirements.txt
RUN pip3 install -r requirements.txt
COPY . /auth-app
ENTRYPOINT ["python"]
CMD ["__main__.py"]
2 changes: 2 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Project pigeonhole backend
![tests](https://github.com/SELab-2/UGent-3/actions/workflows/ci-test-backend.yaml/badge.svg?branch=development)
![linter](https://github.com/SELab-2/UGent-3/actions/workflows/ci-linter-backend.yaml/badge.svg?branch=development)
## Prerequisites
**1. Clone the repo**
```sh
Expand Down
4 changes: 4 additions & 0 deletions backend/auth_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flask~=3.0.2
flask-restful
python-dotenv~=1.0.1
psycopg2-binary
41 changes: 33 additions & 8 deletions backend/db_construct.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
CREATE TYPE role AS ENUM ('STUDENT', 'TEACHER', 'ADMIN');

CREATE TYPE submission_status AS ENUM ('SUCCESS', 'LATE', 'FAIL', 'RUNNING');

CREATE TABLE users (
uid VARCHAR(255),
is_teacher BOOLEAN,
is_admin BOOLEAN,
role role NOT NULL,
PRIMARY KEY(uid)
);

Expand All @@ -10,10 +13,18 @@ CREATE TABLE courses (
name VARCHAR(50) NOT NULL,
ufora_id VARCHAR(50),
teacher VARCHAR(255) NOT NULL,
CONSTRAINT fk_teacher FOREIGN KEY(teacher) REFERENCES users(uid),
CONSTRAINT fk_teacher FOREIGN KEY(teacher) REFERENCES users(uid) ON DELETE CASCADE,
PRIMARY KEY(course_id)
);

CREATE TABLE course_join_codes (
join_code UUID DEFAULT gen_random_uuid() NOT NULL,
course_id INT NOT NULL,
expiry_time DATE,
for_admins BOOLEAN NOT NULL,
CONSTRAINT fk_course_join_link FOREIGN KEY(course_id) REFERENCES courses(course_id) ON DELETE CASCADE,
PRIMARY KEY(join_code)
);

CREATE TABLE course_admins (
course_id INT NOT NULL REFERENCES courses(course_id) ON DELETE CASCADE,
Expand All @@ -30,12 +41,12 @@ CREATE TABLE course_students (
CREATE TABLE projects (
project_id INT GENERATED ALWAYS AS IDENTITY,
title VARCHAR(50) NOT NULL,
descriptions TEXT NOT NULL,
description TEXT NOT NULL,
assignment_file VARCHAR(50),
deadline TIMESTAMP WITH TIME ZONE,
course_id INT NOT NULL,
visible_for_students BOOLEAN NOT NULL,
archieved BOOLEAN NOT NULL,
archived BOOLEAN NOT NULL,
test_path VARCHAR(50),
script_name VARCHAR(50),
regex_expressions VARCHAR(50)[],
Expand All @@ -47,11 +58,25 @@ CREATE TABLE submissions (
submission_id INT GENERATED ALWAYS AS IDENTITY,
uid VARCHAR(255) NOT NULL,
project_id INT NOT NULL,
grading INTEGER CHECK (grading >= 0 AND grading <= 20),
grading FLOAT CHECK (grading >= 0 AND grading <= 20),
submission_time TIMESTAMP WITH TIME ZONE NOT NULL,
submission_path VARCHAR(50) NOT NULL,
submission_status BOOLEAN NOT NULL,
submission_status submission_status NOT NULL,
PRIMARY KEY(submission_id),
CONSTRAINT fk_project FOREIGN KEY(project_id) REFERENCES projects(project_id) ON DELETE CASCADE,
CONSTRAINT fk_user FOREIGN KEY(uid) REFERENCES users(uid)
CONSTRAINT fk_user FOREIGN KEY(uid) REFERENCES users(uid) ON DELETE CASCADE
);

CREATE OR REPLACE FUNCTION remove_expired_codes()
RETURNS TRIGGER AS $$
BEGIN
DELETE FROM course_join_codes
WHERE expiry_time < CURRENT_DATE;

RETURN NULL;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER remove_expired_codes_trigger
AFTER INSERT OR UPDATE ON course_join_codes
FOR EACH ROW EXECUTE FUNCTION remove_expired_codes();
27 changes: 27 additions & 0 deletions backend/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions backend/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
description = "Python pip DevShell";

inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

outputs = { self, nixpkgs }: let
systems = [ "x86_64-linux" ];
forAllSystems = function: nixpkgs.lib.genAttrs systems (system: function {
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
});
in {
devShells = forAllSystems ({ pkgs }: {
default = (pkgs.buildFHSUserEnv {
name = "pip-zone";
targetPkgs = pkgs: with pkgs; [
python311Full
python311Packages.pip

postgresql
dbeaver
];
runScript = "zsh || bash";
}).env;
});
};
}
Loading

0 comments on commit 20c0d8d

Please sign in to comment.