Coursys Environment Setup

From SFU_Public
Jump to: navigation, search

Coursys

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

Git

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

The url is:

git@github.com:sfu-fas/coursys.git

Installing Git

Ubuntu

apt-get install git

Windows

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.

Now run

git clone git@github.com:sfu-fas/coursys.git

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


Using Git

Here are some links on Git:

Environment

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

https://www.virtualbox.org/

2. Install Vagrant

http://vagrantup.com/

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. - 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

0:8000

as an argument to runserver.

4.5. Interact with the server.

Open

http://localhost:8001

in your browser.

5. Modify the code.

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

C:\Users\Awesome\Code\courses

- is mounted on the virtual machine as

/home/vagrant/courses

. 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.

Ubuntu

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

Gentoo/FreeBSD

http://i0.kym-cdn.com/photos/images/newsfeed/000/198/010/tysonreaction.gif

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 git@github.com:sfu-fas/coursys.git
cd coursys
pip install -r build_deps/working_deps.txt

Test Data

Setup

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).

Change

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.

Reset

To reset the database to its initial state, run

/tools/reset_db.sh

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