Coursys Environment Setup
Welcome to the project. Let's get your environment set up.
- 1 Git
- 2 Environment
- 2.1 Vagrant (Windows/Mac OS X/Linux)
- 2.2 Ubuntu
- 2.3 Gentoo/FreeBSD
- 2.4 With VirtualEnv
- 3 Test Data
In order to work with the Courses codebase, you'll need to check the codebase out of our git repository.
The url is:
apt-get install git
Download and install Git for Windows from http://git-scm.com/
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.
git clone email@example.com:sfu-fas/coursys.git
You should now have a copy of the git codebase on your system.
Here are some links on Git:
- Basics: http://cworth.org/hgbook-git/tour/
- A more complete tutorial: http://www-cs-students.stanford.edu/~blynn/gitmagic/
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
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. - http://stackoverflow.com/questions/9885108/ssh-to-vagrant-box-in-windows
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 manage.py syncdb python manage.py migrate python manage.py loaddata test_data python manage.py update_index python manage.py 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
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 firstname.lastname@example.org:sfu-fas/coursys.git cd coursys pip install -r build_deps/working_deps.txt
To get your database set up for development, run these commands:
python manage.py syncdb python manage.py migrate python manage.py 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 `serialize.py` and the comments therein.) If you modify the model for an app and reset the database, you can do this:
python manage.py 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