Commit 6543b1ca by Will Daly

Merge pull request #149 from edx/will/minimize

Minify JavaScript, remove whitespace from templates
parents ade749ab 2e0becf3
......@@ -53,3 +53,6 @@ config.codekit
node_modules
npm-debug.log
coverage
# Dev database
timdb
language: python
python:
- "2.7"
install:
- "pip install -r requirements/test.txt --use-mirrors"
- "pip install -e ."
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- "pip install coveralls"
script:
- "python manage.py test"
- "./scripts/test.sh"
- "python setup.py install"
after_success:
coveralls
......@@ -11,32 +11,42 @@ This is an initial prototype for redesigning Peer Grading and general Open Ended
Submission Evaluation. This project is in the early stages of development and is
not ready for general use.
Installation
============
The intent of this project is to be installed as Django apps that will be
included in `edx-platform <https://github.com/edx/edx-platform>`_. To install
for development purposes, run::
included in `edx-platform <https://github.com/edx/edx-platform>`_.
To install dependencies and start the development ("workbench") server:
pip install -r requirements/dev.txt
pip install -e .
.. code:: bash
The second line is necessary to register edx-tim's XBlock so that it will show
up in the XBlock workbench.
./scripts/workbench.sh
To setup the database, run::
By default, the XBlock JavaScript will be combined and minified. To
preserve indentation and line breaks in JavaScript source files:
.. code:: bash
DEBUG_JS=1 ./scripts/workbench.sh
Additional arguments are passed to ``runserver``. For example,
to start the server on port 8001:
.. code:: bash
python manage.py syncdb --migrate
./scripts/workbench.sh 8001
Running Tests
=============
To run the unit test suite:
To run the Python and Javascript unit test suites:
.. code:: bash
python manage.py test
./scripts/test.sh
Quality Check
......
{% spaceless %}
<li id="openassessment__grade" class="openassessment__steps__step step--grade is--complete has--grade">
<header class="step__header ui-toggle-visibility__control">
<h2 class="step__title">
......@@ -147,10 +148,5 @@
</form>
</div>
</div>
</li>
</li>
{% endspaceless %}
{% spaceless %}
<li id="openassessment__grade" class="openassessment__steps__step step--grade is--incomplete">
<header class="step__header ui-toggle-visibility__control">
<h2 class="step__title">
......@@ -11,3 +12,4 @@
</h2>
</header>
</li>
{% endspaceless %}
{% spaceless %}
<li id="openassessment__grade" class="openassessment__steps__step step--grade is--unstarted">
<header class="step__header ui-toggle-visibility__control">
<h2 class="step__title">
......@@ -11,3 +12,4 @@
</h2>
</header>
</li>
{% endspaceless %}
{% spaceless %}
<li id="openassessment__grade" class="openassessment__steps__step step--grade is--incomplete awaiting--peer-evaluations">
<header class="step__header ui-toggle-visibility__control">
<h2 class="step__title">
......@@ -11,4 +12,5 @@
</span>
</h2>
</header>
</li>
\ No newline at end of file
</li>
{% endspaceless %}
{% spaceless %}
<div class="wrapper wrapper--xblock wrapper--openassessment theme--basic">
<div class="openassessment" id="openassessment">
<div class="wrapper--grid">
......@@ -68,3 +69,4 @@
</div>
</div>
</div>
{% endspaceless %}
{% block list_item %}
<li id="openassessment__peer-assessment" class="openassessment__steps__step step--peer-assessment ui-toggle-visibility">
{% endblock %}
{% spaceless %}
<span class="system__element" id="peer_submission_uuid">
{{ peer_submission.uuid }}
</span>
......@@ -130,4 +131,5 @@
</div>
</div>
{% endblock %}
{% endspaceless %}
</li>
{% spaceless %}
{% block list_item %}
<li id="openassessment__response" class="openassessment__steps__step step--response ui-toggle-visibility">
{% endblock %}
......@@ -84,3 +85,4 @@
</div>
{% endblock %}
</li>
{% endspaceless %}
{% load i18n %}
{% spaceless %}
{% block list_item %}
<li id="openassessment__self-assessment" class="openassessment__steps__step step--self-assessment ui-toggle-visibility">
{% endblock %}
......@@ -100,3 +100,4 @@
</div>
{% endblock %}
</li>
{% endspaceless %}
"""An XBlock where students can read a question and compose their response"""
import datetime as dt
import json
import pkg_resources
import pytz
import dateutil.parser
from django.template.context import Context
from django.template.loader import get_template
......@@ -305,8 +303,7 @@ class OpenAssessmentBlock(
context = Context(context_dict)
frag = Fragment(template.render(context))
frag.add_css(load("static/css/openassessment.css"))
frag.add_javascript(load("static/js/src/oa_server.js"))
frag.add_javascript(load("static/js/src/oa_base.js"))
frag.add_javascript(load("static/js/openassessment.min.js"))
frag.initialize_js('OpenAssessmentBlock')
return frag
......
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
# For convenience, use the test-specific settings by default
# when running nose or lettuce test suites.
# Otherwise, use the base settings.
if 'test' in sys.argv or 'harvest' in sys.argv:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.test")
else:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
# Execute JavaScript tests
if 'test' in sys.argv:
os.system('npm install && npm test')
{
"repository" : { "type": "git", "url": "http://github.com/npm/npm.git" },
"devDependencies": {
"karma": "~0.11",
"karma-jasmine": "0.1.3",
"karma-coverage": "0.1.5",
"karma-firefox-launcher": "~0.1.3"
"karma-firefox-launcher": "~0.1.3",
"uglify-js": "2.3.6"
},
"scripts": {
"test": "./node_modules/karma/bin/karma start"
......
......@@ -8,7 +8,6 @@ django==1.4.8
django-extensions==1.2.5
django-model-utils==1.4.0
djangorestframework==2.3.5
Mako==0.9.1
python-dateutil==2.1
pytz==2012h
South==0.7.6
......@@ -13,4 +13,7 @@ MarkupSafe==0.18
Pygments==1.6
Sphinx==1.2
sphinx-rtd-theme==0.1.5
sphinxcontrib-napoleon==0.2.3
\ No newline at end of file
sphinxcontrib-napoleon==0.2.3
# runserver_plus
Werkzeug==0.9.4
#!/usr/bin/env bash
cd `dirname $BASH_SOURCE` && cd ..
STATIC_JS="apps/openassessment/xblock/static/js"
if [[ -n "$1" ]]; then
REQS="$1"
else
REQS="dev"
fi
echo "Installing Python requirements..."
pip install -q -r requirements/$REQS.txt
echo "Installing XBlock..."
pip install -q -e .
echo "Installing Node requirements..."
npm config set loglevel warn
npm install
echo "Minimizing XBlock JavaScript..."
echo "(set DEBUG_JS=1 to preserve indentation and line breaks)"
if [[ -n "$DEBUG_JS" ]]; then
UGLIFY_EXTRA_ARGS="--beautify"
fi
node_modules/.bin/uglifyjs $STATIC_JS/src/*.js $UGLIFY_EXTRA_ARGS > "$STATIC_JS/openassessment.min.js"
#!/usr/bin/env bash
# Need to exit with an error code to fail the Travis build
set -e
cd `dirname $BASH_SOURCE` && cd ..
./scripts/install.sh test
echo "Running Python tests..."
export DJANGO_SETTINGS_MODULE="settings.test"
python manage.py test
echo "Running JavaScript tests..."
npm test
#!/usr/bin/env bash
cd `dirname $BASH_SOURCE` && cd ..
# Install dependencies
./scripts/install.sh
# Configure Django settings
export DJANGO_SETTINGS_MODULE="settings.dev"
# Create the database
echo "Updating the database..."
python manage.py syncdb --migrate --noinput -v 0
echo "Starting server..."
python manage.py runserver_plus "${@:1}"
......@@ -21,7 +21,7 @@ MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '../timdb', # Or path to database file if using sqlite3.
'NAME': 'timdb', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
......@@ -94,9 +94,10 @@ SECRET_KEY = ')68&amp;-c!+og)cy$o9pju_$c707+fett&amp;ph%t%gqgu-@5)!cl$cr'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
('django.template.loaders.cached.Loader', (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)),
)
MIDDLEWARE_CLASSES = (
......@@ -114,12 +115,6 @@ ROOT_URLCONF = 'urls'
# Python dotted path to the WSGI application used by Django's runserver.
# WSGI_APPLICATION = 'wsgi.application'
TEMPLATE_DIRS = (
"apps/submissions/templates",
"apps/openassessment/peer/templates",
"apps/openassessment/xblock",
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
......@@ -177,4 +172,4 @@ LOGGING = {
# TODO: add config for XBLOCK_WORKBENCH { SCENARIO_CLASSES }
WORKBENCH = {
'reset_state_on_restart': False,
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment