Getting Started - RedwoodAdmin/RedwoodFramework GitHub Wiki
First, redwood needs to be installed on a server. The server can be either a physical machine or a virtual machine. Redwood has been developed and tested on Windows 7 and Ubuntu Linux although other flavors of Windows and Linux should also work with a possibly modified setup procedure. The installation instructions can be found at these links for Windows and Ubuntu.
For the remainder of this guide we will assume that redwood has been installed on a server named myserver.university.edu
Redwood consists of three main components:
-
Django web application
All pages are served by a Django web application. The admin portal of this application is where experiments can be created and edited.
URL to admin portal:http://myserver.university.edu/admin/
-
Experiment pages
These are the pages that are created for a particular experiment, including the admin and subject pages.
URL to admin page:http://myserver.university.edu/session/<session-id>/admin
URL to subject pages:http://myserver.university.edu/session/<session-id>/subject/<subject-id>
-
Router
This is a standalone application that transfers messages between clients during a running experiment. During a running experiment, the client browsers (admin and subjects) load the experiment pages which then communicate via the router by sending messages over web socket connections.
To add a new experiment, go to ``http://myserver.university.edu/admin/expecon/experiment/` as show below.
Then follow the steps below:
- Click 'Add experiment' in the top right
- Select an 'experimenter' and a name for the experiment.
- Save the experiment by pressing ctrl+S
This will create a blank experiment that can be edited using the text areas provided. An existing experiment can also be uploaded, such as one of the example experiments on the website.
The easiest way to build an experiment is to start with one of the example experiments from the Redwood website which can be found at http://redwoodadmin.github.io/RedwoodFramework/. Clicking one of the experiment links will download a zip file including a .json file and a .csv file. The .json file contains the code for the experiment and can be uploaded via the Django admin portal. In the admin portal, open an existing experiment and click 'choose file' from the row of buttons at the top the page. Select the .json file and click 'Upload Experiment'. NOTE: At this stage the upload process only works on an existing, saved experiment.
You can now add a session to the experiment so that it can be run. At the bottom of the page click 'Add another session' and then save (ctrl+s). This will result in a 'View on site' link being displayed. Clicking this link should open the experiment admin page which should similar to the page shown below.
The admin page is where the experimenter controls the experiment. The page provides buttons to start, pause, and reset the experiment and a table showing all connected subjects. It also allows a configuration file to be uploaded.
All example experiments are bundled with a default configuration file. The first thing to do next is upload the example config.csv file. Under 'config' on the admin page, click upload file and select the .csv file. Subjects can now be added by opening browser pages to the url http://myserver.university.edu/session/<session-id>/subject/<subject-id>
where <subject_id>
should be replaced with any positive integer unique to each subject. Newly added subjects should see a 'wait' page that looks similar to page shown below.
Once the required subjects have been added, the experiment can be started on the admin page by clicking Start Session
The Django application provides editing boxes where experiment code can be edited directly. This is manageable for small simple experiments however it is inefficient and error-prone when developing anything slightly more complicated. There two alternatives to this.
A more user-friendly text editor can be used to develop javascript and html and then copy and paste the code into the text boxes on the experiment Django page. This is still fairly inefficient, however.
If direct access to editing server files is available, the experiment can be changed to include files directly from the server during development. Editing and saving the files in an IDE/text editor, will then update the experiment without the need for copy paste.
The Redwood JavaScript framework is based on AngularJS which is well suited to the dynamic needs of experiment pages. It allows all of the display logic to be written in html and angular directives leaving only experiment logic in the controller. The controller is where all experiment state and experiment ‘rules’ should be defined and should not contain any code that directly manipulates the DOM (ie, should not contain any jQuery that modifies the html). Most jQuery can be avoided by simply using angular directives in the html and when jQuery is required it should only be used in directives.
The first function in your experiment that will be called by the framework is that passed to rs.on_load. This is where experiment initialization should take place. At this point the page has loaded and all required variables are available such as rs.config, rs.subjects, etc.