moocunsw / ontask3_UNSW

A platform offering teachers and educational designers the capacity to use data to personalise the experience for the learners.
https://ontasklearning.org
6 stars 6 forks source link

OnTask v2.5

Running the application

For development

  1. Perform the configuration steps outlined here
  2. Install Docker and docker-compose
  3. From your terminal, run docker-compose build followed by docker-compose up in the root OnTask directory
  4. If this is the first time running, the following must be performed:
    • Attach to the backend container by running docker-compose exec backend sh
    • Initialise the database by running python3 manage.py makemigrations accounts, python3 manage.py makemigrations and lastly python3 manage.py migrate
    • Load data into user groups by running python3 manage.py loaddata user_groups
    • Create the first admin user by running python manage.py createsuperuser
    • Create a term Table in the ontask Database (you can use a Database client like MongoDB Compass) and import Term Codes.csv (or create your own Terms). This is to ensure that you have Terms to search and create containers via the UI. term table should have fields: code (number), name (string), start (date), end (date)
  5. In order to work with LTI via localhost, the application runs in SSL mode with self-signed certs

For production

  1. Complete steps 1-4 from above, however, instead run docker-compose -f docker-compose.prod.yaml up (in step 3)
  2. Compile the frontend by running npm run build in the frontend directory
  3. Serve the files in the frontend/build/ directory as a static website (e.g. through S3 behind a CloudFront distribution)
  4. Add a proxy pass in your webserver configuration from your backend domain (e.g. api.ontask.org) to http://localhost:8000 (not https)

Configuration

General configuration

  1. Create an environment file env.py in the backend/ontask/ directory
  2. Run pip install cryptography
  3. From a Python shell, run the following command:
from cryptography.fernet import Fernet
# The following generated secret key will be used for encrypting sensitive data
# Loss or change of the secret key will result in the loss of all datasource passwords
# This is a breaking issue for dynamic data sources, as update attempts will fail
Fernet.generate_key().decode("utf-8")
  1. Configure the environment file as follows:
SECRET_KEY = "<SECRET_KEY_GENERATED_ABOVE>"

 # List of admins that will recieve user signup notifications via email
ADMINS = ["<ADMIN_EMAIL_1>"]

FRONTEND_DOMAIN = "https://<YOUR_FRONTEND_DOMAIN>"
BACKEND_DOMAIN = "https://<YOUR_BACKEND_DOMAIN>"
ALLOWED_HOSTS = ["<YOUR_FRONTEND_DOMAIN>"] # Without the protocol specified

# If uncommented, use the given named profile from your AWS credentials
# file (usually ~/.aws/credentials). Otherwise, boto3 will assume the AWS role
# of the server itself
# AWS_PROFILE = "<YOUR_AWS_NAMED_PROFILE>"
AWS_REGION = "<YOUR_AWS_REGION>"
ENABLE_CLOUDWATCH_LOGGING  = False
DEMO_BUCKET = "<YOUR_S3_BUCKET>"

# SMTP credentials to enable email sending from OnTask
EMAIL_HOST = "<YOUR_SMTP_HOST>"
EMAIL_PORT = 587
EMAIL_NAME = "OnTask" # Default name to appear in emails sent
EMAIL_ALIAS = "<YOUR_EMAIL_ALIAS>" # Default alias email to use in emails sent
EMAIL_HOST_USER = "<YOUR_SMTP_USER>" # SMTP login user
EMAIL_HOST_PASSWORD = "<YOUR_SMTP_PASSWORD>" # SMTP login password
EMAIL_USE_TLS = True
EMAIL_BATCH_SIZE = 50  # Maximum number of emails to send at a time (i.e. a batch)
EMAIL_BATCH_PAUSE = 300  # Minutes to wait between batches of emails

# Configuration for AAF Rapid Connect
AAF_CONFIG = {
    "secret_key": "<YOUR_AAF_SECRET>",
    "aaf.edu.au": {
        "iss": "https://rapid.aaf.edu.au", # https://rapid.test.aaf.edu.au for dev
        "aud": "https://<YOUR_DOMAIN>", # https://localhost:8000 for dev
        "idp": "<YOUR_AAF_IDP>",
    }
}

LTI_CONFIG = {
    "staff_role": "Instructor", # Role that will be added to the instructor group when coming from LTI
    "consumers": {
        "ontask": { # App name registered in LTI
            "secret": "<YOUR_LTI_SECRET>"
        }
    },
    "url": "<YOUR_LTI_URL>",
    "username_field": "<YOUR_LTI_USERNAME_FIELD>", # Specify which field in the LTI payload maps to your institution's user ID
    "auto_create_share_containers": True # Allows for the auto creation and sharing of containers in lti context.
}
  1. Create environment files .env.development (for development) and/or .env.production (for production) in the frontend/ directory
  2. Configure the environment file(s) created above:
REACT_APP_API_DOMAIN = "https://<YOUR_BACKEND_DOMAIN>";
REACT_APP_AWS_ID = "YOUR_AWS_ID";
REACT_APP_AAF_URL = "<YOUR_AAF_IDP>";
// If uncommented, show the Register Account interface
// REACT_APP_DEMO = True

Packages Used

Frontend Dependencies

Package Name License
React.js MIT
create-react-app MIT
react-router MIT
Ant Design MIT
Slate MIT
is-hotkey MIT
react-dnd BSD
react-draggable MIT
lodash MIT
moment MIT
query-string MIT
sanitize-html MIT
memoize-one MIT
highcharts CC
d3 BSD

Backend Dependencies

Package Name License
Django BSD
djangorestframework BSD
mongoengine MIT
django-rest-framework-mongoengine MIT
django-cors-headers License
uWSGI GPL
SQLAlchemy MIT
pyjwt MIT
boto3 Apache
celery BSD
django-celery-beat BSD
cryptography Apache/BSD
python-dateutil Apache
xlrd License
numexpr MIT
pandas BSD
djongo AGPL
PyLTI BSD