Coursys Environment Setup

From SFU_Public
Jump to: navigation, search


Welcome to the project. Let's get your environment set up.


In order to work with the Courses codebase, you'll need to check the codebase out of our git repository.

The url is:

Installing Git


apt-get install git


Download and install Git for Windows from

Generating a SSH Key

Git over HTTP doesn't work particularly well. It's slow, and authentication can be a lot of trouble (Imagine a CAS authentication handshake for every file in a repository. It takes a while, is what I'm saying.)

So, in order to authenticate users and allow rapid access to the repo? SSH authentication. Particularly, SSH public-key authentication.

The way this works is:

2. Load the private-key pair into Github

Their instructions are quite complete.

3. Git clone.

Now run

git clone

You should now have a copy of the git codebase on your system.

Using Git

Here are some links on Git:


There are a few different ways to install courses.

Vagrant (Windows/Mac OS X/Linux)

Vagrant and VirtualBox can be used to keep courses running within a virtual machine.

1. Install VirtualBox

2. Install Vagrant

3. Provision your server.

cd coursys/machines/developer
vagrant up

This will download the 32-bit Ubuntu Precise Pangolin base box and install Courses and all of its dependencies.

4. Run the server.

If you'd like to interact with your server, type in

vagrant ssh

On a Windows box, you'll need to install PuTTY and PuTTYGen to SSH into your Vagrant box. Vagrant will generate an insecure private key for connecting to local Vagrant instances. You'll need to convert this insecure private key into a .ppk file (using PuTTYGen), then tell PuTTY where to find the .ppk file. -

From within the virtual machine, you can navigate to the code, which is in your home directory, under 'courses', and run the server.

cd courses

python syncdb
python migrate
python loaddata test_data
python update_index

python runserver 0:8000

As an important note, the only outward-facing port on this virtual machine is 8000 (aliased to 8001 on your host machine), so you must specify


as an argument to runserver.

4.5. Interact with the server.



in your browser.

5. Modify the code.

So, wherever you've checked out your codebase on your host machine - let's imagine


- is mounted on the virtual machine as


. So, you can work on the code within the virtual machine or from the host machine, and either set of changes will be reflected in the codebase.

6. Recreate the VM

To reload the VM from scratch - perhaps because somebody has updated the environment - enter the following commands from your host computer:

vagrant destroy
vagrant up 

7. Change the Machine or Environment

The configuration file that determines the properties of the generated machine lives at courses/virtual_machine/Vagrantfile .

The file that loads the Coursys environment lives at courses/virtual_machine/chef-repo/cookbooks/coursys/recipes/default.rb

After changing either of these, you will need to recreate your VM to see any changes.


To set-up CourSys without a Vagrant VM, in Ubuntu, you'll need to install the following packages from apt:

sudo apt-get install git python python-pip python-dev python-lxml libxslt1-dev sqlite3 zlib1g-dev

then, use PIP to install the program's python dependencies.

pip install -r build_deps/working_deps.txt

possibly your machine will have other/older versions of some packages; we found the --upgrade option was effective:

pip install --upgrade -r build_deps/working_deps.txt


With VirtualEnv

The Ubuntu instructions can be combined with VirtualEnv to create a separate environment for your libraries.

virtualenv coursys
cd coursys
source bin/activate
git clone -b master
cd coursys
pip install -r build_deps/working_deps.txt

Test Data


To get your database set up for development, run these commands:

python syncdb
python migrate
python loaddata test_data

This will initialize the database with a collection of test data. Instructor data (excluding employee ID) is real; TA and student data is fake. You can log is as any user with the fake authentication system used for the development environment. Fake userids all start with "0" (to distinguish them from real people).


Additional test data can be added to `test_data.json` as needed. (See `` and the comments therein.) If you modify the model for an app and reset the database, you can do this:

python reset <appname>

...and then repeat the above steps (syncdb and loaddata) to rebuild the tables for that app.


To reset the database to its initial state, run


Notable Test Data

  • Instructors of courses with enrolment: ggbaker
  • Grad student and TA: 0aaagrad, 0bbbgrad, 0ccccgrad, etc
  • Undergrad Students: 0aaa0-0aaa19, 0bbb0-0bbb19, 0ccc0-0ccc19, etc
  • Courses with interesting test data: CMPT 383 D1 summer 2012
  • Advisor: dzhao