PrairieLearn is an online problem-driven learning system. It consists of a server component that presents questions and other data via an API, and a webapp that interfaces with the user and communicates with the server.
- Install the pre-requisites:
On OS X these can be installed with MacPorts or Homebrew.
-
Next clone the latest code:
$ git clone https://github.com/PrairieLearn/PrairieLearn.git -
Install the backend libraries:
$ cd PrairieLearn/backend $ npm install -
(Optional) Render question TeX image files for figures
$ cd PrairieLearn/backend $ make
-
Run the database:
$ mongod --dbpath ~/db -
Run the server:
$ cd PrairieLearn/backend $ node server -
In a web-browswer view the PrairieLearn/frontend/index.html file:
$ open file://...<path>.../PrairieLearn/frontend/index.html
To test the database, you can access it directly:
$ mongo
> show dbs
> use data
> show collections
> db.users.find()
> db.users.save({uid: "[email protected]"})
To test the server, you can access it from the commandline:
$ curl http://localhost:3000/questions
$ curl http://localhost:3000/questions/scalarAdd
$ curl -H "X-Auth-UID: [email protected]" -H "X-Auth-Name: User Name" -H "X-Auth-Date: 2013-08-17T09:44:18Z" -H "X-Auth-Signature: 3d38a7acba63047cf8bcf29f9691c68a2cae30e3ae5057ef1ea4616d2060a4be" http://localhost:3000/users
$ curl -H "X-Auth-UID: [email protected]" -H "X-Auth-Name: User Name" -H "X-Auth-Date: 2013-08-17T09:44:18Z" -H "X-Auth-Signature: 3d38a7acba63047cf8bcf29f9691c68a2cae30e3ae5057ef1ea4616d2060a4be" http://localhost:3000/users/[email protected]
$ curl -H "X-Auth-UID: [email protected]" -H "X-Auth-Name: User Name" -H "X-Auth-Date: 2013-08-17T09:44:18Z" -H "X-Auth-Signature: 3d38a7acba63047cf8bcf29f9691c68a2cae30e3ae5057ef1ea4616d2060a4be" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"uid": "[email protected]", "qid": "scalarAdd"}' http://localhost:3000/qInstances
$ curl http://localhost:3000/questions/scalarAdd/1/question.html
$ curl http://localhost:3000/questions/scalarAdd/1/client.js
$ curl http://localhost:3000/questions/scalarAdd/1/params
$ curl -H "X-Auth-UID: [email protected]" -H "X-Auth-Name: User Name" -H "X-Auth-Date: 2013-08-17T09:44:18Z" -H "X-Auth-Signature: 3d38a7acba63047cf8bcf29f9691c68a2cae30e3ae5057ef1ea4616d2060a4be" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"uid": "[email protected]", "qid": "scalarAdd", "vid": "1", "qiid": "qi32", "submittedAnswer": {"c": "43"}}' http://localhost:3000/submissions
Useful curl options:
--trace
--trace-time
-w, --write-out
-v, --verbose
To access the client we can either run a webserver locally or acess the files directly from disk.
Simply open frontend/index.html in a web browser. Chrome will give
cross-origin errors when loading non-javascript from disk, so it must
be run with the --allow-file-access-from-files commandline
argument. Under OS X this can be done with:
open '/Applications/Google Chrome.app' --new --args --allow-file-access-from-files
On Windows this can be done by adding the
--allow-file-access-from-files flag to a special shortcut (edit it
with right-click and properties -> target).
To disable cross-origin errors in Firefox go to about:config and set
security.fileuri.strict_origin_policy to false.
Any webserver that can serve up the frontend directory tree can be
used to access the client. One particularly easy way to do this is to
run python -m SimpleHTTPServer in the frontend directory, and then
point the webbrowser to http://localhost:8000.
When the DB is stopped:
mongorestore --dbpath ~/db ~/path-to-dump
$ sudo npm install -g grunt-cli
$ grunt
$ sudo npm install -g marked
$ marked --gfm README.md > README.html
- Node.js
- npm
- MongoDB
- Express
- jQuery
- Underscore.js
- Backbone.js
- Bootstrap
- Grunt
- async
- JSHint
- RequireJS
- tween.js
- Sylvester
- MathJax
- Rivets.js
Install:
- VirtualBox: http://www.virtualbox.org/
- Vagrant: http://www.vagrantup.com/
In the PrairieLearn directory run:
vagrant up # download and boot the VM and install packages
To run the PrairieLearn server do:
vagrant ssh # login to the VM
cd /vagrant/backend # change to the PrairieLearn backend server directory
npm install # install libary packages (one time only)
make # compile latex in figures (only after changing figure latex)
grunt # check code for syntax and style (optional)
node server # run the PrairieLearn server
When the server is running, access PrairieLearn in a web browser on the host at the URL http://localhost:8080/
To stop the server and logout of the VM:
ctrl-c # stop the server
logout # logout of the VM (can also use ctrl-d)
Other useful vagrant commands on the host:
vagrant halt # shutdown the VM
vagrant destroy # delete the VM completely
vagrant up # start the VM again (after halt or destroy)
vagrant suspend # suspend the VM
vagrant resume # resume a suspended VM