Skip to content

umsi/Online-Study-Game

 
 

Repository files navigation

Online-Study-Game

This repository contains code for running the invest_game study and supporting questionnaires. It also contains (deprecated!) non-invest_game code designed to run other game experiments. This functionality is siloed in its own Django app but could be restored in the future.

Setting up a local environment

This application uses virtualenv to manage the local development environment. Follow the steps below to set up your environment:

  1. If you do not have pip installed, follow the instructions here.
  2. Install virtualenv: pip3 install virtualenv
  3. Set up you virtual environment. From the root directory of this repository, run:
virtualenv --python=$(which python3) env
  1. Enter your new virtual environment: source ./env/bin/activate
  2. Install dependencies: pip install -r requirements.txt
  3. If running the app for the first time, build the database: python manage.py migrate

In development, we use sqlite as the database backend for convenience. In production, we use Postgres.

Running the development server

Start Django's development server with the following command:

python manage.py runserver

You can then run the application at localhost:8000?id=<some_id>.

Cleaning up

To leave your virtual environment when you've finished working on the project, run: deactivate.

Migrating the database

If any changes are made to Django models, you'll need to make a migrations file and run migrations locally to see those changes reflected in the database. To make a new migrations file, run:

python manage.py makemigrations

To apply new migrations, run:

python manage.py migrate

In the production environment, new migrations will be automatically applied.

Creating a superuser

In the local environment, you can create a superuser that will have access to the admin panel. Run:

python manage.py createsuperuser

and follow the prompts.

Deployment

The application is configured to be deployed to an Elastic Beanstalk environment in AWS. This readme assumes that the EB environment is already set up. The environment should have a Postgres database instance connected to it. Database configuration can be managed via the Elastic Beanstalk console.

Assuming such an environment exists, the application can be deployed by running:

eb deploy <environment_name>

where <environment_name> is the name of the EB environment. If no <environment_name> is supplied, the deployment will default to an environment called Online-Study-Game. It's intended that the default environment name be used for the production application.

If you need to create an environment, use the eb create command, documented here.

Production deployment

The production application will deploy automatically when new commits are merged and pushed to the master branch of the umsi/Online-Study-Game repository.

Admin panel

The standard Django admin application can be accessed at <application_url>/admin. The username and password are set using a database fixture found in games/invest_game/fixtures/users.json.

From the admin panel, you can export study data to a CSV file.

Running tests

Run tests with:

python manage.py test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 55.3%
  • Python 33.1%
  • CSS 9.2%
  • JavaScript 2.4%