OpenDSA System Documentation

13. OpenDSA Backend Installation and Setup

«  12. The Document Processor   ::   Contents   ::   14. Back-end web services and user interface  »

13. OpenDSA Backend Installation and Setup

The OpenDSA “backend” provides support for collecting student scoring data (in a MySQL database), logs user interaction details with OpenDSA content for analysis purposes, and provides tools for instructors to manage the student score data. Most OpenDSA developers do not need to worry about intalling a copy of the OpenDSA back end. Instructors who would like to use OpenDSA will probably want to contact the OpenDSA team about getting hosting support, rather than set up their own server.

13.1. Windows

  1. Install Python

  2. Install python setuptools

  3. Install Django:

    tar xzvf Django-1.4.1.tar.gz
    cd Django-1.4.1
    python setup.py install
  4. Install MySQL Server

  • Start a MySQL command prompt and then do:

    CREATE DATABASE <database_name>;
    GRANT ALL ON <database_name>.* TO '<database_user>'@'localhost' IDENTIFIED BY '<database_user_password>';
    exit

See “Both” section for remaining instructions

13.2. Linux

  1. Install Python:

    sudo apt-get install python
  2. Download and install Django:

    tar xzvf Django-1.4.1.tar.gz
    cd Django-1.4.1
    python setup.py install
  3. Install python setuptools:

    sudo apt-get install python-setuptools (easy_install)
  4. Install MySQL Server:

    sudo apt-get install mysql-server
    • Start mysql prompt and do:

      mysql -u root -p
      < Enter your password when prompted >
      CREATE DATABASE <database_name>;
      GRANT ALL ON <database_name>.* TO '<database_user>'@'localhost' IDENTIFIED BY '<database_user_password>';
      exit

See “Both” section for remaining instructions

13.3. Both

  1. easy_install MySQL-python
  1. Install required modules, (remove sudo for Windows):

    sudo easy_install oauth2
    sudo easy_install simplejson
    sudo easy_install feedparser
    sudo easy_install icalendar
    sudo easy_install mimeparse
    sudo easy_install python-dateutil
    sudo easy_install django-tastypie
    sudo easy_install html5lib
  2. Install memcache:

    pip install python-memcached
  3. Install user agent (http://pypi.python.org/pypi/django-user_agents):

    pip install pyyaml ua-parser user-agents
    pip install django-user-agents
  4. Install OpenDSA-server:

    git clone https://YOURGITHUBID@github.com/OpenDSA/OpenDSA-server.git
    cd OpenDSA-server/ODSA-django
    • Change values in settings.py file

      • ‘ENGINE’: ‘django.db.backends.mysql’, # Add ‘postgresql_psycopg2’, ‘postgresql’, ‘mysql’, ‘sqlite3’ or ‘oracle’.
      • ‘NAME’: ‘<database_name>’, #g3et_path(‘test.db’), # Or path to database file if using sqlite3.
      • ‘USER’: ‘<database_user>’, # Not used with sqlite3.
      • ‘PASSWORD’: ‘<database_user_password>’, # Not used with sqlite3.
      • ‘HOST’: ‘’, # Set to empty string for localhost. Not used with sqlite3.
      • ‘PORT’: ‘’, # Set to empty string for default. Not used with sqlite3.
      • For both values under ‘TEMPLATE_LOADERS = (‘ change ‘load_template_source’ to ‘Loader’
      • Update BASE_URL to have IP and port of Django server (optional?)
        • BASE_URL = “<IP>:<PORT>”
        • Ex: BASE_URL = “127.0.0.1:8000”
  5. Create an empty file named daily_stats.json, inside the “media root” directory specified in settings.py file

  6. python manage.py syncdb

  7. Create an administrator (superuser) account when prompted

  8. python manage.py runserver 0.0.0.0:8000

  9. In your web browser, go to: http://127.0.0.1:8000/admin/

13.4. SSL Certificates

An OpenDSA installation might encounter the symptom that some students cannot log on. If this is happening, it might be caused by a problem with your SSL certificate chain. If this is the cause, then hopefully you will be able to tell because either the browser console window or the Network tab under Firebug might indicate a message such as “Failed to load response data network error, ERR_INSECURE_RESPONSE”.

The cause for this condition is that either the root certificate is missing in your Apache configuration, or else the certifciate signature chain is broken. In our experience, this can easily happen in a University setting.

You can use online tools to help diagnose SSL installation issues. See https://www.digicert.com/help/ or https://www.sslshopper.com/ssl-checker.html. Then, if necessary you will have to update your Apache configuration file (such as /etc/apache2/sites-enabled/default-ssl). Depending on your problem, you might need to:

13.5. Caching

If you frequently update your OpenDSA’s files, you might want to configure Apache to cache your files for a shorter period of time. In our case we configured Apache to cache js and css files for an hour.

The Apache documentation recommends to make configuration changes inside httpd main server config file rather that using .htaccess files (see http://httpd.apache.org/docs/2.4/howto/htaccess.html). Below is our caching settings:

ExpiresActive On
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType application/javascript "now plus 1 hour"
ExpiresByType application/x-javascript "now plus 1 hour"
ExpiresByType text/javascript "now plus 1 hour"
ExpiresByType text/css "now plus 1 hour"

13.6. Notes

Due to cross-domain communication issues, the files communicating with the Django server must be hosted on a server and that server must be listed in the XS_SHARING_ALLOWED_ORIGINS variable in the settings.py file. For OpenDSA development, we host our files on http://algoviz-beta.cc.vt.edu.

To enable OpenDSA to communicate with the Django server, you must include the IP of your server in your book instance configuration file.

«  12. The Document Processor   ::   Contents   ::   14. Back-end web services and user interface  »