From 195fa158cc25ad98722f3bbd375e54c9ccf83b95 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Fri, 1 Jun 2012 16:03:30 -0400 Subject: [PATCH 01/80] Changed setup script to pull instead of clone if the repo already exists. --- create-dev-env.sh | 54 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/create-dev-env.sh b/create-dev-env.sh index a45fc0dba0..c0a052ba04 100755 --- a/create-dev-env.sh +++ b/create-dev-env.sh @@ -48,21 +48,45 @@ EO clone_repos() { cd "$BASE" - output "Cloning mitx" - if [[ -d "$BASE/mitx" ]]; then - mv "$BASE/mitx" "${BASE}/mitx.bak.$$" - fi - git clone git@github.com:MITx/mitx.git >>$LOG - output "Cloning askbot-devel" - if [[ -d "$BASE/askbot-devel" ]]; then - mv "$BASE/askbot-devel" "${BASE}/askbot-devel.bak.$$" - fi - git clone git@github.com:MITx/askbot-devel >>$LOG - output "Cloning data" - if [[ -d "$BASE/data" ]]; then - mv "$BASE/data" "${BASE}/data.bak.$$" - fi - hg clone ssh://hg-content@gp.mitx.mit.edu/data >>$LOG + + if [[ -d "$BASE/mitx/.git" ]]; then + output "Pulling mitx" + cd "$BASE/mitx" + git pull >>$LOG + else + output "Cloning mitx" + if [[ -d "$BASE/mitx" ]]; then + mv "$BASE/mitx" "${BASE}/mitx.bak.$$" + fi + git clone git@github.com:MITx/mitx.git >>$LOG + fi + + cd "$BASE" + if [[ -d "$BASE/askbot-devel/.git" ]]; then + output "Pulling askbot-devel" + cd "$BASE/askbot-devel" + git pull >>$LOG + else + output "Cloning askbot-devel" + if [[ -d "$BASE/askbot-devel" ]]; then + mv "$BASE/askbot-devel" "${BASE}/askbot-devel.bak.$$" + fi + git clone git@github.com:MITx/askbot-devel >>$LOG + fi + + cd "$BASE" + if [[ -d "$BASE/data/.hg" ]]; then + output "Pulling data" + cd "$BASE/data" + hg pull >>$LOG + hg update >>$LOG + else + output "Cloning data" + if [[ -d "$BASE/data" ]]; then + mv "$BASE/data" "${BASE}/data.bak.$$" + fi + hg clone ssh://hg-content@gp.mitx.mit.edu/data >>$LOG + fi } PROG=${0##*/} From 05436e591b71c34676d4bb5a143955cb7c1cf747 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Jun 2012 11:27:22 -0400 Subject: [PATCH 02/80] Make mitxmako available to both the lms and the cms --- {lms => common}/lib/mitxmako/README | 0 {lms => common}/lib/mitxmako/__init__.py | 0 {lms => common}/lib/mitxmako/middleware.py | 10 +++++----- {lms => common}/lib/mitxmako/shortcuts.py | 10 +++------- {lms => common}/lib/mitxmako/template.py | 9 +++++---- 5 files changed, 13 insertions(+), 16 deletions(-) rename {lms => common}/lib/mitxmako/README (100%) rename {lms => common}/lib/mitxmako/__init__.py (100%) rename {lms => common}/lib/mitxmako/middleware.py (88%) rename {lms => common}/lib/mitxmako/shortcuts.py (84%) rename {lms => common}/lib/mitxmako/template.py (87%) diff --git a/lms/lib/mitxmako/README b/common/lib/mitxmako/README similarity index 100% rename from lms/lib/mitxmako/README rename to common/lib/mitxmako/README diff --git a/lms/lib/mitxmako/__init__.py b/common/lib/mitxmako/__init__.py similarity index 100% rename from lms/lib/mitxmako/__init__.py rename to common/lib/mitxmako/__init__.py diff --git a/lms/lib/mitxmako/middleware.py b/common/lib/mitxmako/middleware.py similarity index 88% rename from lms/lib/mitxmako/middleware.py rename to common/lib/mitxmako/middleware.py index 1d175abbf7..50f2840a05 100644 --- a/lms/lib/mitxmako/middleware.py +++ b/common/lib/mitxmako/middleware.py @@ -20,10 +20,10 @@ from django.conf import settings requestcontext = None lookup = {} + class MakoMiddleware(object): def __init__(self): """Setup mako variables and lookup object""" - from django.conf import settings # Set all mako variables based on django settings template_locations = settings.MAKO_TEMPLATES module_directory = getattr(settings, 'MAKO_MODULE_DIR', None) @@ -32,17 +32,17 @@ class MakoMiddleware(object): module_directory = tempfile.mkdtemp() for location in template_locations: - lookup[location] = TemplateLookup(directories=template_locations[location], + lookup[location] = TemplateLookup(directories=template_locations[location], module_directory=module_directory, - output_encoding='utf-8', - input_encoding='utf-8', + output_encoding='utf-8', + input_encoding='utf-8', encoding_errors='replace', ) import mitxmako mitxmako.lookup = lookup - def process_request (self, request): + def process_request(self, request): global requestcontext requestcontext = RequestContext(request) requestcontext['is_secure'] = request.is_secure() diff --git a/lms/lib/mitxmako/shortcuts.py b/common/lib/mitxmako/shortcuts.py similarity index 84% rename from lms/lib/mitxmako/shortcuts.py rename to common/lib/mitxmako/shortcuts.py index 7286a4e259..9f6044b81e 100644 --- a/lms/lib/mitxmako/shortcuts.py +++ b/common/lib/mitxmako/shortcuts.py @@ -15,10 +15,9 @@ from django.template import Context from django.http import HttpResponse -import mitxmako.middleware as middleware +from . import middleware from django.conf import settings -import mitxmako.middleware def render_to_string(template_name, dictionary, context=None, namespace='main'): context_instance = Context(dictionary) @@ -28,15 +27,12 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'): context_dictionary = {} context_instance['settings'] = settings context_instance['MITX_ROOT_URL'] = settings.MITX_ROOT_URL - for d in mitxmako.middleware.requestcontext: + for d in middleware.requestcontext: context_dictionary.update(d) for d in context_instance: context_dictionary.update(d) - if context: + if context: context_dictionary.update(context) - ## HACK - ## We should remove this, and possible set COURSE_TITLE in the middleware from the session. - if 'COURSE_TITLE' not in context_dictionary: context_dictionary['COURSE_TITLE'] = '' # fetch and render template template = middleware.lookup[namespace].get_template(template_name) return template.render(**context_dictionary) diff --git a/lms/lib/mitxmako/template.py b/common/lib/mitxmako/template.py similarity index 87% rename from lms/lib/mitxmako/template.py rename to common/lib/mitxmako/template.py index 9e5897ef25..911f5a5b28 100644 --- a/lms/lib/mitxmako/template.py +++ b/common/lib/mitxmako/template.py @@ -14,10 +14,11 @@ from mako.template import Template as MakoTemplate -import middleware +from . import middleware + +django_variables = ['lookup', 'template_dirs', 'output_encoding', + 'module_directory', 'encoding_errors'] -django_variables = ['lookup', 'template_dirs', 'output_encoding', - 'module_directory', 'encoding_errors',] class Template(MakoTemplate): def __init__(self, *args, **kwargs): @@ -25,4 +26,4 @@ class Template(MakoTemplate): if not kwargs.get('no_django', False): overrides = dict([(k, getattr(middleware, k, None),) for k in django_variables]) kwargs.update(overrides) - super(Template, self).__init__(*args, **kwargs) + super(Template, self).__init__(*args, **kwargs) From a8940fc71e1a2656f863302be2e6595662120d5e Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Fri, 8 Jun 2012 11:30:13 -0400 Subject: [PATCH 03/80] adding less option to skip the intro screen for ruby install --- create-dev-env.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/create-dev-env.sh b/create-dev-env.sh index c0a052ba04..2fdfd183f7 100755 --- a/create-dev-env.sh +++ b/create-dev-env.sh @@ -14,6 +14,7 @@ ouch() { script again with the -v flag. EOL + printf '\E[0m' } error() { @@ -235,7 +236,10 @@ esac output "Installing rvm and ruby" curl -sL get.rvm.io | bash -s stable source $RUBY_DIR/scripts/rvm +# skip the intro +export LESS="-E" rvm install $RUBY_VER +unset LESS virtualenv "$PYTHON_DIR" source $PYTHON_DIR/bin/activate output "Installing gem bundler" From eb4272e38670d930cb3ded0f8596bdd0f623e245 Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Fri, 8 Jun 2012 11:50:57 -0400 Subject: [PATCH 04/80] converted tabs to spaces, updated LESS cmdline override --- create-dev-env.sh | 78 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/create-dev-env.sh b/create-dev-env.sh index 2fdfd183f7..9e644fe046 100755 --- a/create-dev-env.sh +++ b/create-dev-env.sh @@ -49,45 +49,45 @@ EO clone_repos() { cd "$BASE" - + if [[ -d "$BASE/mitx/.git" ]]; then - output "Pulling mitx" - cd "$BASE/mitx" - git pull >>$LOG - else - output "Cloning mitx" - if [[ -d "$BASE/mitx" ]]; then - mv "$BASE/mitx" "${BASE}/mitx.bak.$$" - fi - git clone git@github.com:MITx/mitx.git >>$LOG - fi - - cd "$BASE" - if [[ -d "$BASE/askbot-devel/.git" ]]; then - output "Pulling askbot-devel" - cd "$BASE/askbot-devel" - git pull >>$LOG - else - output "Cloning askbot-devel" - if [[ -d "$BASE/askbot-devel" ]]; then - mv "$BASE/askbot-devel" "${BASE}/askbot-devel.bak.$$" - fi - git clone git@github.com:MITx/askbot-devel >>$LOG - fi - - cd "$BASE" + output "Pulling mitx" + cd "$BASE/mitx" + git pull >>$LOG + else + output "Cloning mitx" + if [[ -d "$BASE/mitx" ]]; then + mv "$BASE/mitx" "${BASE}/mitx.bak.$$" + fi + git clone git@github.com:MITx/mitx.git >>$LOG + fi + + cd "$BASE" + if [[ -d "$BASE/askbot-devel/.git" ]]; then + output "Pulling askbot-devel" + cd "$BASE/askbot-devel" + git pull >>$LOG + else + output "Cloning askbot-devel" + if [[ -d "$BASE/askbot-devel" ]]; then + mv "$BASE/askbot-devel" "${BASE}/askbot-devel.bak.$$" + fi + git clone git@github.com:MITx/askbot-devel >>$LOG + fi + + cd "$BASE" if [[ -d "$BASE/data/.hg" ]]; then - output "Pulling data" - cd "$BASE/data" - hg pull >>$LOG - hg update >>$LOG - else - output "Cloning data" - if [[ -d "$BASE/data" ]]; then - mv "$BASE/data" "${BASE}/data.bak.$$" - fi - hg clone ssh://hg-content@gp.mitx.mit.edu/data >>$LOG - fi + output "Pulling data" + cd "$BASE/data" + hg pull >>$LOG + hg update >>$LOG + else + output "Cloning data" + if [[ -d "$BASE/data" ]]; then + mv "$BASE/data" "${BASE}/data.bak.$$" + fi + hg clone ssh://hg-content@gp.mitx.mit.edu/data >>$LOG + fi } PROG=${0##*/} @@ -237,9 +237,7 @@ output "Installing rvm and ruby" curl -sL get.rvm.io | bash -s stable source $RUBY_DIR/scripts/rvm # skip the intro -export LESS="-E" -rvm install $RUBY_VER -unset LESS +LESS="-E" rvm install $RUBY_VER virtualenv "$PYTHON_DIR" source $PYTHON_DIR/bin/activate output "Installing gem bundler" From 8134bcbc3df80595b9fcdfa11991772148ca1922 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Jun 2012 14:01:41 -0400 Subject: [PATCH 05/80] Get the cms up to the point of rendering a template --- {lms/djangoapps/track => cms}/__init__.py | 0 .../templatetags => cms/envs}/__init__.py | 0 cms/envs/common.py | 151 ++++++++++++++++++ cms/envs/dev.py | 37 +++++ cms/manage.py | 14 ++ lms/lib/util/__init__.py => cms/models.py | 0 cms/templates/calendar.html | 3 + cms/urls.py | 9 ++ cms/views.py | 5 + common/djangoapps/track/__init__.py | 0 .../djangoapps/track/middleware.py | 0 {lms => common}/djangoapps/track/models.py | 0 {lms => common}/djangoapps/track/tests.py | 0 {lms => common}/djangoapps/track/views.py | 0 {lms => common}/lib/cache_toolbox/COPYING | 0 {lms => common}/lib/cache_toolbox/README.rst | 0 {lms => common}/lib/cache_toolbox/__init__.py | 0 .../lib/cache_toolbox/app_settings.py | 0 {lms => common}/lib/cache_toolbox/core.py | 0 .../lib/cache_toolbox/middleware.py | 0 {lms => common}/lib/cache_toolbox/model.py | 0 {lms => common}/lib/cache_toolbox/relation.py | 0 .../cache_toolbox/templatetags/__init__.py | 0 .../templatetags/cache_toolbox.py | 0 common/lib/monitoring/__init__.py | 0 common/lib/monitoring/exceptions.py | 10 ++ common/lib/util/__init__.py | 0 {lms => common}/lib/util/cache.py | 0 {lms => common}/lib/util/memcache.py | 0 {lms => common}/lib/util/middleware.py | 0 {lms => common}/lib/util/models.py | 0 {lms => common}/lib/util/tests.py | 0 {lms => common}/lib/util/views.py | 0 lms/envs/common.py | 1 + rakefile | 20 +-- 35 files changed, 240 insertions(+), 10 deletions(-) rename {lms/djangoapps/track => cms}/__init__.py (100%) rename {lms/lib/cache_toolbox/templatetags => cms/envs}/__init__.py (100%) create mode 100644 cms/envs/common.py create mode 100644 cms/envs/dev.py create mode 100644 cms/manage.py rename lms/lib/util/__init__.py => cms/models.py (100%) create mode 100644 cms/templates/calendar.html create mode 100644 cms/urls.py create mode 100644 cms/views.py create mode 100644 common/djangoapps/track/__init__.py rename {lms => common}/djangoapps/track/middleware.py (100%) rename {lms => common}/djangoapps/track/models.py (100%) rename {lms => common}/djangoapps/track/tests.py (100%) rename {lms => common}/djangoapps/track/views.py (100%) rename {lms => common}/lib/cache_toolbox/COPYING (100%) rename {lms => common}/lib/cache_toolbox/README.rst (100%) rename {lms => common}/lib/cache_toolbox/__init__.py (100%) rename {lms => common}/lib/cache_toolbox/app_settings.py (100%) rename {lms => common}/lib/cache_toolbox/core.py (100%) rename {lms => common}/lib/cache_toolbox/middleware.py (100%) rename {lms => common}/lib/cache_toolbox/model.py (100%) rename {lms => common}/lib/cache_toolbox/relation.py (100%) create mode 100644 common/lib/cache_toolbox/templatetags/__init__.py rename {lms => common}/lib/cache_toolbox/templatetags/cache_toolbox.py (100%) create mode 100644 common/lib/monitoring/__init__.py create mode 100644 common/lib/monitoring/exceptions.py create mode 100644 common/lib/util/__init__.py rename {lms => common}/lib/util/cache.py (100%) rename {lms => common}/lib/util/memcache.py (100%) rename {lms => common}/lib/util/middleware.py (100%) rename {lms => common}/lib/util/models.py (100%) rename {lms => common}/lib/util/tests.py (100%) rename {lms => common}/lib/util/views.py (100%) diff --git a/lms/djangoapps/track/__init__.py b/cms/__init__.py similarity index 100% rename from lms/djangoapps/track/__init__.py rename to cms/__init__.py diff --git a/lms/lib/cache_toolbox/templatetags/__init__.py b/cms/envs/__init__.py similarity index 100% rename from lms/lib/cache_toolbox/templatetags/__init__.py rename to cms/envs/__init__.py diff --git a/cms/envs/common.py b/cms/envs/common.py new file mode 100644 index 0000000000..9b349a06d0 --- /dev/null +++ b/cms/envs/common.py @@ -0,0 +1,151 @@ +""" +This is the common settings file, intended to set sane defaults. If you have a +piece of configuration that's dependent on a set of feature flags being set, +then create a function that returns the calculated value based on the value of +MITX_FEATURES[...]. Modules that extend this one can change the feature +configuration in an environment specific config file and re-calculate those +values. + +We should make a method that calls all these config methods so that you just +make one call at the end of your site-specific dev file to reset all the +dependent variables (like INSTALLED_APPS) for you. + +Longer TODO: +1. Right now our treatment of static content in general and in particular + course-specific static content is haphazard. +2. We should have a more disciplined approach to feature flagging, even if it + just means that we stick them in a dict called MITX_FEATURES. +3. We need to handle configuration for multiple courses. This could be as + multiple sites, but we do need a way to map their data assets. +""" + +import sys +import tempfile +from path import path + +############################# SET PATH INFORMATION ############################# +PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /mitx/cms +COMMON_ROOT = PROJECT_ROOT.dirname() / "common" +ENV_ROOT = PROJECT_ROOT.dirname().dirname() # virtualenv dir /mitx is in +ASKBOT_ROOT = ENV_ROOT / "askbot-devel" +COURSES_ROOT = ENV_ROOT / "data" + +# FIXME: To support multiple courses, we should walk the courses dir at startup +DATA_DIR = COURSES_ROOT + +sys.path.append(ENV_ROOT) +sys.path.append(ASKBOT_ROOT) +sys.path.append(ASKBOT_ROOT / "askbot" / "deps") +sys.path.append(PROJECT_ROOT / 'djangoapps') +sys.path.append(PROJECT_ROOT / 'lib') +sys.path.append(COMMON_ROOT / 'djangoapps') +sys.path.append(COMMON_ROOT / 'lib') + + +############################# WEB CONFIGURATION ############################# +# This is where we stick our compiled template files. +MAKO_MODULE_DIR = tempfile.mkdtemp('mako') +MAKO_TEMPLATES = {} +MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates'] + +MITX_ROOT_URL = '' + +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.core.context_processors.request', + 'django.core.context_processors.static', + 'django.contrib.messages.context_processors.messages', + 'django.core.context_processors.auth', # this is required for admin + 'django.core.context_processors.csrf', # necessary for csrf protection +) + +################################# Middleware ################################### +# List of finder classes that know how to find static files in +# various locations. +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +) + +# 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', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.cache.UpdateCacheMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + + # Instead of AuthenticationMiddleware, we use a cached backed version + 'cache_toolbox.middleware.CacheBackedAuthenticationMiddleware', + + 'django.contrib.messages.middleware.MessageMiddleware', + 'track.middleware.TrackMiddleware', + 'mitxmako.middleware.MakoMiddleware', + + 'django.middleware.transaction.TransactionMiddleware', +) + +############################ SIGNAL HANDLERS ################################ +import monitoring.exceptions # noqa + +############################ DJANGO_BUILTINS ################################ +# Change DEBUG/TEMPLATE_DEBUG in your environment settings files, not here +DEBUG = False +TEMPLATE_DEBUG = False + +# Site info +SITE_ID = 1 +SITE_NAME = "localhost:8000" +HTTPS = 'on' +ROOT_URLCONF = 'mitx.cms.urls' +IGNORABLE_404_ENDS = ('favicon.ico') + +# Email +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +DEFAULT_FROM_EMAIL = 'registration@mitx.mit.edu' +DEFAULT_FEEDBACK_EMAIL = 'feedback@mitx.mit.edu' +ADMINS = ( + ('MITx Admins', 'admin@mitx.mit.edu'), +) +MANAGERS = ADMINS + +# Static content +STATIC_URL = '/static/' +ADMIN_MEDIA_PREFIX = '/static/admin/' +STATIC_ROOT = ENV_ROOT / "staticfiles" + +# FIXME: We should iterate through the courses we have, adding the static +# contents for each of them. (Right now we just use symlinks.) +STATICFILES_DIRS = [ + PROJECT_ROOT / "static", + +# This is how you would use the textbook images locally +# ("book", ENV_ROOT / "book_images") +] + +# Locale/Internationalization +TIME_ZONE = 'America/New_York' # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +LANGUAGE_CODE = 'en' # http://www.i18nguy.com/unicode/language-identifiers.html +USE_I18N = True +USE_L10N = True + +# Messages +MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' + +############################ APPS ##################################### + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + # Uncomment the next line to enable the admin: + # 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + # 'django.contrib.admindocs', +) diff --git a/cms/envs/dev.py b/cms/envs/dev.py new file mode 100644 index 0000000000..72a5e512c4 --- /dev/null +++ b/cms/envs/dev.py @@ -0,0 +1,37 @@ +""" +This config file runs the simplest dev environment""" + +from .common import * + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': ENV_ROOT / "db" / "mitx.db", + } +} + +CACHES = { + # This is the cache used for most things. Askbot will not work without a + # functioning cache -- it relies on caching to load its settings in places. + # In staging/prod envs, the sessions also live here. + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'mitx_loc_mem_cache', + 'KEY_FUNCTION': 'util.memcache.safe_key', + }, + + # The general cache is what you get if you use our util.cache. It's used for + # things like caching the course.xml file for different A/B test groups. + # We set it to be a DummyCache to force reloading of course.xml in dev. + # In staging environments, we would grab VERSION from data uploaded by the + # push process. + 'general': { + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', + 'KEY_PREFIX': 'general', + 'VERSION': 4, + 'KEY_FUNCTION': 'util.cache.memcache_safe_key', + } +} diff --git a/cms/manage.py b/cms/manage.py new file mode 100644 index 0000000000..3e4eedc9ff --- /dev/null +++ b/cms/manage.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +import imp +try: + imp.find_module('settings') # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__) + sys.exit(1) + +import settings + +if __name__ == "__main__": + execute_manager(settings) diff --git a/lms/lib/util/__init__.py b/cms/models.py similarity index 100% rename from lms/lib/util/__init__.py rename to cms/models.py diff --git a/cms/templates/calendar.html b/cms/templates/calendar.html new file mode 100644 index 0000000000..05b2f88806 --- /dev/null +++ b/cms/templates/calendar.html @@ -0,0 +1,3 @@ +% for week in weeks: +${week} +% endfor diff --git a/cms/urls.py b/cms/urls.py new file mode 100644 index 0000000000..80e2b19e9d --- /dev/null +++ b/cms/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls.defaults import patterns, url + +# Uncomment the next two lines to enable the admin: +# from django.contrib import admin +# admin.autodiscover() + +urlpatterns = patterns('cms.views', + url(r'^(?P[^/]+)/calendar/', 'calendar', name='calendar'), +) diff --git a/cms/views.py b/cms/views.py new file mode 100644 index 0000000000..d0d4f4871c --- /dev/null +++ b/cms/views.py @@ -0,0 +1,5 @@ +from mitxmako.shortcuts import render_to_response + + +def calendar(request, course): + return render_to_response('calendar.html', {}) diff --git a/common/djangoapps/track/__init__.py b/common/djangoapps/track/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/djangoapps/track/middleware.py b/common/djangoapps/track/middleware.py similarity index 100% rename from lms/djangoapps/track/middleware.py rename to common/djangoapps/track/middleware.py diff --git a/lms/djangoapps/track/models.py b/common/djangoapps/track/models.py similarity index 100% rename from lms/djangoapps/track/models.py rename to common/djangoapps/track/models.py diff --git a/lms/djangoapps/track/tests.py b/common/djangoapps/track/tests.py similarity index 100% rename from lms/djangoapps/track/tests.py rename to common/djangoapps/track/tests.py diff --git a/lms/djangoapps/track/views.py b/common/djangoapps/track/views.py similarity index 100% rename from lms/djangoapps/track/views.py rename to common/djangoapps/track/views.py diff --git a/lms/lib/cache_toolbox/COPYING b/common/lib/cache_toolbox/COPYING similarity index 100% rename from lms/lib/cache_toolbox/COPYING rename to common/lib/cache_toolbox/COPYING diff --git a/lms/lib/cache_toolbox/README.rst b/common/lib/cache_toolbox/README.rst similarity index 100% rename from lms/lib/cache_toolbox/README.rst rename to common/lib/cache_toolbox/README.rst diff --git a/lms/lib/cache_toolbox/__init__.py b/common/lib/cache_toolbox/__init__.py similarity index 100% rename from lms/lib/cache_toolbox/__init__.py rename to common/lib/cache_toolbox/__init__.py diff --git a/lms/lib/cache_toolbox/app_settings.py b/common/lib/cache_toolbox/app_settings.py similarity index 100% rename from lms/lib/cache_toolbox/app_settings.py rename to common/lib/cache_toolbox/app_settings.py diff --git a/lms/lib/cache_toolbox/core.py b/common/lib/cache_toolbox/core.py similarity index 100% rename from lms/lib/cache_toolbox/core.py rename to common/lib/cache_toolbox/core.py diff --git a/lms/lib/cache_toolbox/middleware.py b/common/lib/cache_toolbox/middleware.py similarity index 100% rename from lms/lib/cache_toolbox/middleware.py rename to common/lib/cache_toolbox/middleware.py diff --git a/lms/lib/cache_toolbox/model.py b/common/lib/cache_toolbox/model.py similarity index 100% rename from lms/lib/cache_toolbox/model.py rename to common/lib/cache_toolbox/model.py diff --git a/lms/lib/cache_toolbox/relation.py b/common/lib/cache_toolbox/relation.py similarity index 100% rename from lms/lib/cache_toolbox/relation.py rename to common/lib/cache_toolbox/relation.py diff --git a/common/lib/cache_toolbox/templatetags/__init__.py b/common/lib/cache_toolbox/templatetags/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/lib/cache_toolbox/templatetags/cache_toolbox.py b/common/lib/cache_toolbox/templatetags/cache_toolbox.py similarity index 100% rename from lms/lib/cache_toolbox/templatetags/cache_toolbox.py rename to common/lib/cache_toolbox/templatetags/cache_toolbox.py diff --git a/common/lib/monitoring/__init__.py b/common/lib/monitoring/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/common/lib/monitoring/exceptions.py b/common/lib/monitoring/exceptions.py new file mode 100644 index 0000000000..6a34d9a38f --- /dev/null +++ b/common/lib/monitoring/exceptions.py @@ -0,0 +1,10 @@ +from django.core.signals import got_request_exception +from django.dispatch import receiver +import logging + + +@receiver(got_request_exception) +def record_request_exception(sender, **kwargs): + logging.exception("Uncaught exception from {sender}".format( + sender=sender + )) diff --git a/common/lib/util/__init__.py b/common/lib/util/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/lib/util/cache.py b/common/lib/util/cache.py similarity index 100% rename from lms/lib/util/cache.py rename to common/lib/util/cache.py diff --git a/lms/lib/util/memcache.py b/common/lib/util/memcache.py similarity index 100% rename from lms/lib/util/memcache.py rename to common/lib/util/memcache.py diff --git a/lms/lib/util/middleware.py b/common/lib/util/middleware.py similarity index 100% rename from lms/lib/util/middleware.py rename to common/lib/util/middleware.py diff --git a/lms/lib/util/models.py b/common/lib/util/models.py similarity index 100% rename from lms/lib/util/models.py rename to common/lib/util/models.py diff --git a/lms/lib/util/tests.py b/common/lib/util/tests.py similarity index 100% rename from lms/lib/util/tests.py rename to common/lib/util/tests.py diff --git a/lms/lib/util/views.py b/common/lib/util/views.py similarity index 100% rename from lms/lib/util/views.py rename to common/lib/util/views.py diff --git a/lms/envs/common.py b/lms/envs/common.py index 806c379747..3ac026fd81 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -60,6 +60,7 @@ sys.path.append(ASKBOT_ROOT) sys.path.append(ASKBOT_ROOT / "askbot" / "deps") sys.path.append(PROJECT_ROOT / 'djangoapps') sys.path.append(PROJECT_ROOT / 'lib') +sys.path.append(COMMON_ROOT / 'djangoapps') sys.path.append(COMMON_ROOT / 'lib') ################################## MITXWEB ##################################### diff --git a/rakefile b/rakefile index 8f49668506..6bd582783e 100644 --- a/rakefile +++ b/rakefile @@ -58,7 +58,7 @@ task :pylint => LMS_REPORT_DIR do end end -[:lms].each do |system| +[:lms, :cms].each do |system| task_name = "test_#{system}" report_dir = File.join(REPORT_DIR, task_name) directory report_dir @@ -69,6 +69,15 @@ end sh(django_admin(:lms, :test, 'test', *Dir['lms/djangoapps'].each)) end task :test => task_name + + desc <<-desc + Start the #{system} locally with the specified environment (defaults to dev). + Other useful environments are devplus (for dev testing with a real local database) + desc + task system, [:env, :options] => [] do |t, args| + args.with_defaults(:env => 'dev', :options => '') + sh(django_admin(system, args.env, 'runserver', args.options)) + end end Dir["common/lib/*"].each do |lib| @@ -85,15 +94,6 @@ Dir["common/lib/*"].each do |lib| task :test => task_name end -desc <<-desc - Start the lms locally with the specified environment (defaults to dev). - Other useful environments are devplus (for dev testing with a real local database) - desc -task :lms, [:env] => [] do |t, args| - args.with_defaults(:env => 'dev') - sh(django_admin(:lms, args.env, 'runserver')) -end - task :runserver => :lms desc "Run django-admin against the specified system and environment" From b46b7daf0f8aae5454f1496cf88b8531cdb473cc Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Fri, 8 Jun 2012 14:59:21 -0400 Subject: [PATCH 06/80] added a posix compliant check to make sure you are using bash to run the script, added option to use --system-site-packages for virtualenv, updated the ending instructions on how to start the server --- create-dev-env.sh | 57 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/create-dev-env.sh b/create-dev-env.sh index 9e644fe046..7b798c5b8c 100755 --- a/create-dev-env.sh +++ b/create-dev-env.sh @@ -1,5 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash set -e + +# posix compliant sanity check +if [ -z $BASH ] || [ $BASH = "/bin/sh" ]; then + echo "Please use the bash interpreter to run this script" + exit 1 +fi + trap "ouch" ERR ouch() { @@ -29,6 +36,7 @@ usage() { Usage: $PROG [-c] [-v] [-h] -c compile scipy and numpy + -s --system-site-packages for virtualenv -v set -x + spew -h this @@ -106,7 +114,7 @@ if [[ $EUID -eq 0 ]]; then usage exit 1 fi -ARGS=$(getopt "cvh" "$*") +ARGS=$(getopt "cvhs" "$*") if [[ $? != 0 ]]; then usage exit 1 @@ -118,6 +126,10 @@ while true; do compile=true shift ;; + -s) + systempkgs=true + shift + ;; -v) set -x verbose=true @@ -148,7 +160,7 @@ cat< + + $ rake django-admin[runserver,lms,dev,] + + If the Django development server starts properly you + should see: + + Development server is running at http://127.0.0.1:/ + Quit the server with CONTROL-C. + + Connect your browser to http://127.0.0.1: to + view the Django site. + + END exit 0 From dc85e46315dfb30ed9a3ead1df2c4e38411b7e6f Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Jun 2012 16:55:38 -0400 Subject: [PATCH 07/80] Allow login in the cms, and read a particular course from mongo --- .../djangoapps/instructor}/__init__.py | 0 cms/djangoapps/instructor/models.py | 61 ++++++++++++++ cms/djangoapps/instructor/tests.py | 16 ++++ cms/djangoapps/instructor/views.py | 49 ++++++++++++ cms/envs/dev.py | 6 ++ cms/lib/keystore/__init__.py | 80 +++++++++++++++++++ cms/lib/keystore/django.py | 12 +++ cms/lib/keystore/exceptions.py | 7 ++ cms/lib/keystore/mongo.py | 26 ++++++ cms/templates/login.html | 11 +++ cms/urls.py | 5 +- cms/views.py | 11 ++- common/lib/django_future/__init__.py | 0 {lms => common}/lib/django_future/csrf.py | 0 requirements.txt | 1 + 15 files changed, 281 insertions(+), 4 deletions(-) rename {lms/lib/django_future => cms/djangoapps/instructor}/__init__.py (100%) create mode 100644 cms/djangoapps/instructor/models.py create mode 100644 cms/djangoapps/instructor/tests.py create mode 100644 cms/djangoapps/instructor/views.py create mode 100644 cms/lib/keystore/__init__.py create mode 100644 cms/lib/keystore/django.py create mode 100644 cms/lib/keystore/exceptions.py create mode 100644 cms/lib/keystore/mongo.py create mode 100644 cms/templates/login.html create mode 100644 common/lib/django_future/__init__.py rename {lms => common}/lib/django_future/csrf.py (100%) diff --git a/lms/lib/django_future/__init__.py b/cms/djangoapps/instructor/__init__.py similarity index 100% rename from lms/lib/django_future/__init__.py rename to cms/djangoapps/instructor/__init__.py diff --git a/cms/djangoapps/instructor/models.py b/cms/djangoapps/instructor/models.py new file mode 100644 index 0000000000..906aeee2f1 --- /dev/null +++ b/cms/djangoapps/instructor/models.py @@ -0,0 +1,61 @@ +""" +WE'RE USING MIGRATIONS! + +If you make changes to this model, be sure to create an appropriate migration +file and check it in at the same time as your model changes. To do that, + +1. Go to the mitx dir +2. ./manage.py schemamigration user --auto description_of_your_change +3. Add the migration file created in mitx/courseware/migrations/ +""" +import uuid + +from django.db import models +from django.contrib.auth.models import User + + +class UserProfile(models.Model): + class Meta: + db_table = "auth_userprofile" + + ## CRITICAL TODO/SECURITY + # Sanitize all fields. + # This is not visible to other users, but could introduce holes later + user = models.OneToOneField(User, unique=True, db_index=True, related_name='profile') + name = models.CharField(blank=True, max_length=255, db_index=True) + org = models.CharField(blank=True, max_length=255, db_index=True) + + +class Registration(models.Model): + ''' Allows us to wait for e-mail before user is registered. A + registration profile is created when the user creates an + account, but that account is inactive. Once the user clicks + on the activation key, it becomes active. ''' + class Meta: + db_table = "auth_registration" + + user = models.ForeignKey(User, unique=True) + activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) + + def register(self, user): + # MINOR TODO: Switch to crypto-secure key + self.activation_key = uuid.uuid4().hex + self.user = user + self.save() + + def activate(self): + self.user.is_active = True + self.user.save() + #self.delete() + + +class PendingNameChange(models.Model): + user = models.OneToOneField(User, unique=True, db_index=True) + new_name = models.CharField(blank=True, max_length=255) + rationale = models.CharField(blank=True, max_length=1024) + + +class PendingEmailChange(models.Model): + user = models.OneToOneField(User, unique=True, db_index=True) + new_email = models.CharField(blank=True, max_length=255, db_index=True) + activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) diff --git a/cms/djangoapps/instructor/tests.py b/cms/djangoapps/instructor/tests.py new file mode 100644 index 0000000000..501deb776c --- /dev/null +++ b/cms/djangoapps/instructor/tests.py @@ -0,0 +1,16 @@ +""" +This file demonstrates writing tests using the unittest module. These will pass +when you run "manage.py test". + +Replace this with more appropriate tests for your application. +""" + +from django.test import TestCase + + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.assertEqual(1 + 1, 2) diff --git a/cms/djangoapps/instructor/views.py b/cms/djangoapps/instructor/views.py new file mode 100644 index 0000000000..fbb341b468 --- /dev/null +++ b/cms/djangoapps/instructor/views.py @@ -0,0 +1,49 @@ +import logging + +from django.views.decorators.http import require_http_methods, require_POST, require_GET +from django.contrib.auth import logout, authenticate, login +from django.shortcuts import redirect +from mitxmako.shortcuts import render_to_response + +from django_future.csrf import ensure_csrf_cookie + +log = logging.getLogger("mitx.student") + + +@require_http_methods(['GET', 'POST']) +def do_login(request): + if request.method == 'POST': + return post_login(request) + elif request.method == 'GET': + return get_login(request) + + +@require_POST +@ensure_csrf_cookie +def post_login(request): + username = request.POST['username'] + password = request.POST['password'] + user = authenticate(username=username, password=password) + if user is not None: + if user.is_active: + login(request, user) + return redirect(request.POST.get('next', '/')) + else: + raise Exception("Can't log in, account disabled") + else: + raise Exception("Can't log in, invalid authentication") + + +@require_GET +@ensure_csrf_cookie +def get_login(request): + return render_to_response('login.html', { + 'next': request.GET.get('next') + }) + + +@ensure_csrf_cookie +def logout_user(request): + ''' HTTP request to log in the user. Redirects to marketing page''' + logout(request) + return redirect('/') diff --git a/cms/envs/dev.py b/cms/envs/dev.py index 72a5e512c4..f7277b3d3f 100644 --- a/cms/envs/dev.py +++ b/cms/envs/dev.py @@ -6,6 +6,12 @@ from .common import * DEBUG = True TEMPLATE_DEBUG = DEBUG +KEYSTORE = { + 'host': 'localhost', + 'db': 'mongo_base', + 'collection': 'key_store', +} + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', diff --git a/cms/lib/keystore/__init__.py b/cms/lib/keystore/__init__.py new file mode 100644 index 0000000000..5e6374cf4a --- /dev/null +++ b/cms/lib/keystore/__init__.py @@ -0,0 +1,80 @@ +""" +This module provides an abstraction for working objects that conceptually have +the following attributes: + + location: An identifier for an item, of which there might be many revisions + children: A list of urls for other items required to fully define this object + data: A set of nested data needed to define this object + editor: The editor/owner of the object + parents: Url pointers for objects that this object was derived from + revision: What revision of the item this is +""" + + +class Location(object): + ''' Encodes a location. + Can be: + * String (url) + * Tuple + * Dictionary + ''' + def __init__(self, location): + self.update(location) + + def update(self, location): + if isinstance(location, basestring): + self.tag = location.split('/')[0][:-1] + (self.org, self.course, self.category, self.name) = location.split('/')[2:] + elif isinstance(location, list): + (self.tag, self.org, self.course, self.category, self.name) = location + elif isinstance(location, dict): + self.tag = location['tag'] + self.org = location['org'] + self.course = location['course'] + self.category = location['category'] + self.name = location['name'] + elif isinstance(location, Location): + self.update(location.list()) + + def url(self): + return "i4x://{org}/{course}/{category}/{name}".format(**self.dict()) + + def list(self): + return [self.tag, self.org, self.course, self.category, self.name] + + def dict(self): + return {'tag': self.tag, + 'org': self.org, + 'course': self.course, + 'category': self.category, + 'name': self.name} + + def to_json(self): + return self.dict() + + +class KeyStore(object): + def get_children_for_item(self, location): + """ + Returns the children for the most recent revision of the object + with the specified location. + + If no object is found at that location, raises keystore.exceptions.ItemNotFoundError + """ + raise NotImplementedError + + +class KeyStoreItem(object): + """ + An object from a KeyStore, which can be saved back to that keystore + """ + def __init__(self, location, children, data, editor, parents, revision): + self.location = location + self.children = children + self.data = data + self.editor = editor + self.parents = parents + self.revision = revision + + def save(self): + raise NotImplementedError diff --git a/cms/lib/keystore/django.py b/cms/lib/keystore/django.py new file mode 100644 index 0000000000..b6ffb83b5c --- /dev/null +++ b/cms/lib/keystore/django.py @@ -0,0 +1,12 @@ +""" +Module that provides a connection to the keystore specified in the django settings. + +Passes settings.KEYSTORE as kwargs to MongoKeyStore +""" + +from __future__ import absolute_import + +from django.conf import settings +from .mongo import MongoKeyStore + +keystore = MongoKeyStore(**settings.KEYSTORE) diff --git a/cms/lib/keystore/exceptions.py b/cms/lib/keystore/exceptions.py new file mode 100644 index 0000000000..b66470859f --- /dev/null +++ b/cms/lib/keystore/exceptions.py @@ -0,0 +1,7 @@ +""" +Exceptions thrown by KeyStore objects +""" + + +class ItemNotFoundError(Exception): + pass diff --git a/cms/lib/keystore/mongo.py b/cms/lib/keystore/mongo.py new file mode 100644 index 0000000000..fc190ee098 --- /dev/null +++ b/cms/lib/keystore/mongo.py @@ -0,0 +1,26 @@ +import pymongo +from . import KeyStore +from .exceptions import ItemNotFoundError + + +class MongoKeyStore(KeyStore): + """ + A Mongodb backed KeyStore + """ + def __init__(self, host, db, collection, port=27017): + self.collection = pymongo.connection.Connection( + host=host, + port=port + )[db][collection] + + def get_children_for_item(self, location): + item = self.collection.find_one( + {'location': location.dict()}, + fields={'children': True}, + sort=[('revision', pymongo.ASCENDING)], + ) + + if item is None: + raise ItemNotFoundError() + + return item['children'] diff --git a/cms/templates/login.html b/cms/templates/login.html new file mode 100644 index 0000000000..03ea5f967c --- /dev/null +++ b/cms/templates/login.html @@ -0,0 +1,11 @@ +
+ + + % if next is not None: + + % endif + + Username: + Possword: + +
diff --git a/cms/urls.py b/cms/urls.py index 80e2b19e9d..55d7a1086e 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -4,6 +4,7 @@ from django.conf.urls.defaults import patterns, url # from django.contrib import admin # admin.autodiscover() -urlpatterns = patterns('cms.views', - url(r'^(?P[^/]+)/calendar/', 'calendar', name='calendar'), +urlpatterns = patterns('', + url(r'^(?P[^/]+)/(?P[^/]+)/calendar/', 'cms.views.calendar', name='calendar'), + url(r'^accounts/login/', 'instructor.views.do_login', name='login'), ) diff --git a/cms/views.py b/cms/views.py index d0d4f4871c..c6786b03c4 100644 --- a/cms/views.py +++ b/cms/views.py @@ -1,5 +1,12 @@ from mitxmako.shortcuts import render_to_response +from keystore import Location +from keystore.django import keystore +from django.contrib.auth.decorators import login_required -def calendar(request, course): - return render_to_response('calendar.html', {}) +@login_required +def calendar(request, org, course): + weeks = keystore.get_children_for_item( + Location(['i4x', org, course, 'Course', 'course']) + ) + return render_to_response('calendar.html', {'weeks': weeks}) diff --git a/common/lib/django_future/__init__.py b/common/lib/django_future/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/lib/django_future/csrf.py b/common/lib/django_future/csrf.py similarity index 100% rename from lms/lib/django_future/csrf.py rename to common/lib/django_future/csrf.py diff --git a/requirements.txt b/requirements.txt index 82b28b09cf..5e95e1bf9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,3 +23,4 @@ requests sympy newrelic glob2 +pymongo From ae44d86e2780c6e0cae137a318cde5bb23630d99 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sat, 9 Jun 2012 18:26:49 -0400 Subject: [PATCH 08/80] add msg to textinput_dynamath --- common/lib/capa/templates/textinput_dynamath.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/lib/capa/templates/textinput_dynamath.html b/common/lib/capa/templates/textinput_dynamath.html index e8b26c5fcc..41b9c5d172 100644 --- a/common/lib/capa/templates/textinput_dynamath.html +++ b/common/lib/capa/templates/textinput_dynamath.html @@ -30,4 +30,7 @@ + % if msg: + ${msg|n} + % endif From 46b45969d04680b8e1cd74f389d006b8dd064b47 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sat, 9 Jun 2012 18:27:09 -0400 Subject: [PATCH 09/80] first pass in capa cleanup: - responsetype used to be instantiated multiple times(!) in capa_problem now it is instantiated once, and stored in self.responders - responsetypes.GenericResponse restructured; each superclass show now provide setup_response (and not __init__), and may provide get_max_score(); general __init__ provided to clean up superclasses. --- common/lib/capa/capa_problem.py | 191 ++++++------- common/lib/capa/responsetypes.py | 275 ++++++++++++------- common/lib/capa/util.py | 18 ++ lms/djangoapps/courseware/module_render.py | 2 +- lms/static/coffee/src/modules/problem.coffee | 2 +- 5 files changed, 287 insertions(+), 201 deletions(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index b655270a9a..f790190215 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -1,6 +1,11 @@ # # File: capa/capa_problem.py # +# Nomenclature: +# +# A capa Problem is a collection of text and capa Response questions. Each Response may have one or more +# Input entry fields. The capa Problem may include a solution. +# ''' Main module which shows problems (of "capa" type). @@ -83,17 +88,32 @@ html_skip = ["numericalresponse", "customresponse", "schematicresponse", "formul class LoncapaProblem(object): + ''' + Main class for capa Problems. + ''' + def __init__(self, fileobject, id, state=None, seed=None, system=None): + ''' + Initializes capa Problem. The problem itself is defined by the XML file + pointed to by fileobject. + + Arguments: + + - filesobject : an OSFS instance: see fs.osfs + - id : string used as the identifier for this problem; often a filename (no spaces) + - state : student state (represented as a dict) + - seed : random number generator seed (int) + - system : I4xSystem instance which provides OS, rendering, and user context + + ''' + ## Initialize class variables from state - self.seed = None self.student_answers = dict() self.correct_map = dict() self.done = False self.problem_id = id self.system = system - - if seed is not None: - self.seed = seed + self.seed = seed if state: if 'seed' in state: @@ -109,22 +129,21 @@ class LoncapaProblem(object): if not self.seed: self.seed = struct.unpack('i', os.urandom(4))[0] - ## Parse XML file - if getattr(system, 'DEBUG', False): + self.fileobject = fileobject # save problem file object, so we can use for debugging information later + if getattr(system, 'DEBUG', False): # get the problem XML string from the problem file log.info("[courseware.capa.capa_problem.lcp.init] fileobject = %s" % fileobject) file_text = fileobject.read() - self.fileobject = fileobject # save it, so we can use for debugging information later - # Convert startouttext and endouttext to proper - # TODO: Do with XML operations - file_text = re.sub("startouttext\s*/", "text", file_text) + file_text = re.sub("startouttext\s*/", "text", file_text) # Convert startouttext and endouttext to proper file_text = re.sub("endouttext\s*/", "/text", file_text) - self.tree = etree.XML(file_text) - self.preprocess_problem(self.tree, correct_map=self.correct_map, answer_map=self.student_answers) + self.tree = etree.XML(file_text) # parse problem XML file into an element tree + + # construct script processor context (eg for customresponse problems) self.context = self.extract_context(self.tree, seed=self.seed) - for response in self.tree.xpath('//' + "|//".join(response_types)): - responder = response_types[response.tag](response, self.context, self.system) - responder.preprocess_response() + + # pre-parse the XML tree: modifies it to add ID's and perform some in-place transformations + # this also creates the list (self.responders) of Response instances for each question in the problem + self.preprocess_problem(self.tree, correct_map=self.correct_map, answer_map=self.student_answers) def __unicode__(self): return u"LoncapaProblem ({0})".format(self.fileobject) @@ -140,12 +159,27 @@ class LoncapaProblem(object): def get_max_score(self): ''' - TODO: multiple points for programming problems. + Return maximum score for this problem. + We do this by counting the number of answers available for each question + in the problem. If the Response for a question has a get_max_score() method + then we call that and add its return value to the count. That can be + used to give complex problems (eg programming questions) multiple points. ''' - sum = 0 - for et in entry_types: - sum = sum + self.tree.xpath('count(//' + et + ')') - return int(sum) + maxscore = 0 + for responder in self.responders: + if hasattr(responder,'get_max_score'): + try: + maxscore += responder.get_max_score() + except Exception, err: + log.error('responder %s failed to properly return from get_max_score()' % responder) + raise + else: + try: + maxscore += len(responder.get_answers()) + except: + log.error('responder %s failed to properly return get_answers()' % responder) + raise + return maxscore def get_score(self): correct = 0 @@ -166,34 +200,35 @@ class LoncapaProblem(object): of each key removed (the string before the first "_"). Thus, for example, input_ID123 -> ID123, and input_fromjs_ID123 -> fromjs_ID123 + + Calles the Response for each question in this problem, to do the actual grading. ''' self.student_answers = answers self.correct_map = dict() - problems_simple = self.extract_problems(self.tree) - for response in problems_simple: - grader = response_types[response.tag](response, self.context, self.system) - results = grader.get_score(answers) # call the responsetype instance to do the actual grading + log.info('%s: in grade_answers, answers=%s' % (self,answers)) + for responder in self.responders: + results = responder.get_score(answers) # call the responsetype instance to do the actual grading self.correct_map.update(results) return self.correct_map def get_question_answers(self): - """Returns a dict of answer_ids to answer values. If we can't generate + """Returns a dict of answer_ids to answer values. If we cannot generate an answer (this sometimes happens in customresponses), that answer_id is not included. Called by "show answers" button JSON request (see capa_module) """ answer_map = dict() - problems_simple = self.extract_problems(self.tree) # purified (flat) XML tree of just response queries - for response in problems_simple: - responder = response_types[response.tag](response, self.context, self.system) # instance of numericalresponse, customresponse,... + for responder in self.responders: results = responder.get_answers() answer_map.update(results) # dict of (id,correct_answer) + # This should be handled in each responsetype, not here. # example for the following: - for entry in problems_simple.xpath("//" + "|//".join(response_properties + entry_types)): - answer = entry.get('correct_answer') # correct answer, when specified elsewhere, eg in a textline - if answer: - answer_map[entry.get('id')] = contextualize_text(answer, self.context) + for responder in self.responders: + for entry in responder.inputfields: + answer = entry.get('correct_answer') # correct answer, when specified elsewhere, eg in a textline + if answer: + answer_map[entry.get('id')] = contextualize_text(answer, self.context) # include solutions from ... stanzas # Tentative merge; we should figure out how we want to handle hints and solutions @@ -209,17 +244,16 @@ class LoncapaProblem(object): the dicts returned by grade_answers and get_question_answers. (Though get_question_answers may only return a subset of these.""" answer_ids = [] - problems_simple = self.extract_problems(self.tree) - for response in problems_simple: - responder = response_types[response.tag](response, self.context) - if hasattr(responder, "answer_id"): - answer_ids.append(responder.answer_id) - # customresponse types can have multiple answer_ids - elif hasattr(responder, "answer_ids"): - answer_ids.extend(responder.answer_ids) - + for responder in self.responders: + answer_ids.append(responder.get_answers().keys()) return answer_ids + def get_html(self): + ''' + Main method called externally to get the HTML to be rendered for this capa Problem. + ''' + return contextualize_text(etree.tostring(self.extract_html(self.tree)[0]), self.context) + # ======= Private ======== def extract_context(self, tree, seed=struct.unpack('i', os.urandom(4))[0]): # private ''' @@ -253,9 +287,6 @@ class LoncapaProblem(object): log.exception("Error while execing code: " + code) return context - def get_html(self): - return contextualize_text(etree.tostring(self.extract_html(self.tree)[0]), self.context) - def extract_html(self, problemtree): # private ''' Helper function for get_html. Recursively converts XML tree to HTML ''' @@ -335,76 +366,34 @@ class LoncapaProblem(object): Assign sub-IDs to all entries (textline, schematic, etc.) Annoted correctness and value In-place transformation + + Also create capa Response instances for each responsetype and save as self.responders ''' response_id = 1 + self.responders = [] for response in tree.xpath('//' + "|//".join(response_types)): response_id_str = self.problem_id + "_" + str(response_id) - response.attrib['id'] = response_id_str - if response_id not in correct_map: - correct = 'unsubmitted' - response.attrib['state'] = correct - response_id = response_id + 1 + response.attrib['id'] = response_id_str # create and save ID for this response + + # if response_id not in correct_map: correct = 'unsubmitted' # unused - to be removed + # response.attrib['state'] = correct + response_id += response_id + answer_id = 1 - for entry in tree.xpath("|".join(['//' + response.tag + '[@id=$id]//' + x for x in (entry_types + solution_types)]), - id=response_id_str): - # assign one answer_id for each entry_type or solution_type + inputfields = tree.xpath("|".join(['//' + response.tag + '[@id=$id]//' + x for x in (entry_types + solution_types)]), + id=response_id_str) + for entry in inputfields: # assign one answer_id for each entry_type or solution_type entry.attrib['response_id'] = str(response_id) entry.attrib['answer_id'] = str(answer_id) entry.attrib['id'] = "%s_%i_%i" % (self.problem_id, response_id, answer_id) answer_id = answer_id + 1 + responder = response_types[response.tag](response, inputfields, self.context, self.system) # instantiate capa Response + self.responders.append(responder) # save in list in self + # ... may not be associated with any specific response; give IDs for those separately # TODO: We should make the namespaces consistent and unique (e.g. %s_problem_%i). solution_id = 1 for solution in tree.findall('.//solution'): solution.attrib['id'] = "%s_solution_%i" % (self.problem_id, solution_id) solution_id += 1 - - def extract_problems(self, problem_tree): - ''' Remove layout from the problem, and give a purified XML tree of just the problems ''' - problem_tree = copy.deepcopy(problem_tree) - tree = Element('problem') - for response in problem_tree.xpath("//" + "|//".join(response_types)): - newresponse = copy.copy(response) - for e in newresponse: - newresponse.remove(e) - # copy.copy is needed to make xpath work right. Otherwise, it starts at the root - # of the tree. We should figure out if there's some work-around - for e in copy.copy(response).xpath("//" + "|//".join(response_properties + entry_types)): - newresponse.append(e) - - tree.append(newresponse) - return tree - -if __name__ == '__main__': - problem_id = 'simpleFormula' - filename = 'simpleFormula.xml' - - problem_id = 'resistor' - filename = 'resistor.xml' - - lcp = LoncapaProblem(filename, problem_id) - - context = lcp.extract_context(lcp.tree) - problem = lcp.extract_problems(lcp.tree) - print lcp.grade_problems({'resistor_2_1': '1.0', 'resistor_3_1': '2.0'}) - #print lcp.grade_problems({'simpleFormula_2_1':'3*x^3'}) -#numericalresponse(problem, context) - -#print etree.tostring((lcp.tree)) - print '============' - print -#print etree.tostring(lcp.extract_problems(lcp.tree)) - print lcp.get_html() -#print extract_context(tree) - - - - # def handle_fr(self, element): - # problem={"answer":self.contextualize_text(answer), - # "type":"formularesponse", - # "tolerance":evaluator({},{},self.contextualize_text(tolerance)), - # "sample_range":dict(zip(variables, sranges)), - # "samples_count": numsamples, - # "id":id, - # self.questions[self.lid]=problem diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index c5683bb0bf..c0ad98baa2 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -21,40 +21,123 @@ import abc # specific library imports from calc import evaluator, UndefinedVariable -from util import contextualize_text +from util import * from lxml import etree from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful Soup!!! FIXME? -log = logging.getLogger(__name__) +#log = logging.getLogger(__name__) +log = logging.getLogger('mitx.common.lib.capa.responsetypes') -def compare_with_tolerance(v1, v2, tol): - ''' Compare v1 to v2 with maximum tolerance tol - tol is relative if it ends in %; otherwise, it is absolute +#----------------------------------------------------------------------------- +# Exceptions + +class LoncapaProblemError(Exception): ''' - relative = "%" in tol - if relative: - tolerance_rel = evaluator(dict(),dict(),tol[:-1]) * 0.01 - tolerance = tolerance_rel * max(abs(v1), abs(v2)) - else: - tolerance = evaluator(dict(),dict(),tol) - return abs(v1-v2) <= tolerance + Error in specification of a problem + ''' + pass + +class ResponseError(Exception): + ''' + Error for failure in processing a response + ''' + pass + +class StudentInputError(Exception): + pass + +#----------------------------------------------------------------------------- +# +# Main base class for CAPA responsetypes class GenericResponse(object): + ''' + Base class for CAPA responsetypes. Each response type (ie a capa question, + which is part of a capa problem) is represented as a superclass, + which should provide the following methods: + + - get_score : evaluate the given student answers, and return a CorrectMap + - get_answers : provide a dict of the expected answers for this problem + + In addition, these methods are optional: + + - get_max_score : if defined, this is called to obtain the maximum score possible for this question + - setup_response : find and note the answer input field IDs for the response; called by __init__ + + Each response type may also specify the following attributes: + + - max_inputfields : (int) maximum number of answer input fields (checked in __init__ if not None) + - allowed_inputfields : list of allowed input fields (each a string) for this Response + - required_attributes : list of required attributes (each a string) on the main response XML stanza + + ''' __metaclass__=abc.ABCMeta # abc = Abstract Base Class + max_inputfields = None + allowed_inputfields = [] + required_attributes = [] + + def __init__(self, xml, inputfields, context, system=None): + ''' + Init is passed the following arguments: + + - xml : ElementTree of this Response + - inputfields : list of ElementTrees for each input entry field in this Response + - context : script processor context + - system : I4xSystem instance which provides OS, rendering, and user context + - __unicode__ : unicode representation of this Response + + ''' + self.xml = xml + self.inputfields = inputfields + self.context = context + self.system = system + + for abox in inputfields: + if not abox.tag in self.allowed_inputfields: + msg = "%s: cannot have input field %s" % (unicode(self),abox.tag) + msg += "\nSee XML source line %s" % getattr(xml,'sourceline','') + raise LoncapaProblemError(msg) + + if self.max_inputfields and len(inputfields)>self.max_inputfields: + msg = "%s: cannot have more than %s input fields" % (unicode(self),self.max_inputfields) + msg += "\nSee XML source line %s" % getattr(xml,'sourceline','') + raise LoncapaProblemError(msg) + + for prop in self.required_attributes: + if not xml.get(prop): + msg = "Error in problem specification: %s missing required attribute %s" % (unicode(self),prop) + msg += "\nSee XML source line %s" % getattr(xml,'sourceline','') + raise LoncapaProblemError(msg) + + self.answer_ids = [x.get('id') for x in self.inputfields] + if self.max_inputfields==1: + self.answer_id = self.answer_ids[0] # for convenience + + if hasattr(self,'setup_response'): + self.setup_response() + @abc.abstractmethod def get_score(self, student_answers): + ''' + Return a CorrectMap for the answers expected vs given. This includes + (correctness, npoints, msg) for each answer_id. + ''' pass @abc.abstractmethod def get_answers(self): + ''' + Return a dict of (answer_id,answer_text) for each answer for this question. + ''' pass #not an abstract method because plenty of responses will not want to preprocess anything, and we should not require that they override this method. - def preprocess_response(self): + def setup_response(self): pass -#Every response type needs methods "get_score" and "get_answers" + def __unicode__(self): + return 'LoncapaProblem Response %s' % self.xml.tag #----------------------------------------------------------------------------- @@ -69,30 +152,19 @@ class MultipleChoiceResponse(GenericResponse): '''}] - def __init__(self, xml, context, system=None): - self.xml = xml - self.correct_choices = xml.xpath('//*[@id=$id]//choice[@correct="true"]', - id=xml.get('id')) - self.correct_choices = [choice.get('name') for choice in self.correct_choices] - self.context = context - self.answer_field = xml.find('choicegroup') # assumes only ONE choicegroup within this response - self.answer_id = xml.xpath('//*[@id=$id]//choicegroup/@id', - id=xml.get('id')) - if not len(self.answer_id) == 1: - raise Exception("should have exactly one choice group per multiplechoicceresponse") - self.answer_id=self.answer_id[0] + max_inputfields = 1 + allowed_inputfields = ['choicegroup'] - def get_score(self, student_answers): - if self.answer_id in student_answers and student_answers[self.answer_id] in self.correct_choices: - return {self.answer_id:'correct'} - else: - return {self.answer_id:'incorrect'} + def setup_response(self): + self.mc_setup_response() # call secondary setup for MultipleChoice questions, to set name attributes - def get_answers(self): - return {self.answer_id:self.correct_choices} + # define correct choices (after calling secondary setup) + xml = self.xml + cxml = xml.xpath('//*[@id=$id]//choice[@correct="true"]',id=xml.get('id')) + self.correct_choices = [choice.get('name') for choice in cxml] - def preprocess_response(self): + def mc_setup_response(self): ''' Initialize name attributes in stanzas in the in this response. ''' @@ -107,9 +179,22 @@ class MultipleChoiceResponse(GenericResponse): i+=1 else: choice.set("name", "choice_"+choice.get("name")) - + + def get_score(self, student_answers): + ''' + grade student response. + ''' + # log.debug('%s: student_answers=%s, correct_choices=%s' % (unicode(self),student_answers,self.correct_choices)) + if self.answer_id in student_answers and student_answers[self.answer_id] in self.correct_choices: + return {self.answer_id:'correct'} + else: + return {self.answer_id:'incorrect'} + + def get_answers(self): + return {self.answer_id:self.correct_choices} + class TrueFalseResponse(MultipleChoiceResponse): - def preprocess_response(self): + def mc_setup_response(self): i=0 for response in self.xml.xpath("choicegroup"): response.set("type", "TrueFalse") @@ -140,12 +225,13 @@ class OptionResponse(GenericResponse): The location of the earth '''}] - def __init__(self, xml, context, system=None): - self.xml = xml - self.answer_fields = xml.findall('optioninput') - self.context = context + allowed_inputfields = ['optioninput'] + + def setup_response(self): + self.answer_fields = self.inputfields def get_score(self, student_answers): + # log.debug('%s: student_answers=%s' % (unicode(self),student_answers)) cmap = {} amap = self.get_answers() for aid in amap: @@ -157,17 +243,20 @@ class OptionResponse(GenericResponse): def get_answers(self): amap = dict([(af.get('id'),af.get('correct')) for af in self.answer_fields]) + # log.debug('%s: expected answers=%s' % (unicode(self),amap)) return amap #----------------------------------------------------------------------------- class NumericalResponse(GenericResponse): - def __init__(self, xml, context, system=None): - self.xml = xml - if not xml.get('answer'): - msg = "Error in problem specification: numericalresponse missing required answer attribute\n" - msg += "See XML source line %s" % getattr(xml,'sourceline','') - raise Exception,msg + + allowed_inputfields = ['textline'] + required_attributes = ['answer'] + max_inputfields = 1 + + def setup_response(self): + xml = self.xml + context = self.context self.correct_answer = contextualize_text(xml.get('answer'), context) try: self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default', @@ -182,7 +271,7 @@ class NumericalResponse(GenericResponse): self.answer_id = None def get_score(self, student_answers): - ''' Display HTML for a numeric response ''' + '''Grade a numeric response ''' student_answer = student_answers[self.answer_id] try: correct = compare_with_tolerance (evaluator(dict(),dict(),student_answer), complex(self.correct_answer), self.tolerance) @@ -241,16 +330,11 @@ def sympy_check2(): '''}] - def __init__(self, xml, context, system=None): - self.xml = xml - self.system = system - ## CRITICAL TODO: Should cover all entrytypes - ## NOTE: xpath will look at root of XML tree, not just - ## what's in xml. @id=id keeps us in the right customresponse. - self.answer_ids = xml.xpath('//*[@id=$id]//textline/@id', - id=xml.get('id')) - self.answer_ids += [x.get('id') for x in xml.findall('textbox')] # also allow textbox inputs - self.context = context + allowed_inputfields = ['textline','textbox'] + + def setup_response(self): + xml = self.xml + context = self.context # if has an "expect" (or "answer") attribute then save that self.expect = xml.get('expect') or xml.get('answer') @@ -271,15 +355,17 @@ def sympy_check2(): cfn = xml.get('cfn') if cfn: log.debug("cfn = %s" % cfn) - if cfn in context: - self.code = context[cfn] + if cfn in self.context: + self.code = self.context[cfn] else: - print "can't find cfn in context = ",context + msg = "%s: can't find cfn in context = %s" % (unicode(self),self.context) + msg += "\nSee XML source line %s" % getattr(self.xml,'sourceline','') + raise LoncapaProblemError(msg) if not self.code: if answer is None: # raise Exception,"[courseware.capa.responsetypes.customresponse] missing code checking script! id=%s" % self.myid - print "[courseware.capa.responsetypes.customresponse] missing code checking script! id=%s" % self.myid + log.error("[courseware.capa.responsetypes.customresponse] missing code checking script! id=%s" % self.myid) self.code = '' else: answer_src = answer.get('src') @@ -294,6 +380,8 @@ def sympy_check2(): of each key removed (the string before the first "_"). ''' + log.debug('%s: student_answers=%s' % (unicode(self),student_answers)) + idset = sorted(self.answer_ids) # ordered list of answer id's try: submission = [student_answers[k] for k in idset] # ordered list of answers @@ -425,12 +513,12 @@ class SymbolicResponse(CustomResponse): Your input should be typed in as a list of lists, eg [[1,2],[3,4]]. '''}] - def __init__(self, xml, context, system=None): - xml.set('cfn','symmath_check') + + def setup_response(self): + self.xml.set('cfn','symmath_check') code = "from symmath import *" - exec code in context,context - CustomResponse.__init__(self,xml,context,system) - + exec code in self.context,self.context + CustomResponse.setup_response(self) #----------------------------------------------------------------------------- @@ -480,15 +568,13 @@ main() '''}] - def __init__(self, xml, context, system=None): - self.xml = xml - self.url = xml.get('url') or "http://eecs1.mit.edu:8889/pyloncapa" # FIXME - hardcoded URL - self.answer_ids = xml.xpath('//*[@id=$id]//textbox/@id|//*[@id=$id]//textline/@id', - id=xml.get('id')) - self.context = context - answer = xml.xpath('//*[@id=$id]//answer', - id=xml.get('id'))[0] + allowed_inputfields = ['textline','textbox'] + def setup_response(self): + xml = self.xml + self.url = xml.get('url') or "http://eecs1.mit.edu:8889/pyloncapa" # FIXME - hardcoded URL + + answer = xml.xpath('//*[@id=$id]//answer',id=xml.get('id'))[0] # FIXME - catch errors answer_src = answer.get('src') if answer_src is not None: self.code = self.system.filesystem.open('src/'+answer_src).read() @@ -590,8 +676,6 @@ main() raise Exception,'Short response from external server' return dict(zip(self.answer_ids,exans)) -class StudentInputError(Exception): - pass #----------------------------------------------------------------------------- @@ -617,8 +701,13 @@ class FormulaResponse(GenericResponse): '''}] - def __init__(self, xml, context, system=None): - self.xml = xml + allowed_inputfields = ['textline'] + required_attributes = ['answer'] + max_inputfields = 1 + + def setup_response(self): + xml = self.xml + context = self.context self.correct_answer = contextualize_text(xml.get('answer'), context) self.samples = contextualize_text(xml.get('samples'), context) try: @@ -628,14 +717,6 @@ class FormulaResponse(GenericResponse): except Exception: self.tolerance = 0 - try: - self.answer_id = xml.xpath('//*[@id=$id]//textline/@id', - id=xml.get('id'))[0] - except Exception: - self.answer_id = None - raise Exception, "[courseware.capa.responsetypes.FormulaResponse] Error: missing answer_id!!" - - self.context = context ts = xml.get('type') if ts is None: typeslist = [] @@ -648,7 +729,6 @@ class FormulaResponse(GenericResponse): else: # Default self.case_sensitive = False - def get_score(self, student_answers): variables=self.samples.split('@')[0].split(',') numsamples=int(self.samples.split('@')[1].split('#')[1]) @@ -697,13 +777,12 @@ class FormulaResponse(GenericResponse): #----------------------------------------------------------------------------- class SchematicResponse(GenericResponse): - def __init__(self, xml, context, system=None): - self.xml = xml - self.answer_ids = xml.xpath('//*[@id=$id]//schematic/@id', - id=xml.get('id')) - self.context = context - answer = xml.xpath('//*[@id=$id]//answer', - id=xml.get('id'))[0] + + allowed_inputfields = ['schematic'] + + def setup_response(self): + xml = self.xml + answer = xml.xpath('//*[@id=$id]//answer', id=xml.get('id'))[0] answer_src = answer.get('src') if answer_src is not None: self.code = self.system.filestore.open('src/'+answer_src).read() # Untested; never used @@ -740,10 +819,10 @@ class ImageResponse(GenericResponse): '''}] - def __init__(self, xml, context, system=None): - self.xml = xml - self.context = context - self.ielements = xml.findall('imageinput') + allowed_inputfields = ['imageinput'] + + def setup_response(self): + self.ielements = self.inputfields self.answer_ids = [ie.get('id') for ie in self.ielements] def get_score(self, student_answers): diff --git a/common/lib/capa/util.py b/common/lib/capa/util.py index d042aa21d3..996f6c8dac 100644 --- a/common/lib/capa/util.py +++ b/common/lib/capa/util.py @@ -1,3 +1,21 @@ +from calc import evaluator, UndefinedVariable + +#----------------------------------------------------------------------------- +# +# Utility functions used in CAPA responsetypes + +def compare_with_tolerance(v1, v2, tol): + ''' Compare v1 to v2 with maximum tolerance tol + tol is relative if it ends in %; otherwise, it is absolute + ''' + relative = "%" in tol + if relative: + tolerance_rel = evaluator(dict(),dict(),tol[:-1]) * 0.01 + tolerance = tolerance_rel * max(abs(v1), abs(v2)) + else: + tolerance = evaluator(dict(),dict(),tol) + return abs(v1-v2) <= tolerance + def contextualize_text(text, context): # private ''' Takes a string with variables. E.g. $a+$b. Does a substitution of those variables from the context ''' diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 97fd1b948c..0f82d9ba94 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -169,7 +169,7 @@ def render_x_module(user, request, xml_module, module_object_preload, position=N content = instance.get_html() # special extra information about each problem, only for users who are staff - if user.is_staff: + if False and user.is_staff: module_id = xml_module.get('id') histogram = grade_histogram(module_id) render_histogram = len(histogram) > 0 diff --git a/lms/static/coffee/src/modules/problem.coffee b/lms/static/coffee/src/modules/problem.coffee index c1a801d2b2..e1e062e949 100644 --- a/lms/static/coffee/src/modules/problem.coffee +++ b/lms/static/coffee/src/modules/problem.coffee @@ -48,7 +48,7 @@ class @Problem @$("label[for='input_#{key}_#{choice}']").attr correct_answer: 'true' else - @$("#answer_#{key}").text(value) + @$("#answer_#{key}").html(value) // needs to be html, not text, for complex solutions (eg coding) @$('.show').val 'Hide Answer' @element.addClass 'showed' else From 7b3ad553074dc323d079d0d564a0c5eeede160ae Mon Sep 17 00:00:00 2001 From: ichuang Date: Sat, 9 Jun 2012 18:35:42 -0400 Subject: [PATCH 10/80] responsetypes - fix comment --- common/lib/capa/responsetypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index c0ad98baa2..1c09493b03 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -63,6 +63,7 @@ class GenericResponse(object): - get_max_score : if defined, this is called to obtain the maximum score possible for this question - setup_response : find and note the answer input field IDs for the response; called by __init__ + - __unicode__ : unicode representation of this Response Each response type may also specify the following attributes: @@ -85,7 +86,6 @@ class GenericResponse(object): - inputfields : list of ElementTrees for each input entry field in this Response - context : script processor context - system : I4xSystem instance which provides OS, rendering, and user context - - __unicode__ : unicode representation of this Response ''' self.xml = xml @@ -137,7 +137,7 @@ class GenericResponse(object): pass def __unicode__(self): - return 'LoncapaProblem Response %s' % self.xml.tag + return u'LoncapaProblem Response %s' % self.xml.tag #----------------------------------------------------------------------------- From 7b3c79698fb3e537da9c06a7b3233ec4fe05303e Mon Sep 17 00:00:00 2001 From: ichuang Date: Sat, 9 Jun 2012 21:29:11 -0400 Subject: [PATCH 11/80] second pass in capa cleanup: - each response can now render its own xhtml - cleaned up LoncapaProblem.extract_html --- common/lib/capa/capa_problem.py | 119 ++++++++++++------------------- common/lib/capa/inputtypes.py | 71 ++++-------------- common/lib/capa/responsetypes.py | 40 ++++++++--- 3 files changed, 89 insertions(+), 141 deletions(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index f790190215..c63c13d420 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -23,7 +23,6 @@ import scipy import struct from lxml import etree -from lxml.etree import Element from xml.sax.saxutils import unescape from util import contextualize_text @@ -36,6 +35,7 @@ import eia log = logging.getLogger(__name__) +# dict of tagname, Response Class -- this should come from auto-registering response_types = {'numericalresponse': NumericalResponse, 'formularesponse': FormulaResponse, 'customresponse': CustomResponse, @@ -47,20 +47,13 @@ response_types = {'numericalresponse': NumericalResponse, 'optionresponse': OptionResponse, 'symbolicresponse': SymbolicResponse, } -entry_types = ['textline', 'schematic', 'choicegroup', 'textbox', 'imageinput', 'optioninput'] -solution_types = ['solution'] # extra things displayed after "show answers" is pressed -response_properties = ["responseparam", "answer"] # these get captured as student responses -# How to convert from original XML to HTML -# We should do this with xlst later +entry_types = ['textline', 'schematic', 'choicegroup', 'textbox', 'imageinput', 'optioninput'] +solution_types = ['solution'] # extra things displayed after "show answers" is pressed +response_properties = ["responseparam", "answer"] # these get captured as student responses + +# special problem tags which should be turned into innocuous HTML html_transforms = {'problem': {'tag': 'div'}, - "numericalresponse": {'tag': 'span'}, - "customresponse": {'tag': 'span'}, - "externalresponse": {'tag': 'span'}, - "schematicresponse": {'tag': 'span'}, - "formularesponse": {'tag': 'span'}, - "symbolicresponse": {'tag': 'span'}, - "multiplechoiceresponse": {'tag': 'span'}, "text": {'tag': 'span'}, "math": {'tag': 'span'}, } @@ -74,18 +67,6 @@ global_context = {'random': random, # These should be removed from HTML output, including all subelements html_problem_semantics = ["responseparam", "answer", "script"] -# These should be removed from HTML output, but keeping subelements -html_skip = ["numericalresponse", "customresponse", "schematicresponse", "formularesponse", "text", "externalresponse", 'symbolicresponse'] - -# removed in MC -## These should be transformed -#html_special_response = {"textline":inputtypes.textline.render, -# "schematic":inputtypes.schematic.render, -# "textbox":inputtypes.textbox.render, -# "formulainput":inputtypes.jstextline.render, -# "solution":inputtypes.solution.render, -# } - class LoncapaProblem(object): ''' @@ -142,7 +123,8 @@ class LoncapaProblem(object): self.context = self.extract_context(self.tree, seed=self.seed) # pre-parse the XML tree: modifies it to add ID's and perform some in-place transformations - # this also creates the list (self.responders) of Response instances for each question in the problem + # this also creates the dict (self.responders) of Response instances for each question in the problem. + # the dict has keys = xml subtree of Response, values = Response instance self.preprocess_problem(self.tree, correct_map=self.correct_map, answer_map=self.student_answers) def __unicode__(self): @@ -166,7 +148,7 @@ class LoncapaProblem(object): used to give complex problems (eg programming questions) multiple points. ''' maxscore = 0 - for responder in self.responders: + for responder in self.responders.values(): if hasattr(responder,'get_max_score'): try: maxscore += responder.get_max_score() @@ -182,6 +164,10 @@ class LoncapaProblem(object): return maxscore def get_score(self): + ''' + Compute score for this problem. The score is the number of points awarded. + Returns an integer, from 0 to get_max_score(). + ''' correct = 0 for key in self.correct_map: if self.correct_map[key] == u'correct': @@ -206,7 +192,7 @@ class LoncapaProblem(object): self.student_answers = answers self.correct_map = dict() log.info('%s: in grade_answers, answers=%s' % (self,answers)) - for responder in self.responders: + for responder in self.responders.values(): results = responder.get_score(answers) # call the responsetype instance to do the actual grading self.correct_map.update(results) return self.correct_map @@ -218,24 +204,14 @@ class LoncapaProblem(object): (see capa_module) """ answer_map = dict() - for responder in self.responders: + for responder in self.responders.values(): results = responder.get_answers() answer_map.update(results) # dict of (id,correct_answer) - # This should be handled in each responsetype, not here. - # example for the following: - for responder in self.responders: - for entry in responder.inputfields: - answer = entry.get('correct_answer') # correct answer, when specified elsewhere, eg in a textline - if answer: - answer_map[entry.get('id')] = contextualize_text(answer, self.context) - # include solutions from ... stanzas - # Tentative merge; we should figure out how we want to handle hints and solutions for entry in self.tree.xpath("//" + "|//".join(solution_types)): answer = etree.tostring(entry) - if answer: - answer_map[entry.get('id')] = answer + if answer: answer_map[entry.get('id')] = answer return answer_map @@ -244,7 +220,7 @@ class LoncapaProblem(object): the dicts returned by grade_answers and get_question_answers. (Though get_question_answers may only return a subset of these.""" answer_ids = [] - for responder in self.responders: + for responder in self.responders.values(): answer_ids.append(responder.get_answers().keys()) return answer_ids @@ -252,7 +228,7 @@ class LoncapaProblem(object): ''' Main method called externally to get the HTML to be rendered for this capa Problem. ''' - return contextualize_text(etree.tostring(self.extract_html(self.tree)[0]), self.context) + return contextualize_text(etree.tostring(self.extract_html(self.tree)), self.context) # ======= Private ======== def extract_context(self, tree, seed=struct.unpack('i', os.urandom(4))[0]): # private @@ -264,12 +240,11 @@ class LoncapaProblem(object): Problem XML goes to Python execution context. Runs everything in script tags ''' random.seed(self.seed) - context = {'global_context': global_context} # save global context in here also - context.update(global_context) # initialize context to have stuff in global_context - context['__builtins__'] = globals()['__builtins__'] # put globals there also - context['the_lcp'] = self # pass instance of LoncapaProblem in + context = {'global_context': global_context} # save global context in here also + context.update(global_context) # initialize context to have stuff in global_context + context['__builtins__'] = globals()['__builtins__'] # put globals there also + context['the_lcp'] = self # pass instance of LoncapaProblem in - #for script in tree.xpath('/problem/script'): for script in tree.findall('.//script'): stype = script.get('type') if stype: @@ -288,16 +263,20 @@ class LoncapaProblem(object): return context def extract_html(self, problemtree): # private - ''' Helper function for get_html. Recursively converts XML tree to HTML + ''' + Main (private) function which converts Problem XML tree to HTML. + Calls itself recursively. + + Returns Element tree of XHTML representation of problemtree. + Calls render_html of Response instances to render responses into XHTML. + + Used by get_html. ''' if problemtree.tag in html_problem_semantics: return problemid = problemtree.get('id') # my ID - # used to be - # if problemtree.tag in html_special_response: - if problemtree.tag in inputtypes.get_input_xml_tags(): # status is currently the answer for the problem ID for the input element, # but it will turn into a dict containing both the answer and any associated message @@ -334,31 +313,25 @@ class LoncapaProblem(object): use='capa_input') return render_object.get_html() # function(problemtree, value, status, msg) # render the special response (textline, schematic,...) - tree = Element(problemtree.tag) + if problemtree in self.responders: # let each Response render itself + return self.responders[problemtree].render_html(self.extract_html) + + tree = etree.Element(problemtree.tag) for item in problemtree: - subitems = self.extract_html(item) - if subitems is not None: - for subitem in subitems: - tree.append(subitem) - for (key, value) in problemtree.items(): - tree.set(key, value) + item_xhtml = self.extract_html(item) # nothing special: recurse + if item_xhtml is not None: + tree.append(item_xhtml) + + if tree.tag in html_transforms: + tree.tag = html_transforms[problemtree.tag]['tag'] + else: + for (key, value) in problemtree.items(): # copy attributes over if not innocufying + tree.set(key, value) tree.text = problemtree.text tree.tail = problemtree.tail - if problemtree.tag in html_transforms: - tree.tag = html_transforms[problemtree.tag]['tag'] - # Reset attributes. Otherwise, we get metadata in HTML - # (e.g. answers) - # TODO: We should remove and not zero them. - # I'm not sure how to do that quickly with lxml - for k in tree.keys(): - tree.set(k, "") - - # TODO: Fix. This loses Element().tail - #if problemtree.tag in html_skip: - # return tree - return [tree] + return tree def preprocess_problem(self, tree, correct_map=dict(), answer_map=dict()): # private ''' @@ -370,7 +343,7 @@ class LoncapaProblem(object): Also create capa Response instances for each responsetype and save as self.responders ''' response_id = 1 - self.responders = [] + self.responders = {} for response in tree.xpath('//' + "|//".join(response_types)): response_id_str = self.problem_id + "_" + str(response_id) response.attrib['id'] = response_id_str # create and save ID for this response @@ -389,7 +362,7 @@ class LoncapaProblem(object): answer_id = answer_id + 1 responder = response_types[response.tag](response, inputfields, self.context, self.system) # instantiate capa Response - self.responders.append(responder) # save in list in self + self.responders[response] = responder # save in list in self # ... may not be associated with any specific response; give IDs for those separately # TODO: We should make the namespaces consistent and unique (e.g. %s_problem_%i). diff --git a/common/lib/capa/inputtypes.py b/common/lib/capa/inputtypes.py index 3b25be3db7..10fbdb7f98 100644 --- a/common/lib/capa/inputtypes.py +++ b/common/lib/capa/inputtypes.py @@ -33,26 +33,17 @@ def get_input_xml_tags(): class SimpleInput():# XModule ''' Type for simple inputs -- plain HTML with a form element + State is a dictionary with optional keys: * Value * ID * Status (answered, unanswered, unsubmitted) * Feedback (dictionary containing keys for hints, errors, or other feedback from previous attempt) + ''' xml_tags = {} ## Maps tags to functions - - @classmethod - def get_xml_tags(c): - return c.xml_tags.keys() - - @classmethod - def get_uses(c): - return ['capa_input', 'capa_transform'] - - def get_html(self): - return self.xml_tags[self.tag](self.xml, self.value, self.status, self.system.render_template, self.msg) def __init__(self, system, xml, item_id = None, track_url=None, state=None, use = 'capa_input'): self.xml = xml @@ -83,49 +74,16 @@ class SimpleInput():# XModule if 'status' in state: self.status = state['status'] -## TODO -# class SimpleTransform(): -# ''' Type for simple XML to HTML transforms. Examples: -# * Math tags, which go from LON-CAPA-style m-tags to MathJAX -# ''' -# xml_tags = {} ## Maps tags to functions - -# @classmethod -# def get_xml_tags(c): -# return c.xml_tags.keys() + @classmethod + def get_xml_tags(c): + return c.xml_tags.keys() -# @classmethod -# def get_uses(c): -# return ['capa_transform'] - -# def get_html(self): -# return self.xml_tags[self.tag](self.xml, self.value, self.status, self.msg) - -# def __init__(self, system, xml, item_id = None, track_url=None, state=None, use = 'capa_input'): -# self.xml = xml -# self.tag = xml.tag -# if not state: -# state = {} -# if item_id: -# self.id = item_id -# if xml.get('id'): -# self.id = xml.get('id') -# if 'id' in state: -# self.id = state['id'] -# self.system = system - -# self.value = '' -# if 'value' in state: -# self.value = state['value'] - -# self.msg = '' -# if 'feedback' in state and 'message' in state['feedback']: -# self.msg = state['feedback']['message'] - -# self.status = 'unanswered' -# if 'status' in state: -# self.status = state['status'] + @classmethod + def get_uses(c): + return ['capa_input', 'capa_transform'] + def get_html(self): + return self.xml_tags[self.tag](self.xml, self.value, self.status, self.system.render_template, self.msg) def register_render_function(fn, names=None, cls=SimpleInput): if names is None: @@ -136,9 +94,6 @@ def register_render_function(fn, names=None, cls=SimpleInput): return fn return wrapped - - - #----------------------------------------------------------------------------- @register_render_function @@ -201,16 +156,16 @@ def choicegroup(element, value, status, render_template, msg=''): return etree.XML(html) @register_render_function -def textline(element, value, state, render_template, msg=""): +def textline(element, value, status, render_template, msg=""): ''' Simple text line input, with optional size specification. ''' if element.get('math') or element.get('dojs'): # 'dojs' flag is temporary, for backwards compatibility with 8.02x - return SimpleInput.xml_tags['textline_dynamath'](element,value,state,render_template,msg) + return SimpleInput.xml_tags['textline_dynamath'](element,value,status,render_template,msg) eid=element.get('id') count = int(eid.split('_')[-2])-1 # HACK size = element.get('size') - context = {'id':eid, 'value':value, 'state':state, 'count':count, 'size': size, 'msg': msg} + context = {'id':eid, 'value':value, 'state':status, 'count':count, 'size': size, 'msg': msg} html = render_template("textinput.html", context) return etree.XML(html) diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index 1c09493b03..bfd42814f7 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -63,7 +63,8 @@ class GenericResponse(object): - get_max_score : if defined, this is called to obtain the maximum score possible for this question - setup_response : find and note the answer input field IDs for the response; called by __init__ - - __unicode__ : unicode representation of this Response + - render_html : render this Response as HTML (must return XHTML compliant string) + - __unicode__ : unicode representation of this Response Each response type may also specify the following attributes: @@ -114,9 +115,30 @@ class GenericResponse(object): if self.max_inputfields==1: self.answer_id = self.answer_ids[0] # for convenience + self.default_answer_map = {} # dict for default answer map (provided in input elements) + for entry in self.inputfields: + answer = entry.get('correct_answer') + if answer: + self.default_answer_map[entry.get('id')] = contextualize_text(answer, self.context) + if hasattr(self,'setup_response'): self.setup_response() + def render_html(self,renderer): + ''' + Return XHTML Element tree representation of this Response. + + Arguments: + + - renderer : procedure which produces HTML given an ElementTree + ''' + tree = etree.Element('span') # render ourself as a + our content + for item in self.xml: + item_xhtml = renderer(item) # call provided procedure to do the rendering + if item_xhtml is not None: tree.append(item_xhtml) + tree.tail = self.xml.tail + return tree + @abc.abstractmethod def get_score(self, student_answers): ''' @@ -132,7 +154,6 @@ class GenericResponse(object): ''' pass - #not an abstract method because plenty of responses will not want to preprocess anything, and we should not require that they override this method. def setup_response(self): pass @@ -485,17 +506,17 @@ def sympy_check2(): ''' Give correct answer expected for this response. - capa_problem handles correct_answers from entry objects like textline, and that - is what should be used when this response has multiple entry objects. + use default_answer_map from entry elements (eg textline), + when this response has multiple entry objects. but for simplicity, if an "expect" attribute was given by the content author - ie then return it now. + ie then that. ''' if len(self.answer_ids)>1: - return {} + return self.default_answer_map if self.expect: return {self.answer_ids[0] : self.expect} - return {} + return self.default_answer_map #----------------------------------------------------------------------------- @@ -797,9 +818,8 @@ class SchematicResponse(GenericResponse): return zip(sorted(self.answer_ids), self.context['correct']) def get_answers(self): - # Since this is explicitly specified in the problem, this will - # be handled by capa_problem - return {} + # use answers provided in input elements + return self.default_answer_map #----------------------------------------------------------------------------- From c724affe316654e031fc66f8f1ebccc6a7f2df90 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sat, 9 Jun 2012 23:29:08 -0400 Subject: [PATCH 12/80] third pass in capa cleanup: correct_map -> CorrectMap - added correctmap.py with CorrectMap class - messages subsumed into CorrectMap - response get_score called with old CorrectMap so hints based on history are possible --- common/lib/capa/capa_problem.py | 83 +++++++++++++++------------- common/lib/capa/correctmap.py | 80 +++++++++++++++++++++++++++ common/lib/capa/responsetypes.py | 92 +++++++++++++++++-------------- common/lib/xmodule/capa_module.py | 25 +++------ 4 files changed, 183 insertions(+), 97 deletions(-) create mode 100644 common/lib/capa/correctmap.py diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index c63c13d420..93d5620aae 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -25,15 +25,14 @@ import struct from lxml import etree from xml.sax.saxutils import unescape -from util import contextualize_text -import inputtypes - -from responsetypes import NumericalResponse, FormulaResponse, CustomResponse, SchematicResponse, MultipleChoiceResponse, TrueFalseResponse, ExternalResponse, ImageResponse, OptionResponse, SymbolicResponse - import calc +from correctmap import CorrectMap import eia +import inputtypes +from util import contextualize_text -log = logging.getLogger(__name__) +# to be replaced with auto-registering +from responsetypes import NumericalResponse, FormulaResponse, CustomResponse, SchematicResponse, MultipleChoiceResponse, TrueFalseResponse, ExternalResponse, ImageResponse, OptionResponse, SymbolicResponse # dict of tagname, Response Class -- this should come from auto-registering response_types = {'numericalresponse': NumericalResponse, @@ -68,6 +67,12 @@ global_context = {'random': random, # These should be removed from HTML output, including all subelements html_problem_semantics = ["responseparam", "answer", "script"] +#log = logging.getLogger(__name__) +log = logging.getLogger('mitx.common.lib.capa.capa_problem') + +#----------------------------------------------------------------------------- +# main class for this module + class LoncapaProblem(object): ''' Main class for capa Problems. @@ -89,9 +94,7 @@ class LoncapaProblem(object): ''' ## Initialize class variables from state - self.student_answers = dict() - self.correct_map = dict() - self.done = False + self.do_reset() self.problem_id = id self.system = system self.seed = seed @@ -102,7 +105,7 @@ class LoncapaProblem(object): if 'student_answers' in state: self.student_answers = state['student_answers'] if 'correct_map' in state: - self.correct_map = state['correct_map'] + self.correct_map.set_dict(state['correct_map']) if 'done' in state: self.done = state['done'] @@ -125,7 +128,15 @@ class LoncapaProblem(object): # pre-parse the XML tree: modifies it to add ID's and perform some in-place transformations # this also creates the dict (self.responders) of Response instances for each question in the problem. # the dict has keys = xml subtree of Response, values = Response instance - self.preprocess_problem(self.tree, correct_map=self.correct_map, answer_map=self.student_answers) + self.preprocess_problem(self.tree, answer_map=self.student_answers) + + def do_reset(self): + ''' + Reset internal state to unfinished, with no answers + ''' + self.student_answers = dict() + self.correct_map = CorrectMap() + self.done = False def __unicode__(self): return u"LoncapaProblem ({0})".format(self.fileobject) @@ -134,9 +145,10 @@ class LoncapaProblem(object): ''' Stored per-user session data neeeded to: 1) Recreate the problem 2) Populate any student answers. ''' + return {'seed': self.seed, 'student_answers': self.student_answers, - 'correct_map': self.correct_map, + 'correct_map': self.correct_map.get_dict(), 'done': self.done} def get_max_score(self): @@ -170,8 +182,12 @@ class LoncapaProblem(object): ''' correct = 0 for key in self.correct_map: - if self.correct_map[key] == u'correct': - correct += 1 + try: + correct += self.correct_map.get_npoints(key) + except Exception,err: + log.error('key=%s, correct_map = %s' % (key,self.correct_map)) + raise + if (not self.student_answers) or len(self.student_answers) == 0: return {'score': 0, 'total': self.get_max_score()} @@ -190,12 +206,14 @@ class LoncapaProblem(object): Calles the Response for each question in this problem, to do the actual grading. ''' self.student_answers = answers - self.correct_map = dict() - log.info('%s: in grade_answers, answers=%s' % (self,answers)) + oldcmap = self.correct_map # old CorrectMap + newcmap = CorrectMap() # start new with empty CorrectMap for responder in self.responders.values(): - results = responder.get_score(answers) # call the responsetype instance to do the actual grading - self.correct_map.update(results) - return self.correct_map + results = responder.get_score(answers,oldcmap) # call the responsetype instance to do the actual grading + newcmap.update(results) + self.correct_map = newcmap + log.debug('%s: in grade_answers, answers=%s, cmap=%s' % (self,answers,newcmap)) + return newcmap def get_question_answers(self): """Returns a dict of answer_ids to answer values. If we cannot generate @@ -282,27 +300,17 @@ class LoncapaProblem(object): # but it will turn into a dict containing both the answer and any associated message # for the problem ID for the input element. status = "unsubmitted" + msg = '' if problemid in self.correct_map: - status = self.correct_map[problemtree.get('id')] + pid = problemtree.get('id') + status = self.correct_map.get_correctness(pid) + msg = self.correct_map.get_msg(pid) value = "" if self.student_answers and problemid in self.student_answers: value = self.student_answers[problemid] - #### This code is a hack. It was merged to help bring two branches - #### in sync, but should be replaced. msg should be passed in a - #### response_type - # prepare the response message, if it exists in correct_map - if 'msg' in self.correct_map: - msg = self.correct_map['msg'] - elif ('msg_%s' % problemid) in self.correct_map: - msg = self.correct_map['msg_%s' % problemid] - else: - msg = '' - # do the rendering - # This should be broken out into a helper function - # that handles all input objects render_object = inputtypes.SimpleInput(system=self.system, xml=problemtree, state={'value': value, @@ -333,7 +341,7 @@ class LoncapaProblem(object): return tree - def preprocess_problem(self, tree, correct_map=dict(), answer_map=dict()): # private + def preprocess_problem(self, tree, answer_map=dict()): # private ''' Assign IDs to all the responses Assign sub-IDs to all entries (textline, schematic, etc.) @@ -346,11 +354,8 @@ class LoncapaProblem(object): self.responders = {} for response in tree.xpath('//' + "|//".join(response_types)): response_id_str = self.problem_id + "_" + str(response_id) - response.attrib['id'] = response_id_str # create and save ID for this response - - # if response_id not in correct_map: correct = 'unsubmitted' # unused - to be removed - # response.attrib['state'] = correct - response_id += response_id + response.set('id',response_id_str) # create and save ID for this response + response_id += 1 answer_id = 1 inputfields = tree.xpath("|".join(['//' + response.tag + '[@id=$id]//' + x for x in (entry_types + solution_types)]), diff --git a/common/lib/capa/correctmap.py b/common/lib/capa/correctmap.py new file mode 100644 index 0000000000..3eac98cc3a --- /dev/null +++ b/common/lib/capa/correctmap.py @@ -0,0 +1,80 @@ +#----------------------------------------------------------------------------- +# class used to store graded responses to CAPA questions +# +# Used by responsetypes and capa_problem + +class CorrectMap(object): + ''' + Stores (correctness, npoints, msg) for each answer_id. + Behaves as a dict. + ''' + cmap = {} + + def __init__(self,*args,**kwargs): + self.set(*args,**kwargs) + + def set(self,answer_id=None,correctness=None,npoints=None,msg=''): + if answer_id is not None: + self.cmap[answer_id] = {'correctness': correctness, + 'npoints': npoints, + 'msg': msg } + + def __repr__(self): + return repr(self.cmap) + + def get_dict(self): + ''' + return dict version of self + ''' + return self.cmap + + def set_dict(self,correct_map): + ''' + set internal dict to provided correct_map dict + for graceful migration, if correct_map is a one-level dict, then convert it to the new + dict of dicts format. + ''' + if correct_map and not (type(correct_map[correct_map.keys()[0]])==dict): + for k in self.cmap.keys(): self.cmap.pop(k) # empty current dict + for k in correct_map: self.set(k,correct_map[k]) # create new dict entries + else: + self.cmap = correct_map + + def is_correct(self,answer_id): + if answer_id in self.cmap: return self.cmap[answer_id]['correctness'] == 'correct' + return None + + def get_npoints(self,answer_id): + if self.is_correct(answer_id): + npoints = self.cmap[answer_id].get('npoints',1) # default to 1 point if correct + return npoints or 1 + return 0 # if not correct, return 0 + + def set_property(self,answer_id,property,value): + if answer_id in self.cmap: self.cmap[answer_id][property] = value + else: self.cmap[answer_id] = {property:value} + + def get_property(self,answer_id,property,default=None): + if answer_id in self.cmap: return self.cmap[answer_id].get(property,default) + return default + + def get_correctness(self,answer_id): + return self.get_property(answer_id,'correctness') + + def get_msg(self,answer_id): + return self.get_property(answer_id,'msg','') + + def update(self,other_cmap): + ''' + Update this CorrectMap with the contents of another CorrectMap + ''' + if not isinstance(other_cmap,CorrectMap): + raise Exception('CorrectMap.update called with invalid argument %s' % other_cmap) + self.cmap.update(other_cmap.get_dict()) + + __getitem__ = cmap.__getitem__ + __iter__ = cmap.__iter__ + items = cmap.items + keys = cmap.keys + + diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index bfd42814f7..2de9e27893 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -21,6 +21,7 @@ import abc # specific library imports from calc import evaluator, UndefinedVariable +from correctmap import CorrectMap from util import * from lxml import etree from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful Soup!!! FIXME? @@ -53,7 +54,7 @@ class StudentInputError(Exception): class GenericResponse(object): ''' Base class for CAPA responsetypes. Each response type (ie a capa question, - which is part of a capa problem) is represented as a superclass, + which is part of a capa problem) is represented as a subclass, which should provide the following methods: - get_score : evaluate the given student answers, and return a CorrectMap @@ -140,10 +141,16 @@ class GenericResponse(object): return tree @abc.abstractmethod - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): ''' Return a CorrectMap for the answers expected vs given. This includes (correctness, npoints, msg) for each answer_id. + + Arguments: + + - student_answers : dict of (answer_id,answer) where answer = student input (string) + - old_cmap : previous CorrectMap (may be empty); useful for analyzing or recording history of responses + ''' pass @@ -201,15 +208,15 @@ class MultipleChoiceResponse(GenericResponse): else: choice.set("name", "choice_"+choice.get("name")) - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): ''' grade student response. ''' # log.debug('%s: student_answers=%s, correct_choices=%s' % (unicode(self),student_answers,self.correct_choices)) if self.answer_id in student_answers and student_answers[self.answer_id] in self.correct_choices: - return {self.answer_id:'correct'} + return CorrectMap(self.answer_id,'correct') else: - return {self.answer_id:'incorrect'} + return CorrectMap(self.answer_id,'incorrect') def get_answers(self): return {self.answer_id:self.correct_choices} @@ -226,14 +233,14 @@ class TrueFalseResponse(MultipleChoiceResponse): else: choice.set("name", "choice_"+choice.get("name")) - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): correct = set(self.correct_choices) answers = set(student_answers.get(self.answer_id, [])) if correct == answers: - return { self.answer_id : 'correct'} + return CorrectMap( self.answer_id , 'correct') - return {self.answer_id : 'incorrect'} + return CorrectMap(self.answer_id ,'incorrect') #----------------------------------------------------------------------------- @@ -251,15 +258,15 @@ class OptionResponse(GenericResponse): def setup_response(self): self.answer_fields = self.inputfields - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): # log.debug('%s: student_answers=%s' % (unicode(self),student_answers)) - cmap = {} + cmap = CorrectMap() amap = self.get_answers() for aid in amap: if aid in student_answers and student_answers[aid]==amap[aid]: - cmap[aid] = 'correct' + cmap.set(aid,'correct') else: - cmap[aid] = 'incorrect' + cmap.set(aid,'incorrect') return cmap def get_answers(self): @@ -291,7 +298,7 @@ class NumericalResponse(GenericResponse): except Exception: self.answer_id = None - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): '''Grade a numeric response ''' student_answer = student_answers[self.answer_id] try: @@ -303,9 +310,9 @@ class NumericalResponse(GenericResponse): raise StudentInputError('Invalid input -- please use a number only') if correct: - return {self.answer_id:'correct'} + return CorrectMap(self.answer_id,'correct') else: - return {self.answer_id:'incorrect'} + return CorrectMap(self.answer_id,'incorrect') def get_answers(self): return {self.answer_id:self.correct_answer} @@ -395,7 +402,7 @@ def sympy_check2(): else: self.code = answer.text - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): ''' student_answers is a dict with everything from request.POST, but with the first part of each key removed (the string before the first "_"). @@ -495,12 +502,10 @@ def sympy_check2(): correct = ['correct']*len(idset) if ret else ['incorrect']*len(idset) # build map giving "correct"ness of the answer(s) - #correct_map = dict(zip(idset, self.context['correct'])) - correct_map = {} + correct_map = CorrectMap() for k in range(len(idset)): - correct_map[idset[k]] = correct[k] - correct_map['msg_%s' % idset[k]] = messages[k] - return correct_map + correct_map.set(idset[k], correct[k], msg=messages[k]) + return correct_map def get_answers(self): ''' @@ -642,9 +647,11 @@ main() return rxml - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): + idset = sorted(self.answer_ids) + cmap = CorrectMap() try: - submission = [student_answers[k] for k in sorted(self.answer_ids)] + submission = [student_answers[k] for k in idset] except Exception,err: log.error('Error %s: cannot get student answer for %s; student_answers=%s' % (err,self.answer_ids,student_answers)) raise Exception,err @@ -658,9 +665,9 @@ main() except Exception, err: log.error('Error %s' % err) if self.system.DEBUG: - correct_map = dict(zip(sorted(self.answer_ids), ['incorrect'] * len(self.answer_ids) )) - correct_map['msg_%s' % self.answer_ids[0]] = '%s' % str(err).replace('<','<') - return correct_map + cmap.set_dict(dict(zip(sorted(self.answer_ids), ['incorrect'] * len(idset) ))) + cmap.set_property(self.answer_ids[0],'msg','%s' % str(err).replace('<','<')) + return cmap ad = rxml.find('awarddetail').text admap = {'EXACT_ANS':'correct', # TODO: handle other loncapa responses @@ -670,13 +677,13 @@ main() if ad in admap: self.context['correct'][0] = admap[ad] - # self.context['correct'] = ['correct','correct'] - correct_map = dict(zip(sorted(self.answer_ids), self.context['correct'])) - - # store message in correct_map - correct_map['msg_%s' % self.answer_ids[0]] = rxml.find('message').text.replace(' ',' ') + # create CorrectMap + for key in idset: + idx = idset.index(key) + msg = rxml.find('message').text.replace(' ',' ') if idx==0 else None + cmap.set(key, self.context['correct'][idx], msg=msg) - return correct_map + return cmap def get_answers(self): ''' @@ -750,7 +757,7 @@ class FormulaResponse(GenericResponse): else: # Default self.case_sensitive = False - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): variables=self.samples.split('@')[0].split(',') numsamples=int(self.samples.split('@')[1].split('#')[1]) sranges=zip(*map(lambda x:map(float, x.split(",")), @@ -776,11 +783,11 @@ class FormulaResponse(GenericResponse): #traceback.print_exc() raise StudentInputError("Error in formula") if numpy.isnan(student_result) or numpy.isinf(student_result): - return {self.answer_id:"incorrect"} + return CorrectMap(self.answer_id, "incorrect") if not compare_with_tolerance(student_result, instructor_result, self.tolerance): - return {self.answer_id:"incorrect"} + return CorrectMap(self.answer_id, "incorrect") - return {self.answer_id:"correct"} + return CorrectMap(self.answer_id, "correct") def strip_dict(self, d): ''' Takes a dict. Returns an identical dict, with all non-word @@ -810,12 +817,13 @@ class SchematicResponse(GenericResponse): else: self.code = answer.text - def get_score(self, student_answers): + def get_score(self, student_answers, old_cmap): from capa_problem import global_context submission = [json.loads(student_answers[k]) for k in sorted(self.answer_ids)] self.context.update({'submission':submission}) exec self.code in global_context, self.context - return zip(sorted(self.answer_ids), self.context['correct']) + cmap = CorrectMap() + return cmap.set_dict(zip(sorted(self.answer_ids), self.context['correct'])) def get_answers(self): # use answers provided in input elements @@ -845,8 +853,8 @@ class ImageResponse(GenericResponse): self.ielements = self.inputfields self.answer_ids = [ie.get('id') for ie in self.ielements] - def get_score(self, student_answers): - correct_map = {} + def get_score(self, student_answers, old_cmap): + correct_map = CorrectMap() expectedset = self.get_answers() for aid in self.answer_ids: # loop through IDs of fields in our stanza @@ -869,9 +877,9 @@ class ImageResponse(GenericResponse): # answer is correct if (x,y) is within the specified rectangle if (llx <= gx <= urx) and (lly <= gy <= ury): - correct_map[aid] = 'correct' + correct_map.set(aid, 'correct') else: - correct_map[aid] = 'incorrect' + correct_map.set(aid, 'incorrect') return correct_map def get_answers(self): diff --git a/common/lib/xmodule/capa_module.py b/common/lib/xmodule/capa_module.py index 6bd7cbebdc..439982a2c1 100644 --- a/common/lib/xmodule/capa_module.py +++ b/common/lib/xmodule/capa_module.py @@ -13,6 +13,7 @@ from lxml import etree from x_module import XModule, XModuleDescriptor from capa.capa_problem import LoncapaProblem from capa.responsetypes import StudentInputError + log = logging.getLogger("mitx.courseware") #----------------------------------------------------------------------------- @@ -365,18 +366,17 @@ class Module(XModule): self.attempts = self.attempts + 1 self.lcp.done=True - success = 'correct' - for i in correct_map: - if correct_map[i]!='correct': + success = 'correct' # success = correct if ALL questions in this problem are correct + for answer_id in correct_map: + if not correct_map.is_correct(answer_id): success = 'incorrect' - event_info['correct_map']=correct_map + event_info['correct_map']=correct_map.get_dict() # log this in the tracker event_info['success']=success - self.tracker('save_problem_check', event_info) try: - html = self.get_problem_html(encapsulate=False) + html = self.get_problem_html(encapsulate=False) # render problem into HTML except Exception,err: log.error('failed to generate html') raise Exception,err @@ -430,17 +430,10 @@ class Module(XModule): self.tracker('reset_problem_fail', event_info) return "Refresh the page and make an attempt before resetting." - self.lcp.done=False - self.lcp.answers=dict() - self.lcp.correct_map=dict() - self.lcp.student_answers = dict() - - + self.lcp.do_reset() # call method in LoncapaProblem to reset itself if self.rerandomize == "always": - self.lcp.context=dict() - self.lcp.questions=dict() # Detailed info about questions in problem instance. TODO: Should be by id and not lid. - self.lcp.seed=None - + self.lcp.seed=None # reset random number generator seed (note the self.lcp.get_state() in next line) + self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, self.lcp.get_state(), system=self.system) event_info['new_state']=self.lcp.get_state() From 5ac13e03aa2bcfb6b798b2730f0e9b7d7c27ad8d Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 17:17:57 -0400 Subject: [PATCH 13/80] fourth pass in capa cleanup: - Added hints + hintmethod - hintgroup compatible with loncapa spec - also does hintfn for custom hints (can do answer history) - GenericResponse -> LoncapaResponse - moved response type tags into responsetype classes - capa_problem should use __future__ division - hints stored in CorrectMap, copied to 'feedback' in SimpleInput for display --- common/lib/capa/capa_problem.py | 40 +++--- common/lib/capa/correctmap.py | 32 ++++- common/lib/capa/inputtypes.py | 55 +++++--- common/lib/capa/responsetypes.py | 226 +++++++++++++++++++++++++------ common/lib/capa/util.py | 5 + 5 files changed, 272 insertions(+), 86 deletions(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index 93d5620aae..b14001ef03 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -12,6 +12,8 @@ Main module which shows problems (of "capa" type). This is used by capa_module. ''' +from __future__ import division + import copy import logging import math @@ -32,20 +34,10 @@ import inputtypes from util import contextualize_text # to be replaced with auto-registering -from responsetypes import NumericalResponse, FormulaResponse, CustomResponse, SchematicResponse, MultipleChoiceResponse, TrueFalseResponse, ExternalResponse, ImageResponse, OptionResponse, SymbolicResponse +import responsetypes # dict of tagname, Response Class -- this should come from auto-registering -response_types = {'numericalresponse': NumericalResponse, - 'formularesponse': FormulaResponse, - 'customresponse': CustomResponse, - 'schematicresponse': SchematicResponse, - 'externalresponse': ExternalResponse, - 'multiplechoiceresponse': MultipleChoiceResponse, - 'truefalseresponse': TrueFalseResponse, - 'imageresponse': ImageResponse, - 'optionresponse': OptionResponse, - 'symbolicresponse': SymbolicResponse, - } +response_tag_dict = dict([(x.response_tag,x) for x in responsetypes.__all__]) entry_types = ['textline', 'schematic', 'choicegroup', 'textbox', 'imageinput', 'optioninput'] solution_types = ['solution'] # extra things displayed after "show answers" is pressed @@ -65,7 +57,7 @@ global_context = {'random': random, 'eia': eia} # These should be removed from HTML output, including all subelements -html_problem_semantics = ["responseparam", "answer", "script"] +html_problem_semantics = ["responseparam", "answer", "script","hintgroup"] #log = logging.getLogger(__name__) log = logging.getLogger('mitx.common.lib.capa.capa_problem') @@ -209,7 +201,7 @@ class LoncapaProblem(object): oldcmap = self.correct_map # old CorrectMap newcmap = CorrectMap() # start new with empty CorrectMap for responder in self.responders.values(): - results = responder.get_score(answers,oldcmap) # call the responsetype instance to do the actual grading + results = responder.evaluate_answers(answers,oldcmap) # call the responsetype instance to do the actual grading newcmap.update(results) self.correct_map = newcmap log.debug('%s: in grade_answers, answers=%s, cmap=%s' % (self,answers,newcmap)) @@ -248,7 +240,8 @@ class LoncapaProblem(object): ''' return contextualize_text(etree.tostring(self.extract_html(self.tree)), self.context) - # ======= Private ======== + # ======= Private Methods Below ======== + def extract_context(self, tree, seed=struct.unpack('i', os.urandom(4))[0]): # private ''' Extract content of from the problem.xml file, and exec it in the @@ -296,15 +289,17 @@ class LoncapaProblem(object): problemid = problemtree.get('id') # my ID if problemtree.tag in inputtypes.get_input_xml_tags(): - # status is currently the answer for the problem ID for the input element, - # but it will turn into a dict containing both the answer and any associated message - # for the problem ID for the input element. + status = "unsubmitted" msg = '' + hint = '' + hintmode = None if problemid in self.correct_map: pid = problemtree.get('id') status = self.correct_map.get_correctness(pid) msg = self.correct_map.get_msg(pid) + hint = self.correct_map.get_hint(pid) + hintmode = self.correct_map.get_hintmode(pid) value = "" if self.student_answers and problemid in self.student_answers: @@ -316,7 +311,10 @@ class LoncapaProblem(object): state={'value': value, 'status': status, 'id': problemtree.get('id'), - 'feedback': {'message': msg} + 'feedback': {'message': msg, + 'hint' : hint, + 'hintmode' : hintmode, + } }, use='capa_input') return render_object.get_html() # function(problemtree, value, status, msg) # render the special response (textline, schematic,...) @@ -352,7 +350,7 @@ class LoncapaProblem(object): ''' response_id = 1 self.responders = {} - for response in tree.xpath('//' + "|//".join(response_types)): + for response in tree.xpath('//' + "|//".join(response_tag_dict)): response_id_str = self.problem_id + "_" + str(response_id) response.set('id',response_id_str) # create and save ID for this response response_id += 1 @@ -366,7 +364,7 @@ class LoncapaProblem(object): entry.attrib['id'] = "%s_%i_%i" % (self.problem_id, response_id, answer_id) answer_id = answer_id + 1 - responder = response_types[response.tag](response, inputfields, self.context, self.system) # instantiate capa Response + responder = response_tag_dict[response.tag](response, inputfields, self.context, self.system) # instantiate capa Response self.responders[response] = responder # save in list in self # ... may not be associated with any specific response; give IDs for those separately diff --git a/common/lib/capa/correctmap.py b/common/lib/capa/correctmap.py index 3eac98cc3a..f694391cc6 100644 --- a/common/lib/capa/correctmap.py +++ b/common/lib/capa/correctmap.py @@ -5,7 +5,16 @@ class CorrectMap(object): ''' - Stores (correctness, npoints, msg) for each answer_id. + Stores map between answer_id and response evaluation result for each question + in a capa problem. The response evaluation result for each answer_id includes + (correctness, npoints, msg, hint, hintmode). + + - correctness : either 'correct' or 'incorrect' + - npoints : None, or integer specifying number of points awarded for this answer_id + - msg : string (may have HTML) giving extra message response (displayed below textline or textbox) + - hint : string (may have HTML) giving optional hint (displayed below textline or textbox, above msg) + - hintmode : one of (None,'on_request','always') criteria for displaying hint + Behaves as a dict. ''' cmap = {} @@ -13,11 +22,14 @@ class CorrectMap(object): def __init__(self,*args,**kwargs): self.set(*args,**kwargs) - def set(self,answer_id=None,correctness=None,npoints=None,msg=''): + def set(self, answer_id=None, correctness=None, npoints=None, msg='', hint='', hintmode=None): if answer_id is not None: self.cmap[answer_id] = {'correctness': correctness, 'npoints': npoints, - 'msg': msg } + 'msg': msg, + 'hint' : hint, + 'hintmode' : hintmode, + } def __repr__(self): return repr(self.cmap) @@ -64,6 +76,20 @@ class CorrectMap(object): def get_msg(self,answer_id): return self.get_property(answer_id,'msg','') + def get_hint(self,answer_id): + return self.get_property(answer_id,'hint','') + + def get_hintmode(self,answer_id): + return self.get_property(answer_id,'hintmode',None) + + def set_hint_and_mode(self,answer_id,hint,hintmode): + ''' + - hint : (string) HTML text for hint + - hintmode : (string) mode for hint display ('always' or 'on_request') + ''' + self.set_property(answer_id,'hint',hint) + self.set_property(answer_id,'hintmode',hintmode) + def update(self,other_cmap): ''' Update this CorrectMap with the contents of another CorrectMap diff --git a/common/lib/capa/inputtypes.py b/common/lib/capa/inputtypes.py index 10fbdb7f98..1fa51f2f84 100644 --- a/common/lib/capa/inputtypes.py +++ b/common/lib/capa/inputtypes.py @@ -32,44 +32,57 @@ def get_input_xml_tags(): return SimpleInput.get_xml_tags() class SimpleInput():# XModule - ''' Type for simple inputs -- plain HTML with a form element - - State is a dictionary with optional keys: - * Value - * ID - * Status (answered, unanswered, unsubmitted) - * Feedback (dictionary containing keys for hints, errors, or other - feedback from previous attempt) - + ''' + Type for simple inputs -- plain HTML with a form element ''' xml_tags = {} ## Maps tags to functions def __init__(self, system, xml, item_id = None, track_url=None, state=None, use = 'capa_input'): + ''' + Instantiate a SimpleInput class. Arguments: + + - system : I4xSystem instance which provides OS, rendering, and user context + - xml : Element tree of this Input element + - item_id : id for this input element (assigned by capa_problem.LoncapProblem) - string + - track_url : URL used for tracking - string + - state : a dictionary with optional keys: + * Value + * ID + * Status (answered, unanswered, unsubmitted) + * Feedback (dictionary containing keys for hints, errors, or other + feedback from previous attempt) + - use : + ''' + self.xml = xml self.tag = xml.tag - if not state: - state = {} + self.system = system + if not state: state = {} + ## ID should only come from one place. ## If it comes from multiple, we use state first, XML second, and parameter ## third. Since we don't make this guarantee, we can swap this around in ## the future if there's a more logical order. - if item_id: - self.id = item_id - if xml.get('id'): - self.id = xml.get('id') - if 'id' in state: - self.id = state['id'] - self.system = system + if item_id: self.id = item_id + if xml.get('id'): self.id = xml.get('id') + if 'id' in state: self.id = state['id'] self.value = '' if 'value' in state: self.value = state['value'] self.msg = '' - if 'feedback' in state and 'message' in state['feedback']: - self.msg = state['feedback']['message'] - + feedback = state.get('feedback') + if feedback is not None: + self.msg = feedback.get('message','') + self.hint = feedback.get('hint','') + self.hintmode = feedback.get('hintmode',None) + + # put hint above msg if to be displayed + if self.hintmode == 'always': + self.msg = self.hint + ('
' if self.msg else '') + self.msg + self.status = 'unanswered' if 'status' in state: self.status = state['status'] diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index 2de9e27893..5a5296d805 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -51,7 +51,7 @@ class StudentInputError(Exception): # # Main base class for CAPA responsetypes -class GenericResponse(object): +class LoncapaResponse(object): ''' Base class for CAPA responsetypes. Each response type (ie a capa question, which is part of a capa problem) is represented as a subclass, @@ -60,22 +60,31 @@ class GenericResponse(object): - get_score : evaluate the given student answers, and return a CorrectMap - get_answers : provide a dict of the expected answers for this problem + Each subclass must also define the following attributes: + + - response_tag : xhtml tag identifying this response (used in auto-registering) + In addition, these methods are optional: - - get_max_score : if defined, this is called to obtain the maximum score possible for this question - - setup_response : find and note the answer input field IDs for the response; called by __init__ - - render_html : render this Response as HTML (must return XHTML compliant string) - - __unicode__ : unicode representation of this Response + - get_max_score : if defined, this is called to obtain the maximum score possible for this question + - setup_response : find and note the answer input field IDs for the response; called by __init__ + - check_hint_condition : check to see if the student's answers satisfy a particular condition for a hint to be displayed + - render_html : render this Response as HTML (must return XHTML compliant string) + - __unicode__ : unicode representation of this Response Each response type may also specify the following attributes: - - max_inputfields : (int) maximum number of answer input fields (checked in __init__ if not None) - - allowed_inputfields : list of allowed input fields (each a string) for this Response - - required_attributes : list of required attributes (each a string) on the main response XML stanza + - max_inputfields : (int) maximum number of answer input fields (checked in __init__ if not None) + - allowed_inputfields : list of allowed input fields (each a string) for this Response + - required_attributes : list of required attributes (each a string) on the main response XML stanza + - hint_tag : xhtml tag identifying hint associated with this response inside hintgroup ''' __metaclass__=abc.ABCMeta # abc = Abstract Base Class + response_tag = None + hint_tag = None + max_inputfields = None allowed_inputfields = [] required_attributes = [] @@ -85,7 +94,7 @@ class GenericResponse(object): Init is passed the following arguments: - xml : ElementTree of this Response - - inputfields : list of ElementTrees for each input entry field in this Response + - inputfields : ordered list of ElementTrees for each input entry field in this Response - context : script processor context - system : I4xSystem instance which provides OS, rendering, and user context @@ -112,7 +121,7 @@ class GenericResponse(object): msg += "\nSee XML source line %s" % getattr(xml,'sourceline','') raise LoncapaProblemError(msg) - self.answer_ids = [x.get('id') for x in self.inputfields] + self.answer_ids = [x.get('id') for x in self.inputfields] # ordered list of answer_id values for this response if self.max_inputfields==1: self.answer_id = self.answer_ids[0] # for convenience @@ -140,8 +149,85 @@ class GenericResponse(object): tree.tail = self.xml.tail return tree + def evaluate_answers(self,student_answers,old_cmap): + ''' + Called by capa_problem.LoncapaProblem to evaluate student answers, and to + generate hints (if any). + + Returns the new CorrectMap, with (correctness,msg,hint,hintmode) for each answer_id. + ''' + new_cmap = self.get_score(student_answers) + self.get_hints(student_answers, new_cmap, old_cmap) + return new_cmap + + def get_hints(self, student_answers, new_cmap, old_cmap): + ''' + Generate adaptive hints for this problem based on student answers, the old CorrectMap, + and the new CorrectMap produced by get_score. + + Does not return anything. + + Modifies new_cmap, by adding hints to answer_id entries as appropriate. + ''' + hintgroup = self.xml.find('hintgroup') + if hintgroup is None: return + + # hint specified by function? + hintfn = hintgroup.get('hintfn') + if hintfn: + ''' + Hint is determined by a function defined in the @@ -358,6 +463,7 @@ def sympy_check2():
'''}] + response_tag = 'customresponse' allowed_inputfields = ['textline','textbox'] def setup_response(self): @@ -402,7 +508,7 @@ def sympy_check2(): else: self.code = answer.text - def get_score(self, student_answers, old_cmap): + def get_score(self, student_answers): ''' student_answers is a dict with everything from request.POST, but with the first part of each key removed (the string before the first "_"). @@ -540,6 +646,8 @@ class SymbolicResponse(CustomResponse): '''}] + response_tag = 'symbolicresponse' + def setup_response(self): self.xml.set('cfn','symmath_check') code = "from symmath import *" @@ -548,7 +656,7 @@ class SymbolicResponse(CustomResponse): #----------------------------------------------------------------------------- -class ExternalResponse(GenericResponse): +class ExternalResponse(LoncapaResponse): ''' Grade the students input using an external server. @@ -594,6 +702,7 @@ main() '''}] + response_tag = 'externalresponse' allowed_inputfields = ['textline','textbox'] def setup_response(self): @@ -647,7 +756,7 @@ main() return rxml - def get_score(self, student_answers, old_cmap): + def get_score(self, student_answers): idset = sorted(self.answer_ids) cmap = CorrectMap() try: @@ -707,7 +816,7 @@ main() #----------------------------------------------------------------------------- -class FormulaResponse(GenericResponse): +class FormulaResponse(LoncapaResponse): ''' Checking of symbolic math response using numerical sampling. ''' @@ -729,6 +838,8 @@ class FormulaResponse(GenericResponse): '''}] + response_tag = 'formularesponse' + hint_tag = 'formulahint' allowed_inputfields = ['textline'] required_attributes = ['answer'] max_inputfields = 1 @@ -743,7 +854,7 @@ class FormulaResponse(GenericResponse): id=xml.get('id'))[0] self.tolerance = contextualize_text(self.tolerance_xml, context) except Exception: - self.tolerance = 0 + self.tolerance = '0.00001' ts = xml.get('type') if ts is None: @@ -757,11 +868,16 @@ class FormulaResponse(GenericResponse): else: # Default self.case_sensitive = False - def get_score(self, student_answers, old_cmap): - variables=self.samples.split('@')[0].split(',') - numsamples=int(self.samples.split('@')[1].split('#')[1]) + def get_score(self, student_answers): + given = student_answers[self.answer_id] + correctness = self.check_formula(self.correct_answer, given, self.samples) + return CorrectMap(self.answer_id, correctness) + + def check_formula(self,expected, given, samples): + variables=samples.split('@')[0].split(',') + numsamples=int(samples.split('@')[1].split('#')[1]) sranges=zip(*map(lambda x:map(float, x.split(",")), - self.samples.split('@')[1].split('#')[0].split(':'))) + samples.split('@')[1].split('#')[0].split(':'))) ranges=dict(zip(variables, sranges)) for i in range(numsamples): @@ -771,23 +887,26 @@ class FormulaResponse(GenericResponse): value = random.uniform(*ranges[var]) instructor_variables[str(var)] = value student_variables[str(var)] = value - instructor_result = evaluator(instructor_variables,dict(),self.correct_answer, cs = self.case_sensitive) + #log.debug('formula: instructor_vars=%s, expected=%s' % (instructor_variables,expected)) + instructor_result = evaluator(instructor_variables,dict(),expected, cs = self.case_sensitive) try: - #print student_variables,dict(),student_answers[self.answer_id] - student_result = evaluator(student_variables,dict(), - student_answers[self.answer_id], + #log.debug('formula: student_vars=%s, given=%s' % (student_variables,given)) + student_result = evaluator(student_variables, + dict(), + given, cs = self.case_sensitive) except UndefinedVariable as uv: + log.debbug('formularesponse: undefined variable in given=%s' % given) raise StudentInputError(uv.message+" not permitted in answer") - except: + except Exception, err: #traceback.print_exc() + log.debug('formularesponse: error %s in formula' % err) raise StudentInputError("Error in formula") if numpy.isnan(student_result) or numpy.isinf(student_result): - return CorrectMap(self.answer_id, "incorrect") + return "incorrect" if not compare_with_tolerance(student_result, instructor_result, self.tolerance): - return CorrectMap(self.answer_id, "incorrect") - - return CorrectMap(self.answer_id, "correct") + return "incorrect" + return "correct" def strip_dict(self, d): ''' Takes a dict. Returns an identical dict, with all non-word @@ -799,13 +918,30 @@ class FormulaResponse(GenericResponse): isinstance(d[k], numbers.Number)]) return d + def check_hint_condition(self,hxml_set,student_answers): + given = student_answers[self.answer_id] + hints_to_show = [] + for hxml in hxml_set: + samples = hxml.get('samples') + name = hxml.get('name') + correct_answer = contextualize_text(hxml.get('answer'),self.context) + try: + correctness = self.check_formula(correct_answer, given, samples) + except Exception,err: + correctness = 'incorrect' + if correctness=='correct': + hints_to_show.append(name) + log.debug('hints_to_show = %s' % hints_to_show) + return hints_to_show + def get_answers(self): return {self.answer_id:self.correct_answer} #----------------------------------------------------------------------------- -class SchematicResponse(GenericResponse): +class SchematicResponse(LoncapaResponse): + response_tag = 'schematicresponse' allowed_inputfields = ['schematic'] def setup_response(self): @@ -817,7 +953,7 @@ class SchematicResponse(GenericResponse): else: self.code = answer.text - def get_score(self, student_answers, old_cmap): + def get_score(self, student_answers): from capa_problem import global_context submission = [json.loads(student_answers[k]) for k in sorted(self.answer_ids)] self.context.update({'submission':submission}) @@ -831,7 +967,7 @@ class SchematicResponse(GenericResponse): #----------------------------------------------------------------------------- -class ImageResponse(GenericResponse): +class ImageResponse(LoncapaResponse): """ Handle student response for image input: the input is a click on an image, which produces an [x,y] coordinate pair. The click is correct if it falls @@ -847,13 +983,14 @@ class ImageResponse(GenericResponse): '''}] + response_tag = 'imageresponse' allowed_inputfields = ['imageinput'] def setup_response(self): self.ielements = self.inputfields self.answer_ids = [ie.get('id') for ie in self.ielements] - def get_score(self, student_answers, old_cmap): + def get_score(self, student_answers): correct_map = CorrectMap() expectedset = self.get_answers() @@ -884,3 +1021,10 @@ class ImageResponse(GenericResponse): def get_answers(self): return dict([(ie.get('id'),ie.get('rectangle')) for ie in self.ielements]) + +#----------------------------------------------------------------------------- +# TEMPORARY: List of all response subclasses +# FIXME: To be replaced by auto-registration + +__all__ = [ NumericalResponse, FormulaResponse, CustomResponse, SchematicResponse, MultipleChoiceResponse, TrueFalseResponse, ExternalResponse, ImageResponse, OptionResponse, SymbolicResponse ] + diff --git a/common/lib/capa/util.py b/common/lib/capa/util.py index 996f6c8dac..f1cc8f859e 100644 --- a/common/lib/capa/util.py +++ b/common/lib/capa/util.py @@ -7,6 +7,11 @@ from calc import evaluator, UndefinedVariable def compare_with_tolerance(v1, v2, tol): ''' Compare v1 to v2 with maximum tolerance tol tol is relative if it ends in %; otherwise, it is absolute + + - v1 : student result (number) + - v2 : instructor result (number) + - tol : tolerance (string or number) + ''' relative = "%" in tol if relative: From 5eda2f3a63bd6fe5edbb2772af94ecd435ed6cbb Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 18:41:54 -0400 Subject: [PATCH 14/80] bugfixes - correctmap should reinit self.cmap on init --- common/lib/capa/capa_problem.py | 1 + common/lib/capa/correctmap.py | 16 +++++++++------- common/lib/capa/responsetypes.py | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index b14001ef03..a341f954bc 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -200,6 +200,7 @@ class LoncapaProblem(object): self.student_answers = answers oldcmap = self.correct_map # old CorrectMap newcmap = CorrectMap() # start new with empty CorrectMap + log.debug('Responders: %s' % self.responders) for responder in self.responders.values(): results = responder.evaluate_answers(answers,oldcmap) # call the responsetype instance to do the actual grading newcmap.update(results) diff --git a/common/lib/capa/correctmap.py b/common/lib/capa/correctmap.py index f694391cc6..ec3fed54c2 100644 --- a/common/lib/capa/correctmap.py +++ b/common/lib/capa/correctmap.py @@ -17,11 +17,17 @@ class CorrectMap(object): Behaves as a dict. ''' - cmap = {} - def __init__(self,*args,**kwargs): + self.cmap = dict() # start with empty dict + self.__getitem__ = self.cmap.__getitem__ + self.__iter__ = self.cmap.__iter__ + self.items = self.cmap.items + self.keys = self.cmap.keys self.set(*args,**kwargs) + def __iter__(self): + return self.cmap.__iter__() + def set(self, answer_id=None, correctness=None, npoints=None, msg='', hint='', hintmode=None): if answer_id is not None: self.cmap[answer_id] = {'correctness': correctness, @@ -47,7 +53,7 @@ class CorrectMap(object): dict of dicts format. ''' if correct_map and not (type(correct_map[correct_map.keys()[0]])==dict): - for k in self.cmap.keys(): self.cmap.pop(k) # empty current dict + self.__init__() # empty current dict for k in correct_map: self.set(k,correct_map[k]) # create new dict entries else: self.cmap = correct_map @@ -98,9 +104,5 @@ class CorrectMap(object): raise Exception('CorrectMap.update called with invalid argument %s' % other_cmap) self.cmap.update(other_cmap.get_dict()) - __getitem__ = cmap.__getitem__ - __iter__ = cmap.__iter__ - items = cmap.items - keys = cmap.keys diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index 5a5296d805..a63cb991cf 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -158,6 +158,7 @@ class LoncapaResponse(object): ''' new_cmap = self.get_score(student_answers) self.get_hints(student_answers, new_cmap, old_cmap) + # log.debug('new_cmap = %s' % new_cmap) return new_cmap def get_hints(self, student_answers, new_cmap, old_cmap): @@ -492,7 +493,7 @@ def sympy_check2(): if cfn in self.context: self.code = self.context[cfn] else: - msg = "%s: can't find cfn in context = %s" % (unicode(self),self.context) + msg = "%s: can't find cfn %s in context" % (unicode(self),cfn) msg += "\nSee XML source line %s" % getattr(self.xml,'sourceline','') raise LoncapaProblemError(msg) @@ -896,7 +897,7 @@ class FormulaResponse(LoncapaResponse): given, cs = self.case_sensitive) except UndefinedVariable as uv: - log.debbug('formularesponse: undefined variable in given=%s' % given) + log.debug('formularesponse: undefined variable in given=%s' % given) raise StudentInputError(uv.message+" not permitted in answer") except Exception, err: #traceback.print_exc() From 58e359e7ec80e0e8e4609070ddc2393725a1d5d3 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 20:04:30 -0400 Subject: [PATCH 15/80] problem.coffee change: show answer -> also show solution_* & do mathjax typeset --- lms/static/coffee/src/modules/problem.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lms/static/coffee/src/modules/problem.coffee b/lms/static/coffee/src/modules/problem.coffee index e1e062e949..1f17d01405 100644 --- a/lms/static/coffee/src/modules/problem.coffee +++ b/lms/static/coffee/src/modules/problem.coffee @@ -48,11 +48,15 @@ class @Problem @$("label[for='input_#{key}_#{choice}']").attr correct_answer: 'true' else - @$("#answer_#{key}").html(value) // needs to be html, not text, for complex solutions (eg coding) + @$("#answer_#{key}").html(value) # needs to be html, not text, for complex solutions (eg coding) + @$("#solution_#{key}").html(value) # needs to be html, not text, for complex solutions (eg coding) + MathJax.Hub.Queue ["Typeset", MathJax.Hub] + MathJax.Hub.Queue ["Typeset", MathJax.Hub] @$('.show').val 'Hide Answer' @element.addClass 'showed' else @$('[id^=answer_]').text '' + @$('[id^=solution_]').text '' @$('[correct_answer]').attr correct_answer: null @element.removeClass 'showed' @$('.show').val 'Show Answer' From 989a74ba3f67bcb8b81bf93b99f4e0a71bffd633 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 20:05:33 -0400 Subject: [PATCH 16/80] django pipeline working now (with new pip -e git+git...) --- common/lib/capa/capa_problem.py | 1 + lms/envs/dev_ike.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index a341f954bc..16ecb9186a 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -224,6 +224,7 @@ class LoncapaProblem(object): answer = etree.tostring(entry) if answer: answer_map[entry.get('id')] = answer + log.debug('answer_map = %s' % answer_map) return answer_map def get_answer_ids(self): diff --git a/lms/envs/dev_ike.py b/lms/envs/dev_ike.py index ee5b6e831b..0930ef4651 100644 --- a/lms/envs/dev_ike.py +++ b/lms/envs/dev_ike.py @@ -27,7 +27,7 @@ DEBUG = True ENABLE_MULTICOURSE = True # set to False to disable multicourse display (see lib.util.views.mitxhome) QUICKEDIT = True -MITX_FEATURES['USE_DJANGO_PIPELINE'] = False +# MITX_FEATURES['USE_DJANGO_PIPELINE'] = False COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x', 'title' : 'Circuits and Electronics', From 2af525f19c3489905d1f57e8fc77724aee1a423c Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 20:52:10 -0400 Subject: [PATCH 17/80] fixes to schematicresponse to work with new CorrectMap --- common/lib/capa/responsetypes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index a63cb991cf..947a66b13c 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -960,7 +960,8 @@ class SchematicResponse(LoncapaResponse): self.context.update({'submission':submission}) exec self.code in global_context, self.context cmap = CorrectMap() - return cmap.set_dict(zip(sorted(self.answer_ids), self.context['correct'])) + cmap.set_dict(dict(zip(sorted(self.answer_ids), self.context['correct']))) + return cmap def get_answers(self): # use answers provided in input elements From f4a3c54481c0d6ba7cca09d72dd09b66c6c6d6ec Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 21:05:21 -0400 Subject: [PATCH 18/80] fix xmodule/capa tests to use new CorrectMap --- common/lib/capa/capa_problem.py | 4 ++-- common/lib/xmodule/tests.py | 34 ++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index 16ecb9186a..80ec8806f3 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -200,12 +200,12 @@ class LoncapaProblem(object): self.student_answers = answers oldcmap = self.correct_map # old CorrectMap newcmap = CorrectMap() # start new with empty CorrectMap - log.debug('Responders: %s' % self.responders) + # log.debug('Responders: %s' % self.responders) for responder in self.responders.values(): results = responder.evaluate_answers(answers,oldcmap) # call the responsetype instance to do the actual grading newcmap.update(results) self.correct_map = newcmap - log.debug('%s: in grade_answers, answers=%s, cmap=%s' % (self,answers,newcmap)) + # log.debug('%s: in grade_answers, answers=%s, cmap=%s' % (self,answers,newcmap)) return newcmap def get_question_answers(self): diff --git a/common/lib/xmodule/tests.py b/common/lib/xmodule/tests.py index 69e69aa1d9..f8187269e9 100644 --- a/common/lib/xmodule/tests.py +++ b/common/lib/xmodule/tests.py @@ -1,9 +1,9 @@ # -# unittests for courseware +# unittests for xmodule (and capa) # # Note: run this using a like like this: # -# django-admin.py test --settings=envs.test_ike --pythonpath=. courseware +# django-admin.py test --settings=lms.envs.test_ike --pythonpath=. common/lib/xmodule import unittest import os @@ -96,31 +96,31 @@ class MultiChoiceTest(unittest.TestCase): multichoice_file = os.path.dirname(__file__)+"/test_files/multichoice.xml" test_lcp = lcp.LoncapaProblem(open(multichoice_file), '1', system=i4xs) correct_answers = {'1_2_1':'choice_foil3'} - self.assertEquals(test_lcp.grade_answers(correct_answers)['1_2_1'], 'correct') + self.assertEquals(test_lcp.grade_answers(correct_answers).get_correctness('1_2_1'), 'correct') false_answers = {'1_2_1':'choice_foil2'} - self.assertEquals(test_lcp.grade_answers(false_answers)['1_2_1'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(false_answers).get_correctness('1_2_1'), 'incorrect') def test_MC_bare_grades(self): multichoice_file = os.path.dirname(__file__)+"/test_files/multi_bare.xml" test_lcp = lcp.LoncapaProblem(open(multichoice_file), '1', system=i4xs) correct_answers = {'1_2_1':'choice_2'} - self.assertEquals(test_lcp.grade_answers(correct_answers)['1_2_1'], 'correct') + self.assertEquals(test_lcp.grade_answers(correct_answers).get_correctness('1_2_1'), 'correct') false_answers = {'1_2_1':'choice_1'} - self.assertEquals(test_lcp.grade_answers(false_answers)['1_2_1'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(false_answers).get_correctness('1_2_1'), 'incorrect') def test_TF_grade(self): truefalse_file = os.path.dirname(__file__)+"/test_files/truefalse.xml" test_lcp = lcp.LoncapaProblem(open(truefalse_file), '1', system=i4xs) correct_answers = {'1_2_1':['choice_foil2', 'choice_foil1']} - self.assertEquals(test_lcp.grade_answers(correct_answers)['1_2_1'], 'correct') + self.assertEquals(test_lcp.grade_answers(correct_answers).get_correctness('1_2_1'), 'correct') false_answers = {'1_2_1':['choice_foil1']} - self.assertEquals(test_lcp.grade_answers(false_answers)['1_2_1'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(false_answers).get_correctness('1_2_1'), 'incorrect') false_answers = {'1_2_1':['choice_foil1', 'choice_foil3']} - self.assertEquals(test_lcp.grade_answers(false_answers)['1_2_1'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(false_answers).get_correctness('1_2_1'), 'incorrect') false_answers = {'1_2_1':['choice_foil3']} - self.assertEquals(test_lcp.grade_answers(false_answers)['1_2_1'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(false_answers).get_correctness('1_2_1'), 'incorrect') false_answers = {'1_2_1':['choice_foil1', 'choice_foil2', 'choice_foil3']} - self.assertEquals(test_lcp.grade_answers(false_answers)['1_2_1'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(false_answers).get_correctness('1_2_1'), 'incorrect') class ImageResponseTest(unittest.TestCase): def test_ir_grade(self): @@ -131,8 +131,8 @@ class ImageResponseTest(unittest.TestCase): test_answers = {'1_2_1':'[500,20]', '1_2_2':'[250,300]', } - self.assertEquals(test_lcp.grade_answers(test_answers)['1_2_1'], 'correct') - self.assertEquals(test_lcp.grade_answers(test_answers)['1_2_2'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(test_answers).get_correctness('1_2_1'), 'correct') + self.assertEquals(test_lcp.grade_answers(test_answers).get_correctness('1_2_2'), 'incorrect') class SymbolicResponseTest(unittest.TestCase): def test_sr_grade(self): @@ -220,8 +220,8 @@ class SymbolicResponseTest(unittest.TestCase): ''', } - self.assertEquals(test_lcp.grade_answers(correct_answers)['1_2_1'], 'correct') - self.assertEquals(test_lcp.grade_answers(wrong_answers)['1_2_1'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(correct_answers).get_correctness('1_2_1'), 'correct') + self.assertEquals(test_lcp.grade_answers(wrong_answers).get_correctness('1_2_1'), 'incorrect') class OptionResponseTest(unittest.TestCase): ''' @@ -237,8 +237,8 @@ class OptionResponseTest(unittest.TestCase): test_answers = {'1_2_1':'True', '1_2_2':'True', } - self.assertEquals(test_lcp.grade_answers(test_answers)['1_2_1'], 'correct') - self.assertEquals(test_lcp.grade_answers(test_answers)['1_2_2'], 'incorrect') + self.assertEquals(test_lcp.grade_answers(test_answers).get_correctness('1_2_1'), 'correct') + self.assertEquals(test_lcp.grade_answers(test_answers).get_correctness('1_2_2'), 'incorrect') #----------------------------------------------------------------------------- # Grading tests From fdc4a14cf0a26a557e42342d0966d9feac604e08 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 21:11:04 -0400 Subject: [PATCH 19/80] fix i4xs in tests.py; move symbolicresponse.xml test back to where it should be --- .../xmodule/test_files/{test_files => }/symbolicresponse.xml | 0 common/lib/xmodule/tests.py | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename common/lib/xmodule/test_files/{test_files => }/symbolicresponse.xml (100%) diff --git a/common/lib/xmodule/test_files/test_files/symbolicresponse.xml b/common/lib/xmodule/test_files/symbolicresponse.xml similarity index 100% rename from common/lib/xmodule/test_files/test_files/symbolicresponse.xml rename to common/lib/xmodule/test_files/symbolicresponse.xml diff --git a/common/lib/xmodule/tests.py b/common/lib/xmodule/tests.py index f8187269e9..00711ce0da 100644 --- a/common/lib/xmodule/tests.py +++ b/common/lib/xmodule/tests.py @@ -28,12 +28,13 @@ class I4xSystem(object): self.track_function = lambda x: None self.render_function = lambda x: {} # Probably incorrect self.exception404 = Exception + self.DEBUG = True def __repr__(self): return repr(self.__dict__) def __str__(self): return str(self.__dict__) -i4xs = I4xSystem +i4xs = I4xSystem() class ModelsTest(unittest.TestCase): def setUp(self): @@ -136,7 +137,7 @@ class ImageResponseTest(unittest.TestCase): class SymbolicResponseTest(unittest.TestCase): def test_sr_grade(self): - raise SkipTest() # This test fails due to dependencies on a local copy of snuggletex-webapp. Until we have figured that out, we'll just skip this test + # raise SkipTest() # This test fails due to dependencies on a local copy of snuggletex-webapp. Until we have figured that out, we'll just skip this test symbolicresponse_file = os.path.dirname(__file__)+"/test_files/symbolicresponse.xml" test_lcp = lcp.LoncapaProblem(open(symbolicresponse_file), '1', system=i4xs) correct_answers = {'1_2_1':'cos(theta)*[[1,0],[0,1]] + i*sin(theta)*[[0,1],[1,0]]', From a7d0f8322d5727b3085b95f96e61db46e6428f20 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 21:11:43 -0400 Subject: [PATCH 20/80] SymbolicResponseTest works if snuggletex war running ; back to skipping it for now --- common/lib/xmodule/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/tests.py b/common/lib/xmodule/tests.py index 00711ce0da..1ba423983c 100644 --- a/common/lib/xmodule/tests.py +++ b/common/lib/xmodule/tests.py @@ -137,7 +137,7 @@ class ImageResponseTest(unittest.TestCase): class SymbolicResponseTest(unittest.TestCase): def test_sr_grade(self): - # raise SkipTest() # This test fails due to dependencies on a local copy of snuggletex-webapp. Until we have figured that out, we'll just skip this test + raise SkipTest() # This test fails due to dependencies on a local copy of snuggletex-webapp. Until we have figured that out, we'll just skip this test symbolicresponse_file = os.path.dirname(__file__)+"/test_files/symbolicresponse.xml" test_lcp = lcp.LoncapaProblem(open(symbolicresponse_file), '1', system=i4xs) correct_answers = {'1_2_1':'cos(theta)*[[1,0],[0,1]] + i*sin(theta)*[[0,1],[1,0]]', From b48b33e65ecc22a22dfa03e211d0163943cb7562 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 21:27:11 -0400 Subject: [PATCH 21/80] add FormulaResponseWithHintTest test --- common/lib/xmodule/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/lib/xmodule/tests.py b/common/lib/xmodule/tests.py index 1ba423983c..6f054b4bfb 100644 --- a/common/lib/xmodule/tests.py +++ b/common/lib/xmodule/tests.py @@ -241,6 +241,21 @@ class OptionResponseTest(unittest.TestCase): self.assertEquals(test_lcp.grade_answers(test_answers).get_correctness('1_2_1'), 'correct') self.assertEquals(test_lcp.grade_answers(test_answers).get_correctness('1_2_2'), 'incorrect') +class FormulaResponseWithHintTest(unittest.TestCase): + ''' + Test Formula response problem with a hint + This problem also uses calc. + ''' + def test_or_grade(self): + problem_file = os.path.dirname(__file__)+"/test_files/formularesponse_with_hint.xml" + test_lcp = lcp.LoncapaProblem(open(problem_file), '1', system=i4xs) + correct_answers = {'1_2_1':'2.5*x-5.0'} + test_answers = {'1_2_1':'0.4*x-5.0'} + self.assertEquals(test_lcp.grade_answers(correct_answers).get_correctness('1_2_1'), 'correct') + cmap = test_lcp.grade_answers(test_answers) + self.assertEquals(cmap.get_correctness('1_2_1'), 'incorrect') + self.assertTrue('You have inverted' in cmap.get_hint('1_2_1')) + #----------------------------------------------------------------------------- # Grading tests From 855112f8e744520f7b3470112ea50541ed0c83ea Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 21:59:29 -0400 Subject: [PATCH 22/80] added StringResponse (with hints) for hints, still to be done: numericalhint, optionhint no default hint processing done yet (ie hintmode = on_request) --- common/lib/capa/inputtypes.py | 4 ++++ common/lib/capa/responsetypes.py | 38 +++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/common/lib/capa/inputtypes.py b/common/lib/capa/inputtypes.py index 1fa51f2f84..75588e8aea 100644 --- a/common/lib/capa/inputtypes.py +++ b/common/lib/capa/inputtypes.py @@ -176,6 +176,10 @@ def textline(element, value, status, render_template, msg=""): if element.get('math') or element.get('dojs'): # 'dojs' flag is temporary, for backwards compatibility with 8.02x return SimpleInput.xml_tags['textline_dynamath'](element,value,status,render_template,msg) eid=element.get('id') + if eid is None: + msg = 'textline has no id: it probably appears outside of a known response type' + msg += "\nSee problem XML source line %s" % getattr(element,'sourceline','') + raise Exception(msg) count = int(eid.split('_')[-2])-1 # HACK size = element.get('size') context = {'id':eid, 'value':value, 'state':status, 'count':count, 'size': size, 'msg': msg} diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index 947a66b13c..cf7310f92e 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -425,6 +425,42 @@ class NumericalResponse(LoncapaResponse): #----------------------------------------------------------------------------- +class StringResponse(LoncapaResponse): + + response_tag = 'stringresponse' + hint_tag = 'stringhint' + allowed_inputfields = ['textline'] + required_attributes = ['answer'] + max_inputfields = 1 + + def setup_response(self): + self.correct_answer = contextualize_text(self.xml.get('answer'), self.context).strip() + + def get_score(self, student_answers): + '''Grade a string response ''' + student_answer = student_answers[self.answer_id].strip() + correct = self.check_string(self.correct_answer,student_answer) + return CorrectMap(self.answer_id,'correct' if correct else 'incorrect') + + def check_string(self,expected,given): + if self.xml.get('type')=='ci': return given.lower() == expected.lower() + return given == expected + + def check_hint_condition(self,hxml_set,student_answers): + given = student_answers[self.answer_id].strip() + hints_to_show = [] + for hxml in hxml_set: + name = hxml.get('name') + correct_answer = contextualize_text(hxml.get('answer'),self.context).strip() + if self.check_string(correct_answer,given): hints_to_show.append(name) + log.debug('hints_to_show = %s' % hints_to_show) + return hints_to_show + + def get_answers(self): + return {self.answer_id:self.correct_answer} + +#----------------------------------------------------------------------------- + class CustomResponse(LoncapaResponse): ''' Custom response. The python code to be run should be in ... @@ -1028,5 +1064,5 @@ class ImageResponse(LoncapaResponse): # TEMPORARY: List of all response subclasses # FIXME: To be replaced by auto-registration -__all__ = [ NumericalResponse, FormulaResponse, CustomResponse, SchematicResponse, MultipleChoiceResponse, TrueFalseResponse, ExternalResponse, ImageResponse, OptionResponse, SymbolicResponse ] +__all__ = [ NumericalResponse, FormulaResponse, CustomResponse, SchematicResponse, MultipleChoiceResponse, TrueFalseResponse, ExternalResponse, ImageResponse, OptionResponse, SymbolicResponse, StringResponse ] From 4f6d9143c0fa30b70975b3de6dfcc364e404346f Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 22:06:13 -0400 Subject: [PATCH 23/80] added stringresponse_with_hint test --- .../test_files/formularesponse_with_hint.xml | 45 +++++++++++++++++++ .../test_files/stringresponse_with_hint.xml | 25 +++++++++++ common/lib/xmodule/tests.py | 14 ++++++ 3 files changed, 84 insertions(+) create mode 100644 common/lib/xmodule/test_files/formularesponse_with_hint.xml create mode 100644 common/lib/xmodule/test_files/stringresponse_with_hint.xml diff --git a/common/lib/xmodule/test_files/formularesponse_with_hint.xml b/common/lib/xmodule/test_files/formularesponse_with_hint.xml new file mode 100644 index 0000000000..e5b3e28708 --- /dev/null +++ b/common/lib/xmodule/test_files/formularesponse_with_hint.xml @@ -0,0 +1,45 @@ + + + + +

Hints can be provided to students, based on the last response given, as well as the history of responses given. Here is an example of a hint produced by a Formula Response problem.

+ +

+What is the equation of the line which passess through ($x1,$y1) and +($x2,$y2)?

+ +

The correct answer is $answer. A common error is to invert the equation for the slope. Enter +$wrongans to see a hint.

+ +
+ + + + y = + + + + + You have inverted the slope in the question. + + + +
+ diff --git a/common/lib/xmodule/test_files/stringresponse_with_hint.xml b/common/lib/xmodule/test_files/stringresponse_with_hint.xml new file mode 100644 index 0000000000..86efdf0f18 --- /dev/null +++ b/common/lib/xmodule/test_files/stringresponse_with_hint.xml @@ -0,0 +1,25 @@ + +

Example: String Response Problem

+
+
+ + Which US state has Lansing as its capital? + + + + + + + + + The state capital of Wisconsin is Madison. + + + The state capital of Minnesota is St. Paul. + + + The state you are looking for is also known as the 'Great Lakes State' + + + +
diff --git a/common/lib/xmodule/tests.py b/common/lib/xmodule/tests.py index 6f054b4bfb..370b3befe5 100644 --- a/common/lib/xmodule/tests.py +++ b/common/lib/xmodule/tests.py @@ -256,6 +256,20 @@ class FormulaResponseWithHintTest(unittest.TestCase): self.assertEquals(cmap.get_correctness('1_2_1'), 'incorrect') self.assertTrue('You have inverted' in cmap.get_hint('1_2_1')) +class StringResponseWithHintTest(unittest.TestCase): + ''' + Test String response problem with a hint + ''' + def test_or_grade(self): + problem_file = os.path.dirname(__file__)+"/test_files/stringresponse_with_hint.xml" + test_lcp = lcp.LoncapaProblem(open(problem_file), '1', system=i4xs) + correct_answers = {'1_2_1':'Michigan'} + test_answers = {'1_2_1':'Minnesota'} + self.assertEquals(test_lcp.grade_answers(correct_answers).get_correctness('1_2_1'), 'correct') + cmap = test_lcp.grade_answers(test_answers) + self.assertEquals(cmap.get_correctness('1_2_1'), 'incorrect') + self.assertTrue('St. Paul' in cmap.get_hint('1_2_1')) + #----------------------------------------------------------------------------- # Grading tests From 6d444de05bf767f11f0662d6a64614b9a83c4aeb Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 22:20:56 -0400 Subject: [PATCH 24/80] fix capa_problems pep8 --- common/lib/capa/capa_problem.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index 80ec8806f3..eed6953521 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -146,7 +146,7 @@ class LoncapaProblem(object): def get_max_score(self): ''' Return maximum score for this problem. - We do this by counting the number of answers available for each question + We do this by counting the number of answers available for each question in the problem. If the Response for a question has a get_max_score() method then we call that and add its return value to the count. That can be used to give complex problems (eg programming questions) multiple points. @@ -351,7 +351,7 @@ class LoncapaProblem(object): Also create capa Response instances for each responsetype and save as self.responders ''' response_id = 1 - self.responders = {} + self.responders = {} for response in tree.xpath('//' + "|//".join(response_tag_dict)): response_id_str = self.problem_id + "_" + str(response_id) response.set('id',response_id_str) # create and save ID for this response @@ -367,7 +367,7 @@ class LoncapaProblem(object): answer_id = answer_id + 1 responder = response_tag_dict[response.tag](response, inputfields, self.context, self.system) # instantiate capa Response - self.responders[response] = responder # save in list in self + self.responders[response] = responder # save in list in self # ... may not be associated with any specific response; give IDs for those separately # TODO: We should make the namespaces consistent and unique (e.g. %s_problem_%i). From 6bcb40b52f79bb5f34091c66726d53f5c1793394 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 22:27:40 -0400 Subject: [PATCH 25/80] capa_problem and responsetypes pep8 and pyflakes --- common/lib/capa/capa_problem.py | 5 ++--- common/lib/capa/responsetypes.py | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/common/lib/capa/capa_problem.py b/common/lib/capa/capa_problem.py index eed6953521..516c72494b 100644 --- a/common/lib/capa/capa_problem.py +++ b/common/lib/capa/capa_problem.py @@ -14,7 +14,6 @@ This is used by capa_module. from __future__ import division -import copy import logging import math import numpy @@ -156,7 +155,7 @@ class LoncapaProblem(object): if hasattr(responder,'get_max_score'): try: maxscore += responder.get_max_score() - except Exception, err: + except Exception: log.error('responder %s failed to properly return from get_max_score()' % responder) raise else: @@ -176,7 +175,7 @@ class LoncapaProblem(object): for key in self.correct_map: try: correct += self.correct_map.get_npoints(key) - except Exception,err: + except Exception: log.error('key=%s, correct_map = %s' % (key,self.correct_map)) raise diff --git a/common/lib/capa/responsetypes.py b/common/lib/capa/responsetypes.py index cf7310f92e..32c1c6783c 100644 --- a/common/lib/capa/responsetypes.py +++ b/common/lib/capa/responsetypes.py @@ -505,7 +505,6 @@ def sympy_check2(): def setup_response(self): xml = self.xml - context = self.context # if has an "expect" (or "answer") attribute then save that self.expect = xml.get('expect') or xml.get('answer') @@ -560,7 +559,7 @@ def sympy_check2(): msg = '[courseware.capa.responsetypes.customresponse] error getting student answer from %s' % student_answers msg += '\n idset = %s, error = %s' % (idset,err) log.error(msg) - raise Exception,msg + raise Exception(msg) # global variable in context which holds the Presentation MathML from dynamic math input dynamath = [ student_answers.get(k+'_dynamath',None) for k in idset ] # ordered list of dynamath responses @@ -623,7 +622,7 @@ def sympy_check2(): log.error("oops in customresponse (cfn) error %s" % err) # print "context = ",self.context log.error(traceback.format_exc()) - raise Exception,"oops in customresponse (cfn) error %s" % err + raise Exception("oops in customresponse (cfn) error %s" % err) log.debug("[courseware.capa.responsetypes.customresponse.get_score] ret = %s" % ret) if type(ret)==dict: correct = ['correct']*len(idset) if ret['ok'] else ['incorrect']*len(idset) @@ -777,19 +776,19 @@ main() except Exception,err: msg = 'Error %s - cannot connect to external server url=%s' % (err,self.url) log.error(msg) - raise Exception, msg + raise Exception(msg) if self.system.DEBUG: log.info('response = %s' % r.text) if (not r.text ) or (not r.text.strip()): - raise Exception,'Error: no response from external server url=%s' % self.url + raise Exception('Error: no response from external server url=%s' % self.url) try: rxml = etree.fromstring(r.text) # response is XML; prase it except Exception,err: msg = 'Error %s - cannot parse response from external server r.text=%s' % (err,r.text) log.error(msg) - raise Exception, msg + raise Exception(msg) return rxml @@ -800,7 +799,7 @@ main() submission = [student_answers[k] for k in idset] except Exception,err: log.error('Error %s: cannot get student answer for %s; student_answers=%s' % (err,self.answer_ids,student_answers)) - raise Exception,err + raise Exception(err) self.context.update({'submission':submission}) @@ -817,7 +816,7 @@ main() ad = rxml.find('awarddetail').text admap = {'EXACT_ANS':'correct', # TODO: handle other loncapa responses - 'WRONG_FORMAT': 'incorrect', + 'WRONG_FORMAT': 'incorrect', } self.context['correct'] = ['correct'] if ad in admap: @@ -847,7 +846,7 @@ main() if not (len(exans)==len(self.answer_ids)): log.error('Expected %d answers from external server, only got %d!' % (len(self.answer_ids),len(exans))) - raise Exception,'Short response from external server' + raise Exception('Short response from external server') return dict(zip(self.answer_ids,exans)) @@ -964,7 +963,7 @@ class FormulaResponse(LoncapaResponse): correct_answer = contextualize_text(hxml.get('answer'),self.context) try: correctness = self.check_formula(correct_answer, given, samples) - except Exception,err: + except Exception: correctness = 'incorrect' if correctness=='correct': hints_to_show.append(name) @@ -1041,13 +1040,13 @@ class ImageResponse(LoncapaResponse): if not m: msg = 'Error in problem specification! cannot parse rectangle in %s' % (etree.tostring(self.ielements[aid], pretty_print=True)) - raise Exception,'[capamodule.capa.responsetypes.imageinput] '+msg + raise Exception('[capamodule.capa.responsetypes.imageinput] '+msg) (llx,lly,urx,ury) = [int(x) for x in m.groups()] # parse given answer m = re.match('\[([0-9]+),([0-9]+)]',given.strip().replace(' ','')) if not m: - raise Exception,'[capamodule.capa.responsetypes.imageinput] error grading %s (input=%s)' % (aid,given) + raise Exception('[capamodule.capa.responsetypes.imageinput] error grading %s (input=%s)' % (aid,given)) (gx,gy) = [int(x) for x in m.groups()] # answer is correct if (x,y) is within the specified rectangle From 6f14acee9e216399210e039a21c3730f90f58155 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 22:34:30 -0400 Subject: [PATCH 26/80] add MITX_FEATURES['DISPLAY_HISTOGRAMS_TO_STAFF'] flag to settings --- lms/djangoapps/courseware/module_render.py | 2 +- lms/envs/common.py | 1 + lms/envs/dev_ike.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 0f82d9ba94..fd419a68dc 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -169,7 +169,7 @@ def render_x_module(user, request, xml_module, module_object_preload, position=N content = instance.get_html() # special extra information about each problem, only for users who are staff - if False and user.is_staff: + if settings.MITX_FEATURES.get('DISPLAY_HISTOGRAMS_TO_STAFF') and user.is_staff: module_id = xml_module.get('id') histogram = grade_histogram(module_id) render_histogram = len(histogram) > 0 diff --git a/lms/envs/common.py b/lms/envs/common.py index d583217dc5..430ffc25ab 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -37,6 +37,7 @@ PERFSTATS = False MITX_FEATURES = { 'SAMPLE' : False, 'USE_DJANGO_PIPELINE' : True, + 'DISPLAY_HISTOGRAMS_TO_STAFF' : True, } # Used for A/B testing diff --git a/lms/envs/dev_ike.py b/lms/envs/dev_ike.py index 0930ef4651..af51274433 100644 --- a/lms/envs/dev_ike.py +++ b/lms/envs/dev_ike.py @@ -28,6 +28,7 @@ ENABLE_MULTICOURSE = True # set to False to disable multicourse display (see QUICKEDIT = True # MITX_FEATURES['USE_DJANGO_PIPELINE'] = False +MITX_FEATURES['DISPLAY_HISTOGRAMS_TO_STAFF'] = False COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x', 'title' : 'Circuits and Electronics', From 17ca0e793ca77946b0a4212cc5a3550c04613ef3 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sun, 10 Jun 2012 22:39:16 -0400 Subject: [PATCH 27/80] remove loncapa import in formularesponse_with_hint test (jenkins import path not consistent with dev machines?) --- common/lib/xmodule/test_files/formularesponse_with_hint.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/test_files/formularesponse_with_hint.xml b/common/lib/xmodule/test_files/formularesponse_with_hint.xml index e5b3e28708..90248dcf04 100644 --- a/common/lib/xmodule/test_files/formularesponse_with_hint.xml +++ b/common/lib/xmodule/test_files/formularesponse_with_hint.xml @@ -1,6 +1,6 @@ from the problem.xml file, and exec it in the context of this problem. Provides ability to randomize problems, and also set @@ -273,7 +273,7 @@ class LoncapaProblem(object): log.exception("Error while execing code: " + code) return context - def extract_html(self, problemtree): # private + def _extract_html(self, problemtree): # private ''' Main (private) function which converts Problem XML tree to HTML. Calls itself recursively. @@ -320,11 +320,11 @@ class LoncapaProblem(object): return render_object.get_html() # function(problemtree, value, status, msg) # render the special response (textline, schematic,...) if problemtree in self.responders: # let each Response render itself - return self.responders[problemtree].render_html(self.extract_html) + return self.responders[problemtree].render_html(self._extract_html) tree = etree.Element(problemtree.tag) for item in problemtree: - item_xhtml = self.extract_html(item) # nothing special: recurse + item_xhtml = self._extract_html(item) # nothing special: recurse if item_xhtml is not None: tree.append(item_xhtml) @@ -339,7 +339,7 @@ class LoncapaProblem(object): return tree - def preprocess_problem(self, tree): # private + def _preprocess_problem(self, tree): # private ''' Assign IDs to all the responses Assign sub-IDs to all entries (textline, schematic, etc.) From 5031c838ccdbefb27198e16f3dae9266006c558f Mon Sep 17 00:00:00 2001 From: ichuang Date: Tue, 12 Jun 2012 13:52:34 -0400 Subject: [PATCH 40/80] typo in correctmap --- common/lib/capa/correctmap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/capa/correctmap.py b/common/lib/capa/correctmap.py index 63d4fb33b2..786b2f5e2d 100644 --- a/common/lib/capa/correctmap.py +++ b/common/lib/capa/correctmap.py @@ -24,7 +24,7 @@ class CorrectMap(object): self.set(*args,**kwargs) def __getitem__(self, *args, **kwargs): - return self.cmap.__getitem(*args, **kwargs) + return self.cmap.__getitem__(*args, **kwargs) def __iter__(self): return self.cmap.__iter__() From 35202817d5c102dc9786aea7c6942a05d214db0f Mon Sep 17 00:00:00 2001 From: ichuang Date: Tue, 12 Jun 2012 14:07:48 -0400 Subject: [PATCH 41/80] problem.coffee : queue mathjax typesetting just once --- lms/static/coffee/src/modules/problem.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/lms/static/coffee/src/modules/problem.coffee b/lms/static/coffee/src/modules/problem.coffee index 1f17d01405..17587b9ade 100644 --- a/lms/static/coffee/src/modules/problem.coffee +++ b/lms/static/coffee/src/modules/problem.coffee @@ -51,7 +51,6 @@ class @Problem @$("#answer_#{key}").html(value) # needs to be html, not text, for complex solutions (eg coding) @$("#solution_#{key}").html(value) # needs to be html, not text, for complex solutions (eg coding) MathJax.Hub.Queue ["Typeset", MathJax.Hub] - MathJax.Hub.Queue ["Typeset", MathJax.Hub] @$('.show').val 'Hide Answer' @element.addClass 'showed' else From 8e98e59cfa044364ed0c163339318f87269a6721 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 12 Jun 2012 14:08:43 -0400 Subject: [PATCH 42/80] Cleanup show answer code --- lms/static/coffee/src/modules/problem.coffee | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lms/static/coffee/src/modules/problem.coffee b/lms/static/coffee/src/modules/problem.coffee index 17587b9ade..aad41f23d4 100644 --- a/lms/static/coffee/src/modules/problem.coffee +++ b/lms/static/coffee/src/modules/problem.coffee @@ -45,17 +45,14 @@ class @Problem $.each response, (key, value) => if $.isArray(value) for choice in value - @$("label[for='input_#{key}_#{choice}']").attr - correct_answer: 'true' + @$("label[for='input_#{key}_#{choice}']").attr correct_answer: 'true' else - @$("#answer_#{key}").html(value) # needs to be html, not text, for complex solutions (eg coding) - @$("#solution_#{key}").html(value) # needs to be html, not text, for complex solutions (eg coding) + @$("#answer_#{key}, #solution_#{key}").html(value) MathJax.Hub.Queue ["Typeset", MathJax.Hub] @$('.show').val 'Hide Answer' @element.addClass 'showed' else - @$('[id^=answer_]').text '' - @$('[id^=solution_]').text '' + @$('[id^=answer_], [id^=solution_]').text '' @$('[correct_answer]').attr correct_answer: null @element.removeClass 'showed' @$('.show').val 'Show Answer' From a3561c96f79853751afce497b37a5f8c9b23fc86 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Mon, 11 Jun 2012 15:48:33 -0400 Subject: [PATCH 43/80] added TODO comment --- common/lib/xmodule/capa_module.py | 1 + 1 file changed, 1 insertion(+) diff --git a/common/lib/xmodule/capa_module.py b/common/lib/xmodule/capa_module.py index 439982a2c1..c7b52ae8ba 100644 --- a/common/lib/xmodule/capa_module.py +++ b/common/lib/xmodule/capa_module.py @@ -281,6 +281,7 @@ class Module(XModule): def answer_available(self): ''' Is the user allowed to see an answer? + TODO: simplify. ''' if self.show_answer == '': return False From c9cbc52ffada2abe6fcbfa10704ea2406cb7b2eb Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Mon, 11 Jun 2012 15:49:39 -0400 Subject: [PATCH 44/80] Add rough overview docs --- doc/README | 3 ++ doc/overview.md | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/testing.md | 12 ++++++ 3 files changed, 119 insertions(+) create mode 100644 doc/README create mode 100644 doc/overview.md create mode 100644 doc/testing.md diff --git a/doc/README b/doc/README new file mode 100644 index 0000000000..65f3cd2cb5 --- /dev/null +++ b/doc/README @@ -0,0 +1,3 @@ +This directory contains some high level documentation for the code. We should strive to keep it up-to-date, but don't take it as the absolute truth. + +A good place to start is 'overview' diff --git a/doc/overview.md b/doc/overview.md new file mode 100644 index 0000000000..a53e7371c2 --- /dev/null +++ b/doc/overview.md @@ -0,0 +1,104 @@ +# Documentation for edX code (mitx repo) + +This document explains the general structure of the edX platform, and defines some of the acronyms and terms you'll see flying around in the code. + +## Assumptions: + +You should be familiar with the following. If you're not, go read some docs... + + - python + - django + - javascript + - html, xml -- xpath, xslt + - css + - git + - mako templates -- we use these instead of django templates, because they support embedding real python. + +## Other relevant terms + + - CAPA -- lon-capa.org -- content management system that has defined a standard for online learning and assessment materials. Many of our materials follow this standard. + - TODO: add more details / link to relevant docs. lon-capa.org is not immediately intuitive. + - lcp = loncapa problem + + +## Parts of the system + + - LMS -- Learning Management System. The student-facing parts of the system. Handles student accounts, displaying videos, tutorials, exercies, problems, etc. + + - CMS -- Course Management System. The instructor-facing parts of the system. Allows instructors to see and modify their course, add lectures, problems, reorder things, etc. + + - Askbot -- the discussion forums. We have a custom fork of this project. We're also hoping to replace it with something better later. (e.g. need support for multiple classes, etc) + + - Data. In the data/ dir. There is currently a single `course.xml` file that describes an entire course. Speaking of which... + + - Courses. A course is broken up into Chapters ("week 1", "week 2", etc). A chapter is broken up into Sections ("Lecture 1", "Simple Circuits Exercises", "HW1", etc). A section can contain modules: Problems, Html, Videos, Verticals, or Sequences. + - Problems: specified in problem files. May have python scripts embedded to both generate random parameters and check answers. Also allows specifying things like tolerance or precision in answers + - Html: any html - often description, or links to outside resources + - Videos: links to youtube or elsewhere + - Verticals: a nesting tag: collect several videos, problems, html modules and display them vertically. + - Sequences: a sequence of modules, displayed with a horizontal navigation bar, displaying one component at a time. + - see `data/course.xml` for more examples + + +## High Level Entities in the code + +### Common libraries + +- x_modules -- generic learning modules. *x* can be sequence, video, template, html, vertical, capa, etc. These are the things that one puts inside sections in the course structure. Modules know how to render themselves to html, how to score themselves, and handle ajax calls from the front end. + - x_modules take a 'system' context parameter, which is a reference to an object that knows how to render things, track events, complain about 404s, etc. (TODO: figure out, document the necessary interface--different in `x_module.XModule.__init__` and in `x_module tests.py`) + - in `common/lib/xmodule` + +- capa modules -- defines `LoncapaProblem` and many related things. + - in `common/lib/capa` + +### LMS + +The LMS is a django site, with root in `lms/`. It runs in many different environments--the settings files are in `lms/envs`. + +- We use the Django Auth system, including the is_staff and is_superuser flags. User profiles and related code lives in `lms/djangoapps/student/`. There is support for groups of students (e.g. 'want emails about future courses', 'have unenrolled', etc) in `lms/djangoapps/student/models.py`. + +- `StudentModule` -- keeps track of where a particular student is in a module (problem, video, html)--what's their grade, have they started, are they done, etc. [This is only partly implemented so far.] + - `lms/djangoapps/courseware/models.py` + +- Core rendering path: + - `lms/urls.py` points to `courseware.views.index`, which gets module info from the course xml file, pulls list of `StudentModule` objects for this user (to avoid multiple db hits). + + - Calls `render_accordion` to render the "accordion"--the display of the course structure. + + - To render the current module, calls `module_render.py:render_x_module()`, which gets the `StudentModule` instance, and passes the `StudentModule` state and other system context to the module constructor the get an instance of the appropriate module class for this user. + + - calls the module's `.get_html()` method. If the module has nested submodules, render_x_module() will be called again for each. + + - ajax calls go to `module_render.py:modx_dispatch()`, which passes it to the module's `handle_ajax()` function, and then updates the grade and state if they changed. + +- Tracking: there is support for basic tracking of client-side events in `lms/djangoapps/track`. + +### Other modules + +- Wiki -- in `lms/djangoapps/simplewiki`. Has some markdown extentions for embedding circuits, videos, etc. + +## Testing + +See `testing.md`. + + +## QUESTIONS: + +`common/lib/capa` : what is eia, `eia.py`? Random lists of numbers? + +what is `lms/lib/dogfood`? Looks like a way to test capa problems... Is it being used? + +is lms/envs/README.txt out of date? + +## TODO: + +- Only describes backend code so far. How does the front-end work? + +- What big pieces are missing? + +- Where should reader go next? + +--- +Note: this file uses markdown. To convert to html, run: + + markdown2 overview.md > overview.html diff --git a/doc/testing.md b/doc/testing.md new file mode 100644 index 0000000000..fa134ade66 --- /dev/null +++ b/doc/testing.md @@ -0,0 +1,12 @@ +# Testing + +Testing is good. Here is some useful info about how we set up tests-- + +### Backend code: + +- TODO + +### Frontend code: + +- TODO + From 17af925a8a0016f66c1b169fe463c60c4bc3966a Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Mon, 11 Jun 2012 15:34:52 -0400 Subject: [PATCH 45/80] add function docs to module_render.py --- lms/djangoapps/courseware/module_render.py | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index fd419a68dc..ec13dc11a5 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -89,6 +89,19 @@ def grade_histogram(module_id): return grades def get_module(user, request, xml_module, module_object_preload, position=None): + ''' Get the appropriate xmodule and StudentModule. + + Arguments: + - user : current django User + - request : current django HTTPrequest + - xml_module : lxml etree of xml subtree for the current module + - module_object_preload : list of StudentModule objects, one of which may match this module type and id + - position : extra information from URL for user-specified position within module + + Returns: + - a tuple (xmodule instance, student module, module type). + + ''' module_type=xml_module.tag module_class=xmodule.get_module_class(module_type) module_id=xml_module.get('id') #module_class.id_attribute) or "" @@ -184,7 +197,19 @@ def render_x_module(user, request, xml_module, module_object_preload, position=N return content def modx_dispatch(request, module=None, dispatch=None, id=None): - ''' Generic view for extensions. This is where AJAX calls go.''' + ''' Generic view for extensions. This is where AJAX calls go. + + Arguments: + + - request -- the django request. + - module -- the name of the module, as used in the course configuration xml. + - dispatch -- the command string to pass through to the module's handle_ajax call + (e.g. 'problem_reset'). If this string contains '?', only pass + through the part before the first '?'. + - id -- the module id. Used to look up the student module. + + TODO: why are id and module not the same? + ''' if not request.user.is_authenticated(): return redirect('/') @@ -200,6 +225,8 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): oldgrade = s.grade oldstate = s.state + # TODO: if dispatch is left at default value None, this will go boom. What's the correct + # behavior? dispatch=dispatch.split('?')[0] ajax_url = settings.MITX_ROOT_URL + '/modx/'+module+'/'+id+'/' From 9f38ccb65df418b2a3972932a5b19d49f7f7482c Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Tue, 12 Jun 2012 09:31:22 -0400 Subject: [PATCH 46/80] add README.md for dogfood --- lms/lib/dogfood/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 lms/lib/dogfood/README.md diff --git a/lms/lib/dogfood/README.md b/lms/lib/dogfood/README.md new file mode 100644 index 0000000000..c6a7113049 --- /dev/null +++ b/lms/lib/dogfood/README.md @@ -0,0 +1 @@ +This is a library for edx4edx, allowing users to practice writing problems. From 600899c16cb357f7594b6ba3e395fe88ccb7ad97 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Tue, 12 Jun 2012 09:32:04 -0400 Subject: [PATCH 47/80] add comment/explanation to eia.py --- common/lib/capa/eia.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/lib/capa/eia.py b/common/lib/capa/eia.py index bc962312ec..362dc33a2d 100644 --- a/common/lib/capa/eia.py +++ b/common/lib/capa/eia.py @@ -1,3 +1,6 @@ +""" Standard resistor codes. +http://en.wikipedia.org/wiki/Electronic_color_code +""" E6=[10,15,22,33,47,68] E12=[10,12,15,18,22,27,33,39,47,56,68,82] E24=[10,12,15,18,22,27,33,39,47,56,68,82,11,13,16,20,24,30,36,43,51,62,75,91] From c3a1d7788ccc36a744d251c97d375844d48e3053 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Tue, 12 Jun 2012 09:32:41 -0400 Subject: [PATCH 48/80] clarify docstring for modx_dispatch --- lms/djangoapps/courseware/module_render.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index ec13dc11a5..fe6ebdd585 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -202,13 +202,13 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): Arguments: - request -- the django request. - - module -- the name of the module, as used in the course configuration xml. + - module -- the type of the module, as used in the course configuration xml. + e.g. 'problem', 'video', etc - dispatch -- the command string to pass through to the module's handle_ajax call (e.g. 'problem_reset'). If this string contains '?', only pass through the part before the first '?'. - id -- the module id. Used to look up the student module. - - TODO: why are id and module not the same? + e.g. filenamexformularesponse ''' if not request.user.is_authenticated(): return redirect('/') From 7608003c15121026a4609925f88fc7dcc33a1757 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Tue, 12 Jun 2012 09:33:41 -0400 Subject: [PATCH 49/80] Update overview to reflect suggestions --- doc/README | 2 +- doc/overview.md | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/doc/README b/doc/README index 65f3cd2cb5..d40f5d988d 100644 --- a/doc/README +++ b/doc/README @@ -1,3 +1,3 @@ This directory contains some high level documentation for the code. We should strive to keep it up-to-date, but don't take it as the absolute truth. -A good place to start is 'overview' +A good place to start is 'overview.md' diff --git a/doc/overview.md b/doc/overview.md index a53e7371c2..304d5161b0 100644 --- a/doc/overview.md +++ b/doc/overview.md @@ -45,7 +45,8 @@ You should be familiar with the following. If you're not, go read some docs... ### Common libraries - x_modules -- generic learning modules. *x* can be sequence, video, template, html, vertical, capa, etc. These are the things that one puts inside sections in the course structure. Modules know how to render themselves to html, how to score themselves, and handle ajax calls from the front end. - - x_modules take a 'system' context parameter, which is a reference to an object that knows how to render things, track events, complain about 404s, etc. (TODO: figure out, document the necessary interface--different in `x_module.XModule.__init__` and in `x_module tests.py`) + - x_modules take a 'system context' parameter, which helps isolate xmodules from any particular application, so they can be used in many places. The modules should make no references to Django (though there are still a few left). The system context knows how to render things, track events, complain about 404s, etc. + - TODO: document the system context interface--it's different in `x_module.XModule.__init__` and in `x_module tests.py` (do this in the code, not here) - in `common/lib/xmodule` - capa modules -- defines `LoncapaProblem` and many related things. @@ -71,6 +72,10 @@ The LMS is a django site, with root in `lms/`. It runs in many different enviro - ajax calls go to `module_render.py:modx_dispatch()`, which passes it to the module's `handle_ajax()` function, and then updates the grade and state if they changed. + - [This diagram](https://github.com/MITx/mitx/wiki/MITx-Architecture) visually shows how the clients communicate with problems + modules. + +- See `lms/urls.py` for the wirings of urls to views. + - Tracking: there is support for basic tracking of client-side events in `lms/djangoapps/track`. ### Other modules @@ -81,22 +86,13 @@ The LMS is a django site, with root in `lms/`. It runs in many different enviro See `testing.md`. - -## QUESTIONS: - -`common/lib/capa` : what is eia, `eia.py`? Random lists of numbers? - -what is `lms/lib/dogfood`? Looks like a way to test capa problems... Is it being used? - -is lms/envs/README.txt out of date? - ## TODO: -- Only describes backend code so far. How does the front-end work? +- update lms/envs/README.txt -- What big pieces are missing? +- describe our production environment -- Where should reader go next? +- describe the front-end architecture, tools, etc. Starting point: `lms/static` --- Note: this file uses markdown. To convert to html, run: From b9befbafcd562a037c09140aa2b48cf1f1f18e71 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 13 Jun 2012 11:42:50 -0400 Subject: [PATCH 50/80] Add contentstore from cms proto as a baseline for importing and views for the cms --- cms/djangoapps/contentstore/__init__.py | 0 .../contentstore/management/__init__.py | 0 .../management/commands/__init__.py | 0 .../management/commands/ftpserve.py | 61 +++++++ .../management/commands/import.py | 158 ++++++++++++++++++ cms/djangoapps/contentstore/tests.py | 16 ++ cms/{ => djangoapps/contentstore}/views.py | 0 cms/envs/common.py | 6 +- cms/urls.py | 2 +- 9 files changed, 238 insertions(+), 5 deletions(-) create mode 100644 cms/djangoapps/contentstore/__init__.py create mode 100644 cms/djangoapps/contentstore/management/__init__.py create mode 100644 cms/djangoapps/contentstore/management/commands/__init__.py create mode 100644 cms/djangoapps/contentstore/management/commands/ftpserve.py create mode 100644 cms/djangoapps/contentstore/management/commands/import.py create mode 100644 cms/djangoapps/contentstore/tests.py rename cms/{ => djangoapps/contentstore}/views.py (100%) diff --git a/cms/djangoapps/contentstore/__init__.py b/cms/djangoapps/contentstore/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cms/djangoapps/contentstore/management/__init__.py b/cms/djangoapps/contentstore/management/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cms/djangoapps/contentstore/management/commands/__init__.py b/cms/djangoapps/contentstore/management/commands/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cms/djangoapps/contentstore/management/commands/ftpserve.py b/cms/djangoapps/contentstore/management/commands/ftpserve.py new file mode 100644 index 0000000000..f0a1c19dbf --- /dev/null +++ b/cms/djangoapps/contentstore/management/commands/ftpserve.py @@ -0,0 +1,61 @@ +from django.core.management.base import BaseCommand +from django.contrib.auth.models import User +import contentstore.tasks + +from pyftpdlib import ftpserver +import os + +class DjangoAuthorizer(object): + def validate_authentication(self, username, password): + try: + u=User.objects.get(username=username) + except User.DoesNotExist: + return False + # TODO: Check security groups + return u.check_password(password) + def has_user(self, username): + print "????",username + return True + def has_perm(self, username, perm, path=None): + print "!!!!!",username, perm, path + return True + def get_home_dir(self, username): + d = "/tmp/ftp/"+username + try: + os.mkdir(d) + except OSError: + pass + return "/tmp/ftp/"+username + def get_perms(self, username): + return 'elradfmw' + def get_msg_login(self, username): + return 'Hello' + def get_msg_quit(self, username): + return 'Goodbye' + def __init__(self): + pass + def impersonate_user(self, username, password): + pass + def terminate_impersonation(self, username): + pass + +def on_upload(ftp_handler, filename): + source = ftp_handler.remote_ip + author = ftp_handler.username + print filename, author, source + # We pass on this for now: + # contentstore.tasks.on_upload + # It is a changing API, and it makes testing the FTP server slow. + +class Command(BaseCommand): + help = \ +''' Run FTP server.''' + def handle(self, *args, **options): + authorizer = DjangoAuthorizer() #ftpserver.DummyAuthorizer() + handler = ftpserver.FTPHandler + handler.on_file_received = on_upload + + handler.authorizer = authorizer + address = ("127.0.0.1", 2121) + ftpd = ftpserver.FTPServer(address, handler) + ftpd.serve_forever() diff --git a/cms/djangoapps/contentstore/management/commands/import.py b/cms/djangoapps/contentstore/management/commands/import.py new file mode 100644 index 0000000000..78984f4119 --- /dev/null +++ b/cms/djangoapps/contentstore/management/commands/import.py @@ -0,0 +1,158 @@ +### +### One-off script for importing courseware form XML format +### + + +#import mitxmako.middleware +#from courseware import content_parser +#from django.contrib.auth.models import User +from mako.template import Template +from mako.lookup import TemplateLookup + +from django.core.management.base import BaseCommand +from contentstore.models import create_item, update_item, update_children + +from lxml import etree + +class Command(BaseCommand): + help = \ +''' Run FTP server.''' + def handle(self, *args, **options): + print args + data_dir = args[0] + course_file = 'course.xml' + + parser = etree.XMLParser(remove_comments = True) + + lookup = TemplateLookup(directories=[data_dir]) + template = lookup.get_template("course.xml") + course_string = template.render(groups=[]) + course = etree.XML(course_string, parser=parser) + + elements = course.xpath("//*") + + tag_to_category = {# Inside HTML ==> Skip these + # Custom tags + 'videodev': 'Custom', + 'slides': 'Custom', + 'book': 'Custom', + 'image': 'Custom', + 'discuss': 'Custom', + # Simple lists + 'chapter': 'Sequence', + 'course': 'Sequence', + 'sequential': 'Sequence', + 'vertical': 'Sequence', + 'section': 'Sequence', + # True types + 'video': 'VideoSegment', + 'html': 'HTML', + 'problem': 'Problem', + } + + + name_index=0 + for e in elements: + name = e.attrib.get('name', None) + for f in elements: + if f != e and f.attrib.get('name', None) == name: + name = None + if not name: + name = "{tag}_{index}".format(tag = e.tag,index = name_index) + name_index = name_index + 1 + if e.tag in tag_to_category: + category = tag_to_category[e.tag] + category = category.replace('/', '-') + name = name.replace('/', '-') + e.set('url', 'i4x://mit.edu/6002xs12/{category}/{name}'.format(category = category, + name = name)) + + + def handle_skip(e): + print "Skipping ", e + + results = {} + + def handle_custom(e): + data = {'type':'i4x://mit.edu/6002xs12/tag/{tag}'.format(tag=e.tag), + 'attrib':dict(e.attrib)} + results[e.attrib['url']] = {'data':data} + + def handle_list(e): + if e.attrib.get("class", None) == "tutorials": + return + children = [{'url':le.attrib['url']} for le in e.getchildren()] + results[e.attrib['url']] = {'children':children} + + def handle_video(e): + url = e.attrib['url'] + clip_url = url.replace('VideoSegment', 'VideoClip') + # Take: 0.75:izygArpw-Qo,1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8 + # Make: [(0.75, 'izygArpw-Qo'), (1.0, 'p2Q6BrNhdh8'), (1.25, '1EeWXzPdhSA'), (1.5, 'rABDYkeK0x8')] + youtube_str = e.attrib['youtube'] + youtube_list = [(float(x), y) for x,y in map(lambda x:x.split(':'), youtube_str.split(','))] + clip_infos = [{ "status": "ready", + "format": "youtube", + "sane": True, + "location": "youtube", + "speed": speed, + "id": youtube_id, + "size": None} \ + for (speed, youtube_id) \ + in youtube_list] + results[clip_url] = {'data':{'clip_infos':clip_infos}} + results[url] = {'children' : [{'url':clip_url}]} + + def handle_html(e): + if 'src' in e.attrib: + text = open(data_dir+'html/'+e.attrib['src']).read() + else: + textlist=[e.text]+[etree.tostring(elem) for elem in e]+[e.tail] + textlist=[i for i in textlist if type(i)==str] + text = "".join(textlist) + + results[e.attrib['url']] = {'data':{'text':text}} + + def handle_problem(e): + data = open(data_dir+'problems/'+e.attrib['filename']+'.xml').read() + results[e.attrib['url']] = {'data':{'statement':data}} + + element_actions = {# Inside HTML ==> Skip these + 'a': handle_skip, + 'h1': handle_skip, + 'h2': handle_skip, + 'hr': handle_skip, + 'strong': handle_skip, + 'ul': handle_skip, + 'li': handle_skip, + 'p': handle_skip, + # Custom tags + 'videodev': handle_custom, + 'slides': handle_custom, + 'book': handle_custom, + 'image': handle_custom, + 'discuss': handle_custom, + # Simple lists + 'chapter': handle_list, + 'course': handle_list, + 'sequential': handle_list, + 'vertical': handle_list, + 'section': handle_list, + # True types + 'video': handle_video, + 'html': handle_html, + 'problem': handle_problem, + } + + for e in elements: + element_actions[e.tag](e) + + for k in results: + print k + create_item(k, 'Piotr Mitros') + if 'data' in results[k]: + update_item(k, results[k]['data']) + if 'children' in results[k]: + update_children(k, results[k]['children']) + + diff --git a/cms/djangoapps/contentstore/tests.py b/cms/djangoapps/contentstore/tests.py new file mode 100644 index 0000000000..501deb776c --- /dev/null +++ b/cms/djangoapps/contentstore/tests.py @@ -0,0 +1,16 @@ +""" +This file demonstrates writing tests using the unittest module. These will pass +when you run "manage.py test". + +Replace this with more appropriate tests for your application. +""" + +from django.test import TestCase + + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.assertEqual(1 + 1, 2) diff --git a/cms/views.py b/cms/djangoapps/contentstore/views.py similarity index 100% rename from cms/views.py rename to cms/djangoapps/contentstore/views.py diff --git a/cms/envs/common.py b/cms/envs/common.py index 9b349a06d0..8d402b6fa9 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -144,8 +144,6 @@ INSTALLED_APPS = ( 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', - # Uncomment the next line to enable the admin: - # 'django.contrib.admin', - # Uncomment the next line to enable admin documentation: - # 'django.contrib.admindocs', + 'contentstore', + 'instructor', ) diff --git a/cms/urls.py b/cms/urls.py index 55d7a1086e..a7266066cc 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -5,6 +5,6 @@ from django.conf.urls.defaults import patterns, url # admin.autodiscover() urlpatterns = patterns('', - url(r'^(?P[^/]+)/(?P[^/]+)/calendar/', 'cms.views.calendar', name='calendar'), + url(r'^(?P[^/]+)/(?P[^/]+)/calendar/', 'contentstore.views.calendar', name='calendar'), url(r'^accounts/login/', 'instructor.views.do_login', name='login'), ) From a333612cce7b9e285dfdc1fc38abf552bb320781 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 13 Jun 2012 11:54:17 -0400 Subject: [PATCH 51/80] Add templates directly from cms_proto/ui_prototype --- cms/djangoapps/contentstore/views.py | 4 + cms/static/css/base-style.css | 589 +++++++++++++++++ cms/static/css/ie.css | 196 ++++++ cms/static/css/style.css | 0 cms/static/img/indicator.gif | Bin 0 -> 1553 bytes cms/static/img/video.jpg | Bin 0 -> 7217 bytes cms/static/js/jquery.inlineedit.js | 251 ++++++++ cms/static/js/jquery.leanModal.min.js | 5 + cms/static/js/jquery.tablednd.js | 257 ++++++++ cms/static/js/main.js | 159 +++++ cms/static/js/markitup/jquery.markitup.js | 593 ++++++++++++++++++ .../js/markitup/sets/wiki/images/bold.png | Bin 0 -> 304 bytes .../js/markitup/sets/wiki/images/clean.png | Bin 0 -> 667 bytes .../js/markitup/sets/wiki/images/code.png | Bin 0 -> 859 bytes .../js/markitup/sets/wiki/images/h1.png | Bin 0 -> 276 bytes .../js/markitup/sets/wiki/images/h2.png | Bin 0 -> 304 bytes .../js/markitup/sets/wiki/images/h3.png | Bin 0 -> 306 bytes .../js/markitup/sets/wiki/images/h4.png | Bin 0 -> 293 bytes .../js/markitup/sets/wiki/images/h5.png | Bin 0 -> 304 bytes .../js/markitup/sets/wiki/images/image.png | Bin 0 -> 516 bytes .../js/markitup/sets/wiki/images/italic.png | Bin 0 -> 223 bytes .../js/markitup/sets/wiki/images/link.png | Bin 0 -> 343 bytes .../markitup/sets/wiki/images/list-bullet.png | Bin 0 -> 344 bytes .../sets/wiki/images/list-numeric.png | Bin 0 -> 357 bytes .../js/markitup/sets/wiki/images/picture.png | Bin 0 -> 606 bytes .../js/markitup/sets/wiki/images/preview.png | Bin 0 -> 537 bytes .../js/markitup/sets/wiki/images/quotes.png | Bin 0 -> 743 bytes .../js/markitup/sets/wiki/images/stroke.png | Bin 0 -> 269 bytes .../js/markitup/sets/wiki/images/url.png | Bin 0 -> 957 bytes cms/static/js/markitup/sets/wiki/set.js | 34 + cms/static/js/markitup/sets/wiki/style.css | 57 ++ .../markitup/skins/simple/images/handle.png | Bin 0 -> 258 bytes .../js/markitup/skins/simple/images/menu.png | Bin 0 -> 27151 bytes .../markitup/skins/simple/images/submenu.png | Bin 0 -> 240 bytes cms/static/js/markitup/skins/simple/style.css | 118 ++++ cms/static/sass/_base.scss | 51 ++ cms/static/sass/_calendar.scss | 206 ++++++ cms/static/sass/_problem.scss | 41 ++ cms/static/sass/_reset.scss | 229 +++++++ cms/static/sass/_video.scss | 40 ++ cms/static/sass/_week.scss | 152 +++++ cms/static/sass/base-style.scss | 18 + cms/static/sass/bourbon/_bourbon.scss | 35 ++ cms/static/sass/bourbon/addons/_button.scss | 267 ++++++++ cms/static/sass/bourbon/addons/_clearfix.scss | 29 + .../sass/bourbon/addons/_font-family.scss | 5 + .../bourbon/addons/_html5-input-types.scss | 36 ++ cms/static/sass/bourbon/addons/_position.scss | 30 + .../bourbon/addons/_timing-functions.scss | 32 + cms/static/sass/bourbon/css3/_animation.scss | 171 +++++ cms/static/sass/bourbon/css3/_appearance.scss | 7 + .../sass/bourbon/css3/_background-image.scss | 57 ++ .../sass/bourbon/css3/_background-size.scss | 15 + .../sass/bourbon/css3/_border-image.scss | 56 ++ .../sass/bourbon/css3/_border-radius.scss | 63 ++ cms/static/sass/bourbon/css3/_box-shadow.scss | 14 + cms/static/sass/bourbon/css3/_box-sizing.scss | 6 + cms/static/sass/bourbon/css3/_columns.scss | 67 ++ cms/static/sass/bourbon/css3/_flex-box.scss | 67 ++ .../sass/bourbon/css3/_inline-block.scss | 10 + .../sass/bourbon/css3/_linear-gradient.scss | 41 ++ .../sass/bourbon/css3/_radial-gradient.scss | 31 + cms/static/sass/bourbon/css3/_transform.scss | 19 + cms/static/sass/bourbon/css3/_transition.scss | 104 +++ .../sass/bourbon/css3/_user-select.scss | 6 + .../_deprecated-webkit-gradient.scss | 36 ++ .../sass/bourbon/functions/_flex-grid.scss | 35 ++ .../sass/bourbon/functions/_grid-width.scss | 13 + .../bourbon/functions/_linear-gradient.scss | 23 + .../bourbon/functions/_modular-scale.scss | 40 ++ .../bourbon/functions/_radial-gradient.scss | 15 + .../bourbon/functions/_render-gradients.scss | 14 + .../sass/bourbon/functions/_tint-shade.scss | 9 + cms/static/sass/bourbon/lib/bourbon.rb | 19 + .../bourbon/lib/bourbon/sass_extensions.rb | 6 + .../lib/bourbon/sass_extensions/functions.rb | 13 + .../sass_extensions/functions/compact.rb | 13 + cms/templates/base.html | 30 + cms/templates/index.html | 19 + cms/templates/widgets/captions.html | 242 +++++++ cms/templates/widgets/header.html | 5 + cms/templates/widgets/navigation.html | 120 ++++ cms/templates/widgets/new-module.html | 9 + cms/templates/widgets/problem-edit.html | 73 +++ cms/templates/widgets/problem-new.html | 52 ++ cms/templates/widgets/raw-videos.html | 3 + cms/templates/widgets/save-captions.html | 4 + cms/templates/widgets/speed-tooltip.html | 7 + cms/templates/widgets/video-box-unused.html | 38 ++ cms/templates/widgets/video-box.html | 35 ++ cms/templates/widgets/video-edit.html | 151 +++++ cms/templates/widgets/video-new.html | 48 ++ cms/templates/widgets/week-edit.html | 83 +++ cms/templates/widgets/week-new.html | 62 ++ cms/urls.py | 1 + 95 files changed, 5386 insertions(+) create mode 100644 cms/static/css/base-style.css create mode 100644 cms/static/css/ie.css create mode 100644 cms/static/css/style.css create mode 100755 cms/static/img/indicator.gif create mode 100644 cms/static/img/video.jpg create mode 100755 cms/static/js/jquery.inlineedit.js create mode 100644 cms/static/js/jquery.leanModal.min.js create mode 100644 cms/static/js/jquery.tablednd.js create mode 100644 cms/static/js/main.js create mode 100644 cms/static/js/markitup/jquery.markitup.js create mode 100644 cms/static/js/markitup/sets/wiki/images/bold.png create mode 100644 cms/static/js/markitup/sets/wiki/images/clean.png create mode 100644 cms/static/js/markitup/sets/wiki/images/code.png create mode 100644 cms/static/js/markitup/sets/wiki/images/h1.png create mode 100644 cms/static/js/markitup/sets/wiki/images/h2.png create mode 100644 cms/static/js/markitup/sets/wiki/images/h3.png create mode 100644 cms/static/js/markitup/sets/wiki/images/h4.png create mode 100644 cms/static/js/markitup/sets/wiki/images/h5.png create mode 100644 cms/static/js/markitup/sets/wiki/images/image.png create mode 100644 cms/static/js/markitup/sets/wiki/images/italic.png create mode 100644 cms/static/js/markitup/sets/wiki/images/link.png create mode 100644 cms/static/js/markitup/sets/wiki/images/list-bullet.png create mode 100644 cms/static/js/markitup/sets/wiki/images/list-numeric.png create mode 100644 cms/static/js/markitup/sets/wiki/images/picture.png create mode 100644 cms/static/js/markitup/sets/wiki/images/preview.png create mode 100644 cms/static/js/markitup/sets/wiki/images/quotes.png create mode 100644 cms/static/js/markitup/sets/wiki/images/stroke.png create mode 100644 cms/static/js/markitup/sets/wiki/images/url.png create mode 100644 cms/static/js/markitup/sets/wiki/set.js create mode 100644 cms/static/js/markitup/sets/wiki/style.css create mode 100644 cms/static/js/markitup/skins/simple/images/handle.png create mode 100644 cms/static/js/markitup/skins/simple/images/menu.png create mode 100644 cms/static/js/markitup/skins/simple/images/submenu.png create mode 100644 cms/static/js/markitup/skins/simple/style.css create mode 100644 cms/static/sass/_base.scss create mode 100644 cms/static/sass/_calendar.scss create mode 100644 cms/static/sass/_problem.scss create mode 100644 cms/static/sass/_reset.scss create mode 100644 cms/static/sass/_video.scss create mode 100644 cms/static/sass/_week.scss create mode 100644 cms/static/sass/base-style.scss create mode 100644 cms/static/sass/bourbon/_bourbon.scss create mode 100644 cms/static/sass/bourbon/addons/_button.scss create mode 100644 cms/static/sass/bourbon/addons/_clearfix.scss create mode 100644 cms/static/sass/bourbon/addons/_font-family.scss create mode 100644 cms/static/sass/bourbon/addons/_html5-input-types.scss create mode 100644 cms/static/sass/bourbon/addons/_position.scss create mode 100644 cms/static/sass/bourbon/addons/_timing-functions.scss create mode 100644 cms/static/sass/bourbon/css3/_animation.scss create mode 100644 cms/static/sass/bourbon/css3/_appearance.scss create mode 100644 cms/static/sass/bourbon/css3/_background-image.scss create mode 100644 cms/static/sass/bourbon/css3/_background-size.scss create mode 100644 cms/static/sass/bourbon/css3/_border-image.scss create mode 100644 cms/static/sass/bourbon/css3/_border-radius.scss create mode 100644 cms/static/sass/bourbon/css3/_box-shadow.scss create mode 100644 cms/static/sass/bourbon/css3/_box-sizing.scss create mode 100644 cms/static/sass/bourbon/css3/_columns.scss create mode 100644 cms/static/sass/bourbon/css3/_flex-box.scss create mode 100644 cms/static/sass/bourbon/css3/_inline-block.scss create mode 100644 cms/static/sass/bourbon/css3/_linear-gradient.scss create mode 100644 cms/static/sass/bourbon/css3/_radial-gradient.scss create mode 100644 cms/static/sass/bourbon/css3/_transform.scss create mode 100644 cms/static/sass/bourbon/css3/_transition.scss create mode 100644 cms/static/sass/bourbon/css3/_user-select.scss create mode 100644 cms/static/sass/bourbon/functions/_deprecated-webkit-gradient.scss create mode 100644 cms/static/sass/bourbon/functions/_flex-grid.scss create mode 100644 cms/static/sass/bourbon/functions/_grid-width.scss create mode 100644 cms/static/sass/bourbon/functions/_linear-gradient.scss create mode 100644 cms/static/sass/bourbon/functions/_modular-scale.scss create mode 100644 cms/static/sass/bourbon/functions/_radial-gradient.scss create mode 100644 cms/static/sass/bourbon/functions/_render-gradients.scss create mode 100644 cms/static/sass/bourbon/functions/_tint-shade.scss create mode 100644 cms/static/sass/bourbon/lib/bourbon.rb create mode 100644 cms/static/sass/bourbon/lib/bourbon/sass_extensions.rb create mode 100644 cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions.rb create mode 100644 cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions/compact.rb create mode 100644 cms/templates/base.html create mode 100644 cms/templates/index.html create mode 100644 cms/templates/widgets/captions.html create mode 100644 cms/templates/widgets/header.html create mode 100644 cms/templates/widgets/navigation.html create mode 100644 cms/templates/widgets/new-module.html create mode 100644 cms/templates/widgets/problem-edit.html create mode 100644 cms/templates/widgets/problem-new.html create mode 100644 cms/templates/widgets/raw-videos.html create mode 100644 cms/templates/widgets/save-captions.html create mode 100644 cms/templates/widgets/speed-tooltip.html create mode 100644 cms/templates/widgets/video-box-unused.html create mode 100644 cms/templates/widgets/video-box.html create mode 100644 cms/templates/widgets/video-edit.html create mode 100644 cms/templates/widgets/video-new.html create mode 100644 cms/templates/widgets/week-edit.html create mode 100644 cms/templates/widgets/week-new.html diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index c6786b03c4..38e9e8ad35 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -10,3 +10,7 @@ def calendar(request, org, course): Location(['i4x', org, course, 'Course', 'course']) ) return render_to_response('calendar.html', {'weeks': weeks}) + + +def index(request): + return render_to_response('index.html', {}) diff --git a/cms/static/css/base-style.css b/cms/static/css/base-style.css new file mode 100644 index 0000000000..2cdeafe9e5 --- /dev/null +++ b/cms/static/css/base-style.css @@ -0,0 +1,589 @@ +html, body, div, span, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +abbr, address, cite, code, +del, dfn, em, img, ins, kbd, q, samp, +small, strong, sub, sup, var, +b, i, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, figcaption, figure, +footer, header, hgroup, menu, nav, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + outline: 0; + vertical-align: baseline; + background: transparent; } + +html, body { + font-size: 100%; } + +article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { + display: block; } + +audio, canvas, video { + display: inline-block; } + +audio:not([controls]) { + display: none; } + +[hidden] { + display: none; } + +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; } + +html, button, input, select, textarea { + font-family: sans-serif; } + +a:focus { + outline: thin dotted; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; } +a:hover, a:active { + outline: 0; } + +abbr[title] { + border-bottom: 1px dotted; } + +b, strong { + font-weight: bold; } + +blockquote { + margin: 1em 40px; } + +dfn { + font-style: italic; } + +mark { + background: #ff0; + color: #000; } + +pre, code, kbd, samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; } + +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; } + +blockquote, q { + quotes: none; } + blockquote:before, blockquote:after, q:before, q:after { + content: ''; + content: none; } + +small { + font-size: 75%; } + +sub, sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; } + +sup { + top: -0.5em; } + +sub { + bottom: -0.25em; } + +nav ul, nav ol { + list-style: none; + list-style-image: none; } + +img { + border: 0; + height: auto; + max-width: 100%; + -ms-interpolation-mode: bicubic; } + +svg:not(:root) { + overflow: hidden; } + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; } + +legend { + border: 0; + padding: 0; + white-space: normal; } + +button, input, select, textarea { + font-size: 100%; + margin: 0; + vertical-align: baseline; } + +button, input { + line-height: normal; } + +button, input[type="button"], input[type="reset"], input[type="submit"] { + cursor: pointer; + -webkit-appearance: button; } + +button[disabled], input[disabled] { + cursor: default; } + +input[type="checkbox"], input[type="radio"] { + box-sizing: border-box; + padding: 0; } + +input[type="search"] { + -webkit-appearance: textfield; + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + box-sizing: content-box; } + +input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; } + +button::-moz-focus-inner, input::-moz-focus-inner { + border: 0; + padding: 0; } + +textarea { + overflow: auto; + vertical-align: top; } + +table { + border-collapse: collapse; + border-spacing: 0; } + +html { + height: 100%; } + +body { + zoom: 1; + height: 100%; + font: 14px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif; } + body:before, body:after { + content: ""; + display: table; } + body:after { + clear: both; } + body > section { + display: table; + width: 100%; } + body > header { + background: #000; + color: #fff; + display: block; + float: none; + padding: 6px 20px; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + body > header nav { + zoom: 1; } + body > header nav:before, body > header nav:after { + content: ""; + display: table; } + body > header nav:after { + clear: both; } + body > header nav h2 { + font-size: 14px; + text-transform: uppercase; } + +a { + text-decoration: none; + color: #888; } + +input[type="submit"], .button, section.week-edit > header a, section.week-new > header a { + border: 1px solid #ccc; + background: #efefef; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; + padding: 6px; } + +section.cal { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 25px; + zoom: 1; + overflow: scroll; } + section.cal:before, section.cal:after { + content: ""; + display: table; } + section.cal:after { + clear: both; } + section.cal > header { + zoom: 1; + margin-bottom: 10px; } + section.cal > header:before, section.cal > header:after { + content: ""; + display: table; } + section.cal > header:after { + clear: both; } + section.cal > header h1 { + float: left; + font-size: 18px; } + section.cal > header ul { + float: right; } + section.cal > header ul li { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.cal > header ul li a { + padding: 6px; + border: 1px solid #ddd; + display: block; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; + background: #efefef; } + section.cal > header ul li.dropdown { + position: relative; } + section.cal > header ul li.dropdown ul { + display: none; + position: absolute; + background: #fff; + border: 1px solid #ddd; } + section.cal > header ul li.dropdown ul li { + padding: 6px; + display: block; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; } + section.cal > header ul li.dropdown ul li:hover { + background-color: #efefef; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; } + section.cal > header ul li.dropdown:hover ul { + display: block; } + section.cal > header ul li.dropdown:hover a { + -webkit-border-radius: 3px 3px 0 0; + -moz-border-radius: 3px 3px 0 0; + -ms-border-radius: 3px 3px 0 0; + -o-border-radius: 3px 3px 0 0; + border-radius: 3px 3px 0 0; + border-bottom: 0; } + section.cal ol { + list-style: none; + zoom: 1; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border-left: 1px solid #333; + border-top: 1px solid #333; + width: 100%; } + section.cal ol:before, section.cal ol:after { + content: ""; + display: table; } + section.cal ol:after { + clear: both; } + section.cal ol > li { + border-right: 1px solid #333; + border-bottom: 1px solid; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + float: left; + width: 25.0%; } + section.cal ol > li:last-child { + text-align: center; + background: #eee; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + section.cal ol > li:last-child p { + width: 100%; + height: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + section.cal ol > li:last-child p a { + display: block; + width: 100%; + height: 100%; } + section.cal ol > li:last-child section.new-week header { + background: #fff; + text-align: left; } + section.cal ol > li:last-child section.new-week form { + background: #fff; + width: 50%; + padding: 6px; + border: 1px solid #000; + margin: 0 auto; + -webkit-box-shadow: 0 0 2px #333333; + -moz-box-shadow: 0 0 2px #333333; + box-shadow: 0 0 2px #333333; + position: relative; } + section.cal ol > li:last-child section.new-week form:before { + background: #fff; + border-left: 1px solid #000; + border-top: 1px solid #000; + content: " "; + display: block; + height: 10px; + left: 50%; + position: absolute; + top: -6px; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + width: 10px; + z-index: 0; } + section.cal ol > li:last-child section.new-week form select { + margin-bottom: 6px; + width: 100%; } + section.cal ol > li:last-child section.new-week form select option { + padding: 10px 0 !important; } + section.cal ol > li:last-child section.new-week form input[type="submit"] { + display: block; + margin-bottom: 6px; + width: 100%; } + section.cal ol > li:last-child section.new-week form a:first-child { + float: left; } + section.cal ol > li:last-child section.new-week form a:last-child { + float: right; } + section.cal ol > li header { + border-bottom: 1px solid #000; + -webkit-box-shadow: 0 1px 2px #cccccc; + -moz-box-shadow: 0 1px 2px #cccccc; + box-shadow: 0 1px 2px #cccccc; + display: block; + margin-bottom: 2px; + padding: 6px; } + section.cal ol > li header h1 { + font-size: 14px; } + section.cal ol > li ul { + list-style: none; + margin-bottom: 1px; } + section.cal ol > li ul li { + background: #efefef; + border-bottom: 1px solid #666; + padding: 6px; } + section.cal ol > li ul li.goal { + background: #fff; } + +body.content +section.cal { + width: 25.577%; + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + body.content + section.cal > header ul { + display: none; } + body.content + section.cal ol li { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 100%; } + +section.week-edit > header, section.week-new > header { + border-bottom: 1px solid #ccc; + zoom: 1; + padding: 6px; } + section.week-edit > header:before, section.week-edit > header:after, section.week-new > header:before, section.week-new > header:after { + content: ""; + display: table; } + section.week-edit > header:after, section.week-new > header:after { + clear: both; } + section.week-edit > header h1, section.week-new > header h1 { + font-size: 18px; + float: left; + margin-top: 8px 6px; } + section.week-edit > header a, section.week-new > header a { + float: right; + display: block; } +section.week-edit section header, section.week-new section header { + background: #666; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; } + section.week-edit section header h2, section.week-new section header h2 { + font-size: 14px; } +section.week-edit section.sidebar, section.week-new section.sidebar { + width: 34.368%; + float: left; + background: #ccc; + border-right: 1px solid #333; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + section.week-edit section.sidebar section, section.week-new section.sidebar section { + height: 50%; } + section.week-edit section.sidebar section > ul, section.week-new section.sidebar section > ul { + list-style: none; } + section.week-edit section.sidebar section > ul > li, section.week-new section.sidebar section > ul > li { + padding: 6px; + border-bottom: 1px solid #666; + background: #eee; } + section.week-edit section.sidebar section > ul > li.new-module, section.week-new section.sidebar section > ul > li.new-module { + position: relative; } + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown { + list-style: none; } + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown li, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown li { + display: none; } + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown li:first-child, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown li:first-child { + display: block; } + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown:hover li { + display: block; + padding: 6px 0; } + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li:first-child, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown:hover li:first-child { + padding-top: 0; } + section.week-edit section.sidebar section p, section.week-new section.sidebar section p { + padding: 6px; + border-bottom: 1px solid #666; } +section.week-edit section.weeks-content, section.week-new section.weeks-content { + width: 65.632%; + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + section.week-edit section.weeks-content header, section.week-new section.weeks-content header { + zoom: 1; } + section.week-edit section.weeks-content header:before, section.week-edit section.weeks-content header:after, section.week-new section.weeks-content header:before, section.week-new section.weeks-content header:after { + content: ""; + display: table; } + section.week-edit section.weeks-content header:after, section.week-new section.weeks-content header:after { + clear: both; } + section.week-edit section.weeks-content header h2, section.week-new section.weeks-content header h2 { + float: left; } + section.week-edit section.weeks-content header form, section.week-new section.weeks-content header form { + float: right; + margin: -2px 0; } + section.week-edit section.weeks-content header form input, section.week-new section.weeks-content header form input { + border: 1px solid #000; + background: #ddd; + padding: 2px 4px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + -ms-border-radius: 2px; + -o-border-radius: 2px; + border-radius: 2px; } + section.week-edit section.weeks-content section.filters, section.week-new section.weeks-content section.filters { + border-bottom: 1px solid #999; } + section.week-edit section.weeks-content section.filters ul, section.week-new section.weeks-content section.filters ul { + zoom: 1; + list-style: none; + padding: 6px; } + section.week-edit section.weeks-content section.filters ul:before, section.week-edit section.weeks-content section.filters ul:after, section.week-new section.weeks-content section.filters ul:before, section.week-new section.weeks-content section.filters ul:after { + content: ""; + display: table; } + section.week-edit section.weeks-content section.filters ul:after, section.week-new section.weeks-content section.filters ul:after { + clear: both; } + section.week-edit section.weeks-content section.filters ul li, section.week-new section.weeks-content section.filters ul li { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.week-edit section.weeks-content section.filters ul li.advanced, section.week-new section.weeks-content section.filters ul li.advanced { + float: right; } + section.week-edit section.weeks-content section.modules ul, section.week-new section.weeks-content section.modules ul { + list-style: none; } + section.week-edit section.weeks-content section.modules ul li, section.week-new section.weeks-content section.modules ul li { + padding: 6px; + font-weight: bold; + font-size: 16px; + border-bottom: 1px solid #333; } + section.week-edit section.weeks-content section.modules ul li a, section.week-new section.weeks-content section.modules ul li a { + color: #000; } + +section.video-new, section.video-edit { + position: absolute; + top: 80px; + right: 0; + background: #fff; + width: 40.32%; + -webkit-box-shadow: 0 0 6px #666666; + -moz-box-shadow: 0 0 6px #666666; + box-shadow: 0 0 6px #666666; + border: 1px solid #333; + border-right: 0; + z-index: 4; } + section.video-new > header, section.video-edit > header { + background: #666; + zoom: 1; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; } + section.video-new > header:before, section.video-new > header:after, section.video-edit > header:before, section.video-edit > header:after { + content: ""; + display: table; } + section.video-new > header:after, section.video-edit > header:after { + clear: both; } + section.video-new > header h2, section.video-edit > header h2 { + float: left; + font-size: 14px; } + section.video-new > header a, section.video-edit > header a { + float: right; } + section.video-new section ul, section.video-edit section ul { + list-style: none; } + section.video-new section ul li, section.video-edit section ul li { + border-bottom: 1px solid #333; + padding: 10px 25px; } + +section.problem-new, section.problem-edit { + position: absolute; + top: 80px; + right: 0; + background: #fff; + width: 40.32%; + -webkit-box-shadow: 0 0 6px #666666; + -moz-box-shadow: 0 0 6px #666666; + box-shadow: 0 0 6px #666666; + border: 1px solid #333; + border-right: 0; + z-index: 4; } + section.problem-new > header, section.problem-edit > header { + background: #666; + zoom: 1; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; } + section.problem-new > header:before, section.problem-new > header:after, section.problem-edit > header:before, section.problem-edit > header:after { + content: ""; + display: table; } + section.problem-new > header:after, section.problem-edit > header:after { + clear: both; } + section.problem-new > header h2, section.problem-edit > header h2 { + float: left; + font-size: 14px; } + section.problem-new > header a, section.problem-edit > header a { + float: right; } + section.problem-new section ul, section.problem-edit section ul { + list-style: none; } + section.problem-new section ul li, section.problem-edit section ul li { + border-bottom: 1px solid #333; + padding: 10px 25px; } + +body.content section.main-content { + border-left: 2px solid #000; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 74.423%; + float: left; + -webkit-box-shadow: -2px 0 3px #dddddd; + -moz-box-shadow: -2px 0 3px #dddddd; + box-shadow: -2px 0 3px #dddddd; } diff --git a/cms/static/css/ie.css b/cms/static/css/ie.css new file mode 100644 index 0000000000..f497a329cf --- /dev/null +++ b/cms/static/css/ie.css @@ -0,0 +1,196 @@ +/* line 12, ../sass/_reset.scss */ +html, body, div, span, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +abbr, address, cite, code, +del, dfn, em, img, ins, kbd, q, samp, +small, strong, sub, sup, var, +b, i, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, figcaption, figure, +footer, header, hgroup, menu, nav, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + outline: 0; + vertical-align: baseline; + background: transparent; } + +/* line 21, ../sass/_reset.scss */ +html, body { + font-size: 100%; } + +/* line 26, ../sass/_reset.scss */ +article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { + display: block; } + +/* line 31, ../sass/_reset.scss */ +audio, canvas, video { + display: inline-block; } + +/* line 36, ../sass/_reset.scss */ +audio:not([controls]) { + display: none; } + +/* line 41, ../sass/_reset.scss */ +[hidden] { + display: none; } + +/* line 47, ../sass/_reset.scss */ +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; } + +/* line 54, ../sass/_reset.scss */ +html, button, input, select, textarea { + font-family: sans-serif; } + +/* line 60, ../sass/_reset.scss */ +a:focus { + outline: thin dotted; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; } +/* line 69, ../sass/_reset.scss */ +a:hover, a:active { + outline: 0; } + +/* line 75, ../sass/_reset.scss */ +abbr[title] { + border-bottom: 1px dotted; } + +/* line 80, ../sass/_reset.scss */ +b, strong { + font-weight: bold; } + +/* line 84, ../sass/_reset.scss */ +blockquote { + margin: 1em 40px; } + +/* line 89, ../sass/_reset.scss */ +dfn { + font-style: italic; } + +/* line 94, ../sass/_reset.scss */ +mark { + background: #ff0; + color: #000; } + +/* line 101, ../sass/_reset.scss */ +pre, code, kbd, samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; } + +/* line 108, ../sass/_reset.scss */ +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; } + +/* line 115, ../sass/_reset.scss */ +blockquote, q { + quotes: none; } + /* line 117, ../sass/_reset.scss */ + blockquote:before, blockquote:after, q:before, q:after { + content: ''; + content: none; } + +/* line 123, ../sass/_reset.scss */ +small { + font-size: 75%; } + +/* line 127, ../sass/_reset.scss */ +sub, sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; } + +/* line 134, ../sass/_reset.scss */ +sup { + top: -0.5em; } + +/* line 138, ../sass/_reset.scss */ +sub { + bottom: -0.25em; } + +/* line 143, ../sass/_reset.scss */ +nav ul, nav ol { + list-style: none; + list-style-image: none; } + +/* line 150, ../sass/_reset.scss */ +img { + border: 0; + height: auto; + max-width: 100%; + -ms-interpolation-mode: bicubic; } + +/* line 158, ../sass/_reset.scss */ +svg:not(:root) { + overflow: hidden; } + +/* line 163, ../sass/_reset.scss */ +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; } + +/* line 169, ../sass/_reset.scss */ +legend { + border: 0; + padding: 0; + white-space: normal; } + +/* line 175, ../sass/_reset.scss */ +button, input, select, textarea { + font-size: 100%; + margin: 0; + vertical-align: baseline; } + +/* line 182, ../sass/_reset.scss */ +button, input { + line-height: normal; } + +/* line 186, ../sass/_reset.scss */ +button, input[type="button"], input[type="reset"], input[type="submit"] { + cursor: pointer; + -webkit-appearance: button; } + +/* line 192, ../sass/_reset.scss */ +button[disabled], input[disabled] { + cursor: default; } + +/* line 196, ../sass/_reset.scss */ +input[type="checkbox"], input[type="radio"] { + box-sizing: border-box; + padding: 0; } + +/* line 201, ../sass/_reset.scss */ +input[type="search"] { + -webkit-appearance: textfield; + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + box-sizing: content-box; } + +/* line 209, ../sass/_reset.scss */ +input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; } + +/* line 215, ../sass/_reset.scss */ +button::-moz-focus-inner, input::-moz-focus-inner { + border: 0; + padding: 0; } + +/* line 220, ../sass/_reset.scss */ +textarea { + overflow: auto; + vertical-align: top; } + +/* line 226, ../sass/_reset.scss */ +table { + border-collapse: collapse; + border-spacing: 0; } diff --git a/cms/static/css/style.css b/cms/static/css/style.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cms/static/img/indicator.gif b/cms/static/img/indicator.gif new file mode 100755 index 0000000000000000000000000000000000000000..085ccaecaf5fa5c34bc14cd2c2ed5cbbd8e25dcb GIT binary patch literal 1553 zcma)+TTl~c6vwlh>nb99Af5rT)t{mCEg5urg=A(g z{C|6SPb~9Xage|wB`SrZk2FOMYM!buln2sX?5Y+T78iB(Zu9cS7|LZyZ++}u$^oi1 z_j@S}bW9OzU2R+RMy&~OT>X-oZ98$jq#ogNfJ!BM-42wHGZk*6s2KD}U*IA%epmxb zm}|6BK9YoIF;*xSL!+z@<64lB7->LTW2Vi4ostCA(z&2XniwNIv}fFo-`MbG;)u4G z^p@F!)|9HhZprHd_vXjDoxs6WkK-6P0@lfxnGT>*p(QHoUV=u1FAqb@b%*W=a3{`LsH5k^AvQNL>6fPpy#oU(&MuH(*aEX4b35*} zn4n7)`I2U%=+Z=?BVZQ?vjQFW4gD@~XSOO6b{qu81`4&LFuU2(ilxW+1|ZkNMnWe79C$gs zWT?Ele|HR{JGPe)5BTW>0Ey?-Ls6S#GoV0tbt6ku7B&*0 z;i9QM$W1Rj*rRIdceL)rAOSl+sDe3LkB87<%){;ZdHp6|SNlopDXRx< zxBDF9-lTo&v`8$humFygUij@qgT=Qzhj8{ym2-{Xciwqq_Xwk%=O3B-MNAL_6e`3U zyxwmXex4`g0^1RYw~Dth3av3Dl^AAlpO3mG!nLr#&ZZ7c_wUboI+deC+&%TFjK2Lm z!Y&f1h|T_On%RCV&=4bx`!>(YezqGVhl&QpED?N6GV)HmzJ9&rh$x*i?*@o9#6QI< z5ZI_MRX;0+pY8$`j)eF#TlUyG(eE%E7S!rj;mj^M5vhUicPm zVWQ2z+imFyg}SRABmOBY_@osR!>7Ov!ioK`NB6_Rv}7Ud?35ed5Sb@?yND?kv~RCa wqs^a3Sh>&&L4)!LKI?D2&k@))k(LESaga|C278ChSzn3NWVkcuNoY&{0f?~U_5c6? literal 0 HcmV?d00001 diff --git a/cms/static/img/video.jpg b/cms/static/img/video.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e92271c3ad5e23185f1fac4bbf5954df735d5949 GIT binary patch literal 7217 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 + * Licensed under the MIT (MIT-LICENSE.txt) license. + * + * http://github.com/caphun/jquery.inlineedit/ + * + * Inline (in-place) editing. + */ + +(function($) { + +// cached values +var namespace = '.inlineedit', + placeholderClass = 'inlineEdit-placeholder'; + +// define inlineEdit method +$.fn.inlineEdit = function( options ) { + var self = this; + + return this + + .each( function() { + $.inlineEdit.getInstance( this, options ).initValue(); + }) + + .live( ['click', 'mouseenter','mouseleave'].join(namespace+' '), function( event ) { + + var widget = $.inlineEdit.getInstance( this, options ), + editableElement = widget.element.find( widget.options.control ), + mutated = !!editableElement.length; + + widget.element.removeClass( widget.options.hover ); + + if ( event.target !== editableElement[0] ) { + switch ( event.type ) { + case 'click': + widget[ mutated ? 'mutate' : 'init' ](); + break; + + case 'mouseover': // jquery 1.4.x + case 'mouseout': // jquery 1.4.x + case 'mouseenter': + case 'mouseleave': + if ( !mutated ) { + widget.hoverClassChange( event ); + } + break; + } + } + + }); +} + +// plugin constructor +$.inlineEdit = function( elem, options ) { + + // deep extend + this.options = $.extend( true, {}, $.inlineEdit.defaults, options ); + + // the original element + this.element = $( elem ); + +} + +// plugin instance +$.inlineEdit.getInstance = function( elem, options ) { + return ( $.inlineEdit.initialised( elem ) ) + ? $( elem ).data( 'widget' + namespace ) + : new $.inlineEdit( elem, options ); +} + +// check if plugin initialised +$.inlineEdit.initialised = function( elem ) { + var init = $( elem ).data( 'init' + namespace ); + return init !== undefined && init !== null ? true : false; +} + +// plugin defaults +$.inlineEdit.defaults = { + hover: 'ui-state-hover', + value: '', + save: '', + buttons: ' ', + placeholder: 'Click to edit', + control: 'input', + cancelOnBlur: false, + saveOnBlur: false +}; + +// plugin prototypes +$.inlineEdit.prototype = { + + // initialisation + init: function() { + + // set initialise flag + this.element.data( 'init' + namespace, true ); + + // initialise value + this.initValue(); + + // mutate + this.mutate(); + + // save widget data + this.element.data( 'widget' + namespace, this ); + + }, + + initValue: function() { + this.value( $.trim( this.element.text() ) || this.options.value ); + + if ( !this.value() ) { + this.element.html( $( this.placeholderHtml() ) ); + } else if ( this.options.value ) { + this.element.html( this.options.value ); + } + }, + + mutate: function() { + var self = this; + + return self + .element + .html( self.mutatedHtml( self.value() ) ) + .find( 'button.save' ) + .bind( 'click', function( event ) { + self.save( self.element, event ); + self.change( self.element, event ); + return false; + }) + .end() + .find( 'button.cancel' ) + .bind( 'click', function( event ) { + self.change( self.element, event ); + return false; + }) + .end() + .find( self.options.control ) + .bind( 'blur', function( event ) { + if (self.options.cancelOnBlur === true) + self.change( self.element, event ); + else if (self.options.saveOnBlur == true){ + self.save( self.element, event ); + self.change( self.element, event ); + } + }) + .bind( 'keyup', function( event ) { + switch ( event.keyCode ) { + case 13: // save on ENTER + if (self.options.control !== 'textarea') { + self.save( self.element, event ); + self.change( self.element, event ); + } + break; + case 27: // cancel on ESC + self.change( self.element, event ); + break; + } + }) + .focus() + .end(); + }, + + value: function( newValue ) { + if ( arguments.length ) { + var value = newValue === this.options.placeholder ? '' : newValue; + this.element.data( 'value' + namespace, $( '.' + placeholderClass, this ).length ? '' : value && this.encodeHtml( value.replace( /\n/g,"
" ) ) ); + } + return this.element.data( 'value' + namespace ); + }, + + mutatedHtml: function( value ) { + return this.controls[ this.options.control ].call( this, value ); + }, + + placeholderHtml: function() { + return ''+ this.options.placeholder +''; + }, + + buttonHtml: function( options ) { + var o = $.extend({}, { + before: ' ', + buttons: this.options.buttons, + after: '' + }, options); + + return o.before + o.buttons + o.after; + }, + + save: function( elem, event ) { + var $control = this.element.find( this.options.control ), + hash = { + value: this.encodeHtml( $control.val() ) + }; + + // save value back to control to avoid XSS + $control.val(hash.value); + + if ( ( $.isFunction( this.options.save ) && this.options.save.call( this.element[0], event, hash ) ) !== false || !this.options.save ) { + this.value( hash.value ); + } + }, + + change: function( elem, event ) { + var self = this; + + if ( this.timer ) { + window.clearTimeout( this.timer ); + } + + this.timer = window.setTimeout( function() { + self.element.html( self.value() || self.placeholderHtml() ); + self.element.removeClass( self.options.hover ); + }, 200 ); + + }, + + controls: { + textarea: function( value ) { + return '' + this.buttonHtml( { before: '
' } ); + }, + input: function( value ) { + return '' + this.buttonHtml(); + } + }, + + hoverClassChange: function( event ) { + $( event.target )[ /mouseover|mouseenter/.test( event.type ) ? 'addClass':'removeClass']( this.options.hover ); + }, + + encodeHtml: function( s ) { + var encoding = [ + {key: //g, value: '>'}, + {key: /"/g, value: '"'} + ], + value = s; + + $.each(encoding, function(i,n) { + value = value.replace(n.key, n.value); + }); + + return value; + } + +}; + +})(jQuery); diff --git a/cms/static/js/jquery.leanModal.min.js b/cms/static/js/jquery.leanModal.min.js new file mode 100644 index 0000000000..a5772dd8e2 --- /dev/null +++ b/cms/static/js/jquery.leanModal.min.js @@ -0,0 +1,5 @@ +// leanModal v1.1 by Ray Stone - http://finelysliced.com.au +// Dual licensed under the MIT and GPL + +(function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null};var overlay=$("
");$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");$("#lean_overlay").click(function(){close_modal(modal_id)});$(o.closeButton).click(function(){close_modal(modal_id)});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth(); +$("#lean_overlay").css({"display":"block",opacity:0});$("#lean_overlay").fadeTo(200,o.overlay);$(modal_id).css({"display":"block","position":"fixed","opacity":0,"z-index":11000,"left":50+"%","margin-left":-(modal_width/2)+"px","top":o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault()})});function close_modal(modal_id){$("#lean_overlay").fadeOut(200);$(modal_id).css({"display":"none"})}}})})(jQuery); diff --git a/cms/static/js/jquery.tablednd.js b/cms/static/js/jquery.tablednd.js new file mode 100644 index 0000000000..56413ccb08 --- /dev/null +++ b/cms/static/js/jquery.tablednd.js @@ -0,0 +1,257 @@ + +jQuery.tableDnD = { + /** Keep hold of the current table being dragged */ + currentTable : null, + /** Keep hold of the current drag object if any */ + dragObject: null, + /** The current mouse offset */ + mouseOffset: null, + /** Remember the old value of Y so that we don't do too much processing */ + oldY: 0, + + /** Actually build the structure */ + build: function(options) { + // Make sure options exists + options = options || {}; + // Set up the defaults if any + + this.each(function() { + // Remember the options + this.tableDnDConfig = { + onDragStyle: options.onDragStyle, + onDropStyle: options.onDropStyle, + // Add in the default class for whileDragging + onDragClass: options.onDragClass ? options.onDragClass : "dragged", + onDrop: options.onDrop, + onDragStart: options.onDragStart, + scrollAmount: options.scrollAmount ? options.scrollAmount : 5 + }; + // Now make the rows draggable + jQuery.tableDnD.makeDraggable(this); + }); + + // Now we need to capture the mouse up and mouse move event + // We can use bind so that we don't interfere with other event handlers + jQuery(document) + .bind('mousemove', jQuery.tableDnD.mousemove) + .bind('mouseup', jQuery.tableDnD.mouseup); + + // Don't break the chain + return this; + }, + + /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */ + makeDraggable: function(table) { + // Now initialise the rows + var rows = table.rows; //getElementsByTagName("tr") + var config = table.tableDnDConfig; + for (var i=0; i jQuery.tableDnD.oldY; + // update the old value + jQuery.tableDnD.oldY = y; + // update the style to show we're dragging + if (config.onDragClass) { + dragObj.addClass(config.onDragClass); + } else { + dragObj.css(config.onDragStyle); + } + // If we're over a row then move the dragged row to there so that the user sees the + // effect dynamically + var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y); + if (currentRow) { + // TODO worry about what happens when there are multiple TBODIES + if (movingDown && jQuery.tableDnD.dragObject != currentRow) { + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling); + } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) { + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow); + } + } + } + + return false; + }, + + /** We're only worried about the y position really, because we can only move rows up and down */ + findDropTargetRow: function(draggedRow, y) { + var rows = jQuery.tableDnD.currentTable.rows; + for (var i=0; i rowY - rowHeight) && (y < (rowY + rowHeight))) { + // that's the row we're over + // If it's the same as the current row, ignore it + if (row == draggedRow) {return null;} + var config = jQuery.tableDnD.currentTable.tableDnDConfig; + if (config.onAllowDrop) { + if (config.onAllowDrop(draggedRow, row)) { + return row; + } else { + return null; + } + } else { + // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic) + var nodrop = $(row).hasClass("nodrop"); + if (! nodrop) { + return row; + } else { + return null; + } + } + return row; + } + } + return null; + }, + + mouseup: function(e) { + if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) { + var droppedRow = jQuery.tableDnD.dragObject; + var config = jQuery.tableDnD.currentTable.tableDnDConfig; + // If we have a dragObject, then we need to release it, + // The row will already have been moved to the right place so we just reset stuff + if (config.onDragClass) { + jQuery(droppedRow).removeClass(config.onDragClass); + } else { + jQuery(droppedRow).css(config.onDropStyle); + } + jQuery.tableDnD.dragObject = null; + if (config.onDrop) { + // Call the onDrop method if there is one + config.onDrop(jQuery.tableDnD.currentTable, droppedRow); + } + jQuery.tableDnD.currentTable = null; // let go of the table too + } + }, + + serialize: function() { + if (jQuery.tableDnD.currentTable) { + var result = ""; + var tableId = jQuery.tableDnD.currentTable.id; + var rows = jQuery.tableDnD.currentTable.rows; + for (var i=0; i 0) result += "&"; + result += tableId + '[]=' + rows[i].id; + } + return result; + } else { + return "Error: No Table id set, you need to set an id on your table and every row"; + } + } +} + +jQuery.fn.extend( + { + tableDnD : jQuery.tableDnD.build + } + ); diff --git a/cms/static/js/main.js b/cms/static/js/main.js new file mode 100644 index 0000000000..45f94849f8 --- /dev/null +++ b/cms/static/js/main.js @@ -0,0 +1,159 @@ +$(document).ready(function(){ + $('section.main-content').children().hide(); + + $(function(){ + $('.editable').inlineEdit(); + $('.editable-textarea').inlineEdit({control: 'textarea'}); + }); + + // $("a[rel*=leanModal]").leanModal(); + + // $(".remove").click(function(){ + // $(this).parents('li').hide(); + // }); + + // $("#show-sidebar").click(function(){ + // $("#video-selector").toggleClass('hidden'); + // return false; + // }); + + // $('.use-video').click(function() { + // var used = $('#used'); + // if (used.is(':visible')) { + // used.hide().show('slow'); + // } + // used.show(); + // $('.no-video').hide(); + // }); + + // $('.remove-video').click(function() { + // $('#used').hide(); + // $('.no-video').show(); + // }); + + // $('#new-upload').click(function() { + // $('.selected-files').toggle(); + // return false; + // }); + + // /* $('.block').append('✕<\/a>'); */ + + // $('a.delete').click(function() { + // $(this).parents('.block').hide(); + // }); + + // $('.speed-list > li').hover(function(){ + // $(this).children('.tooltip').toggle(); + // }); + + // $('.delete-speed').click(function(){ + // $(this).parents('li.speed').hide(); + // return false; + // }); + + // $('.edit-captions').click(function(){ + // var parentVid = $(this).parents('div'); + // parentVid.siblings('div.caption-box').toggle(); + // return false; + // }); + + // $('.close-box').click(function(){ + // $(this).parents('.caption-box').hide(); + // return false; + // }); + + // $('ul.dropdown').hide(); + // $('li.questions').click(function() { + // $('ul.dropdown').toggle(); + // return false; + // }); + + // $('#mchoice').click(function(){ + // $('div.used').append($('
').load("/widgets/multi-choice.html")); + // return false; + // }); + + // $('#text').click(function(){ + // $('div.used').append($('
').load("/widgets/text.html")); + // return false; + // }); + + // $('#numerical').click(function(){ + // $('div.used').append($('
').load("/widgets/text-question.html")); + // return false; + // }); + + // $('#equation').click(function(){ + // $('div.used').append($('
').load("/widgets/latex-equation.html")); + // return false; + // }); + + // $('#script').click(function(){ + // $('div.used').append($('
').load("/widgets/script-widget.html")); + // return false; + // }); + + // $("#mark").markItUp(myWikiSettings); + + + var heighest = 0; + $('.cal ol > li').each(function(){ + heighest = ($(this).height() > heighest) ? $(this).height() : heighest; + + }); + + $('.cal ol > li').css('height',heighest + 'px'); + + $('.new-week').hide(); + $('.add-new-week').click(function() { + $(this).hide(); + $('.new-week').show(); + return false; + }); + + $('.new-week .close').click( function(){ + $(this).parents('.new-week').hide(); + $('p.add-new-week').show(); + return false; + }); + + var windowHeight = $(window).resize().height(); + + $('.sidebar').css('height', windowHeight); + + $('.edit-week').click( function() { + $('body').addClass('content'); + $('body.content .cal').css('height', windowHeight); + $('section.week-new').show(); + return false; + }); + + $('.cal ol li header h1 a').click( function() { + $('body').addClass('content'); + $('body.content .cal').css('height', windowHeight); + $('section.week-edit').show(); + return false; + }); + + + $('.video-new a').click(function(){ + $('section.video-new').show(); + return false; + }); + + $('.video-edit a').click(function(){ + $('section.video-edit').show(); + return false; + }); + + $('.problem-new a').click(function(){ + $('section.problem-new').show(); + return false; + }); + + $('.problem-edit a').click(function(){ + $('section.problem-edit').show(); + return false; + }); +}); + diff --git a/cms/static/js/markitup/jquery.markitup.js b/cms/static/js/markitup/jquery.markitup.js new file mode 100644 index 0000000000..10add9d27c --- /dev/null +++ b/cms/static/js/markitup/jquery.markitup.js @@ -0,0 +1,593 @@ +// ---------------------------------------------------------------------------- +// markItUp! Universal MarkUp Engine, JQuery plugin +// v 1.1.x +// Dual licensed under the MIT and GPL licenses. +// ---------------------------------------------------------------------------- +// Copyright (C) 2007-2011 Jay Salvat +// http://markitup.jaysalvat.com/ +// ---------------------------------------------------------------------------- +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// ---------------------------------------------------------------------------- +(function($) { + $.fn.markItUp = function(settings, extraSettings) { + var options, ctrlKey, shiftKey, altKey; + ctrlKey = shiftKey = altKey = false; + + options = { id: '', + nameSpace: '', + root: '', + previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes' + previewAutoRefresh: true, + previewPosition: 'after', + previewTemplatePath: '~/templates/preview.html', + previewParser: false, + previewParserPath: '', + previewParserVar: 'data', + resizeHandle: true, + beforeInsert: '', + afterInsert: '', + onEnter: {}, + onShiftEnter: {}, + onCtrlEnter: {}, + onTab: {}, + markupSet: [ { /* set */ } ] + }; + $.extend(options, settings, extraSettings); + + // compute markItUp! path + if (!options.root) { + $('script').each(function(a, tag) { + miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/); + if (miuScript !== null) { + options.root = miuScript[1]; + } + }); + } + + return this.each(function() { + var $$, textarea, levels, scrollPosition, caretPosition, caretOffset, + clicked, hash, header, footer, previewWindow, template, iFrame, abort; + $$ = $(this); + textarea = this; + levels = []; + abort = false; + scrollPosition = caretPosition = 0; + caretOffset = -1; + + options.previewParserPath = localize(options.previewParserPath); + options.previewTemplatePath = localize(options.previewTemplatePath); + + // apply the computed path to ~/ + function localize(data, inText) { + if (inText) { + return data.replace(/("|')~\//g, "$1"+options.root); + } + return data.replace(/^~\//, options.root); + } + + // init and build editor + function init() { + id = ''; nameSpace = ''; + if (options.id) { + id = 'id="'+options.id+'"'; + } else if ($$.attr("id")) { + id = 'id="markItUp'+($$.attr("id").substr(0, 1).toUpperCase())+($$.attr("id").substr(1))+'"'; + + } + if (options.nameSpace) { + nameSpace = 'class="'+options.nameSpace+'"'; + } + $$.wrap('
'); + $$.wrap('
'); + $$.wrap('
'); + $$.addClass("markItUpEditor"); + + // add the header before the textarea + header = $('
').insertBefore($$); + $(dropMenus(options.markupSet)).appendTo(header); + + // add the footer after the textarea + footer = $('
').insertAfter($$); + + // add the resize handle after textarea + if (options.resizeHandle === true && $.browser.safari !== true) { + resizeHandle = $('
') + .insertAfter($$) + .bind("mousedown", function(e) { + var h = $$.height(), y = e.clientY, mouseMove, mouseUp; + mouseMove = function(e) { + $$.css("height", Math.max(20, e.clientY+h-y)+"px"); + return false; + }; + mouseUp = function(e) { + $("html").unbind("mousemove", mouseMove).unbind("mouseup", mouseUp); + return false; + }; + $("html").bind("mousemove", mouseMove).bind("mouseup", mouseUp); + }); + footer.append(resizeHandle); + } + + // listen key events + $$.keydown(keyPressed).keyup(keyPressed); + + // bind an event to catch external calls + $$.bind("insertion", function(e, settings) { + if (settings.target !== false) { + get(); + } + if (textarea === $.markItUp.focused) { + markup(settings); + } + }); + + // remember the last focus + $$.focus(function() { + $.markItUp.focused = this; + }); + } + + // recursively build header with dropMenus from markupset + function dropMenus(markupSet) { + var ul = $('
    '), i = 0; + $('li:hover > ul', ul).css('display', 'block'); + $.each(markupSet, function() { + var button = this, t = '', title, li, j; + title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||''); + key = (button.key) ? 'accesskey="'+button.key+'"' : ''; + if (button.separator) { + li = $('
  • '+(button.separator||'')+'
  • ').appendTo(ul); + } else { + i++; + for (j = levels.length -1; j >= 0; j--) { + t += levels[j]+"-"; + } + li = $('
  • '+(button.name||'')+'
  • ') + .bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click + return false; + }).click(function() { + return false; + }).bind("focusin", function(){ + $$.focus(); + }).mouseup(function() { + if (button.call) { + eval(button.call)(); + } + setTimeout(function() { markup(button) },1); + return false; + }).hover(function() { + $('> ul', this).show(); + $(document).one('click', function() { // close dropmenu if click outside + $('ul ul', header).hide(); + } + ); + }, function() { + $('> ul', this).hide(); + } + ).appendTo(ul); + if (button.dropMenu) { + levels.push(i); + $(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu)); + } + } + }); + levels.pop(); + return ul; + } + + // markItUp! markups + function magicMarkups(string) { + if (string) { + string = string.toString(); + string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g, + function(x, a) { + var b = a.split('|!|'); + if (altKey === true) { + return (b[1] !== undefined) ? b[1] : b[0]; + } else { + return (b[1] === undefined) ? "" : b[0]; + } + } + ); + // [![prompt]!], [![prompt:!:value]!] + string = string.replace(/\[\!\[([\s\S]*?)\]\!\]/g, + function(x, a) { + var b = a.split(':!:'); + if (abort === true) { + return false; + } + value = prompt(b[0], (b[1]) ? b[1] : ''); + if (value === null) { + abort = true; + } + return value; + } + ); + return string; + } + return ""; + } + + // prepare action + function prepare(action) { + if ($.isFunction(action)) { + action = action(hash); + } + return magicMarkups(action); + } + + // build block to insert + function build(string) { + var openWith = prepare(clicked.openWith); + var placeHolder = prepare(clicked.placeHolder); + var replaceWith = prepare(clicked.replaceWith); + var closeWith = prepare(clicked.closeWith); + var openBlockWith = prepare(clicked.openBlockWith); + var closeBlockWith = prepare(clicked.closeBlockWith); + var multiline = clicked.multiline; + + if (replaceWith !== "") { + block = openWith + replaceWith + closeWith; + } else if (selection === '' && placeHolder !== '') { + block = openWith + placeHolder + closeWith; + } else { + string = string || selection; + + var lines = selection.split(/\r?\n/), blocks = []; + + for (var l=0; l < lines.length; l++) { + line = lines[l]; + var trailingSpaces; + if (trailingSpaces = line.match(/ *$/)) { + blocks.push(openWith + line.replace(/ *$/g, '') + closeWith + trailingSpaces); + } else { + blocks.push(openWith + line + closeWith); + } + } + + block = blocks.join("\n"); + } + + block = openBlockWith + block + closeBlockWith; + + return { block:block, + openWith:openWith, + replaceWith:replaceWith, + placeHolder:placeHolder, + closeWith:closeWith + }; + } + + // define markup to insert + function markup(button) { + var len, j, n, i; + hash = clicked = button; + get(); + $.extend(hash, { line:"", + root:options.root, + textarea:textarea, + selection:(selection||''), + caretPosition:caretPosition, + ctrlKey:ctrlKey, + shiftKey:shiftKey, + altKey:altKey + } + ); + // callbacks before insertion + prepare(options.beforeInsert); + prepare(clicked.beforeInsert); + if ((ctrlKey === true && shiftKey === true) || button.multiline === true) { + prepare(clicked.beforeMultiInsert); + } + $.extend(hash, { line:1 }); + + if ((ctrlKey === true && shiftKey === true)) { + lines = selection.split(/\r?\n/); + for (j = 0, n = lines.length, i = 0; i < n; i++) { + if ($.trim(lines[i]) !== '') { + $.extend(hash, { line:++j, selection:lines[i] } ); + lines[i] = build(lines[i]).block; + } else { + lines[i] = ""; + } + } + string = { block:lines.join('\n')}; + start = caretPosition; + len = string.block.length + (($.browser.opera) ? n-1 : 0); + } else if (ctrlKey === true) { + string = build(selection); + start = caretPosition + string.openWith.length; + len = string.block.length - string.openWith.length - string.closeWith.length; + len = len - (string.block.match(/ $/) ? 1 : 0); + len -= fixIeBug(string.block); + } else if (shiftKey === true) { + string = build(selection); + start = caretPosition; + len = string.block.length; + len -= fixIeBug(string.block); + } else { + string = build(selection); + start = caretPosition + string.block.length ; + len = 0; + start -= fixIeBug(string.block); + } + if ((selection === '' && string.replaceWith === '')) { + caretOffset += fixOperaBug(string.block); + + start = caretPosition + string.openWith.length; + len = string.block.length - string.openWith.length - string.closeWith.length; + + caretOffset = $$.val().substring(caretPosition, $$.val().length).length; + caretOffset -= fixOperaBug($$.val().substring(0, caretPosition)); + } + $.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } ); + + if (string.block !== selection && abort === false) { + insert(string.block); + set(start, len); + } else { + caretOffset = -1; + } + get(); + + $.extend(hash, { line:'', selection:selection }); + + // callbacks after insertion + if ((ctrlKey === true && shiftKey === true) || button.multiline === true) { + prepare(clicked.afterMultiInsert); + } + prepare(clicked.afterInsert); + prepare(options.afterInsert); + + // refresh preview if opened + if (previewWindow && options.previewAutoRefresh) { + refreshPreview(); + } + + // reinit keyevent + shiftKey = altKey = ctrlKey = abort = false; + } + + // Substract linefeed in Opera + function fixOperaBug(string) { + if ($.browser.opera) { + return string.length - string.replace(/\n*/g, '').length; + } + return 0; + } + // Substract linefeed in IE + function fixIeBug(string) { + if ($.browser.msie) { + return string.length - string.replace(/\r*/g, '').length; + } + return 0; + } + + // add markup + function insert(block) { + if (document.selection) { + var newSelection = document.selection.createRange(); + newSelection.text = block; + } else { + textarea.value = textarea.value.substring(0, caretPosition) + block + textarea.value.substring(caretPosition + selection.length, textarea.value.length); + } + } + + // set a selection + function set(start, len) { + if (textarea.createTextRange){ + // quick fix to make it work on Opera 9.5 + if ($.browser.opera && $.browser.version >= 9.5 && len == 0) { + return false; + } + range = textarea.createTextRange(); + range.collapse(true); + range.moveStart('character', start); + range.moveEnd('character', len); + range.select(); + } else if (textarea.setSelectionRange ){ + textarea.setSelectionRange(start, start + len); + } + textarea.scrollTop = scrollPosition; + textarea.focus(); + } + + // get the selection + function get() { + textarea.focus(); + + scrollPosition = textarea.scrollTop; + if (document.selection) { + selection = document.selection.createRange().text; + if ($.browser.msie) { // ie + var range = document.selection.createRange(), rangeCopy = range.duplicate(); + rangeCopy.moveToElementText(textarea); + caretPosition = -1; + while(rangeCopy.inRange(range)) { + rangeCopy.moveStart('character'); + caretPosition ++; + } + } else { // opera + caretPosition = textarea.selectionStart; + } + } else { // gecko & webkit + caretPosition = textarea.selectionStart; + + selection = textarea.value.substring(caretPosition, textarea.selectionEnd); + } + return selection; + } + + // open preview window + function preview() { + if (!previewWindow || previewWindow.closed) { + if (options.previewInWindow) { + previewWindow = window.open('', 'preview', options.previewInWindow); + $(window).unload(function() { + previewWindow.close(); + }); + } else { + iFrame = $(''); + if (options.previewPosition == 'after') { + iFrame.insertAfter(footer); + } else { + iFrame.insertBefore(header); + } + previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1]; + } + } else if (altKey === true) { + if (iFrame) { + iFrame.remove(); + } else { + previewWindow.close(); + } + previewWindow = iFrame = false; + } + if (!options.previewAutoRefresh) { + refreshPreview(); + } + if (options.previewInWindow) { + previewWindow.focus(); + } + } + + // refresh Preview window + function refreshPreview() { + renderPreview(); + } + + function renderPreview() { + var phtml; + if (options.previewParser && typeof options.previewParser === 'function') { + var data = options.previewParser( $$.val() ); + writeInPreview( localize(data, 1) ); + } else if (options.previewParserPath !== '') { + $.ajax({ + type: 'POST', + dataType: 'text', + global: false, + url: options.previewParserPath, + data: options.previewParserVar+'='+encodeURIComponent($$.val()), + success: function(data) { + writeInPreview( localize(data, 1) ); + } + }); + } else { + if (!template) { + $.ajax({ + url: options.previewTemplatePath, + dataType: 'text', + global: false, + success: function(data) { + writeInPreview( localize(data, 1).replace(//g, $$.val()) ); + } + }); + } + } + return false; + } + + function writeInPreview(data) { + if (previewWindow.document) { + try { + sp = previewWindow.document.documentElement.scrollTop + } catch(e) { + sp = 0; + } + previewWindow.document.open(); + previewWindow.document.write(data); + previewWindow.document.close(); + previewWindow.document.documentElement.scrollTop = sp; + } + } + + // set keys pressed + function keyPressed(e) { + shiftKey = e.shiftKey; + altKey = e.altKey; + ctrlKey = (!(e.altKey && e.ctrlKey)) ? (e.ctrlKey || e.metaKey) : false; + + if (e.type === 'keydown') { + if (ctrlKey === true) { + li = $('a[accesskey="'+String.fromCharCode(e.keyCode)+'"]', header).parent('li'); + if (li.length !== 0) { + ctrlKey = false; + setTimeout(function() { + li.triggerHandler('mouseup'); + },1); + return false; + } + } + if (e.keyCode === 13 || e.keyCode === 10) { // Enter key + if (ctrlKey === true) { // Enter + Ctrl + ctrlKey = false; + markup(options.onCtrlEnter); + return options.onCtrlEnter.keepDefault; + } else if (shiftKey === true) { // Enter + Shift + shiftKey = false; + markup(options.onShiftEnter); + return options.onShiftEnter.keepDefault; + } else { // only Enter + markup(options.onEnter); + return options.onEnter.keepDefault; + } + } + if (e.keyCode === 9) { // Tab key + if (shiftKey == true || ctrlKey == true || altKey == true) { + return false; + } + if (caretOffset !== -1) { + get(); + caretOffset = $$.val().length - caretOffset; + set(caretOffset, 0); + caretOffset = -1; + return false; + } else { + markup(options.onTab); + return options.onTab.keepDefault; + } + } + } + } + + init(); + }); + }; + + $.fn.markItUpRemove = function() { + return this.each(function() { + var $$ = $(this).unbind().removeClass('markItUpEditor'); + $$.parent('div').parent('div.markItUp').parent('div').replaceWith($$); + } + ); + }; + + $.markItUp = function(settings) { + var options = { target:false }; + $.extend(options, settings); + if (options.target) { + return $(options.target).each(function() { + $(this).focus(); + $(this).trigger('insertion', [options]); + }); + } else { + $('textarea').trigger('insertion', [options]); + } + }; +})(jQuery); diff --git a/cms/static/js/markitup/sets/wiki/images/bold.png b/cms/static/js/markitup/sets/wiki/images/bold.png new file mode 100644 index 0000000000000000000000000000000000000000..889ae80e37b6167cc15f2a89e05a183815ec18b2 GIT binary patch literal 304 zcmV-00nh%4P)b^}|6b=Y6y(;Y{!a!g z@UQp#@Aw}>L3(}s|7f5BUjeuKZvQRjV<2U7yvu*H{aAbvQ6K!@3oKzW z-{Qa8d3gae1^)HE{~f^!v<1}u>;4xnKvUpW540I-w9J3a{{r=B3T*2g{_BH1CtaZO zpZ`6V0*V5g1e5i;`_=Z#_e=H*@8|93RG@lX;D!K7TKswwko8{x0000LlS^n5Q5c2KWM*m}YV3eAws|yDY&wl?DsIf8f*>k% z<*Hc~7ec_5rHi-`yO3f)SBkFeMi8|t(GpA*#H3ciSWBp+c{r^&PVFO&3C&}i$+#MA zZCZ-`mgm3cyWAfxp=la+gJD~$f3lF*v;Jqx`Q8T$Z@WYD zo5ULg-eG}Z89L0f4Zd=*mecc6xt8;=w2x)zu;*%)sVnHZF8Gfgv50&V?aO?Vg=C`G zqt8;QwVsqD3w#sp>uk4(?#r`&eMV@ShR&fc4IOUt64yxY7gl5?KAAs}zQf1Y-^2&g z$Gu&9-`V$(R7R2uQ}2HsoE!1T1^`G5aq_1Rg+NBCRv6kqwQ}ZBXMdtuFS`d*&78wH z%FqTXD^)8WCsqSp-l}5wzGHH~3TMv4``ZJRQO3=(w6oCI`;E z`gMDg;9p*xrm`moLYyi48W1M{s};+X6Y)q)IQvrJsBPN-$Qt1?9(Dn}gMTvW8Vj;U zv~1YHR;Z*VmZrvRmZz6cE&o6XK(RnVCGj2D!Cx>lhwjfzzEPx#2?dhIYK}l!BvcK! z3)ER+Jz{5>jf6w4x#gTU%_MMNlkNp$oSbvBp&uHw9M;u0-4@=t5BI zP6Hx#-C_{5RMJ z0_P+Xkumexn8%)S+Y)#l(gR;YJP<6#1-=jjK0LONWPdJQIR8uK1HpvVIxBIQ2ztt+ zqoEx_X9S%QGMe=~(k#sebCL-an)%CR%a7YtUOQUgv+G>~?N~XSWhx=? z@$fx}0MB;$`JWcQ-Re{XV~5|{DvU(#*+NF*g)j^qk#b~G9_O!i*y&mZVZ=a3;Go(K z`DkskYn56Nhu+k@1Ke*uY|x zI&k6j$JfNe_a{GH%=n2rZOz$Z8R9V?Pe36hIk}jo+A-`;dt9vyvBu#Xm@veu&@v`| zzt%mwc_$nd0-sMVx2d)b0!MqGxmfCumx7yB#nIUWvA{!HOMfslMyW1iV&nY>zxwyj z8^JfLN|kT z4m^Q1mhO(_r4w@`V?H=YNkOf(i&bHT3Auc3bryK1_{hDSetLoLN{VLB^78ULiNFy^ zkUqqG$fjVkJj5tfWkOn|P5`HVEp5@-mGnc0wvJGHC=+39MC2TWT#i?t*~fNch*he_ zgtS^8dH$(KlW)EF1b4Fzv~?&0IQaNdg;W5&{t&Bmg9&N1-rBBr_;Rg8ekw^mn;@T# zlS{|Rq+-Nlg18i%UY;i|q1NnSwf>I@85#4U4002ovPDHLkV1mEDi4_0< literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/h1.png b/cms/static/js/markitup/sets/wiki/images/h1.png new file mode 100644 index 0000000000000000000000000000000000000000..9c122e91e358860733eaf08fd543e5fc585d4cfd GIT binary patch literal 276 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-$x=IP=XqH%ujg^j!|20W|*-XbO@ zAtBSd^khRzd{=pNv@vN)9uZDqGTXuVPf6#I=?;x2B`Y;1YQMI>>GxvE??vtn{c>{A z7MYxUVrui2JTF|YR&ldntL8M3{q7no52$4`vIX;r@S8@YTFOM5*~nV4Gk-UYI5L$} zDw(h9UDksmVjphbEsSQ?UdGUxU4Htk{EZoY&3@-Y5*_;Wwk`ZAkg@!FaC~ii{N>;; VD%(>GD}XL$@O1TaS?83{1OVXtVO9VD literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/h2.png b/cms/static/js/markitup/sets/wiki/images/h2.png new file mode 100644 index 0000000000000000000000000000000000000000..fbd87657fbe001c0a78fb095284fffc32e739497 GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-$ROXGNhtQ`{C(%$wdeB3 zGTnLdz~IMJtNg?T>Z(s;oVU0)KW5x*9xvq)rPF;` zY|Fc4&#rLa>Txf#@y+aKf+ac0%`STzAI(*qdYo^XFH557y+_x*JpKO5^1S9?c^6}{ zP=+&OVHtDUrGNmdKI;Vst0KHFj AM*si- literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/h3.png b/cms/static/js/markitup/sets/wiki/images/h3.png new file mode 100644 index 0000000000000000000000000000000000000000..c7836cf09e4565cc76c13bd14c13971c9e093c40 GIT binary patch literal 306 zcmV-20nPr2P)wEzGB literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/h4.png b/cms/static/js/markitup/sets/wiki/images/h4.png new file mode 100644 index 0000000000000000000000000000000000000000..4e929eaf583f10cf50eb1666ff6530b9d4cc7915 GIT binary patch literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-&H?&;zfqH%ujg^j$;1_G=B-XbO( zon2btF4r#xDw?mmvtwaL3R_~+Yz66*rrQmiHySwec#9a-mn?F*9`VcnzTNDrbNY9( zxOA;CUb9S|sk-b7=Pc<<>lMA8+|AaBj(NoLhh2`-;+F zenR#-z6;(Syt?;Ub#DVE_OC literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/h5.png b/cms/static/js/markitup/sets/wiki/images/h5.png new file mode 100644 index 0000000000000000000000000000000000000000..30cabebf7445e168a0f31b0ed68c43d54eaf017d GIT binary patch literal 304 zcmV-00nh%4P)ZVg9Hj*!Zw zxkAM~zCH&l><=6QeDdgV4l9hop+%GWq_IPV?Z641X8iiHrWJUN^2}hSiGjhsfbOLp z?d`9_MC0P3jVAVsE0oSgT$J*kO*Aq9I~CW*s{G*(t$KS{OS+#aO%?udUme<*TTEO`Fr@r_QT zk=#}u-n~>Vm!+9S1PE{@3<)G~CPb<$Za;W?3+O}|+q)?*Pn355=}S(XIZmEANjZci zf5 zj<%@MX^bD1^BwlS^+AD|$dm-1wial0hwPI;CDM?Y9SXW#@w-UF0SQ8OgplRTleOB2 zUjkDS|0U9pI|lSN*EvXUa~*UIclJdZ#)Npbwh9>YT?Z;=B8|l&^t~P~om?<5Lre$+ z;%`P>SL7`djY#8Y9$wv9dv|3p)C#5QQ<|d}62BjvZR2H60wE-$B^mK6y(Kw&{<9vg>Q9!g~ne(gm zmj4swoA@7?D86%i^8WzK9JM17E&sp&Z#dpHfz$E-U9ks&4?Z9Gyg!%0k2Q{M-Tz#> z2OnD>vrPZ*#{EHKLq)>Jcx{H|Ovdb&|4aQZWSipI{El%e^Cxx{^9vSw28s;a3IDB= TS1%U=TF&6<>gTe~DWM4fm>N^1 literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/link.png b/cms/static/js/markitup/sets/wiki/images/link.png new file mode 100644 index 0000000000000000000000000000000000000000..25eacb7c2524142262d68bf729c5e2b61adfd6d4 GIT binary patch literal 343 zcmV-d0jU0oP)$`dXYaZs9=SbAto%g@>T~?_bH&lTUn@`uo|1bXE{eSR(AO)ESb=V4`uk}mK|39Px&03WLbv~pzk+s7D@lK^ zn+aB+sp)&Y_x-B3>;6ywU--WQNUr<8>TU0P-|L#1U&;A)67w(+> pDf@fM7q9#F25QXo3rUI;002ro52U44e~JJA002ovPDHLkV1l;_q@Mr) literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/list-bullet.png b/cms/static/js/markitup/sets/wiki/images/list-bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..4a8672bde48f806d3d4d37db192588a9aa3eac10 GIT binary patch literal 344 zcmV-e0jK_nP)PbXFR5;6H z`2YVu10|S&DhA}te_Swi*Xsu$nk)lAnzx?+_#Z@r_~qs0*+Bfiq@?73K|#U)?Ck9S zsi~>|6A}{sM@B~e4-O9gPhA%bd?2RGd{of6>E(lvp1b6Ep>6&12TPB<{a?EDDL4@0 z;^ML+A|n0=1_u83^78uc?CkvC#>VEqiHXU7U0vP(YHDhzff&$ntDt1@;|H#l*M@2! z+U8#>h@W=vfpy*`^1J}j+`sMRe-I7g8yOj8Yin!&S5Z;VicFNp}SURRVGD{CSNFe~ni^^#wyl5uzj4je z|23%2?k#{x(*%mqe9M%mih+W%ElRQ}7!$^91> z7ymCLB=nz$hvz>#JNtiTW@gkt1Zf0eyP_){bPq%T_kY#2Z7&xs00000NkvXXu0mjf DNYA0= literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/picture.png b/cms/static/js/markitup/sets/wiki/images/picture.png new file mode 100644 index 0000000000000000000000000000000000000000..4a158fef7e0da8fd19525f574f2c4966443866cf GIT binary patch literal 606 zcmV-k0-^nhP)Q2rnAt>LM%-F zK|rtwgcU)}7x~z1Hrcs5bH*ZO$!>xO8K#?==bZPQ_ecnV>#P`H`QzGaRhd62G_&rC zTLU$c7_x*nFP_dW#Q+*);mMHE?j)HexK784D4x9l_tfpz2$@1y}9rkF+ zI+J5NMWeZyObc!d+rUc=>D+uOdAOg#%+Ej6h+wn5^xPmVVH*Eu446Y0A_@ zo$rlds-+sL10DbHs{AQG2a)rMyf zFQK~pm1x3+7!nu%-M`k}``c>^00{o_1pjWJUTfl8mg=3qGEl8H@}^@w`VUx0_$uy4 z2FhRqKX}xI*?Tv1DJd8z#F#0c%*~rM30HE1@2o5m~}ZyoWhqv>ql{V z1ZGE0lgcoK^lx+eqc*rAX1Ky;Xx3U%u#zG!m-;eD1Qsn@kf3|F9qz~|95=&g3(7!X zB}JAT>RU;a%vaNOGnJ%e1=K6eAh43c(QN8RQ6~GP%O}Jju$~Ld*%`mO1p?P)vCi#|P&Xm-dkucwL z3)87{8iWe96huvPHfK`KOdC2Z({T6vJ9pwDx$D4>d(Pqff6w7Lmj{5i6;ZyPPpPN; zroaW=6d#@oL2Fa53F~$Su10(RG%K0p3VTuP3?Z=nBA8z$uq+XLUL^QrC74`bU|!e| zr>hK{)%Q!vdmIO5Z3JIvaOyjOX`X@c8-ua03`Q&)f&%p*{(A$q`ZTTjk%q_T7>v^J zu!R-a9fFLScYlKkNBP_Cob=9m9JLVoC-?c{)eOtMnh7qNN{ejy2sM{pS^mgFHJm@(buuM4>=<5Vr$&Kzw{B?uPr; z(1Yf=#g)zADkWnx=MR%ykl| z3Ui42k+O2{bCn)01-s5Sxp|z{G2di&KT(_M6;$EI zDL57JFf}cw4bP1P$pgTRKH$0@h|~aA>j`qZ2*kU5t2EVD5#~@VNhqx{vz8ethDD-=+1vnemftUBA zF;N!Q%PBB5B=KLB#QO(CHe?;R+-C8M?ppDW>R$5`cCPq@YpusFRTaH1i9Kv;l<>I( Ze*oTy+;kdDB`N>_002ovPDHLkV1l3CM+g7_ literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/images/stroke.png b/cms/static/js/markitup/sets/wiki/images/stroke.png new file mode 100644 index 0000000000000000000000000000000000000000..612058a78eba4e3ca259aa13417fd60cd6cf2fbd GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-%c@9E+gqH#X?$N2_%qkv$?&V++! z-fX$@sb%KG-5a$|R8J4(Tcmu7`G0cYgxS-++3#dN^zA^J(=P8r|6lx9G_LLaZ+v5S z!d9iC@)!RP{FnQmdw#}3Ee(C$|NPA#|L6YmR@fBO9w|C7oMMQ$vc`Tu(RETvC<`(>OPJ!ieM-fH~m>7>j(^b;|pVbz=yzjpaJj$ zhrpuriKefui_0DvN;1Ymq&%nwWg*IrK!Xz^eJWuq3u2H~0ra?EC@ge%+`A>6mV z9{TYo{=G6 zt@5m|4G+Q2zKv;Ch@O;`PfWArmB5n3gvMsxV&Iu>97{a!2kL74wd@!f_AP^O%_&ND zm}1c*+F;TcH^{p$P_|akvD5o7vmT>HCkP;z;;&+8tDBI;koi9eX`W!oH4`pYaHlFZwV;$>vvfQTw zM-`m&R_SPIBa^FUasC0GCCh%{h`$~db`z&-lFX#%(f>H6JD6Z(sIW`RKE+xOL+?+uQ%q z){?+F%=6pqEH{6=NzusC-*<`PZYiLCGyKD}Z8^V8ul-K=AV@SE1t4~D2*b1(9UUc= zN-;Dv#Ngl{rd7e$ZUPXC##BFmV>$26ZQi?6Po#@{4gllsPbku3Vq${Y+FAf~T}OJb zGWEz9{(zcvI&CUaN&p7GcqMG4&7ULx##68M4k(F4l7Q+Xm&>uSv4N&(w6?a=)YOC{ zoYLN-J?7@-9xGBx007$C+kK7w_2Z$(k&l}jo2#`dO;J#Ipsbc$pS#^Dy3Q&nSeE5x fGMT)t>sS8=`naU3reLNz00000NkvXXu0mjf)bGN+ literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/sets/wiki/set.js b/cms/static/js/markitup/sets/wiki/set.js new file mode 100644 index 0000000000..895625621d --- /dev/null +++ b/cms/static/js/markitup/sets/wiki/set.js @@ -0,0 +1,34 @@ +// ---------------------------------------------------------------------------- +// markItUp! +// ---------------------------------------------------------------------------- +// Copyright (C) 2008 Jay Salvat +// http://markitup.jaysalvat.com/ +// ---------------------------------------------------------------------------- +myWikiSettings = { + nameSpace: "wiki", // Useful to prevent multi-instances CSS conflict + previewParserPath: "~/sets/wiki/preview.php", + onShiftEnter: {keepDefault:false, replaceWith:'\n\n'}, + markupSet: [ + {name:'Heading 1', key:'1', openWith:'== ', closeWith:' ==', placeHolder:'Your title here...' }, + {name:'Heading 2', key:'2', openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...' }, + {name:'Heading 3', key:'3', openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...' }, + {name:'Heading 4', key:'4', openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...' }, + {name:'Heading 5', key:'5', openWith:'====== ', closeWith:' ======', placeHolder:'Your title here...' }, + {separator:'---------------' }, + {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"}, + {name:'Italic', key:'I', openWith:"''", closeWith:"''"}, + {name:'Stroke through', key:'S', openWith:'', closeWith:''}, + {separator:'---------------' }, + {name:'Bulleted list', openWith:'(!(* |!|*)!)'}, + {name:'Numeric list', openWith:'(!(# |!|#)!)'}, + {separator:'---------------' }, + {name:'Picture', key:'P', replaceWith:'[[Image:[![Url:!:http://]!]|[![name]!]]]'}, + {name:'Link', key:'L', openWith:'[[![Link]!] ', closeWith:']', placeHolder:'Your text to link here...' }, + {name:'Url', openWith:'[[![Url:!:http://]!] ', closeWith:']', placeHolder:'Your text to link here...' }, + {separator:'---------------' }, + {name:'Quotes', openWith:'(!(> |!|>)!)'}, + {name:'Code', openWith:'(!(|!|
    )!)', closeWith:'(!(|!|
    )!)'}, + {separator:'---------------' }, + {name:'Preview', call:'preview', className:'preview'} + ] +} diff --git a/cms/static/js/markitup/sets/wiki/style.css b/cms/static/js/markitup/sets/wiki/style.css new file mode 100644 index 0000000000..0a26c698f5 --- /dev/null +++ b/cms/static/js/markitup/sets/wiki/style.css @@ -0,0 +1,57 @@ +/* ------------------------------------------------------------------- +// markItUp! +// By Jay Salvat - http://markitup.jaysalvat.com/ +// ------------------------------------------------------------------*/ +.wiki .markItUpButton1 a { + background-image:url(images/h1.png); +} +.wiki .markItUpButton2 a { + background-image:url(images/h2.png); +} +.wiki .markItUpButton3 a { + background-image:url(images/h3.png); +} +.wiki .markItUpButton4 a { + background-image:url(images/h4.png); +} +.wiki .markItUpButton5 a { + background-image:url(images/h5.png); +} + +.wiki .markItUpButton6 a { + background-image:url(images/bold.png); +} +.wiki .markItUpButton7 a { + background-image:url(images/italic.png); +} +.wiki .markItUpButton8 a { + background-image:url(images/stroke.png); +} + +.wiki .markItUpButton9 a { + background-image:url(images/list-bullet.png); +} +.wiki .markItUpButton10 a { + background-image:url(images/list-numeric.png); +} + +.wiki .markItUpButton11 a { + background-image:url(images/picture.png); +} +.wiki .markItUpButton12 a { + background-image:url(images/link.png); +} +.wiki .markItUpButton13 a { + background-image:url(images/url.png); +} + +.wiki .markItUpButton14 a { + background-image:url(images/quotes.png); +} +.wiki .markItUpButton15 a { + background-image:url(images/code.png); +} + +.wiki .preview a { + background-image:url(images/preview.png); +} diff --git a/cms/static/js/markitup/skins/simple/images/handle.png b/cms/static/js/markitup/skins/simple/images/handle.png new file mode 100644 index 0000000000000000000000000000000000000000..3993b20337e33a36c9125d139f1f53a279a4c128 GIT binary patch literal 258 zcmeAS@N?(olHy`uVBq!ia0vp^qCm{X#0(?@t!)i}6mzkYX9x!e$L)vy4}e^r0G|-o z4LkP#|NsB{_wSo_?oZ!X{TC?CQWE4B{GZ|f|H~VSrU3bz1s;*b3=G^tAk28_ZrvZC zpje4(M2T}zYGO%dex5=|W^O8jfw{hsp}v86ds2l5P=!25MR0yvNqJ&XDuZuga#4P6 zYD#9Jf?H-$YI%N9cCmuR){ILPK&1wrE{-7_Gm{H=1WS1m6Eb=Pa(faIBBVrjnVf1= soMNglKFuA6ghUcX`bbD&-ZPgg&ebxsLQ0Hz~TmH+?% literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/skins/simple/images/menu.png b/cms/static/js/markitup/skins/simple/images/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..44a07afd30f499cdba30847094a1e92f13e1320e GIT binary patch literal 27151 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

    +35?Hj$O) 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 literal 0 HcmV?d00001 diff --git a/cms/static/js/markitup/skins/simple/style.css b/cms/static/js/markitup/skins/simple/style.css new file mode 100644 index 0000000000..af8dc9cdb5 --- /dev/null +++ b/cms/static/js/markitup/skins/simple/style.css @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------- +// markItUp! Universal MarkUp Engine, JQuery plugin +// By Jay Salvat - http://markitup.jaysalvat.com/ +// ------------------------------------------------------------------*/ +.markItUp * { + margin:0px; padding:0px; + outline:none; +} +.markItUp a:link, +.markItUp a:visited { + color:#000; + text-decoration:none; +} +.markItUp { + /* width:700px; */ + margin:5px 0 10px 0; +} +.markItUpContainer { + font:11px Verdana, Arial, Helvetica, sans-serif; +} +.markItUpEditor { + font:12px 'Courier New', Courier, monospace; + padding:5px; + /* width:690px; */ + height:320px; + clear:both; + line-height:18px; + overflow:auto; +} +.markItUpPreviewFrame { + overflow:auto; + background-color:#FFF; + width:99.9%; + height:300px; + margin:5px 0; +} +.markItUpFooter { + width:100%; +} +.markItUpResizeHandle { + overflow:hidden; + width:22px; height:5px; + margin-left:auto; + margin-right:auto; + background-image:url(images/handle.png); + cursor:n-resize; +} +/***************************************************************************************/ +/* first row of buttons */ +.markItUpHeader ul li { + list-style:none; + float:left; + position:relative; +} +.markItUpHeader ul li:hover > ul{ + display:block; +} +.markItUpHeader ul .markItUpDropMenu { + background:transparent url(images/menu.png) no-repeat 115% 50%; + margin-right:5px; +} +.markItUpHeader ul .markItUpDropMenu li { + margin-right:0px; +} +/* next rows of buttons */ +.markItUpHeader ul ul { + display:none; + position:absolute; + top:18px; left:0px; + background:#FFF; + border:1px solid #000; +} +.markItUpHeader ul ul li { + float:none; + border-bottom:1px solid #000; +} +.markItUpHeader ul ul .markItUpDropMenu { + background:#FFF url(images/submenu.png) no-repeat 100% 50%; +} +.markItUpHeader ul .markItUpSeparator { + margin:0 10px; + width:1px; + height:16px; + overflow:hidden; + background-color:#CCC; +} +.markItUpHeader ul ul .markItUpSeparator { + width:auto; height:1px; + margin:0px; +} +/* next rows of buttons */ +.markItUpHeader ul ul ul { + position:absolute; + top:-1px; left:150px; +} +.markItUpHeader ul ul ul li { + float:none; +} +.markItUpHeader ul a { + display:block; + width:16px; height:16px; + text-indent:-10000px; + background-repeat:no-repeat; + padding:3px; + margin:0px; +} +.markItUpHeader ul ul a { + display:block; + padding-left:0px; + text-indent:0; + width:120px; + padding:5px 5px 5px 25px; + background-position:2px 50%; +} +.markItUpHeader ul ul a:hover { + color:#FFF; + background-color:#000; +} diff --git a/cms/static/sass/_base.scss b/cms/static/sass/_base.scss new file mode 100644 index 0000000000..d9f3971d9e --- /dev/null +++ b/cms/static/sass/_base.scss @@ -0,0 +1,51 @@ + +$fg-column: 70px; +$fg-gutter: 26px; +$fg-max-columns: 12; + +html { + height: 100%; +} + +body { + @include clearfix(); + height: 100%; + font: 14px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif; + + > section { + display: table; + width: 100%; + } + + > header { + background: #000; + color: #fff; + display: block; + float: none; + padding: 6px 20px; + width: 100%; + @include box-sizing(border-box); + + nav { + @include clearfix; + + h2 { + font-size: 14px; + text-transform: uppercase; + } + } + } +} + +a { + text-decoration: none; + color: #888; +} + +input[type="submit"], .button { + border: 1px solid #ccc; + background: #efefef; + @include border-radius(3px); + padding: 6px; +} + diff --git a/cms/static/sass/_calendar.scss b/cms/static/sass/_calendar.scss new file mode 100644 index 0000000000..b149346ad6 --- /dev/null +++ b/cms/static/sass/_calendar.scss @@ -0,0 +1,206 @@ +section.cal { + @include box-sizing(border-box); + padding: 25px; + @include clearfix; + overflow: scroll; + + > header { + @include clearfix; + margin-bottom: 10px; + + h1 { + float: left; + font-size: 18px; + } + + ul { + float: right; + + li { + @include inline-block; + + a { + padding: 6px; + border: 1px solid #ddd; + display: block; + @include border-radius(3px); + background: #efefef; + } + + &.dropdown { + position: relative; + + ul { + display: none; + position: absolute; + background: #fff; + border: 1px solid #ddd; + + li { + padding: 6px; + display: block; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + + &:hover { + background-color: #efefef; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + } + } + } + + &:hover { + + ul { + display: block; + } + + a { + @include border-radius(3px 3px 0 0); + border-bottom: 0; + } + } + } + } + } + } + + ol { + list-style: none; + @include clearfix; + @include box-sizing(border-box); + border-left: 1px solid #333; + border-top: 1px solid #333; + width: 100%; + + > li { + border-right: 1px solid #333; + border-bottom: 1px solid; + @include box-sizing(border-box); + float: left; + width: flex-grid(3) + ((flex-gutter() * 3) / 4); + + &:last-child { + text-align: center; + background: #eee; + @include box-sizing(border-box); + + p { + width: 100%; + height: 100%; + @include box-sizing(border-box); + + a { + display: block; + width: 100%; + height: 100%; + } + } + + section.new-week { + header { + background: #fff; + text-align: left; + } + + form { + background: #fff; + width: 50%; + padding: 6px; + border: 1px solid #000; + margin: 0 auto; + @include box-shadow(0 0 2px #333); + position: relative; + + &:before { + background: #fff; + border-left: 1px solid #000; + border-top: 1px solid #000; + content: " "; + display: block; + height: 10px; + left: 50%; + position: absolute; + top: -6px; + @include transform(rotate(45deg)); + width: 10px; + z-index: 0; + } + + select { + margin-bottom: 6px; + width: 100%; + + option { + padding: 10px 0 !important; + } + } + + input[type="submit"] { + display: block; + margin-bottom: 6px; + width: 100%; + } + + a { + + &:first-child { + float: left; + } + + &:last-child { + float: right; + } + } + } + } + } + + header { + border-bottom: 1px solid #000; + @include box-shadow(0 1px 2px #ccc); + display: block; + margin-bottom: 2px; + padding: 6px; + + h1 { + font-size: 14px; + } + } + + ul { + list-style: none; + margin-bottom: 1px; + + li { + background: #efefef; + border-bottom: 1px solid #666; + padding: 6px; + + &.goal { + background: #fff; + } + } + } + } + } +} + +body.content + section.cal { + width: flex-grid(3) + flex-gutter(); + float: left; + @include box-sizing(border-box); + + > header ul { + display: none; + } + + ol { + li { + @include box-sizing(border-box); + width: 100%; + } + } + } diff --git a/cms/static/sass/_problem.scss b/cms/static/sass/_problem.scss new file mode 100644 index 0000000000..c513ce38d9 --- /dev/null +++ b/cms/static/sass/_problem.scss @@ -0,0 +1,41 @@ +section.problem-new, section.problem-edit { + position: absolute; + top: 80px; + right: 0; + background: #fff; + width: flex-grid(5); + @include box-shadow(0 0 6px #666); + border: 1px solid #333; + border-right: 0; + z-index: 4; + + > header { + background: #666; + @include clearfix; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; + + h2 { + float: left; + font-size: 14px; + } + + a { + float: right; + } + } + + section { + ul { + list-style: none; + + li { + border-bottom: 1px solid #333; + padding: 10px 25px; + } + } + } +} + diff --git a/cms/static/sass/_reset.scss b/cms/static/sass/_reset.scss new file mode 100644 index 0000000000..bfe619c1b0 --- /dev/null +++ b/cms/static/sass/_reset.scss @@ -0,0 +1,229 @@ +html, body, div, span, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +abbr, address, cite, code, +del, dfn, em, img, ins, kbd, q, samp, +small, strong, sub, sup, var, +b, i, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, figcaption, figure, +footer, header, hgroup, menu, nav, section, summary, +time, mark, audio, video { + margin:0; + padding:0; + border:0; + outline:0; + vertical-align:baseline; + background:transparent; +} + +html,body { + font-size: 100%; +} + +// Corrects block display not defined in IE8/9 & FF3 +article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { + display: block; +} + +// Corrects inline-block display not defined in IE8/9 & FF3 +audio, canvas, video { + display: inline-block; +} + +// Prevents modern browsers from displaying 'audio' without controls +audio:not([controls]) { + display: none; +} + +// Addresses styling for 'hidden' attribute not present in IE8/9, FF3, S4 +[hidden] { + display: none; +} + +// Prevents iOS text size adjust after orientation change, without disabling user zoom +// www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +// Addresses font-family inconsistency between 'textarea' and other form elements. +html, button, input, select, textarea { + font-family: sans-serif; +} + +a { + // Addresses outline displayed oddly in Chrome + &:focus { + outline: thin dotted; + // Webkit + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; + } + + // Improves readability when focused and also mouse hovered in all browsers + // people.opera.com/patrickl/experiments/keyboard/test + &:hover, &:active { + outline: 0; + } +} + +// Addresses styling not present in IE8/9, S5, Chrome +abbr[title] { + border-bottom: 1px dotted; +} + +// Addresses style set to 'bolder' in FF3+, S4/5, Chrome +b, strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +// Addresses styling not present in S5, Chrome +dfn { + font-style: italic; +} + +// Addresses styling not present in IE8/9 +mark { + background: #ff0; + color: #000; +} + +// Corrects font family set oddly in S4/5, Chrome +// en.wikipedia.org/wiki/User:Davidgothberg/Test59 +pre, code, kbd, samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +// Improves readability of pre-formatted text in all browsers +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +// Addresses quote property not supported in S4 +blockquote, q { + quotes: none; + &:before, &:after { + content: ''; + content: none; + } +} + +small { + font-size: 75%; +} + +sub, sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +nav { + ul, ol { + list-style: none; + list-style-image: none; + } +} + +// Removes border when inside 'a' element in IE8/9, FF3 +img { + border: 0; + height: auto; + max-width: 100%; + -ms-interpolation-mode: bicubic; +} + +// Corrects overflow displayed oddly in IE9 +svg:not(:root) { + overflow: hidden; +} + +// Define consistent border, margin, and padding +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +legend { + border: 0; // Corrects color not being inherited in IE8/9 + padding: 0; + white-space: normal; // Corrects text not wrapping in FF3 +} + +button, input, select, textarea { + font-size: 100%; // Corrects font size not being inherited in all browsers + margin: 0; // Addresses margins set differently in FF3+, S5, Chrome + vertical-align: baseline; // Improves appearance and consistency in all browsers +} + +// Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet +button, input { + line-height: normal; +} + +button, input[type="button"], input[type="reset"], input[type="submit"] { + cursor: pointer; // Improves usability and consistency of cursor style between image-type 'input' and others + -webkit-appearance: button; // Corrects inability to style clickable 'input' types in iOS +} + +// Re-set default cursor for disabled elements +button[disabled], input[disabled] { + cursor: default; +} + +input[type="checkbox"], input[type="radio"] { + box-sizing: border-box; // Addresses box sizing set to content-box in IE8/9 + padding: 0; //Removes excess padding in IE8/9 +} + +input[type="search"] { + -webkit-appearance: textfield; // Addresses appearance set to searchfield in S5, Chrome + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; // Addresses box-sizing set to border-box in S5, Chrome (-moz to future-proof) + box-sizing: content-box; +} + +// Removes inner padding and search cancel button in S5, Chrome on OS X +input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +// Removes inner padding and border in FF3+ +// www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ +button::-moz-focus-inner, input::-moz-focus-inner { + border: 0; + padding: 0; +} + +textarea { + overflow: auto; // Removes default vertical scrollbar in IE8/9 + vertical-align: top; // Improves readability and alignment in all browsers +} + +// Remove most spacing between table cells +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/cms/static/sass/_video.scss b/cms/static/sass/_video.scss new file mode 100644 index 0000000000..cb234108f4 --- /dev/null +++ b/cms/static/sass/_video.scss @@ -0,0 +1,40 @@ +section.video-new, section.video-edit { + position: absolute; + top: 80px; + right: 0; + background: #fff; + width: flex-grid(5); + @include box-shadow(0 0 6px #666); + border: 1px solid #333; + border-right: 0; + z-index: 4; + + > header { + background: #666; + @include clearfix; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; + + h2 { + float: left; + font-size: 14px; + } + + a { + float: right; + } + } + + section { + ul { + list-style: none; + + li { + border-bottom: 1px solid #333; + padding: 10px 25px; + } + } + } +} diff --git a/cms/static/sass/_week.scss b/cms/static/sass/_week.scss new file mode 100644 index 0000000000..a628b0f164 --- /dev/null +++ b/cms/static/sass/_week.scss @@ -0,0 +1,152 @@ +section.week-edit, section.week-new { + + > header { + border-bottom: 1px solid #ccc; + @include clearfix(); + padding: 6px; + + h1 { + font-size: 18px; + float: left; + margin-top: 8px 6px; + } + + a { + float: right; + @extend .button; + display: block; + } + } + + section { + header { + background: #666; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; + + h2 { + font-size: 14px; + } + } + + &.sidebar { + width: flex-grid(3, 9) + flex-gutter(9); + float: left; + background: #ccc; + border-right: 1px solid #333; + @include box-sizing(border-box); + + section { + height: 50%; + + > ul { + list-style: none; + + > li { + padding: 6px; + border-bottom: 1px solid #666; + background: #eee; + + &.new-module { + position: relative; + + ul.new-dropdown { + list-style: none; + + li { + display: none; + + &:first-child { + display: block; + } + } + + &:hover { + li { + display: block; + padding: 6px 0; + + &:first-child { + padding-top: 0; + } + } + } + } + } + } + } + + p { + padding: 6px; + border-bottom: 1px solid #666; + } + } + } + + &.weeks-content { + width: flex-grid(6, 9); + float: left; + @include box-sizing(border-box); + + header { + @include clearfix; + + h2 { + float: left; + } + + form { + float: right; + margin: -2px 0; + + input { + border: 1px solid #000; + background: #ddd; + padding: 2px 4px; + @include border-radius(2px); + } + } + } + + + section { + &.filters { + border-bottom: 1px solid #999; + + ul { + @include clearfix(); + list-style: none; + padding: 6px; + + li { + @include inline-block(); + + &.advanced { + float: right; + } + } + } + } + + &.modules { + ul { + list-style: none; + + li { + padding: 6px; + font-weight: bold; + font-size: 16px; + border-bottom: 1px solid #333; + + a { + color: #000; + } + } + } + } + } + } + } +} diff --git a/cms/static/sass/base-style.scss b/cms/static/sass/base-style.scss new file mode 100644 index 0000000000..6a2dfbd0d2 --- /dev/null +++ b/cms/static/sass/base-style.scss @@ -0,0 +1,18 @@ +@import 'bourbon/bourbon'; +@import 'reset'; + +@import 'base'; +@import 'calendar'; +@import 'week', 'video', 'problem'; + +body { + &.content { + section.main-content { + border-left: 2px solid #000; + @include box-sizing(border-box); + width: flex-grid(9); + float: left; + @include box-shadow( -2px 0 3px #ddd ); + } + } +} diff --git a/cms/static/sass/bourbon/_bourbon.scss b/cms/static/sass/bourbon/_bourbon.scss new file mode 100644 index 0000000000..27b056e303 --- /dev/null +++ b/cms/static/sass/bourbon/_bourbon.scss @@ -0,0 +1,35 @@ +// Custom Functions +@import "functions/deprecated-webkit-gradient"; +@import "functions/flex-grid"; +@import "functions/grid-width"; +@import "functions/linear-gradient"; +@import "functions/modular-scale"; +@import "functions/radial-gradient"; +@import "functions/render-gradients"; +@import "functions/tint-shade"; + +// CSS3 Mixins +@import "css3/animation"; +@import "css3/appearance"; +@import "css3/background-image"; +@import "css3/background-size"; +@import "css3/border-image"; +@import "css3/border-radius"; +@import "css3/box-shadow"; +@import "css3/box-sizing"; +@import "css3/columns"; +@import "css3/flex-box"; +@import "css3/inline-block"; +@import "css3/linear-gradient"; +@import "css3/radial-gradient"; +@import "css3/transform"; +@import "css3/transition"; +@import "css3/user-select"; + +// Addons & other mixins +@import "addons/button"; +@import "addons/clearfix"; +@import "addons/font-family"; +@import "addons/html5-input-types"; +@import "addons/position"; +@import "addons/timing-functions"; diff --git a/cms/static/sass/bourbon/addons/_button.scss b/cms/static/sass/bourbon/addons/_button.scss new file mode 100644 index 0000000000..1d32125140 --- /dev/null +++ b/cms/static/sass/bourbon/addons/_button.scss @@ -0,0 +1,267 @@ +@mixin button ($style: simple, $base-color: #4294f0) { + + @if type-of($style) == color { + $base-color: $style; + $style: simple; + } + + // Grayscale button + @if $base-color == grayscale($base-color) { + @if $style == simple { + @include simple($base-color, $grayscale: true); + } + + @else if $style == shiny { + @include shiny($base-color, $grayscale: true); + } + + @else if $style == pill { + @include pill($base-color, $grayscale: true); + } + } + + // Colored button + @else { + @if $style == simple { + @include simple($base-color); + } + + @else if $style == shiny { + @include shiny($base-color); + } + + @else if $style == pill { + @include pill($base-color); + } + } +} + + +// Simple Button +//************************************************************************// +@mixin simple($base-color, $grayscale: false) { + $color: hsl(0, 0, 100%); + $border: adjust-color($base-color, $saturation: 9%, $lightness: -14%); + $inset-shadow: adjust-color($base-color, $saturation: -8%, $lightness: 15%); + $stop-gradient: adjust-color($base-color, $saturation: 9%, $lightness: -11%); + $text-shadow: adjust-color($base-color, $saturation: 15%, $lightness: -18%); + + @if lightness($base-color) > 70% { + $color: hsl(0, 0, 20%); + $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%); + } + + @if $grayscale == true { + $border: grayscale($border); + $inset-shadow: grayscale($inset-shadow); + $stop-gradient: grayscale($stop-gradient); + $text-shadow: grayscale($text-shadow); + } + + border: 1px solid $border; + @include border-radius (3px); + @include box-shadow (inset 0 1px 0 0 $inset-shadow); + color: $color; + display: inline; + font-size: 11px; + font-weight: bold; + @include linear-gradient ($base-color, $stop-gradient); + padding: 6px 18px 7px; + text-shadow: 0 1px 0 $text-shadow; + -webkit-background-clip: padding-box; + + &:hover { + $base-color-hover: adjust-color($base-color, $saturation: -4%, $lightness: -5%); + $inset-shadow-hover: adjust-color($base-color, $saturation: -7%, $lightness: 5%); + $stop-gradient-hover: adjust-color($base-color, $saturation: 8%, $lightness: -14%); + + @if $grayscale == true { + $base-color-hover: grayscale($base-color-hover); + $inset-shadow-hover: grayscale($inset-shadow-hover); + $stop-gradient-hover: grayscale($stop-gradient-hover); + } + + @include box-shadow (inset 0 1px 0 0 $inset-shadow-hover); + cursor: pointer; + @include linear-gradient ($base-color-hover, $stop-gradient-hover); + } + + &:active { + $border-active: adjust-color($base-color, $saturation: 9%, $lightness: -14%); + $inset-shadow-active: adjust-color($base-color, $saturation: 7%, $lightness: -17%); + + @if $grayscale == true { + $border-active: grayscale($border-active); + $inset-shadow-active: grayscale($inset-shadow-active); + } + + border: 1px solid $border-active; + @include box-shadow (inset 0 0 8px 4px $inset-shadow-active, inset 0 0 8px 4px $inset-shadow-active, 0 1px 1px 0 #eee); + } +} + + +// Shiny Button +//************************************************************************// +@mixin shiny($base-color, $grayscale: false) { + $color: hsl(0, 0, 100%); + $border: adjust-color($base-color, $red: -117, $green: -111, $blue: -81); + $border-bottom: adjust-color($base-color, $red: -126, $green: -127, $blue: -122); + $fourth-stop: adjust-color($base-color, $red: -79, $green: -70, $blue: -46); + $inset-shadow: adjust-color($base-color, $red: 37, $green: 29, $blue: 12); + $second-stop: adjust-color($base-color, $red: -56, $green: -50, $blue: -33); + $text-shadow: adjust-color($base-color, $red: -140, $green: -141, $blue: -114); + $third-stop: adjust-color($base-color, $red: -86, $green: -75, $blue: -48); + + @if lightness($base-color) > 70% { + $color: hsl(0, 0, 20%); + $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%); + } + + @if $grayscale == true { + $border: grayscale($border); + $border-bottom: grayscale($border-bottom); + $fourth-stop: grayscale($fourth-stop); + $inset-shadow: grayscale($inset-shadow); + $second-stop: grayscale($second-stop); + $text-shadow: grayscale($text-shadow); + $third-stop: grayscale($third-stop); + } + + border: 1px solid $border; + border-bottom: 1px solid $border-bottom; + @include border-radius(5px); + @include box-shadow(inset 0 1px 0 0 $inset-shadow); + color: $color; + display: inline; + font-size: 14px; + font-weight: bold; + @include linear-gradient(top, $base-color 0%, $second-stop 50%, $third-stop 50%, $fourth-stop 100%); + padding: 7px 20px 8px; + text-align: center; + text-decoration: none; + text-shadow: 0 -1px 1px $text-shadow; + + &:hover { + $first-stop-hover: adjust-color($base-color, $red: -13, $green: -15, $blue: -18); + $second-stop-hover: adjust-color($base-color, $red: -66, $green: -62, $blue: -51); + $third-stop-hover: adjust-color($base-color, $red: -93, $green: -85, $blue: -66); + $fourth-stop-hover: adjust-color($base-color, $red: -86, $green: -80, $blue: -63); + + @if $grayscale == true { + $first-stop-hover: grayscale($first-stop-hover); + $second-stop-hover: grayscale($second-stop-hover); + $third-stop-hover: grayscale($third-stop-hover); + $fourth-stop-hover: grayscale($fourth-stop-hover); + } + + cursor: pointer; + @include linear-gradient(top, $first-stop-hover 0%, + $second-stop-hover 50%, + $third-stop-hover 50%, + $fourth-stop-hover 100%); + } + + &:active { + $inset-shadow-active: adjust-color($base-color, $red: -111, $green: -116, $blue: -122); + + @if $grayscale == true { + $inset-shadow-active: grayscale($inset-shadow-active); + } + + @include box-shadow(inset 0 0 20px 0 $inset-shadow-active, 0 1px 0 #fff); + } +} + + +// Pill Button +//************************************************************************// +@mixin pill($base-color, $grayscale: false) { + $color: hsl(0, 0, 100%); + $border-bottom: adjust-color($base-color, $hue: 8, $saturation: -11%, $lightness: -26%); + $border-sides: adjust-color($base-color, $hue: 4, $saturation: -21%, $lightness: -21%); + $border-top: adjust-color($base-color, $hue: -1, $saturation: -30%, $lightness: -15%); + $inset-shadow: adjust-color($base-color, $hue: -1, $saturation: -1%, $lightness: 7%); + $stop-gradient: adjust-color($base-color, $hue: 8, $saturation: 14%, $lightness: -10%); + $text-shadow: adjust-color($base-color, $hue: 5, $saturation: -19%, $lightness: -15%); + + @if lightness($base-color) > 70% { + $color: hsl(0, 0, 20%); + $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%); + } + + @if $grayscale == true { + $border-bottom: grayscale($border-bottom); + $border-sides: grayscale($border-sides); + $border-top: grayscale($border-top); + $inset-shadow: grayscale($inset-shadow); + $stop-gradient: grayscale($stop-gradient); + $text-shadow: grayscale($text-shadow); + } + + border: 1px solid $border-top; + border-color: $border-top $border-sides $border-bottom; + @include border-radius(16px); + @include box-shadow(inset 0 1px 0 0 $inset-shadow, 0 1px 2px 0 #b3b3b3); + color: $color; + display: inline; + font-size: 11px; + font-weight: normal; + line-height: 1; + @include linear-gradient ($base-color, $stop-gradient); + padding: 3px 16px 5px; + text-align: center; + text-shadow: 0 -1px 1px $text-shadow; + -webkit-background-clip: padding-box; + + &:hover { + $base-color-hover: adjust-color($base-color, $lightness: -4.5%); + $border-bottom: adjust-color($base-color, $hue: 8, $saturation: 13.5%, $lightness: -32%); + $border-sides: adjust-color($base-color, $hue: 4, $saturation: -2%, $lightness: -27%); + $border-top: adjust-color($base-color, $hue: -1, $saturation: -17%, $lightness: -21%); + $inset-shadow-hover: adjust-color($base-color, $saturation: -1%, $lightness: 3%); + $stop-gradient-hover: adjust-color($base-color, $hue: 8, $saturation: -4%, $lightness: -15.5%); + $text-shadow-hover: adjust-color($base-color, $hue: 5, $saturation: -5%, $lightness: -22%); + + @if $grayscale == true { + $base-color-hover: grayscale($base-color-hover); + $border-bottom: grayscale($border-bottom); + $border-sides: grayscale($border-sides); + $border-top: grayscale($border-top); + $inset-shadow-hover: grayscale($inset-shadow-hover); + $stop-gradient-hover: grayscale($stop-gradient-hover); + $text-shadow-hover: grayscale($text-shadow-hover); + } + + border: 1px solid $border-top; + border-color: $border-top $border-sides $border-bottom; + @include box-shadow(inset 0 1px 0 0 $inset-shadow-hover); + cursor: pointer; + @include linear-gradient ($base-color-hover, $stop-gradient-hover); + text-shadow: 0 -1px 1px $text-shadow-hover; + -webkit-background-clip: padding-box; + } + + &:active { + $active-color: adjust-color($base-color, $hue: 4, $saturation: -12%, $lightness: -10%); + $border-active: adjust-color($base-color, $hue: 6, $saturation: -2.5%, $lightness: -30%); + $border-bottom-active: adjust-color($base-color, $hue: 11, $saturation: 6%, $lightness: -31%); + $inset-shadow-active: adjust-color($base-color, $hue: 9, $saturation: 2%, $lightness: -21.5%); + $text-shadow-active: adjust-color($base-color, $hue: 5, $saturation: -12%, $lightness: -21.5%); + + @if $grayscale == true { + $active-color: grayscale($active-color); + $border-active: grayscale($border-active); + $border-bottom-active: grayscale($border-bottom-active); + $inset-shadow-active: grayscale($inset-shadow-active); + $text-shadow-active: grayscale($text-shadow-active); + } + + background: $active-color; + border: 1px solid $border-active; + border-bottom: 1px solid $border-bottom-active; + @include box-shadow(inset 0 0 6px 3px $inset-shadow-active, 0 1px 0 0 #fff); + text-shadow: 0 -1px 1px $text-shadow-active; + } +} + diff --git a/cms/static/sass/bourbon/addons/_clearfix.scss b/cms/static/sass/bourbon/addons/_clearfix.scss new file mode 100644 index 0000000000..a9f6a795c5 --- /dev/null +++ b/cms/static/sass/bourbon/addons/_clearfix.scss @@ -0,0 +1,29 @@ +// Micro clearfix provides an easy way to contain floats without adding additional markup +// +// Example usage: +// +// // Contain all floats within .wrapper +// .wrapper { +// @include clearfix; +// .content, +// .sidebar { +// float : left; +// } +// } + +@mixin clearfix { + zoom: 1; + + &:before, + &:after { + content: ""; + display: table; + } + + &:after { + clear: both; + } +} + +// Acknowledgements +// Micro clearfix: [Nicolas Gallagher](http://nicolasgallagher.com/micro-clearfix-hack/) diff --git a/cms/static/sass/bourbon/addons/_font-family.scss b/cms/static/sass/bourbon/addons/_font-family.scss new file mode 100644 index 0000000000..df8a80ddfc --- /dev/null +++ b/cms/static/sass/bourbon/addons/_font-family.scss @@ -0,0 +1,5 @@ +$georgia: Georgia, Cambria, "Times New Roman", Times, serif; +$helvetica: "Helvetica Neue", Helvetica, Arial, sans-serif; +$lucida-grande: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif; +$monospace: "Bitstream Vera Sans Mono", Consolas, Courier, monospace; +$verdana: Verdana, Geneva, sans-serif; diff --git a/cms/static/sass/bourbon/addons/_html5-input-types.scss b/cms/static/sass/bourbon/addons/_html5-input-types.scss new file mode 100644 index 0000000000..9d86fbb4d4 --- /dev/null +++ b/cms/static/sass/bourbon/addons/_html5-input-types.scss @@ -0,0 +1,36 @@ +//************************************************************************// +// Generate a variable ($all-text-inputs) with a list of all html5 +// input types that have a text-based input, excluding textarea. +// http://diveintohtml5.org/forms.html +//************************************************************************// +$inputs-list: 'input[type="email"]', + 'input[type="number"]', + 'input[type="password"]', + 'input[type="search"]', + 'input[type="tel"]', + 'input[type="text"]', + 'input[type="url"]', + + // Webkit & Gecko may change the display of these in the future + 'input[type="color"]', + 'input[type="date"]', + 'input[type="datetime"]', + 'input[type="datetime-local"]', + 'input[type="month"]', + 'input[type="time"]', + 'input[type="week"]'; + +$unquoted-inputs-list: (); + +@each $input-type in $inputs-list { + $unquoted-inputs-list: append($unquoted-inputs-list, unquote($input-type), comma); +} + +$all-text-inputs: $unquoted-inputs-list; + +// You must use interpolation on the variable: +// #{$all-text-inputs} +//************************************************************************// +// #{$all-text-inputs}, textarea { +// border: 1px solid red; +// } diff --git a/cms/static/sass/bourbon/addons/_position.scss b/cms/static/sass/bourbon/addons/_position.scss new file mode 100644 index 0000000000..6ad330f1df --- /dev/null +++ b/cms/static/sass/bourbon/addons/_position.scss @@ -0,0 +1,30 @@ +@mixin position ($position: relative, $coordinates: 0 0 0 0) { + + @if type-of($position) == list { + $coordinates: $position; + $position: relative; + } + + $top: nth($coordinates, 1); + $right: nth($coordinates, 2); + $bottom: nth($coordinates, 3); + $left: nth($coordinates, 4); + + position: $position; + + @if not(unitless($top)) { + top: $top; + } + + @if not(unitless($right)) { + right: $right; + } + + @if not(unitless($bottom)) { + bottom: $bottom; + } + + @if not(unitless($left)) { + left: $left; + } +} diff --git a/cms/static/sass/bourbon/addons/_timing-functions.scss b/cms/static/sass/bourbon/addons/_timing-functions.scss new file mode 100644 index 0000000000..51b2410914 --- /dev/null +++ b/cms/static/sass/bourbon/addons/_timing-functions.scss @@ -0,0 +1,32 @@ +// CSS cubic-bezier timing functions. Timing functions courtesy of jquery.easie (github.com/jaukia/easie) +// Timing functions are the same as demo'ed here: http://jqueryui.com/demos/effect/easing.html + +// EASE IN +$ease-in-quad: cubic-bezier(0.550, 0.085, 0.680, 0.530); +$ease-in-cubic: cubic-bezier(0.550, 0.055, 0.675, 0.190); +$ease-in-quart: cubic-bezier(0.895, 0.030, 0.685, 0.220); +$ease-in-quint: cubic-bezier(0.755, 0.050, 0.855, 0.060); +$ease-in-sine: cubic-bezier(0.470, 0.000, 0.745, 0.715); +$ease-in-expo: cubic-bezier(0.950, 0.050, 0.795, 0.035); +$ease-in-circ: cubic-bezier(0.600, 0.040, 0.980, 0.335); +$ease-in-back: cubic-bezier(0.600, -0.280, 0.735, 0.045); + +// EASE OUT +$ease-out-quad: cubic-bezier(0.250, 0.460, 0.450, 0.940); +$ease-out-cubic: cubic-bezier(0.215, 0.610, 0.355, 1.000); +$ease-out-quart: cubic-bezier(0.165, 0.840, 0.440, 1.000); +$ease-out-quint: cubic-bezier(0.230, 1.000, 0.320, 1.000); +$ease-out-sine: cubic-bezier(0.390, 0.575, 0.565, 1.000); +$ease-out-expo: cubic-bezier(0.190, 1.000, 0.220, 1.000); +$ease-out-circ: cubic-bezier(0.075, 0.820, 0.165, 1.000); +$ease-out-back: cubic-bezier(0.175, 0.885, 0.320, 1.275); + +// EASE IN OUT +$ease-in-out-quad: cubic-bezier(0.455, 0.030, 0.515, 0.955); +$ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1.000); +$ease-in-out-quart: cubic-bezier(0.770, 0.000, 0.175, 1.000); +$ease-in-out-quint: cubic-bezier(0.860, 0.000, 0.070, 1.000); +$ease-in-out-sine: cubic-bezier(0.445, 0.050, 0.550, 0.950); +$ease-in-out-expo: cubic-bezier(1.000, 0.000, 0.000, 1.000); +$ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.150, 0.860); +$ease-in-out-back: cubic-bezier(0.680, -0.550, 0.265, 1.550); diff --git a/cms/static/sass/bourbon/css3/_animation.scss b/cms/static/sass/bourbon/css3/_animation.scss new file mode 100644 index 0000000000..f99e06eb6f --- /dev/null +++ b/cms/static/sass/bourbon/css3/_animation.scss @@ -0,0 +1,171 @@ +// http://www.w3.org/TR/css3-animations/#the-animation-name-property- +// Each of these mixins support comma separated lists of values, which allows different transitions for individual properties to be described in a single style rule. Each value in the list corresponds to the value at that same position in the other properties. + +// Official animation shorthand property. +@mixin animation ($animation-1, + $animation-2: false, $animation-3: false, + $animation-4: false, $animation-5: false, + $animation-6: false, $animation-7: false, + $animation-8: false, $animation-9: false) + { + $full: compact($animation-1, $animation-2, $animation-3, $animation-4, + $animation-5, $animation-6, $animation-7, $animation-8, $animation-9); + + -webkit-animation: $full; + -moz-animation: $full; + animation: $full; +} + +// Individual Animation Properties +@mixin animation-name ($name-1, + $name-2: false, $name-3: false, + $name-4: false, $name-5: false, + $name-6: false, $name-7: false, + $name-8: false, $name-9: false) + { + $full: compact($name-1, $name-2, $name-3, $name-4, + $name-5, $name-6, $name-7, $name-8, $name-9); + + -webkit-animation-name: $full; + -moz-animation-name: $full; + animation-name: $full; +} + + +@mixin animation-duration ($time-1: 0, + $time-2: false, $time-3: false, + $time-4: false, $time-5: false, + $time-6: false, $time-7: false, + $time-8: false, $time-9: false) + { + $full: compact($time-1, $time-2, $time-3, $time-4, + $time-5, $time-6, $time-7, $time-8, $time-9); + + -webkit-animation-duration: $full; + -moz-animation-duration: $full; + animation-duration: $full; +} + + +@mixin animation-timing-function ($motion-1: ease, +// ease | linear | ease-in | ease-out | ease-in-out + $motion-2: false, $motion-3: false, + $motion-4: false, $motion-5: false, + $motion-6: false, $motion-7: false, + $motion-8: false, $motion-9: false) + { + $full: compact($motion-1, $motion-2, $motion-3, $motion-4, + $motion-5, $motion-6, $motion-7, $motion-8, $motion-9); + + -webkit-animation-timing-function: $full; + -moz-animation-timing-function: $full; + animation-timing-function: $full; +} + + +@mixin animation-iteration-count ($value-1: 1, +// infinite | + $value-2: false, $value-3: false, + $value-4: false, $value-5: false, + $value-6: false, $value-7: false, + $value-8: false, $value-9: false) + { + $full: compact($value-1, $value-2, $value-3, $value-4, + $value-5, $value-6, $value-7, $value-8, $value-9); + + -webkit-animation-iteration-count: $full; + -moz-animation-iteration-count: $full; + animation-iteration-count: $full; +} + + +@mixin animation-direction ($direction-1: normal, +// normal | alternate + $direction-2: false, $direction-3: false, + $direction-4: false, $direction-5: false, + $direction-6: false, $direction-7: false, + $direction-8: false, $direction-9: false) + { + $full: compact($direction-1, $direction-2, $direction-3, $direction-4, + $direction-5, $direction-6, $direction-7, $direction-8, $direction-9); + + -webkit-animation-direction: $full; + -moz-animation-direction: $full; + animation-direction: $full; +} + + +@mixin animation-play-state ($state-1: running, +// running | paused + $state-2: false, $state-3: false, + $state-4: false, $state-5: false, + $state-6: false, $state-7: false, + $state-8: false, $state-9: false) + { + $full: compact($state-1, $state-2, $state-3, $state-4, + $state-5, $state-6, $state-7, $state-8, $state-9); + + -webkit-animation-play-state: $full; + -moz-animation-play-state: $full; + animation-play-state: $full; +} + + +@mixin animation-delay ($time-1: 0, + $time-2: false, $time-3: false, + $time-4: false, $time-5: false, + $time-6: false, $time-7: false, + $time-8: false, $time-9: false) + { + $full: compact($time-1, $time-2, $time-3, $time-4, + $time-5, $time-6, $time-7, $time-8, $time-9); + + -webkit-animation-delay: $full; + -moz-animation-delay: $full; + animation-delay: $full; +} + + +@mixin animation-fill-mode ($mode-1: none, +// http://goo.gl/l6ckm +// none | forwards | backwards | both + $mode-2: false, $mode-3: false, + $mode-4: false, $mode-5: false, + $mode-6: false, $mode-7: false, + $mode-8: false, $mode-9: false) + { + $full: compact($mode-1, $mode-2, $mode-3, $mode-4, + $mode-5, $mode-6, $mode-7, $mode-8, $mode-9); + + -webkit-animation-fill-mode: $full; + -moz-animation-fill-mode: $full; + animation-fill-mode: $full; +} + + +// Deprecated +@mixin animation-basic ($name, $time: 0, $motion: ease) { + $length-of-name: length($name); + $length-of-time: length($time); + $length-of-motion: length($motion); + + @if $length-of-name > 1 { + @include animation-name(zip($name)); + } @else { + @include animation-name( $name); + } + + @if $length-of-time > 1 { + @include animation-duration(zip($time)); + } @else { + @include animation-duration( $time); + } + + @if $length-of-motion > 1 { + @include animation-timing-function(zip($motion)); + } @else { + @include animation-timing-function( $motion); + } + @warn "The animation-basic mixin is deprecated. Use the animation mixin instead."; +} + diff --git a/cms/static/sass/bourbon/css3/_appearance.scss b/cms/static/sass/bourbon/css3/_appearance.scss new file mode 100644 index 0000000000..548767e166 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_appearance.scss @@ -0,0 +1,7 @@ +@mixin appearance ($value) { + -webkit-appearance: $value; + -moz-appearance: $value; + -ms-appearance: $value; + -o-appearance: $value; + appearance: $value; +} diff --git a/cms/static/sass/bourbon/css3/_background-image.scss b/cms/static/sass/bourbon/css3/_background-image.scss new file mode 100644 index 0000000000..c23cef7c31 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_background-image.scss @@ -0,0 +1,57 @@ +//************************************************************************// +// Background-image property for adding multiple background images with +// gradients, or for stringing multiple gradients together. +//************************************************************************// + +@mixin background-image( + $image-1 , $image-2: false, + $image-3: false, $image-4: false, + $image-5: false, $image-6: false, + $image-7: false, $image-8: false, + $image-9: false, $image-10: false +) { + $images: compact($image-1, $image-2, + $image-3, $image-4, + $image-5, $image-6, + $image-7, $image-8, + $image-9, $image-10); + + background-image: add-prefix($images, webkit); + background-image: add-prefix($images, moz); + background-image: add-prefix($images, ms); + background-image: add-prefix($images, o); + background-image: add-prefix($images); +} + + +@function add-prefix($images, $vendor: false) { + $images-prefixed: (); + + @for $i from 1 through length($images) { + $type: type-of(nth($images, $i)); // Get type of variable - List or String + + // If variable is a list - Gradient + @if $type == list { + $gradient-type: nth(nth($images, $i), 1); // Get type of gradient (linear || radial) + $gradient-args: nth(nth($images, $i), 2); // Get actual gradient (red, blue) + + $gradient: render-gradients($gradient-args, $gradient-type, $vendor); + $images-prefixed: append($images-prefixed, $gradient, comma); + } + + // If variable is a string - Image + @else if $type == string { + $images-prefixed: join($images-prefixed, nth($images, $i), comma); + } + } + @return $images-prefixed; +} + + + +//Examples: + //@include background-image(linear-gradient(top, orange, red)); + //@include background-image(radial-gradient(50% 50%, cover circle, orange, red)); + //@include background-image(url("/images/a.png"), linear-gradient(orange, red)); + //@include background-image(url("image.png"), linear-gradient(orange, red), url("image.png")); + //@include background-image(linear-gradient(hsla(0, 100%, 100%, 0.25) 0%, hsla(0, 100%, 100%, 0.08) 50%, transparent 50%), linear-gradient(orange, red); diff --git a/cms/static/sass/bourbon/css3/_background-size.scss b/cms/static/sass/bourbon/css3/_background-size.scss new file mode 100644 index 0000000000..4bba11027d --- /dev/null +++ b/cms/static/sass/bourbon/css3/_background-size.scss @@ -0,0 +1,15 @@ +@mixin background-size ($length-1, + $length-2: false, $length-3: false, + $length-4: false, $length-5: false, + $length-6: false, $length-7: false, + $length-8: false, $length-9: false) + { + $full: compact($length-1, $length-2, $length-3, $length-4, + $length-5, $length-6, $length-7, $length-8, $length-9); + + -webkit-background-size: $full; + -moz-background-size: $full; + -ms-background-size: $full; + -o-background-size: $full; + background-size: $full; +} diff --git a/cms/static/sass/bourbon/css3/_border-image.scss b/cms/static/sass/bourbon/css3/_border-image.scss new file mode 100644 index 0000000000..da4f20ba49 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_border-image.scss @@ -0,0 +1,56 @@ +@mixin border-image($images) { + -webkit-border-image: border-add-prefix($images, webkit); + -moz-border-image: border-add-prefix($images, moz); + -o-border-image: border-add-prefix($images, o); + border-image: border-add-prefix($images); +} + +@function border-add-prefix($images, $vendor: false) { + $border-image: (); + $images-type: type-of(nth($images, 1)); + $first-var: nth(nth($images, 1), 1); // Get type of Gradient (Linear || radial) + + // If input is a gradient + @if $images-type == string { + @if ($first-var == "linear") or ($first-var == "radial") { + @for $i from 2 through length($images) { + $gradient-type: nth($images, 1); // Get type of gradient (linear || radial) + $gradient-args: nth($images, $i); // Get actual gradient (red, blue) + $border-image: render-gradients($gradient-args, $gradient-type, $vendor); + } + } + + // If input is a URL + @else { + $border-image: $images; + } + } + + // If input is gradient or url + additional args + @else if $images-type == list { + @for $i from 1 through length($images) { + $type: type-of(nth($images, $i)); // Get type of variable - List or String + + // If variable is a list - Gradient + @if $type == list { + $gradient-type: nth(nth($images, $i), 1); // Get type of gradient (linear || radial) + $gradient-args: nth(nth($images, $i), 2); // Get actual gradient (red, blue) + $border-image: render-gradients($gradient-args, $gradient-type, $vendor); + } + + // If variable is a string - Image or number + @else if ($type == string) or ($type == number) { + $border-image: append($border-image, nth($images, $i)); + } + } + } + @return $border-image; +} + +//Examples: +// @include border-image(url("image.png")); +// @include border-image(url("image.png") 20 stretch); +// @include border-image(linear-gradient(45deg, orange, yellow)); +// @include border-image(linear-gradient(45deg, orange, yellow) stretch); +// @include border-image(linear-gradient(45deg, orange, yellow) 20 30 40 50 stretch round); +// @include border-image(radial-gradient(top, cover, orange, yellow, orange)); diff --git a/cms/static/sass/bourbon/css3/_border-radius.scss b/cms/static/sass/bourbon/css3/_border-radius.scss new file mode 100644 index 0000000000..f24389ebbe --- /dev/null +++ b/cms/static/sass/bourbon/css3/_border-radius.scss @@ -0,0 +1,63 @@ +@mixin border-radius ($radii) { + -webkit-border-radius: $radii; + -moz-border-radius: $radii; + -ms-border-radius: $radii; + -o-border-radius: $radii; + border-radius: $radii; +} + +@mixin border-top-left-radius($radii) { + -webkit-border-top-left-radius: $radii; + -moz-border-top-left-radius: $radii; + -moz-border-radius-topleft: $radii; + -ms-border-top-left-radius: $radii; + -o-border-top-left-radius: $radii; + border-top-left-radius: $radii; +} + +@mixin border-top-right-radius($radii) { + -webkit-border-top-right-radius: $radii; + -moz-border-top-right-radius: $radii; + -moz-border-radius-topright: $radii; + -ms-border-top-right-radius: $radii; + -o-border-top-right-radius: $radii; + border-top-right-radius: $radii; +} + +@mixin border-bottom-left-radius($radii) { + -webkit-border-bottom-left-radius: $radii; + -moz-border-bottom-left-radius: $radii; + -moz-border-radius-bottomleft: $radii; + -ms-border-bottom-left-radius: $radii; + -o-border-bottom-left-radius: $radii; + border-bottom-left-radius: $radii; +} + +@mixin border-bottom-right-radius($radii) { + -webkit-border-bottom-right-radius: $radii; + -moz-border-bottom-right-radius: $radii; + -moz-border-radius-bottomright: $radii; + -ms-border-bottom-right-radius: $radii; + -o-border-bottom-right-radius: $radii; + border-bottom-right-radius: $radii; +} + +@mixin border-top-radius($radii) { + @include border-top-left-radius($radii); + @include border-top-right-radius($radii); +} + +@mixin border-right-radius($radii) { + @include border-top-right-radius($radii); + @include border-bottom-right-radius($radii); +} + +@mixin border-bottom-radius($radii) { + @include border-bottom-left-radius($radii); + @include border-bottom-right-radius($radii); +} + +@mixin border-left-radius($radii) { + @include border-top-left-radius($radii); + @include border-bottom-left-radius($radii); +} diff --git a/cms/static/sass/bourbon/css3/_box-shadow.scss b/cms/static/sass/bourbon/css3/_box-shadow.scss new file mode 100644 index 0000000000..327b66d251 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_box-shadow.scss @@ -0,0 +1,14 @@ +// Box-Shadow Mixin Requires Sass v3.1.1+ +@mixin box-shadow ($shadow-1, + $shadow-2: false, $shadow-3: false, + $shadow-4: false, $shadow-5: false, + $shadow-6: false, $shadow-7: false, + $shadow-8: false, $shadow-9: false) + { + $full: compact($shadow-1, $shadow-2, $shadow-3, $shadow-4, + $shadow-5, $shadow-6, $shadow-7, $shadow-8, $shadow-9); + + -webkit-box-shadow: $full; + -moz-box-shadow: $full; + box-shadow: $full; +} diff --git a/cms/static/sass/bourbon/css3/_box-sizing.scss b/cms/static/sass/bourbon/css3/_box-sizing.scss new file mode 100644 index 0000000000..3f3f7cca9a --- /dev/null +++ b/cms/static/sass/bourbon/css3/_box-sizing.scss @@ -0,0 +1,6 @@ +@mixin box-sizing ($box) { +// content-box | border-box | inherit + -webkit-box-sizing: $box; + -moz-box-sizing: $box; + box-sizing: $box; +} diff --git a/cms/static/sass/bourbon/css3/_columns.scss b/cms/static/sass/bourbon/css3/_columns.scss new file mode 100644 index 0000000000..2896c91d7f --- /dev/null +++ b/cms/static/sass/bourbon/css3/_columns.scss @@ -0,0 +1,67 @@ +@mixin columns($arg: auto) { +// || + -webkit-columns: $arg; + -moz-columns: $arg; + columns: $arg; +} + +@mixin column-count($int: auto) { +// auto || integer + -webkit-column-count: $int; + -moz-column-count: $int; + column-count: $int; +} + +@mixin column-gap($length: normal) { +// normal || length + -webkit-column-gap: $length; + -moz-column-gap: $length; + column-gap: $length; +} + +@mixin column-fill($arg: auto) { +// auto || length + -webkit-columns-fill: $arg; + -moz-columns-fill: $arg; + columns-fill: $arg; +} + +@mixin column-rule($arg) { +// || || + -webkit-column-rule: $arg; + -moz-column-rule: $arg; + column-rule: $arg; +} + +@mixin column-rule-color($color) { + -webkit-column-rule-color: $color; + -moz-column-rule-color: $color; + column-rule-color: $color; +} + +@mixin column-rule-style($style: none) { +// none | hidden | dashed | dotted | double | groove | inset | inset | outset | ridge | solid + -webkit-column-rule-style: $style; + -moz-column-rule-style: $style; + column-rule-style: $style; +} + +@mixin column-rule-width ($width: none) { + -webkit-column-rule-width: $width; + -moz-column-rule-width: $width; + column-rule-width: $width; +} + +@mixin column-span($arg: none) { +// none || all + -webkit-column-span: $arg; + -moz-column-span: $arg; + column-span: $arg; +} + +@mixin column-width($length: auto) { +// auto || length + -webkit-column-width: $length; + -moz-column-width: $length; + column-width: $length; +} diff --git a/cms/static/sass/bourbon/css3/_flex-box.scss b/cms/static/sass/bourbon/css3/_flex-box.scss new file mode 100644 index 0000000000..44c1dfd789 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_flex-box.scss @@ -0,0 +1,67 @@ +// CSS3 Flexible Box Model and property defaults + +// Custom shorthand notation for flexbox +@mixin box($orient: inline-axis, $pack: start, $align: stretch) { + @include display-box; + @include box-orient($orient); + @include box-pack($pack); + @include box-align($align); +} + +@mixin display-box { + display: -webkit-box; + display: -moz-box; + display: box; +} + +@mixin box-orient($orient: inline-axis) { +// horizontal|vertical|inline-axis|block-axis|inherit + -webkit-box-orient: $orient; + -moz-box-orient: $orient; + box-orient: $orient; +} + +@mixin box-pack($pack: start) { +// start|end|center|justify + -webkit-box-pack: $pack; + -moz-box-pack: $pack; + box-pack: $pack; +} + +@mixin box-align($align: stretch) { +// start|end|center|baseline|stretch + -webkit-box-align: $align; + -moz-box-align: $align; + box-align: $align; +} + +@mixin box-direction($direction: normal) { +// normal|reverse|inherit + -webkit-box-direction: $direction; + -moz-box-direction: $direction; + box-direction: $direction; +} +@mixin box-lines($lines: single) { +// single|multiple + -webkit-box-lines: $lines; + -moz-box-lines: $lines; + box-lines: $lines; +} + +@mixin box-ordinal-group($integer: 1) { + -webkit-box-ordinal-group: $integer; + -moz-box-ordinal-group: $integer; + box-ordinal-group: $integer; +} + +@mixin box-flex($value: 0.0) { + -webkit-box-flex: $value; + -moz-box-flex: $value; + box-flex: $value; +} + +@mixin box-flex-group($integer: 1) { + -webkit-box-flex-group: $integer; + -moz-box-flex-group: $integer; + box-flex-group: $integer; +} diff --git a/cms/static/sass/bourbon/css3/_inline-block.scss b/cms/static/sass/bourbon/css3/_inline-block.scss new file mode 100644 index 0000000000..d79a13c851 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_inline-block.scss @@ -0,0 +1,10 @@ +// Legacy support for inline-block in IE7 (maybe IE6) +@mixin inline-block { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; +} diff --git a/cms/static/sass/bourbon/css3/_linear-gradient.scss b/cms/static/sass/bourbon/css3/_linear-gradient.scss new file mode 100644 index 0000000000..e366a299a9 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_linear-gradient.scss @@ -0,0 +1,41 @@ +@mixin linear-gradient($pos, $G1, $G2: false, + $G3: false, $G4: false, + $G5: false, $G6: false, + $G7: false, $G8: false, + $G9: false, $G10: false, + $fallback: false) { + // Detect what type of value exists in $pos + $pos-type: type-of(nth($pos, 1)); + + // If $pos is missing from mixin, reassign vars and add default position + @if ($pos-type == color) or (nth($pos, 1) == "transparent") { + $G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5; + $G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos; + $pos: top; // Default position + } + + $full: compact($G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10); + + // Set $G1 as the default fallback color + $fallback-color: nth($G1, 1); + + // If $fallback is a color use that color as the fallback color + @if (type-of($fallback) == color) or ($fallback == "transparent") { + $fallback-color: $fallback; + } + + background-color: $fallback-color; + background-image: deprecated-webkit-gradient(linear, $full); // Safari <= 5.0 + background-image: -webkit-linear-gradient($pos, $full); // Safari 5.1+, Chrome + background-image: -moz-linear-gradient($pos, $full); + background-image: -ms-linear-gradient($pos, $full); + background-image: -o-linear-gradient($pos, $full); + background-image: unquote("linear-gradient(#{$pos}, #{$full})"); +} + + +// Usage: Gradient position is optional, default is top. Position can be a degree. Color stops are optional as well. +// @include linear-gradient(#1e5799, #2989d8); +// @include linear-gradient(#1e5799, #2989d8, $fallback:#2989d8); +// @include linear-gradient(top, #1e5799 0%, #2989d8 50%); +// @include linear-gradient(50deg, rgba(10, 10, 10, 0.5) 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); diff --git a/cms/static/sass/bourbon/css3/_radial-gradient.scss b/cms/static/sass/bourbon/css3/_radial-gradient.scss new file mode 100644 index 0000000000..e83cab5234 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_radial-gradient.scss @@ -0,0 +1,31 @@ +// Requires Sass 3.1+ +@mixin radial-gradient($pos, $shape-size, + $G1, $G2, + $G3: false, $G4: false, + $G5: false, $G6: false, + $G7: false, $G8: false, + $G9: false, $G10: false, + $fallback: false) { + + $full: compact($G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10); + + // Set $G1 as the default fallback color + $fallback-color: nth($G1, 1); + + // If $fallback is a color use that color as the fallback color + @if (type-of($fallback) == color) or ($fallback == "transparent") { + $fallback-color: $fallback; + } + + background-color: $fallback-color; + background-image: deprecated-webkit-gradient(radial, $full); // Safari <= 5.0 + background-image: -webkit-radial-gradient($pos, $shape-size, $full); + background-image: -moz-radial-gradient($pos, $shape-size, $full); + background-image: -ms-radial-gradient($pos, $shape-size, $full); + background-image: -o-radial-gradient($pos, $shape-size, $full); + background-image: unquote("radial-gradient(#{$pos}, #{$shape-size}, #{$full})"); +} + +// Usage: Gradient position and shape-size are required. Color stops are optional. +// @include radial-gradient(50% 50%, circle cover, #1e5799, #efefef); +// @include radial-gradient(50% 50%, circle cover, #eee 10%, #1e5799 30%, #efefef); diff --git a/cms/static/sass/bourbon/css3/_transform.scss b/cms/static/sass/bourbon/css3/_transform.scss new file mode 100644 index 0000000000..8d19e8b88d --- /dev/null +++ b/cms/static/sass/bourbon/css3/_transform.scss @@ -0,0 +1,19 @@ +@mixin transform($property: none) { +// none | + -webkit-transform: $property; + -moz-transform: $property; + -ms-transform: $property; + -o-transform: $property; + transform: $property; +} + +@mixin transform-origin($axes: 50%) { +// x-axis - left | center | right | length | % +// y-axis - top | center | bottom | length | % +// z-axis - length + -webkit-transform-origin: $axes; + -moz-transform-origin: $axes; + -ms-transform-origin: $axes; + -o-transform-origin: $axes; + transform-origin: $axes; +} diff --git a/cms/static/sass/bourbon/css3/_transition.scss b/cms/static/sass/bourbon/css3/_transition.scss new file mode 100644 index 0000000000..058dbe0e33 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_transition.scss @@ -0,0 +1,104 @@ +// Shorthand mixin. Supports multiple parentheses-deliminated values for each variable. +// Example: @include transition (all, 2.0s, ease-in-out); +// @include transition ((opacity, width), (1.0s, 2.0s), ease-in, (0, 2s)); +// @include transition ($property:(opacity, width), $delay: (1.5s, 2.5s)); + +@mixin transition ($property: all, $duration: 0.15s, $timing-function: ease-out, $delay: 0) { + + // Detect # of args passed into each variable + $length-of-property: length($property); + $length-of-duration: length($duration); + $length-of-timing-function: length($timing-function); + $length-of-delay: length($delay); + + @if $length-of-property > 1 { + @include transition-property(zip($property)); } + @else { + @include transition-property( $property); + } + + @if $length-of-duration > 1 { + @include transition-duration(zip($duration)); } + @else { + @include transition-duration( $duration); + } + + @if $length-of-timing-function > 1 { + @include transition-timing-function(zip($timing-function)); } + @else { + @include transition-timing-function( $timing-function); + } + + @if $length-of-delay > 1 { + @include transition-delay(zip($delay)); } + @else { + @include transition-delay( $delay); + } +} + + +@mixin transition-property ($prop-1: all, + $prop-2: false, $prop-3: false, + $prop-4: false, $prop-5: false, + $prop-6: false, $prop-7: false, + $prop-8: false, $prop-9: false) + { + $full: compact($prop-1, $prop-2, $prop-3, $prop-4, $prop-5, + $prop-6, $prop-7, $prop-8, $prop-9); + + -webkit-transition-property: $full; + -moz-transition-property: $full; + -ms-transition-property: $full; + -o-transition-property: $full; + transition-property: $full; +} + +@mixin transition-duration ($time-1: 0, + $time-2: false, $time-3: false, + $time-4: false, $time-5: false, + $time-6: false, $time-7: false, + $time-8: false, $time-9: false) + { + $full: compact($time-1, $time-2, $time-3, $time-4, $time-5, + $time-6, $time-7, $time-8, $time-9); + + -webkit-transition-duration: $full; + -moz-transition-duration: $full; + -ms-transition-duration: $full; + -o-transition-duration: $full; + transition-duration: $full; +} + +@mixin transition-timing-function ($motion-1: ease, + $motion-2: false, $motion-3: false, + $motion-4: false, $motion-5: false, + $motion-6: false, $motion-7: false, + $motion-8: false, $motion-9: false) + { + $full: compact($motion-1, $motion-2, $motion-3, $motion-4, $motion-5, + $motion-6, $motion-7, $motion-8, $motion-9); + +// ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier() + -webkit-transition-timing-function: $full; + -moz-transition-timing-function: $full; + -ms-transition-timing-function: $full; + -o-transition-timing-function: $full; + transition-timing-function: $full; +} + +@mixin transition-delay ($time-1: 0, + $time-2: false, $time-3: false, + $time-4: false, $time-5: false, + $time-6: false, $time-7: false, + $time-8: false, $time-9: false) + { + $full: compact($time-1, $time-2, $time-3, $time-4, $time-5, + $time-6, $time-7, $time-8, $time-9); + + -webkit-transition-delay: $full; + -moz-transition-delay: $full; + -ms-transition-delay: $full; + -o-transition-delay: $full; + transition-delay: $full; +} + diff --git a/cms/static/sass/bourbon/css3/_user-select.scss b/cms/static/sass/bourbon/css3/_user-select.scss new file mode 100644 index 0000000000..d5f5749431 --- /dev/null +++ b/cms/static/sass/bourbon/css3/_user-select.scss @@ -0,0 +1,6 @@ +@mixin user-select($arg: none) { + -webkit-user-select: $arg; + -moz-user-select: $arg; + -ms-user-select: $arg; + user-select: $arg; +} diff --git a/cms/static/sass/bourbon/functions/_deprecated-webkit-gradient.scss b/cms/static/sass/bourbon/functions/_deprecated-webkit-gradient.scss new file mode 100644 index 0000000000..1322f6f60e --- /dev/null +++ b/cms/static/sass/bourbon/functions/_deprecated-webkit-gradient.scss @@ -0,0 +1,36 @@ +// Render Deprecated Webkit Gradient - Linear || Radial +//************************************************************************// +@function deprecated-webkit-gradient($type, $full) { + $gradient-list: (); + $gradient: false; + $full-length: length($full); + $percentage: false; + $gradient-type: $type; + + @for $i from 1 through $full-length { + $gradient: nth($full, $i); + + @if length($gradient) == 2 { + $color-stop: color-stop(nth($gradient, 2), nth($gradient, 1)); + $gradient-list: join($gradient-list, $color-stop, comma); + } + @else { + @if $i == $full-length { + $percentage: 100%; + } + @else { + $percentage: ($i - 1) * (100 / ($full-length - 1)) + "%"; + } + $color-stop: color-stop(unquote($percentage), $gradient); + $gradient-list: join($gradient-list, $color-stop, comma); + } + } + + @if $type == radial { + $gradient: -webkit-gradient(radial, center center, 0, center center, 460, $gradient-list); + } + @else if $type == linear { + $gradient: -webkit-gradient(linear, left top, left bottom, $gradient-list); + } + @return $gradient; +} diff --git a/cms/static/sass/bourbon/functions/_flex-grid.scss b/cms/static/sass/bourbon/functions/_flex-grid.scss new file mode 100644 index 0000000000..707f994e15 --- /dev/null +++ b/cms/static/sass/bourbon/functions/_flex-grid.scss @@ -0,0 +1,35 @@ +// Flexible grid +@function flex-grid($columns, $container-columns: $fg-max-columns) { + $width: $columns * $fg-column + ($columns - 1) * $fg-gutter; + $container-width: $container-columns * $fg-column + ($container-columns - 1) * $fg-gutter; + @return percentage($width / $container-width); +} + +// Flexible gutter +@function flex-gutter($container-columns: $fg-max-columns, $gutter: $fg-gutter) { + $container-width: $container-columns * $fg-column + ($container-columns - 1) * $fg-gutter; + @return percentage($gutter / $container-width); +} + +// The $fg-column, $fg-gutter and $fg-max-columns variables must be defined in your base stylesheet to properly use the flex-grid function. +// This function takes the fluid grid equation (target / context = result) and uses columns to help define each. +// +// $fg-column: 60px; // Column Width +// $fg-gutter: 25px; // Gutter Width +// $fg-max-columns: 12; // Total Columns For Main Container +// +// div { +// width: flex-grid(4); // returns (315px / 1020px) = 30.882353%; +// margin-left: flex-gutter(); // returns (25px / 1020px) = 2.45098%; +// +// p { +// width: flex-grid(2, 4); // returns (145px / 315px) = 46.031746%; +// float: left; +// margin: flex-gutter(4); // returns (25px / 315px) = 7.936508%; +// } +// +// blockquote { +// float: left; +// width: flex-grid(2, 4); // returns (145px / 315px) = 46.031746%; +// } +// } diff --git a/cms/static/sass/bourbon/functions/_grid-width.scss b/cms/static/sass/bourbon/functions/_grid-width.scss new file mode 100644 index 0000000000..8e63d83d60 --- /dev/null +++ b/cms/static/sass/bourbon/functions/_grid-width.scss @@ -0,0 +1,13 @@ +@function grid-width($n) { + @return $n * $gw-column + ($n - 1) * $gw-gutter; +} + +// The $gw-column and $gw-gutter variables must be defined in your base stylesheet to properly use the grid-width function. +// +// $gw-column: 100px; // Column Width +// $gw-gutter: 40px; // Gutter Width +// +// div { +// width: grid-width(4); // returns 520px; +// margin-left: $gw-gutter; // returns 40px; +// } diff --git a/cms/static/sass/bourbon/functions/_linear-gradient.scss b/cms/static/sass/bourbon/functions/_linear-gradient.scss new file mode 100644 index 0000000000..3b10ca82a6 --- /dev/null +++ b/cms/static/sass/bourbon/functions/_linear-gradient.scss @@ -0,0 +1,23 @@ +@function linear-gradient($pos: top, $G1: false, $G2: false, + $G3: false, $G4: false, + $G5: false, $G6: false, + $G7: false, $G8: false, + $G9: false, $G10: false) { + + // Detect what type of value exists in $pos + $pos-type: type-of(nth($pos, 1)); + + // If $pos is missing from mixin, reassign vars and add default position + @if ($pos-type == color) or (nth($pos, 1) == "transparent") { + $G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5; + $G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos; + $pos: top; // Default position + } + + $type: linear; + $gradient: compact($pos, $G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10); + $type-gradient: append($type, $gradient, comma); + + @return $type-gradient; +} + diff --git a/cms/static/sass/bourbon/functions/_modular-scale.scss b/cms/static/sass/bourbon/functions/_modular-scale.scss new file mode 100644 index 0000000000..dddccb5224 --- /dev/null +++ b/cms/static/sass/bourbon/functions/_modular-scale.scss @@ -0,0 +1,40 @@ +@function modular-scale($value, $increment, $ratio) { + @if $increment > 0 { + @for $i from 1 through $increment { + $value: ($value * $ratio); + } + } + + @if $increment < 0 { + $increment: abs($increment); + @for $i from 1 through $increment { + $value: ($value / $ratio); + } + } + + @return $value; +} + +// div { +// Increment Up GR with positive value +// font-size: modular-scale(14px, 1, 1.618); // returns: 22.652px +// +// Increment Down GR with negative value +// font-size: modular-scale(14px, -1, 1.618); // returns: 8.653px +// +// Can be used with ceil(round up) or floor(round down) +// font-size: floor( modular-scale(14px, 1, 1.618) ); // returns: 22px +// font-size: ceil( modular-scale(14px, 1, 1.618) ); // returns: 23px +// } +// +// modularscale.com + +@function golden-ratio($value, $increment) { + @return modular-scale($value, $increment, 1.618) +} + +// div { +// font-size: golden-ratio(14px, 1); // returns: 22.652px +// } +// +// goldenratiocalculator.com diff --git a/cms/static/sass/bourbon/functions/_radial-gradient.scss b/cms/static/sass/bourbon/functions/_radial-gradient.scss new file mode 100644 index 0000000000..3d5461ad6e --- /dev/null +++ b/cms/static/sass/bourbon/functions/_radial-gradient.scss @@ -0,0 +1,15 @@ +// This function is required and used by the background-image mixin. +@function radial-gradient($pos, $shape-size, + $G1, $G2, + $G3: false, $G4: false, + $G5: false, $G6: false, + $G7: false, $G8: false, + $G9: false, $G10: false) { + + $type: radial; + $gradient: compact($pos, $shape-size, $G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10); + $type-gradient: append($type, $gradient, comma); + + @return $type-gradient; +} + diff --git a/cms/static/sass/bourbon/functions/_render-gradients.scss b/cms/static/sass/bourbon/functions/_render-gradients.scss new file mode 100644 index 0000000000..fe7c799ebe --- /dev/null +++ b/cms/static/sass/bourbon/functions/_render-gradients.scss @@ -0,0 +1,14 @@ +// User for linear and radial gradients within background-image or border-image properties + +@function render-gradients($gradients, $gradient-type, $vendor: false) { + $vendor-gradients: false; + @if $vendor { + $vendor-gradients: -#{$vendor}-#{$gradient-type}-gradient($gradients); + } + + @else if $vendor == false { + $vendor-gradients: "#{$gradient-type}-gradient(#{$gradients})"; + $vendor-gradients: unquote($vendor-gradients); + } + @return $vendor-gradients; +} diff --git a/cms/static/sass/bourbon/functions/_tint-shade.scss b/cms/static/sass/bourbon/functions/_tint-shade.scss new file mode 100644 index 0000000000..f7172004ac --- /dev/null +++ b/cms/static/sass/bourbon/functions/_tint-shade.scss @@ -0,0 +1,9 @@ +// Add percentage of white to a color +@function tint($color, $percent){ + @return mix(white, $color, $percent); +} + +// Add percentage of black to a color +@function shade($color, $percent){ + @return mix(black, $color, $percent); +} diff --git a/cms/static/sass/bourbon/lib/bourbon.rb b/cms/static/sass/bourbon/lib/bourbon.rb new file mode 100644 index 0000000000..1635be836d --- /dev/null +++ b/cms/static/sass/bourbon/lib/bourbon.rb @@ -0,0 +1,19 @@ +require "bourbon/generator" + +module Bourbon + if defined?(Rails) + class Engine < ::Rails::Engine + require 'bourbon/engine' + end + + module Rails + class Railtie < ::Rails::Railtie + rake_tasks do + load "tasks/install.rake" + end + end + end + end +end + +require File.join(File.dirname(__FILE__), "/bourbon/sass_extensions") diff --git a/cms/static/sass/bourbon/lib/bourbon/sass_extensions.rb b/cms/static/sass/bourbon/lib/bourbon/sass_extensions.rb new file mode 100644 index 0000000000..ad567200e3 --- /dev/null +++ b/cms/static/sass/bourbon/lib/bourbon/sass_extensions.rb @@ -0,0 +1,6 @@ +module Bourbon::SassExtensions +end + +require "sass" + +require File.join(File.dirname(__FILE__), "/sass_extensions/functions") diff --git a/cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions.rb b/cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions.rb new file mode 100644 index 0000000000..daa877650e --- /dev/null +++ b/cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions.rb @@ -0,0 +1,13 @@ +module Bourbon::SassExtensions::Functions +end + +require File.join(File.dirname(__FILE__), "/functions/compact") + +module Sass::Script::Functions + include Bourbon::SassExtensions::Functions::Compact +end + +# Wierd that this has to be re-included to pick up sub-modules. Ruby bug? +class Sass::Script::Functions::EvaluationContext + include Sass::Script::Functions +end diff --git a/cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions/compact.rb b/cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions/compact.rb new file mode 100644 index 0000000000..5192e921e7 --- /dev/null +++ b/cms/static/sass/bourbon/lib/bourbon/sass_extensions/functions/compact.rb @@ -0,0 +1,13 @@ +# Compact function pulled from compass +module Bourbon::SassExtensions::Functions::Compact + + def compact(*args) + sep = :comma + if args.size == 1 && args.first.is_a?(Sass::Script::List) + args = args.first.value + sep = args.first.separator + end + Sass::Script::List.new(args.reject{|a| !a.to_bool}, sep) + end + +end diff --git a/cms/templates/base.html b/cms/templates/base.html new file mode 100644 index 0000000000..497296ee66 --- /dev/null +++ b/cms/templates/base.html @@ -0,0 +1,30 @@ + + + + + + + + + + {% block title %}{% endblock %} + + + + + + {% include "widgets/header.html"%} + + {% block content %}{% endblock %} + + + + + + + + + + + + diff --git a/cms/templates/index.html b/cms/templates/index.html new file mode 100644 index 0000000000..82c3133a37 --- /dev/null +++ b/cms/templates/index.html @@ -0,0 +1,19 @@ +{% extends "base.html" %} +{% block title %}Course Manager{% endblock %} + +{% block content %} +

    + + {% include "widgets/navigation.html"%} + +
    + {% include "widgets/week-edit.html"%} + {% include "widgets/week-new.html"%} + {% include "widgets/video-edit.html"%} + {% include "widgets/video-new.html"%} + {% include "widgets/problem-edit.html"%} + {% include "widgets/problem-new.html"%} +
    + +
    +{% endblock %} diff --git a/cms/templates/widgets/captions.html b/cms/templates/widgets/captions.html new file mode 100644 index 0000000000..088beb7a33 --- /dev/null +++ b/cms/templates/widgets/captions.html @@ -0,0 +1,242 @@ +
      +
    • English (main)
    • +
    • French
    • +
    • English v2
    • +
    • +
    • +
    + + diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html new file mode 100644 index 0000000000..86a2afb0f9 --- /dev/null +++ b/cms/templates/widgets/header.html @@ -0,0 +1,5 @@ +
    + +
    diff --git a/cms/templates/widgets/navigation.html b/cms/templates/widgets/navigation.html new file mode 100644 index 0000000000..049e5da537 --- /dev/null +++ b/cms/templates/widgets/navigation.html @@ -0,0 +1,120 @@ +
    +
    +

    Circuts & Electronics

    + + +
    + +
      +
    1. +
      +

      Week 1

      +
      + +
        +
      • Goal 1
      • +
      • Goal 2
      • +
      • Lecture Sequence
      • +
      • Lecture Sequence
      • +
      • Lab
      • +
      • Homework
      • +
      • + Add new sequence
      • +
      +
    2. +
    3. +
      +

      Week 2

      +
      + +
        +
      • Goal 1
      • +
      • Lecture Sequence
      • +
      • Lecture Sequence
      • +
      • Lab
      • +
      • Homework
      • +
      • + Add new sequence
      • +
      +
    4. +
    5. +
      +

      Week 3

      +
      + +
        +
      • Goal 1
      • +
      • Lab
      • +
      • Lab
      • +
      • Homework
      • +
      • + Add new sequence
      • +
      +
    6. +
    7. +
      +

      Week 4

      +
      + +
        +
      • Goal 1
      • +
      • Lecture Sequence
      • +
      • Lab
      • +
      • Homework
      • +
      • Homework
      • +
      • + Add new sequence
      • +
      +
    8. + +
    9. +
      +

      Week 5

      +
      + +
        +
      • + Add new sequence
      • +
      +
    10. +
    11. +

      + + Add New +

      + +
      +
      +

      Week 6

      +
      + +
      + + +
      +
      +
    12. +
    +
    + diff --git a/cms/templates/widgets/new-module.html b/cms/templates/widgets/new-module.html new file mode 100644 index 0000000000..070b6462bb --- /dev/null +++ b/cms/templates/widgets/new-module.html @@ -0,0 +1,9 @@ +
  • + +
  • diff --git a/cms/templates/widgets/problem-edit.html b/cms/templates/widgets/problem-edit.html new file mode 100644 index 0000000000..b1d5796a9f --- /dev/null +++ b/cms/templates/widgets/problem-edit.html @@ -0,0 +1,73 @@ +
    +
    + cancel + Save & Update +
    + +
    +
    +

    Old Problem

    +
    + + +
    + Settings +
    + + +
    +
    +
    +

    Tags:

    +

    Click to edit

    +
    + +
    +

    Last modified:

    +

    mm/dd/yy

    +
    + +
    +

    By

    +

    Anant Agarwal

    +
    +
    +
    + +
    + +
    + Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. +
    +
    + +
    +
      +
    • +

      Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.

      +

      Anant Agarwal

      +
    • +
    • +

      Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.

      +

      Anant Agarwal

      +
    • +
    + +
    +

    Add notes

    + + +
    +
    + + Save & Update +
    +
    + diff --git a/cms/templates/widgets/problem-new.html b/cms/templates/widgets/problem-new.html new file mode 100644 index 0000000000..9f91dd1177 --- /dev/null +++ b/cms/templates/widgets/problem-new.html @@ -0,0 +1,52 @@ +
    +
    + cancel + Save & Update +
    + +
    +
    +

    New Problem

    +
    + + Settings + +
    +
    +
    +

    Tags:

    +

    Click to edit

    +
    + + + + + + + + + + +
    +
    + +
    + +
    +
    +
    + +
    +

    Add notes

    +
    + + Save & Update +
    +
    diff --git a/cms/templates/widgets/raw-videos.html b/cms/templates/widgets/raw-videos.html new file mode 100644 index 0000000000..f466fd59bc --- /dev/null +++ b/cms/templates/widgets/raw-videos.html @@ -0,0 +1,3 @@ +
  • +
    Video-file-name
    +
  • diff --git a/cms/templates/widgets/save-captions.html b/cms/templates/widgets/save-captions.html new file mode 100644 index 0000000000..87342f0cd0 --- /dev/null +++ b/cms/templates/widgets/save-captions.html @@ -0,0 +1,4 @@ +
    + Cancel + +
    diff --git a/cms/templates/widgets/speed-tooltip.html b/cms/templates/widgets/speed-tooltip.html new file mode 100644 index 0000000000..2a82e237e7 --- /dev/null +++ b/cms/templates/widgets/speed-tooltip.html @@ -0,0 +1,7 @@ +
    + +
    diff --git a/cms/templates/widgets/video-box-unused.html b/cms/templates/widgets/video-box-unused.html new file mode 100644 index 0000000000..8cde10f151 --- /dev/null +++ b/cms/templates/widgets/video-box-unused.html @@ -0,0 +1,38 @@ +
  • + +
    + +
    + video-name 236mb Uploaded 6 hours ago by Anant Agrawal +

    +

      + Speed +
    • + 0.75x + {% include "widgets/speed-tooltip.html" %} +
    • +
    • Normal + {% include "widgets/speed-tooltip.html" %} +
    • +
    • 1.25x + {% include "widgets/speed-tooltip.html" %} +
    • +
    • 1.5x + {% include "widgets/speed-tooltip.html" %} +
    • +
    • +
    • +
    +

    +

    + Download All — + Delete All — + Edit Captions — + Use clip ⬆ +

    +
    +
    + {% include "widgets/captions.html" %} + {% include "widgets/save-captions.html" %} +
    +
  • + diff --git a/cms/templates/widgets/video-box.html b/cms/templates/widgets/video-box.html new file mode 100644 index 0000000000..9ab17030bd --- /dev/null +++ b/cms/templates/widgets/video-box.html @@ -0,0 +1,35 @@ +
  • +
    + +
    + video-name 236mb +

    Uploaded 6 hours ago by Anant Agrawal

    +

    +

      + Speed +
    • + 0.75x + {% include "widgets/speed-tooltip.html" %} +
    • +
    • Normal + {% include "widgets/speed-tooltip.html" %} +
    • +
    • 1.25x + {% include "widgets/speed-tooltip.html" %} +
    • +
    • 1.5x + {% include "widgets/speed-tooltip.html" %} +
    • +
    • +
    • +
    +

    +

    + Download all — +Remove ⬇ + +

    +
    +
    + {% include "widgets/captions.html" %} +
    +
  • diff --git a/cms/templates/widgets/video-edit.html b/cms/templates/widgets/video-edit.html new file mode 100644 index 0000000000..6b49dc27d7 --- /dev/null +++ b/cms/templates/widgets/video-edit.html @@ -0,0 +1,151 @@ +
    + +
    +
    + +
    +
    + Created 22/03/12 + by Piotr Mitros +
    + +
    + Last edited 22/03/12 + by David Ormsbee +
    +
    +
    +
    +

    Video title

    + +
    + Tag mitx, s4v1, circuits, anant +
    + +
    +
    + Keyword + S4V1 + + + Due Date + 21/03/12 + + Status + + + +
    + +
    + +
    +
    +
    + or + use an already uploaded one +
    +
    + +
    +
    +
      +
    • video-name-@0-75x.extension
    • +
    • video-name-@1x.extension
    • +
    • video-name-@1-25x.extension
    • +
    • video-name-@1-5x.extension
    • +
    +
    + + + Cancel +
    + +
    + +
    +
    +
      +

      Video clip in use

      + {% include "widgets/video-box.html" %} +
    +

    No video clip used. Select one from the list below, upload a new one or import an already uploaded video.

    +
    +
    + +
    +
    + + +
    +
    +
      + {% include "widgets/video-box-unused.html" %} +
    +
    +
    + +
    + +
    +

    Annotations

    + + +
    + +
    + +
    + +
    +

    Notes

    + + + +
    + +
    +
    +
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. +

    By Piotr Mitros 10 hours ago

    +
    +
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

    By Piotr Mitros 10 hours ago

    +
    +
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

    By Piotr Mitros 10 hours ago

    +
    +
    +
    + + + +
    + +
    + Select the source video or directly enter its ID +
    + +
    + +
    + +
    + + + Cancel +
    +
    diff --git a/cms/templates/widgets/video-new.html b/cms/templates/widgets/video-new.html new file mode 100644 index 0000000000..2555169c05 --- /dev/null +++ b/cms/templates/widgets/video-new.html @@ -0,0 +1,48 @@ +
    +
    + cancel + Save & Update +
    + +
    +
    +

    Untitled Video

    +
    + + Settings + +
    + +
    +
    +

    Tags:

    +

    Click to edit

    +
    + + + + + + + + + + +
    +
    + +
    + +
    +
    + Save & Update +
    +
    +
    diff --git a/cms/templates/widgets/week-edit.html b/cms/templates/widgets/week-edit.html new file mode 100644 index 0000000000..5e6ac199e9 --- /dev/null +++ b/cms/templates/widgets/week-edit.html @@ -0,0 +1,83 @@ +{% block content %} +
    +
    +

    Week 3

    + Done +
    + + + +
    +
    +

    Weeks Content

    +
    + +
    +
    + +
    +
      +
    • + + +
    • + +
    • + + +
    • +
    • + +
    • + +
    • + Advanced filters +
    • +
    +
    + +
    + +
    +
    +
    +{% endblock %} diff --git a/cms/templates/widgets/week-new.html b/cms/templates/widgets/week-new.html new file mode 100644 index 0000000000..42f4f78e1e --- /dev/null +++ b/cms/templates/widgets/week-new.html @@ -0,0 +1,62 @@ +{% block content %} +
    +
    +

    Week 6

    + Done +
    + + + +
    +
    +

    Weeks Content

    +
    + +
    +
    + +
    +
      +
    • + + +
    • + +
    • + + +
    • +
    • + +
    • + +
    • + Advanced filters +
    • +
    +
    +
    +
    +{% endblock %} diff --git a/cms/urls.py b/cms/urls.py index a7266066cc..781c2c261f 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -7,4 +7,5 @@ from django.conf.urls.defaults import patterns, url urlpatterns = patterns('', url(r'^(?P[^/]+)/(?P[^/]+)/calendar/', 'contentstore.views.calendar', name='calendar'), url(r'^accounts/login/', 'instructor.views.do_login', name='login'), + url(r'^$', 'contentstore.views.index', name='index'), ) From 8338031f3e90c76ea740d1c000456231511b3822 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 13 Jun 2012 13:22:38 -0400 Subject: [PATCH 52/80] Switch to mako templates --- cms/templates/base.html | 24 ++++++++++----------- cms/templates/index.html | 22 +++++++++---------- cms/templates/widgets/video-box-unused.html | 12 +++++------ cms/templates/widgets/video-box.html | 10 ++++----- cms/templates/widgets/video-edit.html | 8 +++---- cms/templates/widgets/week-edit.html | 6 +++--- cms/templates/widgets/week-new.html | 6 +++--- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/cms/templates/base.html b/cms/templates/base.html index 497296ee66..a23a31d9a5 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -4,26 +4,26 @@ - - - - {% block title %}{% endblock %} + + + + <%block name="title"></%block> - {% include "widgets/header.html"%} + <%include file="widgets/header.html"/> - {% block content %}{% endblock %} + <%block name="content"> - - - - - - + + + + + + diff --git a/cms/templates/index.html b/cms/templates/index.html index 82c3133a37..efd9f9a242 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -1,19 +1,19 @@ -{% extends "base.html" %} -{% block title %}Course Manager{% endblock %} +<%inherit file="base.html" /> +<%block name="title">Course Manager -{% block content %} +<%block name="content">
    - {% include "widgets/navigation.html"%} + <%include file="widgets/navigation.html"/>
    - {% include "widgets/week-edit.html"%} - {% include "widgets/week-new.html"%} - {% include "widgets/video-edit.html"%} - {% include "widgets/video-new.html"%} - {% include "widgets/problem-edit.html"%} - {% include "widgets/problem-new.html"%} + <%include file="widgets/week-edit.html"/> + <%include file="widgets/week-new.html"/> + <%include file="widgets/video-edit.html"/> + <%include file="widgets/video-new.html"/> + <%include file="widgets/problem-edit.html"/> + <%include file="widgets/problem-new.html"/>
    -{% endblock %} + diff --git a/cms/templates/widgets/video-box-unused.html b/cms/templates/widgets/video-box-unused.html index 8cde10f151..3d643ff3c9 100644 --- a/cms/templates/widgets/video-box-unused.html +++ b/cms/templates/widgets/video-box-unused.html @@ -9,16 +9,16 @@ Speed
  • 0.75x - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • Normal - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • 1.25x - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • 1.5x - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • +
  • @@ -31,8 +31,8 @@

    - {% include "widgets/captions.html" %} - {% include "widgets/save-captions.html" %} + <%include file="captions.html"/> + <%include file="save-captions.html"/>
    diff --git a/cms/templates/widgets/video-box.html b/cms/templates/widgets/video-box.html index 9ab17030bd..1f17e33511 100644 --- a/cms/templates/widgets/video-box.html +++ b/cms/templates/widgets/video-box.html @@ -9,16 +9,16 @@ Speed
  • 0.75x - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • Normal - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • 1.25x - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • 1.5x - {% include "widgets/speed-tooltip.html" %} + <%include file="speed-tooltip.html"/>
  • +
  • @@ -30,6 +30,6 @@

    - {% include "widgets/captions.html" %} + <%include file="captions.html"/>
    diff --git a/cms/templates/widgets/video-edit.html b/cms/templates/widgets/video-edit.html index 6b49dc27d7..ac4c921918 100644 --- a/cms/templates/widgets/video-edit.html +++ b/cms/templates/widgets/video-edit.html @@ -71,7 +71,7 @@

      Video clip in use

      - {% include "widgets/video-box.html" %} + <%include file="video-box.html"/>

    No video clip used. Select one from the list below, upload a new one or import an already uploaded video.

    @@ -84,7 +84,7 @@
      - {% include "widgets/video-box-unused.html" %} + <%include file="video-box-unused.html"/>
    @@ -129,7 +129,7 @@ @@ -140,7 +140,7 @@
    - +
    diff --git a/cms/templates/widgets/week-edit.html b/cms/templates/widgets/week-edit.html index 5e6ac199e9..ea6d29ef3b 100644 --- a/cms/templates/widgets/week-edit.html +++ b/cms/templates/widgets/week-edit.html @@ -1,4 +1,4 @@ -{% block content %} +<%block name="content">

    Week 3

    @@ -27,7 +27,7 @@
  • Problem title 13
  • Problem title 14
  • Video 3
  • - {% include "widgets/new-module.html"%} + <%include file="new-module.html"/>
    @@ -80,4 +80,4 @@ -{% endblock %} + diff --git a/cms/templates/widgets/week-new.html b/cms/templates/widgets/week-new.html index 42f4f78e1e..986dc6e05e 100644 --- a/cms/templates/widgets/week-new.html +++ b/cms/templates/widgets/week-new.html @@ -1,4 +1,4 @@ -{% block content %} +<%block name="content">

    Week 6

    @@ -18,7 +18,7 @@

    Scratchpad

      - {% include "widgets/new-module.html"%} + <%include file="new-module.html"/>
    @@ -59,4 +59,4 @@ -{% endblock %} + From f2080fde62335645a4d9ea787e8097e716d55f7a Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 13 Jun 2012 14:43:01 -0400 Subject: [PATCH 53/80] Porting latest changes from ui_prototype --- cms/static/css/base-style.css | 684 ++++++++++++++------- cms/static/js/main.js | 165 ++--- cms/static/sass/_base.scss | 16 +- cms/static/sass/_calendar.scss | 286 +++++---- cms/static/sass/_module-header.scss | 128 ++++ cms/static/sass/_problem.scss | 47 +- cms/static/sass/_video.scss | 59 +- cms/static/sass/_week.scss | 4 +- cms/static/sass/base-style.scss | 14 +- cms/templates/index.html | 1 + cms/templates/widgets/header.html | 3 +- cms/templates/widgets/module-dropdown.html | 28 + cms/templates/widgets/navigation.html | 118 ++-- cms/templates/widgets/new-module.html | 16 +- cms/templates/widgets/problem-edit.html | 72 +-- cms/templates/widgets/problem-new.html | 33 +- cms/templates/widgets/sequnce-edit.html | 85 +++ cms/templates/widgets/video-edit.html | 184 ++---- cms/templates/widgets/video-new.html | 81 ++- cms/templates/widgets/week-edit.html | 94 +-- cms/templates/widgets/week-new.html | 114 ++-- 21 files changed, 1356 insertions(+), 876 deletions(-) create mode 100644 cms/static/sass/_module-header.scss create mode 100644 cms/templates/widgets/module-dropdown.html create mode 100644 cms/templates/widgets/sequnce-edit.html diff --git a/cms/static/css/base-style.css b/cms/static/css/base-style.css index 2cdeafe9e5..518443a41c 100644 --- a/cms/static/css/base-style.css +++ b/cms/static/css/base-style.css @@ -191,13 +191,28 @@ body { clear: both; } body > header nav h2 { font-size: 14px; - text-transform: uppercase; } + text-transform: uppercase; + float: left; } + body > header nav a.new-module { + float: right; } + body.content section.main-content { + border-left: 2px solid #000; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 74.423%; + float: left; + -webkit-box-shadow: -2px 0 3px #dddddd; + -moz-box-shadow: -2px 0 3px #dddddd; + box-shadow: -2px 0 3px #dddddd; } a { text-decoration: none; color: #888; } -input[type="submit"], .button, section.week-edit > header a, section.week-new > header a { +input[type="submit"], .button, section.cal section.new-section > a, section.week-edit > header a, +section.week-new > header a, +section.sequence-edit > header a, section.video-new > section section.upload a.upload-button, section.video-edit > section section.upload a.upload-button, section.video-new > section a.save-update, section.video-edit > section a.save-update, section.problem-new > section a.save, section.problem-edit > section a.save { border: 1px solid #ccc; background: #efefef; -webkit-border-radius: 3px; @@ -221,17 +236,36 @@ section.cal { clear: both; } section.cal > header { zoom: 1; - margin-bottom: 10px; } + margin-bottom: 10px; + background: #efefef; + border: 1px solid #ddd; } section.cal > header:before, section.cal > header:after { content: ""; display: table; } section.cal > header:after { clear: both; } - section.cal > header h1 { - float: left; - font-size: 18px; } + section.cal > header h2 { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + text-transform: uppercase; + letter-spacing: 1px; + font-size: 14px; + padding: 6px; + margin-left: 6px; + font-size: 12px; } section.cal > header ul { - float: right; } + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } section.cal > header ul li { display: -moz-inline-box; -moz-box-orient: vertical; @@ -239,42 +273,37 @@ section.cal { vertical-align: baseline; zoom: 1; *display: inline; - *vertical-align: auto; } + *vertical-align: auto; + margin-left: 6px; + padding-left: 6px; + border-left: 1px solid #ddd; + padding: 6px; } section.cal > header ul li a { - padding: 6px; - border: 1px solid #ddd; - display: block; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - -ms-border-radius: 3px; - -o-border-radius: 3px; - border-radius: 3px; - background: #efefef; } - section.cal > header ul li.dropdown { - position: relative; } - section.cal > header ul li.dropdown ul { - display: none; - position: absolute; - background: #fff; - border: 1px solid #ddd; } - section.cal > header ul li.dropdown ul li { - padding: 6px; - display: block; - border-top: 1px solid transparent; - border-bottom: 1px solid transparent; } - section.cal > header ul li.dropdown ul li:hover { - background-color: #efefef; - border-top: 1px solid #ddd; - border-bottom: 1px solid #ddd; } - section.cal > header ul li.dropdown:hover ul { - display: block; } - section.cal > header ul li.dropdown:hover a { - -webkit-border-radius: 3px 3px 0 0; - -moz-border-radius: 3px 3px 0 0; - -ms-border-radius: 3px 3px 0 0; - -o-border-radius: 3px 3px 0 0; - border-radius: 3px 3px 0 0; - border-bottom: 0; } + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.cal > header ul li ul { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.cal > header ul li ul li { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + padding: 0; + border-left: 0; } section.cal ol { list-style: none; zoom: 1; @@ -297,75 +326,26 @@ section.cal { box-sizing: border-box; float: left; width: 25.0%; } - section.cal ol > li:last-child { - text-align: center; - background: #eee; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - section.cal ol > li:last-child p { - width: 100%; - height: 100%; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; } - section.cal ol > li:last-child p a { - display: block; - width: 100%; - height: 100%; } - section.cal ol > li:last-child section.new-week header { - background: #fff; - text-align: left; } - section.cal ol > li:last-child section.new-week form { - background: #fff; - width: 50%; - padding: 6px; - border: 1px solid #000; - margin: 0 auto; - -webkit-box-shadow: 0 0 2px #333333; - -moz-box-shadow: 0 0 2px #333333; - box-shadow: 0 0 2px #333333; - position: relative; } - section.cal ol > li:last-child section.new-week form:before { - background: #fff; - border-left: 1px solid #000; - border-top: 1px solid #000; - content: " "; - display: block; - height: 10px; - left: 50%; - position: absolute; - top: -6px; - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -ms-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); - width: 10px; - z-index: 0; } - section.cal ol > li:last-child section.new-week form select { - margin-bottom: 6px; - width: 100%; } - section.cal ol > li:last-child section.new-week form select option { - padding: 10px 0 !important; } - section.cal ol > li:last-child section.new-week form input[type="submit"] { - display: block; - margin-bottom: 6px; - width: 100%; } - section.cal ol > li:last-child section.new-week form a:first-child { - float: left; } - section.cal ol > li:last-child section.new-week form a:last-child { - float: right; } section.cal ol > li header { border-bottom: 1px solid #000; - -webkit-box-shadow: 0 1px 2px #cccccc; - -moz-box-shadow: 0 1px 2px #cccccc; - box-shadow: 0 1px 2px #cccccc; + -webkit-box-shadow: 0 1px 2px #aaaaaa; + -moz-box-shadow: 0 1px 2px #aaaaaa; + box-shadow: 0 1px 2px #aaaaaa; display: block; - margin-bottom: 2px; - padding: 6px; } + margin-bottom: 2px; } section.cal ol > li header h1 { - font-size: 14px; } + font-size: 14px; + text-transform: uppercase; + border-bottom: 1px solid #ccc; + padding: 6px; } + section.cal ol > li header h1 a { + color: #000; + display: block; } + section.cal ol > li header ul li { + background: #fff; + color: #888; + border-bottom: 0; + font-size: 12px; } section.cal ol > li ul { list-style: none; margin-bottom: 1px; } @@ -373,8 +353,104 @@ section.cal { background: #efefef; border-bottom: 1px solid #666; padding: 6px; } - section.cal ol > li ul li.goal { - background: #fff; } + section.cal ol > li ul li.create-module { + position: relative; } + section.cal ol > li ul li.create-module > div { + display: none; + position: absolute; + top: 30px; + width: 90%; + background: rgba(0, 0, 0, 0.8); + padding: 10px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; + z-index: 99; } + section.cal ol > li ul li.create-module > div ul li { + border-bottom: 0; + background: none; } + section.cal ol > li ul li.create-module > div ul li input { + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border-color: #000; + padding: 6px; } + section.cal ol > li ul li.create-module > div ul li select { + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + section.cal ol > li ul li.create-module > div ul li select option { + font-size: 14px; } + section.cal ol > li ul li.create-module > div ul li a { + float: right; } + section.cal ol > li ul li.create-module > div ul li a:first-child { + float: left; } + section.cal ol > li ul li.create-module:hover div { + display: block; } + section.cal section.new-section { + margin-top: 10px; } + section.cal section.new-section > a { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.cal section.new-section section { + display: none; } + section.cal section.new-section section header { + background: #fff; + text-align: left; } + section.cal section.new-section section form { + background: #fff; + width: 50%; + padding: 6px; + border: 1px solid #000; + margin: 0 auto; + -webkit-box-shadow: 0 0 2px #333333; + -moz-box-shadow: 0 0 2px #333333; + box-shadow: 0 0 2px #333333; + position: relative; } + section.cal section.new-section section form:before { + background: #fff; + border-left: 1px solid #000; + border-top: 1px solid #000; + content: " "; + display: block; + height: 10px; + left: 50%; + position: absolute; + top: -6px; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + width: 10px; + z-index: 0; } + section.cal section.new-section section form select { + margin-bottom: 6px; + width: 100%; } + section.cal section.new-section section form select option { + padding: 10px 0 !important; } + section.cal section.new-section section form input[type="submit"] { + display: block; + margin-bottom: 6px; + width: 100%; } + section.cal section.new-section section form a:first-child { + float: left; } + section.cal section.new-section section form a:last-child { + float: right; } + section.cal section.new-section:hover section { + display: block; } body.content section.cal { @@ -393,31 +469,49 @@ section.cal { box-sizing: border-box; width: 100%; } -section.week-edit > header, section.week-new > header { +section.week-edit > header, +section.week-new > header, +section.sequence-edit > header { border-bottom: 1px solid #ccc; zoom: 1; padding: 6px; } - section.week-edit > header:before, section.week-edit > header:after, section.week-new > header:before, section.week-new > header:after { + section.week-edit > header:before, section.week-edit > header:after, + section.week-new > header:before, + section.week-new > header:after, + section.sequence-edit > header:before, + section.sequence-edit > header:after { content: ""; display: table; } - section.week-edit > header:after, section.week-new > header:after { + section.week-edit > header:after, + section.week-new > header:after, + section.sequence-edit > header:after { clear: both; } - section.week-edit > header h1, section.week-new > header h1 { + section.week-edit > header h1, + section.week-new > header h1, + section.sequence-edit > header h1 { font-size: 18px; float: left; margin-top: 8px 6px; } - section.week-edit > header a, section.week-new > header a { + section.week-edit > header a, + section.week-new > header a, + section.sequence-edit > header a { float: right; display: block; } -section.week-edit section header, section.week-new section header { +section.week-edit section header, +section.week-new section header, +section.sequence-edit section header { background: #666; color: #fff; padding: 6px; border-bottom: 1px solid #333; -webkit-font-smoothing: antialiased; } - section.week-edit section header h2, section.week-new section header h2 { + section.week-edit section header h2, + section.week-new section header h2, + section.sequence-edit section header h2 { font-size: 14px; } -section.week-edit section.sidebar, section.week-new section.sidebar { +section.week-edit section.sidebar, +section.week-new section.sidebar, +section.sequence-edit section.sidebar { width: 34.368%; float: left; background: #ccc; @@ -425,49 +519,85 @@ section.week-edit section.sidebar, section.week-new section.sidebar { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } - section.week-edit section.sidebar section, section.week-new section.sidebar section { + section.week-edit section.sidebar section, + section.week-new section.sidebar section, + section.sequence-edit section.sidebar section { height: 50%; } - section.week-edit section.sidebar section > ul, section.week-new section.sidebar section > ul { + section.week-edit section.sidebar section > ul, + section.week-new section.sidebar section > ul, + section.sequence-edit section.sidebar section > ul { list-style: none; } - section.week-edit section.sidebar section > ul > li, section.week-new section.sidebar section > ul > li { + section.week-edit section.sidebar section > ul > li, + section.week-new section.sidebar section > ul > li, + section.sequence-edit section.sidebar section > ul > li { padding: 6px; border-bottom: 1px solid #666; background: #eee; } - section.week-edit section.sidebar section > ul > li.new-module, section.week-new section.sidebar section > ul > li.new-module { + section.week-edit section.sidebar section > ul > li.new-module, + section.week-new section.sidebar section > ul > li.new-module, + section.sequence-edit section.sidebar section > ul > li.new-module { position: relative; } - section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown { + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown, + section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown, + section.sequence-edit section.sidebar section > ul > li.new-module ul.new-dropdown { list-style: none; } - section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown li, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown li { + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown li, + section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown li, + section.sequence-edit section.sidebar section > ul > li.new-module ul.new-dropdown li { display: none; } - section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown li:first-child, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown li:first-child { + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown li:first-child, + section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown li:first-child, + section.sequence-edit section.sidebar section > ul > li.new-module ul.new-dropdown li:first-child { display: block; } - section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown:hover li { + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li, + section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown:hover li, + section.sequence-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li { display: block; padding: 6px 0; } - section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li:first-child, section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown:hover li:first-child { + section.week-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li:first-child, + section.week-new section.sidebar section > ul > li.new-module ul.new-dropdown:hover li:first-child, + section.sequence-edit section.sidebar section > ul > li.new-module ul.new-dropdown:hover li:first-child { padding-top: 0; } - section.week-edit section.sidebar section p, section.week-new section.sidebar section p { + section.week-edit section.sidebar section p, + section.week-new section.sidebar section p, + section.sequence-edit section.sidebar section p { padding: 6px; border-bottom: 1px solid #666; } -section.week-edit section.weeks-content, section.week-new section.weeks-content { +section.week-edit section.weeks-content, +section.week-new section.weeks-content, +section.sequence-edit section.weeks-content { width: 65.632%; float: left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } - section.week-edit section.weeks-content header, section.week-new section.weeks-content header { + section.week-edit section.weeks-content header, + section.week-new section.weeks-content header, + section.sequence-edit section.weeks-content header { zoom: 1; } - section.week-edit section.weeks-content header:before, section.week-edit section.weeks-content header:after, section.week-new section.weeks-content header:before, section.week-new section.weeks-content header:after { + section.week-edit section.weeks-content header:before, section.week-edit section.weeks-content header:after, + section.week-new section.weeks-content header:before, + section.week-new section.weeks-content header:after, + section.sequence-edit section.weeks-content header:before, + section.sequence-edit section.weeks-content header:after { content: ""; display: table; } - section.week-edit section.weeks-content header:after, section.week-new section.weeks-content header:after { + section.week-edit section.weeks-content header:after, + section.week-new section.weeks-content header:after, + section.sequence-edit section.weeks-content header:after { clear: both; } - section.week-edit section.weeks-content header h2, section.week-new section.weeks-content header h2 { + section.week-edit section.weeks-content header h2, + section.week-new section.weeks-content header h2, + section.sequence-edit section.weeks-content header h2 { float: left; } - section.week-edit section.weeks-content header form, section.week-new section.weeks-content header form { + section.week-edit section.weeks-content header form, + section.week-new section.weeks-content header form, + section.sequence-edit section.weeks-content header form { float: right; margin: -2px 0; } - section.week-edit section.weeks-content header form input, section.week-new section.weeks-content header form input { + section.week-edit section.weeks-content header form input, + section.week-new section.weeks-content header form input, + section.sequence-edit section.weeks-content header form input { border: 1px solid #000; background: #ddd; padding: 2px 4px; @@ -476,18 +606,30 @@ section.week-edit section.weeks-content, section.week-new section.weeks-content -ms-border-radius: 2px; -o-border-radius: 2px; border-radius: 2px; } - section.week-edit section.weeks-content section.filters, section.week-new section.weeks-content section.filters { + section.week-edit section.weeks-content section.filters, + section.week-new section.weeks-content section.filters, + section.sequence-edit section.weeks-content section.filters { border-bottom: 1px solid #999; } - section.week-edit section.weeks-content section.filters ul, section.week-new section.weeks-content section.filters ul { + section.week-edit section.weeks-content section.filters ul, + section.week-new section.weeks-content section.filters ul, + section.sequence-edit section.weeks-content section.filters ul { zoom: 1; list-style: none; padding: 6px; } - section.week-edit section.weeks-content section.filters ul:before, section.week-edit section.weeks-content section.filters ul:after, section.week-new section.weeks-content section.filters ul:before, section.week-new section.weeks-content section.filters ul:after { + section.week-edit section.weeks-content section.filters ul:before, section.week-edit section.weeks-content section.filters ul:after, + section.week-new section.weeks-content section.filters ul:before, + section.week-new section.weeks-content section.filters ul:after, + section.sequence-edit section.weeks-content section.filters ul:before, + section.sequence-edit section.weeks-content section.filters ul:after { content: ""; display: table; } - section.week-edit section.weeks-content section.filters ul:after, section.week-new section.weeks-content section.filters ul:after { + section.week-edit section.weeks-content section.filters ul:after, + section.week-new section.weeks-content section.filters ul:after, + section.sequence-edit section.weeks-content section.filters ul:after { clear: both; } - section.week-edit section.weeks-content section.filters ul li, section.week-new section.weeks-content section.filters ul li { + section.week-edit section.weeks-content section.filters ul li, + section.week-new section.weeks-content section.filters ul li, + section.sequence-edit section.weeks-content section.filters ul li { display: -moz-inline-box; -moz-box-orient: vertical; display: inline-block; @@ -495,95 +637,201 @@ section.week-edit section.weeks-content, section.week-new section.weeks-content zoom: 1; *display: inline; *vertical-align: auto; } - section.week-edit section.weeks-content section.filters ul li.advanced, section.week-new section.weeks-content section.filters ul li.advanced { + section.week-edit section.weeks-content section.filters ul li.advanced, + section.week-new section.weeks-content section.filters ul li.advanced, + section.sequence-edit section.weeks-content section.filters ul li.advanced { float: right; } - section.week-edit section.weeks-content section.modules ul, section.week-new section.weeks-content section.modules ul { + section.week-edit section.weeks-content section.modules ul, + section.week-new section.weeks-content section.modules ul, + section.sequence-edit section.weeks-content section.modules ul { list-style: none; } - section.week-edit section.weeks-content section.modules ul li, section.week-new section.weeks-content section.modules ul li { + section.week-edit section.weeks-content section.modules ul li, + section.week-new section.weeks-content section.modules ul li, + section.sequence-edit section.weeks-content section.modules ul li { padding: 6px; font-weight: bold; font-size: 16px; border-bottom: 1px solid #333; } - section.week-edit section.weeks-content section.modules ul li a, section.week-new section.weeks-content section.modules ul li a { + section.week-edit section.weeks-content section.modules ul li a, + section.week-new section.weeks-content section.modules ul li a, + section.sequence-edit section.weeks-content section.modules ul li a { color: #000; } -section.video-new, section.video-edit { - position: absolute; - top: 80px; - right: 0; - background: #fff; - width: 40.32%; - -webkit-box-shadow: 0 0 6px #666666; - -moz-box-shadow: 0 0 6px #666666; - box-shadow: 0 0 6px #666666; - border: 1px solid #333; - border-right: 0; - z-index: 4; } - section.video-new > header, section.video-edit > header { - background: #666; +section.video-new > section section.upload, section.video-edit > section section.upload { + padding: 6px; + margin-bottom: 10px; + border: 1px solid #ddd; } + section.video-new > section section.upload a.upload-button, section.video-edit > section section.upload a.upload-button { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; zoom: 1; - color: #fff; - padding: 6px; - border-bottom: 1px solid #333; - -webkit-font-smoothing: antialiased; } - section.video-new > header:before, section.video-new > header:after, section.video-edit > header:before, section.video-edit > header:after { - content: ""; - display: table; } - section.video-new > header:after, section.video-edit > header:after { - clear: both; } - section.video-new > header h2, section.video-edit > header h2 { - float: left; - font-size: 14px; } - section.video-new > header a, section.video-edit > header a { - float: right; } - section.video-new section ul, section.video-edit section ul { - list-style: none; } - section.video-new section ul li, section.video-edit section ul li { - border-bottom: 1px solid #333; - padding: 10px 25px; } + *display: inline; + *vertical-align: auto; } +section.video-new > section section.in-use h2, section.video-edit > section section.in-use h2 { + font-size: 14px; } +section.video-new > section section.in-use div, section.video-edit > section section.in-use div { + background: #eee; + text-align: center; + padding: 6px; } +section.video-new > section a.save-update, section.video-edit > section a.save-update { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + margin-top: 20px; } -section.problem-new, section.problem-edit { - position: absolute; - top: 80px; - right: 0; - background: #fff; - width: 40.32%; - -webkit-box-shadow: 0 0 6px #666666; - -moz-box-shadow: 0 0 6px #666666; - box-shadow: 0 0 6px #666666; - border: 1px solid #333; - border-right: 0; - z-index: 4; } - section.problem-new > header, section.problem-edit > header { - background: #666; - zoom: 1; - color: #fff; - padding: 6px; - border-bottom: 1px solid #333; - -webkit-font-smoothing: antialiased; } - section.problem-new > header:before, section.problem-new > header:after, section.problem-edit > header:before, section.problem-edit > header:after { - content: ""; - display: table; } - section.problem-new > header:after, section.problem-edit > header:after { - clear: both; } - section.problem-new > header h2, section.problem-edit > header h2 { - float: left; - font-size: 14px; } - section.problem-new > header a, section.problem-edit > header a { - float: right; } - section.problem-new section ul, section.problem-edit section ul { - list-style: none; } - section.problem-new section ul li, section.problem-edit section ul li { - border-bottom: 1px solid #333; - padding: 10px 25px; } - -body.content section.main-content { - border-left: 2px solid #000; +section.problem-new > section textarea, section.problem-edit > section textarea { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; - width: 74.423%; - float: left; - -webkit-box-shadow: -2px 0 3px #dddddd; - -moz-box-shadow: -2px 0 3px #dddddd; - box-shadow: -2px 0 3px #dddddd; } + display: block; + width: 100%; } +section.problem-new > section div.preview, section.problem-edit > section div.preview { + background: #eee; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + height: 40px; + padding: 10px; + width: 100%; } +section.problem-new > section a.save, section.problem-edit > section a.save { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + margin-top: 20px; } + +section.video-new, section.video-edit, section.problem-new, section.problem-edit { + position: absolute; + top: 72px; + right: 0; + background: #fff; + width: 48.845%; + -webkit-box-shadow: 0 0 6px #666666; + -moz-box-shadow: 0 0 6px #666666; + box-shadow: 0 0 6px #666666; + border: 1px solid #333; + border-right: 0; + z-index: 4; } + section.video-new > header, section.video-edit > header, section.problem-new > header, section.problem-edit > header { + background: #666; + zoom: 1; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; } + section.video-new > header:before, section.video-new > header:after, section.video-edit > header:before, section.video-edit > header:after, section.problem-new > header:before, section.problem-new > header:after, section.problem-edit > header:before, section.problem-edit > header:after { + content: ""; + display: table; } + section.video-new > header:after, section.video-edit > header:after, section.problem-new > header:after, section.problem-edit > header:after { + clear: both; } + section.video-new > header h2, section.video-edit > header h2, section.problem-new > header h2, section.problem-edit > header h2 { + float: left; + font-size: 14px; } + section.video-new > header a, section.video-edit > header a, section.problem-new > header a, section.problem-edit > header a { + color: #fff; } + section.video-new > header a.save-update, section.video-edit > header a.save-update, section.problem-new > header a.save-update, section.problem-edit > header a.save-update { + float: right; } + section.video-new > header a.cancel, section.video-edit > header a.cancel, section.problem-new > header a.cancel, section.problem-edit > header a.cancel { + float: left; } + section.video-new > section, section.video-edit > section, section.problem-new > section, section.problem-edit > section { + padding: 20px; } + section.video-new > section > header h1, section.video-edit > section > header h1, section.problem-new > section > header h1, section.problem-edit > section > header h1 { + font-size: 24px; + margin: 12px 0; } + section.video-new > section > header section.status-settings ul, section.video-edit > section > header section.status-settings ul, section.problem-new > section > header section.status-settings ul, section.problem-edit > section > header section.status-settings ul { + list-style: none; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + -ms-border-radius: 2px; + -o-border-radius: 2px; + border-radius: 2px; + border: 1px solid #999; + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.video-new > section > header section.status-settings ul li, section.video-edit > section > header section.status-settings ul li, section.problem-new > section > header section.status-settings ul li, section.problem-edit > section > header section.status-settings ul li { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + border-right: 1px solid #999; + padding: 6px; } + section.video-new > section > header section.status-settings ul li:last-child, section.video-edit > section > header section.status-settings ul li:last-child, section.problem-new > section > header section.status-settings ul li:last-child, section.problem-edit > section > header section.status-settings ul li:last-child { + border-right: 0; } + section.video-new > section > header section.status-settings ul li.current, section.video-edit > section > header section.status-settings ul li.current, section.problem-new > section > header section.status-settings ul li.current, section.problem-edit > section > header section.status-settings ul li.current { + background: #eee; } + section.video-new > section > header section.status-settings a.settings, section.video-edit > section > header section.status-settings a.settings, section.problem-new > section > header section.status-settings a.settings, section.problem-edit > section > header section.status-settings a.settings { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + margin: 0 20px; + border: 1px solid #999; + padding: 6px; } + section.video-new > section > header section.status-settings select, section.video-edit > section > header section.status-settings select, section.problem-new > section > header section.status-settings select, section.problem-edit > section > header section.status-settings select { + float: right; } + section.video-new > section > header section.meta, section.video-edit > section > header section.meta, section.problem-new > section > header section.meta, section.problem-edit > section > header section.meta { + background: #eee; + padding: 10px; + margin: 20px 0; + zoom: 1; } + section.video-new > section > header section.meta:before, section.video-new > section > header section.meta:after, section.video-edit > section > header section.meta:before, section.video-edit > section > header section.meta:after, section.problem-new > section > header section.meta:before, section.problem-new > section > header section.meta:after, section.problem-edit > section > header section.meta:before, section.problem-edit > section > header section.meta:after { + content: ""; + display: table; } + section.video-new > section > header section.meta:after, section.video-edit > section > header section.meta:after, section.problem-new > section > header section.meta:after, section.problem-edit > section > header section.meta:after { + clear: both; } + section.video-new > section > header section.meta div, section.video-edit > section > header section.meta div, section.problem-new > section > header section.meta div, section.problem-edit > section > header section.meta div { + float: left; + margin-right: 20px; } + section.video-new > section > header section.meta div h2, section.video-edit > section > header section.meta div h2, section.problem-new > section > header section.meta div h2, section.problem-edit > section > header section.meta div h2 { + font-size: 14px; + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.video-new > section > header section.meta div p, section.video-edit > section > header section.meta div p, section.problem-new > section > header section.meta div p, section.problem-edit > section > header section.meta div p { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.video-new > section section.notes, section.video-edit > section section.notes, section.problem-new > section section.notes, section.problem-edit > section section.notes { + margin-top: 20px; + padding: 6px; + background: #eee; + border: 1px solid #ccc; } + section.video-new > section section.notes textarea, section.video-edit > section section.notes textarea, section.problem-new > section section.notes textarea, section.problem-edit > section section.notes textarea { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: block; + width: 100%; } + section.video-new > section section.notes h2, section.video-edit > section section.notes h2, section.problem-new > section section.notes h2, section.problem-edit > section section.notes h2 { + font-size: 14px; + margin-bottom: 6px; } + section.video-new > section section.notes input[type="submit"], section.video-edit > section section.notes input[type="submit"], section.problem-new > section section.notes input[type="submit"], section.problem-edit > section section.notes input[type="submit"] { + margin-top: 10px; } diff --git a/cms/static/js/main.js b/cms/static/js/main.js index 45f94849f8..e7bdff0f14 100644 --- a/cms/static/js/main.js +++ b/cms/static/js/main.js @@ -6,96 +6,6 @@ $(document).ready(function(){ $('.editable-textarea').inlineEdit({control: 'textarea'}); }); - // $("a[rel*=leanModal]").leanModal(); - - // $(".remove").click(function(){ - // $(this).parents('li').hide(); - // }); - - // $("#show-sidebar").click(function(){ - // $("#video-selector").toggleClass('hidden'); - // return false; - // }); - - // $('.use-video').click(function() { - // var used = $('#used'); - // if (used.is(':visible')) { - // used.hide().show('slow'); - // } - // used.show(); - // $('.no-video').hide(); - // }); - - // $('.remove-video').click(function() { - // $('#used').hide(); - // $('.no-video').show(); - // }); - - // $('#new-upload').click(function() { - // $('.selected-files').toggle(); - // return false; - // }); - - // /* $('.block').append('✕<\/a>'); */ - - // $('a.delete').click(function() { - // $(this).parents('.block').hide(); - // }); - - // $('.speed-list > li').hover(function(){ - // $(this).children('.tooltip').toggle(); - // }); - - // $('.delete-speed').click(function(){ - // $(this).parents('li.speed').hide(); - // return false; - // }); - - // $('.edit-captions').click(function(){ - // var parentVid = $(this).parents('div'); - // parentVid.siblings('div.caption-box').toggle(); - // return false; - // }); - - // $('.close-box').click(function(){ - // $(this).parents('.caption-box').hide(); - // return false; - // }); - - // $('ul.dropdown').hide(); - // $('li.questions').click(function() { - // $('ul.dropdown').toggle(); - // return false; - // }); - - // $('#mchoice').click(function(){ - // $('div.used').append($('
    ').load("/widgets/multi-choice.html")); - // return false; - // }); - - // $('#text').click(function(){ - // $('div.used').append($('
    ').load("/widgets/text.html")); - // return false; - // }); - - // $('#numerical').click(function(){ - // $('div.used').append($('
    ').load("/widgets/text-question.html")); - // return false; - // }); - - // $('#equation').click(function(){ - // $('div.used').append($('
    ').load("/widgets/latex-equation.html")); - // return false; - // }); - - // $('#script').click(function(){ - // $('div.used').append($('
    ').load("/widgets/script-widget.html")); - // return false; - // }); - - // $("#mark").markItUp(myWikiSettings); - - var heighest = 0; $('.cal ol > li').each(function(){ heighest = ($(this).height() > heighest) ? $(this).height() : heighest; @@ -104,10 +14,7 @@ $(document).ready(function(){ $('.cal ol > li').css('height',heighest + 'px'); - $('.new-week').hide(); - $('.add-new-week').click(function() { - $(this).hide(); - $('.new-week').show(); + $('.add-new-section').click(function() { return false; }); @@ -117,43 +24,63 @@ $(document).ready(function(){ return false; }); - var windowHeight = $(window).resize().height(); - - $('.sidebar').css('height', windowHeight); - - $('.edit-week').click( function() { - $('body').addClass('content'); - $('body.content .cal').css('height', windowHeight); - $('section.week-new').show(); - return false; + $('.save-update').click(function(){ + $(this).parent().parent().hide(); + return false; }); - $('.cal ol li header h1 a').click( function() { - $('body').addClass('content'); - $('body.content .cal').css('height', windowHeight); - $('section.week-edit').show(); - return false; - }); + setHeight = function(){ + var windowHeight = $(this).height(); + var calHeight = windowHeight - 29; + var sidebarHeight = windowHeight - 73; + $('.sidebar').css('height', sidebarHeight); + $('body.content .cal').css('height', calHeight); + + $('.edit-week').click( function() { + $('body').addClass('content'); + $('body.content .cal').css('height', calHeight); + $('section.week-new').show(); + return false; + }); + + $('.cal ol li header h1 a').click( function() { + $('body').addClass('content'); + $('body.content .cal').css('height', calHeight); + $('section.week-edit').show(); + return false; + }); + + $('a.sequence-edit').click(function(){ + $('body').addClass('content'); + $('body.content .cal').css('height', calHeight); + $('section.sequence-edit').show(); + return false; + }); + } + + $(document).ready(setHeight); + $(window).bind('resize', setHeight); $('.video-new a').click(function(){ - $('section.video-new').show(); - return false; + $('section.video-new').show(); + return false; }); - $('.video-edit a').click(function(){ - $('section.video-edit').show(); - return false; + $('a.video-edit').click(function(){ + $('section.video-edit').show(); + return false; }); $('.problem-new a').click(function(){ - $('section.problem-new').show(); - return false; + $('section.problem-new').show(); + return false; }); - $('.problem-edit a').click(function(){ - $('section.problem-edit').show(); - return false; + $('a.problem-edit').click(function(){ + $('section.problem-edit').show(); + return false; }); + }); diff --git a/cms/static/sass/_base.scss b/cms/static/sass/_base.scss index d9f3971d9e..d06998c38a 100644 --- a/cms/static/sass/_base.scss +++ b/cms/static/sass/_base.scss @@ -32,7 +32,22 @@ body { h2 { font-size: 14px; text-transform: uppercase; + float: left; } + + a.new-module { + float: right; + } + } + } + + &.content { + section.main-content { + border-left: 2px solid #000; + @include box-sizing(border-box); + width: flex-grid(9); + float: left; + @include box-shadow( -2px 0 3px #ddd ); } } } @@ -48,4 +63,3 @@ input[type="submit"], .button { @include border-radius(3px); padding: 6px; } - diff --git a/cms/static/sass/_calendar.scss b/cms/static/sass/_calendar.scss index b149346ad6..06ac62f549 100644 --- a/cms/static/sass/_calendar.scss +++ b/cms/static/sass/_calendar.scss @@ -7,59 +7,40 @@ section.cal { > header { @include clearfix; margin-bottom: 10px; + background: #efefef; + border: 1px solid #ddd; - h1 { - float: left; - font-size: 18px; + h2 { + @include inline-block(); + text-transform: uppercase; + letter-spacing: 1px; + font-size: 14px; + padding: 6px; + margin-left: 6px; + font-size: 12px; } ul { - float: right; + @include inline-block; li { @include inline-block; + margin-left: 6px; + padding-left: 6px; + border-left: 1px solid #ddd; + padding: 6px; a { - padding: 6px; - border: 1px solid #ddd; - display: block; - @include border-radius(3px); - background: #efefef; + @include inline-block(); } - &.dropdown { - position: relative; + ul { + @include inline-block(); - ul { - display: none; - position: absolute; - background: #fff; - border: 1px solid #ddd; - - li { - padding: 6px; - display: block; - border-top: 1px solid transparent; - border-bottom: 1px solid transparent; - - &:hover { - background-color: #efefef; - border-top: 1px solid #ddd; - border-bottom: 1px solid #ddd; - } - } - } - - &:hover { - - ul { - display: block; - } - - a { - @include border-radius(3px 3px 0 0); - border-bottom: 0; - } + li { + @include inline-block(); + padding: 0; + border-left: 0; } } } @@ -81,91 +62,31 @@ section.cal { float: left; width: flex-grid(3) + ((flex-gutter() * 3) / 4); - &:last-child { - text-align: center; - background: #eee; - @include box-sizing(border-box); - - p { - width: 100%; - height: 100%; - @include box-sizing(border-box); - - a { - display: block; - width: 100%; - height: 100%; - } - } - - section.new-week { - header { - background: #fff; - text-align: left; - } - - form { - background: #fff; - width: 50%; - padding: 6px; - border: 1px solid #000; - margin: 0 auto; - @include box-shadow(0 0 2px #333); - position: relative; - - &:before { - background: #fff; - border-left: 1px solid #000; - border-top: 1px solid #000; - content: " "; - display: block; - height: 10px; - left: 50%; - position: absolute; - top: -6px; - @include transform(rotate(45deg)); - width: 10px; - z-index: 0; - } - - select { - margin-bottom: 6px; - width: 100%; - - option { - padding: 10px 0 !important; - } - } - - input[type="submit"] { - display: block; - margin-bottom: 6px; - width: 100%; - } - - a { - - &:first-child { - float: left; - } - - &:last-child { - float: right; - } - } - } - } - } - header { border-bottom: 1px solid #000; - @include box-shadow(0 1px 2px #ccc); + @include box-shadow(0 1px 2px #aaa); display: block; margin-bottom: 2px; - padding: 6px; h1 { font-size: 14px; + text-transform: uppercase; + border-bottom: 1px solid #ccc; + padding: 6px; + + a { + color: #000; + display: block; + } + } + + ul { + li { + background: #fff; + color: #888; + border-bottom: 0; + font-size: 12px; + } } } @@ -178,13 +99,136 @@ section.cal { border-bottom: 1px solid #666; padding: 6px; - &.goal { - background: #fff; + &.create-module { + position: relative; + + > div { + display: none; + @include position(absolute, 30px 0 0 0); + width: 90%; + background: rgba(#000, .8); + padding: 10px; + @include box-sizing(border-box); + @include border-radius(3px); + z-index: 99; + + ul { + li { + border-bottom: 0; + background: none; + + input { + width: 100%; + @include box-sizing(border-box); + border-color: #000; + padding: 6px; + } + + select { + width: 100%; + @include box-sizing(border-box); + + option { + font-size: 14px; + } + } + + a { + float: right; + + &:first-child { + float: left; + } + } + } + } + } + + &:hover { + div { + display: block; + } + } } } } } } + + section.new-section { + margin-top: 10px; + + > a { + @extend .button; + @include inline-block(); + } + + section { + display: none; + + header { + background: #fff; + text-align: left; + } + + form { + background: #fff; + width: 50%; + padding: 6px; + border: 1px solid #000; + margin: 0 auto; + @include box-shadow(0 0 2px #333); + position: relative; + + &:before { + background: #fff; + border-left: 1px solid #000; + border-top: 1px solid #000; + content: " "; + display: block; + height: 10px; + left: 50%; + position: absolute; + top: -6px; + @include transform(rotate(45deg)); + width: 10px; + z-index: 0; + } + + select { + margin-bottom: 6px; + width: 100%; + + option { + padding: 10px 0 !important; + } + } + + input[type="submit"] { + display: block; + margin-bottom: 6px; + width: 100%; + } + + a { + + &:first-child { + float: left; + } + + &:last-child { + float: right; + } + } + } + } + + &:hover { + section { + display: block; + } + } + } } body.content diff --git a/cms/static/sass/_module-header.scss b/cms/static/sass/_module-header.scss new file mode 100644 index 0000000000..e2af263618 --- /dev/null +++ b/cms/static/sass/_module-header.scss @@ -0,0 +1,128 @@ +section.video-new, section.video-edit, section.problem-new, section.problem-edit { + position: absolute; + top: 72px; + right: 0; + background: #fff; + width: flex-grid(6); + @include box-shadow(0 0 6px #666); + border: 1px solid #333; + border-right: 0; + z-index: 4; + + > header { + background: #666; + @include clearfix; + color: #fff; + padding: 6px; + border-bottom: 1px solid #333; + -webkit-font-smoothing: antialiased; + + h2 { + float: left; + font-size: 14px; + } + + a { + color: #fff; + + &.save-update { + float: right; + } + + &.cancel { + float: left; + } + } + + } + + > section { + padding: 20px; + + > header { + h1 { + font-size: 24px; + margin: 12px 0; + } + + section { + &.status-settings { + ul { + list-style: none; + @include border-radius(2px); + border: 1px solid #999; + @include inline-block(); + + li { + @include inline-block(); + border-right: 1px solid #999; + padding: 6px; + + &:last-child { + border-right: 0; + } + + &.current { + background: #eee; + } + } + } + + a.settings { + @include inline-block(); + margin: 0 20px; + border: 1px solid #999; + padding: 6px; + } + + select { + float: right; + } + } + + &.meta { + background: #eee; + padding: 10px; + margin: 20px 0; + @include clearfix(); + + div { + float: left; + margin-right: 20px; + + h2 { + font-size: 14px; + @include inline-block(); + } + + p { + @include inline-block(); + } + } + } + } + } + + section.notes { + margin-top: 20px; + padding: 6px; + background: #eee; + border: 1px solid #ccc; + + textarea { + @include box-sizing(border-box); + display: block; + width: 100%; + } + + h2 { + font-size: 14px; + margin-bottom: 6px; + } + + input[type="submit"]{ + margin-top: 10px; + } + } + } +} diff --git a/cms/static/sass/_problem.scss b/cms/static/sass/_problem.scss index c513ce38d9..66acacf65c 100644 --- a/cms/static/sass/_problem.scss +++ b/cms/static/sass/_problem.scss @@ -1,40 +1,23 @@ section.problem-new, section.problem-edit { - position: absolute; - top: 80px; - right: 0; - background: #fff; - width: flex-grid(5); - @include box-shadow(0 0 6px #666); - border: 1px solid #333; - border-right: 0; - z-index: 4; - - > header { - background: #666; - @include clearfix; - color: #fff; - padding: 6px; - border-bottom: 1px solid #333; - -webkit-font-smoothing: antialiased; - - h2 { - float: left; - font-size: 14px; + > section { + textarea { + @include box-sizing(border-box); + display: block; + width: 100%; } - a { - float: right; + div.preview { + background: #eee; + @include box-sizing(border-box); + height: 40px; + padding: 10px; + width: 100%; } - } - section { - ul { - list-style: none; - - li { - border-bottom: 1px solid #333; - padding: 10px 25px; - } + a.save { + @extend .button; + @include inline-block(); + margin-top: 20px; } } } diff --git a/cms/static/sass/_video.scss b/cms/static/sass/_video.scss index cb234108f4..b68176e2db 100644 --- a/cms/static/sass/_video.scss +++ b/cms/static/sass/_video.scss @@ -1,40 +1,33 @@ section.video-new, section.video-edit { - position: absolute; - top: 80px; - right: 0; - background: #fff; - width: flex-grid(5); - @include box-shadow(0 0 6px #666); - border: 1px solid #333; - border-right: 0; - z-index: 4; + > section { - > header { - background: #666; - @include clearfix; - color: #fff; - padding: 6px; - border-bottom: 1px solid #333; - -webkit-font-smoothing: antialiased; + section.upload { + padding: 6px; + margin-bottom: 10px; + border: 1px solid #ddd; - h2 { - float: left; - font-size: 14px; - } - - a { - float: right; - } - } - - section { - ul { - list-style: none; - - li { - border-bottom: 1px solid #333; - padding: 10px 25px; + a.upload-button { + @extend .button; + @include inline-block(); } } + + section.in-use { + h2 { + font-size: 14px; + } + + div { + background: #eee; + text-align: center; + padding: 6px; + } + } + + a.save-update { + @extend .button; + @include inline-block(); + margin-top: 20px; + } } } diff --git a/cms/static/sass/_week.scss b/cms/static/sass/_week.scss index a628b0f164..1a32557db5 100644 --- a/cms/static/sass/_week.scss +++ b/cms/static/sass/_week.scss @@ -1,4 +1,6 @@ -section.week-edit, section.week-new { +section.week-edit, +section.week-new, +section.sequence-edit { > header { border-bottom: 1px solid #ccc; diff --git a/cms/static/sass/base-style.scss b/cms/static/sass/base-style.scss index 6a2dfbd0d2..133e1bda1b 100644 --- a/cms/static/sass/base-style.scss +++ b/cms/static/sass/base-style.scss @@ -3,16 +3,4 @@ @import 'base'; @import 'calendar'; -@import 'week', 'video', 'problem'; - -body { - &.content { - section.main-content { - border-left: 2px solid #000; - @include box-sizing(border-box); - width: flex-grid(9); - float: left; - @include box-shadow( -2px 0 3px #ddd ); - } - } -} +@import 'week', 'video', 'problem', 'module-header'; diff --git a/cms/templates/index.html b/cms/templates/index.html index efd9f9a242..11c226ae3d 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -9,6 +9,7 @@
    <%include file="widgets/week-edit.html"/> <%include file="widgets/week-new.html"/> + <%include file="widgets/sequnce-edit.html"/> <%include file="widgets/video-edit.html"/> <%include file="widgets/video-new.html"/> <%include file="widgets/problem-edit.html"/> diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html index 86a2afb0f9..ec550fec37 100644 --- a/cms/templates/widgets/header.html +++ b/cms/templates/widgets/header.html @@ -1,5 +1,6 @@
    diff --git a/cms/templates/widgets/module-dropdown.html b/cms/templates/widgets/module-dropdown.html new file mode 100644 index 0000000000..7c6e1e068c --- /dev/null +++ b/cms/templates/widgets/module-dropdown.html @@ -0,0 +1,28 @@ +
  • + + + Add new module + +
    +
    + +
    +
    +
  • diff --git a/cms/templates/widgets/navigation.html b/cms/templates/widgets/navigation.html index 049e5da537..2edef08a12 100644 --- a/cms/templates/widgets/navigation.html +++ b/cms/templates/widgets/navigation.html @@ -1,9 +1,8 @@
    -

    Circuts & Electronics

    - +

    Filter content:

      -
    • Sequences
        @@ -17,9 +16,20 @@
      • Deadlines + +
          +
        • Today
        • +
        • Tomorrow
        • +
        • This week
        • +
        • In 2 weeks
        • +
        • This month
        • +
      • Goals +
          +
        • Hide
        • +
    @@ -28,93 +38,131 @@
  • Week 1

    +
      +
    • Goal title: This is a goal that will be in the header of the week
    • +
    • Goal title two: This is another fgoal for this week so that students have two things to learn
    • +
      -
    • Goal 1
    • -
    • Goal 2
    • -
    • Lecture Sequence
    • -
    • Lecture Sequence
    • -
    • Lab
    • +
    • Lecture Sequence
    • +
    • Lecture Sequence
    • +
    • Lab
    • Homework
    • -
    • + Add new sequence
    • + <%include file="module-dropdown.html"/>
  • Week 2

    +
      +
    • Another title This is the goal for the week
    • +
      -
    • Goal 1
    • Lecture Sequence
    • Lecture Sequence
    • Lab
    • Homework
    • -
    • + Add new sequence
    • + <%include file="module-dropdown.html"/>
  • Week 3

    +
      +
    • Another title This is the goal for the week
    • +
      -
    • Goal 1
    • Lab
    • Lab
    • Homework
    • -
    • + Add new sequence
    • + <%include file="module-dropdown.html"/>
  • Week 4

    +
      +
    • Another title This is the goal for the week
    • +
    • Goal title two: This is another fgoal for this week so that students have two things to learn
    • +
      -
    • Goal 1
    • Lecture Sequence
    • Lab
    • Homework
    • Homework
    • -
    • + Add new sequence
    • + <%include file="module-dropdown.html"/>
  • Week 5

    +
      +
    • Please create a learning goal for this week
    • +
      -
    • + Add new sequence
    • + <%include file="module-dropdown.html"/>
  • -

    - + Add New -

    +
    +

    Week 6

    +
      +
    • Please create a learning goal for this week
    • +
    +
    -
    -
    -

    Week 6

    -
    +
      + <%include file="module-dropdown.html"/> +
    +
  • +
  • +
    +

    Week 7

    +
      +
    • Please create a learning goal for this week
    • +
    +
    -
    - -
    +
      + <%include file="module-dropdown.html"/> +
    +
  • + + +
    + + Add New Section + +
    + +
    - - - - + + + + + diff --git a/cms/templates/widgets/new-module.html b/cms/templates/widgets/new-module.html index 070b6462bb..6b7794944a 100644 --- a/cms/templates/widgets/new-module.html +++ b/cms/templates/widgets/new-module.html @@ -1,9 +1,7 @@ -
  • - -
  • + diff --git a/cms/templates/widgets/problem-edit.html b/cms/templates/widgets/problem-edit.html index b1d5796a9f..49f67e3e26 100644 --- a/cms/templates/widgets/problem-edit.html +++ b/cms/templates/widgets/problem-edit.html @@ -1,34 +1,13 @@ -
    +
    - cancel - Save & Update + Cancel + Save & Update
    -

    Old Problem

    -
    - - -
    - Settings -
    - - -
    -
    -
    -

    Tags:

    -

    Click to edit

    -
    - +

    New Problem

    +

    Last modified:

    mm/dd/yy

    @@ -39,6 +18,31 @@

    Anant Agarwal

    + +
    + + Settings + + +
    +
    +
    +

    Tags:

    +

    Click to edit

    +
    + +
    +

    Goal

    +

    Click to edit

    +
    +
    @@ -49,6 +53,10 @@
    +

    Add notes

    + + +
    • Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.

      @@ -58,16 +66,8 @@

      Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.

      Anant Agarwal

    • -
    +
    -
    -

    Add notes

    - - -
    -
    - - Save & Update + Save & Update
    - diff --git a/cms/templates/widgets/problem-new.html b/cms/templates/widgets/problem-new.html index 9f91dd1177..d986f5a9ef 100644 --- a/cms/templates/widgets/problem-new.html +++ b/cms/templates/widgets/problem-new.html @@ -1,39 +1,36 @@
    - cancel - Save & Update + Cancel + Save & Update
    -

    New Problem

    -
    +

    New Problem

    + +
    - Settings + Settings +
    -
    +

    Tags:

    Click to edit

    - - - - - - - - - +
    +

    Goal

    +

    Click to edit

    +
    @@ -45,8 +42,10 @@

    Add notes

    + +
    - Save & Update + Save & Update
    diff --git a/cms/templates/widgets/sequnce-edit.html b/cms/templates/widgets/sequnce-edit.html new file mode 100644 index 0000000000..75d4504b68 --- /dev/null +++ b/cms/templates/widgets/sequnce-edit.html @@ -0,0 +1,85 @@ +<%block name="content"> +
    +
    + Done +

    Lecture Sequence name

    + Settings +
    + + + +
    +
    +

    Sequence Content

    +
    + +
    +
    + +
    +
      +
    • + + +
    • + +
    • + + +
    • +
    • + +
    • + +
    • + Advanced filters +
    • +
    +
    + +
    + +
    +
    +
    + + diff --git a/cms/templates/widgets/video-edit.html b/cms/templates/widgets/video-edit.html index ac4c921918..0c82e743fe 100644 --- a/cms/templates/widgets/video-edit.html +++ b/cms/templates/widgets/video-edit.html @@ -1,151 +1,59 @@ -
    +
    +
    + Cancel + Save & Update +
    -
    -
    +
    +
    +

    Untitled Video

    -
    -
    - Created 22/03/12 - by Piotr Mitros -
    +
    +
    -
    -
    -

    Video title

    + Settings -
    - Tag mitx, s4v1, circuits, anant -
    + +
    -
    -
    - Keyword - S4V1 - +
    +
    +

    Tags:

    +

    Click to edit

    +
    +
    +

    Goal

    +

    mitx, s4v1, circuits, anant

    +
    +
    + - Due Date - 21/03/12 - - Status - - - -
    - -
    - -
    -
    -
    - or - use an already uploaded one -
    -
    - -
    -
    -
      -
    • video-name-@0-75x.extension
    • -
    • video-name-@1x.extension
    • -
    • video-name-@1-25x.extension
    • -
    • video-name-@1-5x.extension
    • -
    -
    - - - Cancel -
    - -
    - -
    -
    -
      -

      Video clip in use

      - <%include file="video-box.html"/> -
    -

    No video clip used. Select one from the list below, upload a new one or import an already uploaded video.

    -
    -
    - -
    -
    - - -
    -
    -
      - <%include file="video-box-unused.html"/> -
    -
    -
    - -
    - -
    -

    Annotations

    - - -
    - +
    + Upload new video clip + Or + use an already uploaded one
    - -
    -
    -

    Notes

    - - - -
    - -
    -
    -
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. -

    By Piotr Mitros 10 hours ago

    -
    -
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

    By Piotr Mitros 10 hours ago

    -
    -
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

    By Piotr Mitros 10 hours ago

    +
    +

    Video in use

    +
    +

    No video clip used. Select one from the list below, upload a new one or import already existing video

    -
    - +
    +

    Add notes

    + + +
    -
    - -
    - Select the source video or directly enter its ID -
    - -
    - -
    - -
    - - - Cancel -
    + Save & Update
    +
    diff --git a/cms/templates/widgets/video-new.html b/cms/templates/widgets/video-new.html index 2555169c05..fecbaa423c 100644 --- a/cms/templates/widgets/video-new.html +++ b/cms/templates/widgets/video-new.html @@ -1,48 +1,85 @@
    - cancel - Save & Update + Cancel + Save & Update

    Untitled Video

    -
    -
    -
    - -
    -
    - Save & Update +
    + Upload new video clip + Or + use an already uploaded one + +
    +
    +
      +
    • video-name-@0-75x.extension
    • +
    • video-name-@1x.extension
    • +
    • video-name-@1-25x.extension
    • +
    • video-name-@1-5x.extension
    • +
    +
    + + + Cancel +
    + +
    +

    Video in use

    +
    +

    No video clip used. Select one from the list below, upload a new one or import already existing video

    +
    +
    + +
    +

    Add notes

    + + +
    + + Save & Update
    diff --git a/cms/templates/widgets/week-edit.html b/cms/templates/widgets/week-edit.html index ea6d29ef3b..348185be80 100644 --- a/cms/templates/widgets/week-edit.html +++ b/cms/templates/widgets/week-edit.html @@ -1,37 +1,20 @@ -<%block name="content">

    Week 3

    - Done +

    + new goal

    + +
    +

    Weeks goals:

    +
      +
    • +

      Goal title

      +

      This is the goal body

      +
    • +
    +
    -
    @@ -70,14 +53,55 @@
    + +
    +
    +

    Scratchpad

    +
    + +
      +
    • Problem title 11
    • +
    • Problem title 13
    • +
    • Problem title 14
    • +
    • Video 3
    • + <%include file="new-module.html"/> +
    +
    - diff --git a/cms/templates/widgets/week-new.html b/cms/templates/widgets/week-new.html index 986dc6e05e..fe286a74b3 100644 --- a/cms/templates/widgets/week-new.html +++ b/cms/templates/widgets/week-new.html @@ -1,62 +1,86 @@ -<%block name="content">

    Week 6

    - Done -
    +

    + new goal

    -
    diff --git a/cms/templates/widgets/week-new.html b/cms/templates/widgets/week-new.html index fe286a74b3..46aba9b778 100644 --- a/cms/templates/widgets/week-new.html +++ b/cms/templates/widgets/week-new.html @@ -1,10 +1,13 @@

    Week 6

    -

    + new goal

    -

    Weeks goals:

    +
    +

    Weeks goals:

    +

    +

    +
    +
    • Create new goal

      @@ -40,32 +43,32 @@
    • -
      - -
      +
      + +
    -
    -
    -
    -

    Scratch pad

    -
    +
    -
      -
    • - <%include file="new-module.html"/> -
    • -
    -
    +
    +
    +

    Weeks Content

    +
    +
    -
    -
    -

    Weeks Content

    -
    +
    +
    +

    Scratch pad

    +
    -
    +
      +
    • + <%include file="new-module.html"/> +
    • +
    +
    @@ -83,4 +86,5 @@ New Lab +
    From 01ca43346fed4834f8590b213896343393a53203 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 14 Jun 2012 12:16:29 -0400 Subject: [PATCH 62/80] Use existential operator --- lms/static/coffee/src/modules/video/video_player.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/static/coffee/src/modules/video/video_player.coffee b/lms/static/coffee/src/modules/video/video_player.coffee index 0dd52a128b..20df378267 100644 --- a/lms/static/coffee/src/modules/video/video_player.coffee +++ b/lms/static/coffee/src/modules/video/video_player.coffee @@ -135,7 +135,7 @@ class @VideoPlayer @video.speed volume: (value) -> - if value != undefined + if value? @player.setVolume value else @player.getVolume() From 6fee7928fc9961c08fbcbc7f7f35631a71ffbacf Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 14 Jun 2012 16:15:50 -0400 Subject: [PATCH 63/80] Successfully read course children out of mongodb --- .../management/commands/import.py | 29 +++++---- cms/djangoapps/contentstore/views.py | 5 +- cms/lib/keystore/__init__.py | 34 ++++++++++ cms/lib/keystore/exceptions.py | 4 ++ cms/lib/keystore/mongo.py | 63 ++++++++++++++++--- 5 files changed, 109 insertions(+), 26 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/import.py b/cms/djangoapps/contentstore/management/commands/import.py index 78984f4119..690e3dbea0 100644 --- a/cms/djangoapps/contentstore/management/commands/import.py +++ b/cms/djangoapps/contentstore/management/commands/import.py @@ -6,11 +6,13 @@ #import mitxmako.middleware #from courseware import content_parser #from django.contrib.auth.models import User +import os.path +from StringIO import StringIO from mako.template import Template from mako.lookup import TemplateLookup from django.core.management.base import BaseCommand -from contentstore.models import create_item, update_item, update_children +from keystore.django import keystore from lxml import etree @@ -20,16 +22,15 @@ class Command(BaseCommand): def handle(self, *args, **options): print args data_dir = args[0] - course_file = 'course.xml' parser = etree.XMLParser(remove_comments = True) lookup = TemplateLookup(directories=[data_dir]) template = lookup.get_template("course.xml") course_string = template.render(groups=[]) - course = etree.XML(course_string, parser=parser) + course = etree.parse(StringIO(course_string), parser=parser) - elements = course.xpath("//*") + elements = list(course.iter()) tag_to_category = {# Inside HTML ==> Skip these # Custom tags @@ -39,11 +40,11 @@ class Command(BaseCommand): 'image': 'Custom', 'discuss': 'Custom', # Simple lists - 'chapter': 'Sequence', - 'course': 'Sequence', - 'sequential': 'Sequence', - 'vertical': 'Sequence', - 'section': 'Sequence', + 'chapter': 'Chapter', + 'course': 'Course', + 'sequential': 'LectureSequence', + 'vertical': 'ProblemSet', + 'section': 'Section', # True types 'video': 'VideoSegment', 'html': 'HTML', @@ -114,7 +115,7 @@ class Command(BaseCommand): results[e.attrib['url']] = {'data':{'text':text}} def handle_problem(e): - data = open(data_dir+'problems/'+e.attrib['filename']+'.xml').read() + data = open(os.path.join(data_dir, 'problems', e.attrib['filename']+'.xml')).read() results[e.attrib['url']] = {'data':{'statement':data}} element_actions = {# Inside HTML ==> Skip these @@ -149,10 +150,8 @@ class Command(BaseCommand): for k in results: print k - create_item(k, 'Piotr Mitros') + keystore.create_item(k, 'Piotr Mitros') if 'data' in results[k]: - update_item(k, results[k]['data']) + keystore.update_item(k, results[k]['data']) if 'children' in results[k]: - update_children(k, results[k]['children']) - - + keystore.update_children(k, results[k]['children']) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 38e9e8ad35..429fb6c26b 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -1,14 +1,11 @@ from mitxmako.shortcuts import render_to_response -from keystore import Location from keystore.django import keystore from django.contrib.auth.decorators import login_required @login_required def calendar(request, org, course): - weeks = keystore.get_children_for_item( - Location(['i4x', org, course, 'Course', 'course']) - ) + weeks = keystore.get_children_for_item(['i4x', org, course, 'Course', None]) return render_to_response('calendar.html', {'weeks': weeks}) diff --git a/cms/lib/keystore/__init__.py b/cms/lib/keystore/__init__.py index 5e6374cf4a..d0a24be797 100644 --- a/cms/lib/keystore/__init__.py +++ b/cms/lib/keystore/__init__.py @@ -60,6 +60,40 @@ class KeyStore(object): with the specified location. If no object is found at that location, raises keystore.exceptions.ItemNotFoundError + + Searches for all matches of a partially specifed location, but raises an + keystore.exceptions.InsufficientSpecificationError if more + than a single object matches the query. + + location: Something that can be passed to Location + """ + raise NotImplementedError + + def create_item(self, location, editor): + """ + Create an empty item at the specified location with the supplied editor + + location: Something that can be passed to Location + """ + raise NotImplementedError + + def update_item(self, location, data): + """ + Set the data in the item specified by the location to + data + + location: Something that can be passed to Location + data: A nested dictionary of problem data + """ + raise NotImplementedError + + def update_children(self, location, children): + """ + Set the children for the item specified by the location to + data + + location: Something that can be passed to Location + children: A list of child item identifiers """ raise NotImplementedError diff --git a/cms/lib/keystore/exceptions.py b/cms/lib/keystore/exceptions.py index b66470859f..08fd9b11d0 100644 --- a/cms/lib/keystore/exceptions.py +++ b/cms/lib/keystore/exceptions.py @@ -5,3 +5,7 @@ Exceptions thrown by KeyStore objects class ItemNotFoundError(Exception): pass + + +class InsufficientSpecificationError(Exception): + pass diff --git a/cms/lib/keystore/mongo.py b/cms/lib/keystore/mongo.py index fc190ee098..d29afb4bd2 100644 --- a/cms/lib/keystore/mongo.py +++ b/cms/lib/keystore/mongo.py @@ -1,6 +1,6 @@ import pymongo -from . import KeyStore -from .exceptions import ItemNotFoundError +from . import KeyStore, Location +from .exceptions import ItemNotFoundError, InsufficientSpecificationError class MongoKeyStore(KeyStore): @@ -12,15 +12,64 @@ class MongoKeyStore(KeyStore): host=host, port=port )[db][collection] + + # Force mongo to report errors, at the expense of performance + self.collection.safe = True def get_children_for_item(self, location): - item = self.collection.find_one( - {'location': location.dict()}, + query = dict( + ('location.{key}'.format(key=key), val) + for (key, val) + in Location(location).dict().items() + if val is not None + ) + items = self.collection.find( + query, fields={'children': True}, sort=[('revision', pymongo.ASCENDING)], + limit=1, + ) + if items.count() > 1: + raise InsufficientSpecificationError(location) + + if items.count() == 0: + raise ItemNotFoundError(location) + + return items[0]['children'] + + def create_item(self, location, editor): + """ + Create an empty item at the specified location with the supplied editor + + location: Something that can be passed to Location + """ + self.collection.insert({ + 'location': Location(location).dict(), + 'editor': editor + }) + + def update_item(self, location, data): + """ + Set the data in the item specified by the location to + data + + location: Something that can be passed to Location + data: A nested dictionary of problem data + """ + self.collection.update( + {'location': Location(location).dict()}, + {'$set': {'data': data}} ) - if item is None: - raise ItemNotFoundError() + def update_children(self, location, children): + """ + Set the children for the item specified by the location to + data - return item['children'] + location: Something that can be passed to Location + children: A list of child item identifiers + """ + self.collection.update( + {'location': Location(location).dict()}, + {'$set': {'children': children}} + ) From 57b605dbd3a791c3c73392f185df5e1e86b89ed1 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Thu, 14 Jun 2012 17:15:23 -0400 Subject: [PATCH 64/80] Added more styels to the section view and default section view --- cms/static/css/base-style.css | 170 +++++++++++++++++++------- cms/static/img/drag-handle.png | Bin 0 -> 98 bytes cms/static/sass/_base.scss | 47 ++++++- cms/static/sass/_calendar.scss | 6 + cms/static/sass/_week.scss | 99 +++++++++------ cms/templates/widgets/header.html | 19 ++- cms/templates/widgets/new-module.html | 2 +- cms/templates/widgets/week-edit.html | 42 +++++-- cms/templates/widgets/week-new.html | 93 +++++++------- 9 files changed, 336 insertions(+), 142 deletions(-) create mode 100644 cms/static/img/drag-handle.png diff --git a/cms/static/css/base-style.css b/cms/static/css/base-style.css index c84ab046ff..c4bfc6c415 100644 --- a/cms/static/css/base-style.css +++ b/cms/static/css/base-style.css @@ -193,8 +193,19 @@ body { font-size: 14px; text-transform: uppercase; float: left; } - body > header nav a.new-module { - float: right; } + body > header nav ul { + float: left; } + body > header nav ul.user-nav { + float: right; } + body > header nav ul li { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + margin-left: 15px; } body.content section.main-content { border-left: 2px solid #000; -webkit-box-sizing: border-box; @@ -213,7 +224,11 @@ a { input { font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif; } -input[type="submit"], .button, section.cal section.new-section > a, section.video-new > section section.upload a.upload-button, section.video-edit > section section.upload a.upload-button, section.video-new > section a.save-update, section.video-edit > section a.save-update, section.problem-new > section a.save, section.problem-edit > section a.save { +input[type="submit"], .button, section.cal section.new-section > a, section.week-edit > section.content > div section.modules.empty a, +section.week-new > section.content > div section.modules.empty a, +section.sequence-edit > section.content > div section.modules.empty a, section.week-edit > section.content > div section.scratch-pad ol li ul li.empty a, +section.week-new > section.content > div section.scratch-pad ol li ul li.empty a, +section.sequence-edit > section.content > div section.scratch-pad ol li ul li.empty a, section.video-new > section section.upload a.upload-button, section.video-edit > section section.upload a.upload-button, section.video-new > section a.save-update, section.video-edit > section a.save-update, section.problem-new > section a.save, section.problem-edit > section a.save { border: 1px solid #ccc; background: #efefef; -webkit-border-radius: 3px; @@ -223,6 +238,26 @@ input[type="submit"], .button, section.cal section.new-section > a, section.vide border-radius: 3px; padding: 6px; } +.new-module { + position: relative; } + .new-module a { + padding: 6px; + display: block; } + .new-module ul.new-dropdown { + list-style: none; + position: absolute; } + .new-module ul.new-dropdown li { + display: none; + padding: 6px; } + .new-module:hover ul.new-dropdown { + display: block; } + +.draggable { + width: 7px; + min-height: 14px; + background: url("../img/drag-handle.png") no-repeat center; + text-indent: -9999px; } + section.cal { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; @@ -484,11 +519,35 @@ section.cal { overflow: scroll; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; - box-sizing: border-box; } + box-sizing: border-box; + opacity: .4; + -webkit-transition-property: all; + -moz-transition-property: all; + -ms-transition-property: all; + -o-transition-property: all; + transition-property: all; + -webkit-transition-duration: 0.15s; + -moz-transition-duration: 0.15s; + -ms-transition-duration: 0.15s; + -o-transition-duration: 0.15s; + transition-duration: 0.15s; + -webkit-transition-timing-function: ease-out; + -moz-transition-timing-function: ease-out; + -ms-transition-timing-function: ease-out; + -o-transition-timing-function: ease-out; + transition-timing-function: ease-out; + -webkit-transition-delay: 0; + -moz-transition-delay: 0; + -ms-transition-delay: 0; + -o-transition-delay: 0; + transition-delay: 0; } body.content section.cal > header ul { display: none; } body.content + section.cal:hover { + opacity: 1; } + body.content section.cal ol li { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; @@ -637,6 +696,22 @@ section.sequence-edit > section.content { display: table-cell; width: 65.632%; border-right: 1px solid #333; } + section.week-edit > section.content > div section.modules.empty, + section.week-new > section.content > div section.modules.empty, + section.sequence-edit > section.content > div section.modules.empty { + text-align: center; + vertical-align: middle; } + section.week-edit > section.content > div section.modules.empty a, + section.week-new > section.content > div section.modules.empty a, + section.sequence-edit > section.content > div section.modules.empty a { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + margin-top: 10px; } section.week-edit > section.content > div section.modules ol, section.week-new > section.content > div section.modules ol, section.sequence-edit > section.content > div section.modules ol { @@ -661,17 +736,27 @@ section.sequence-edit > section.content { section.week-edit > section.content > div section.modules ol li ol li, section.week-new > section.content > div section.modules ol li ol li, section.sequence-edit > section.content > div section.modules ol li ol li { - padding: 6px 0 6px 6px; } - section.week-edit > section.content > div section.modules ol li ol li h3, - section.week-new > section.content > div section.modules ol li ol li h3, - section.sequence-edit > section.content > div section.modules ol li ol li h3 { - text-transform: uppercase; - letter-spacing: 1px; - font-size: 12px; } - section.week-edit > section.content > div section.modules ol li ol li ol, - section.week-new > section.content > div section.modules ol li ol li ol, - section.sequence-edit > section.content > div section.modules ol li ol li ol { - border-left: 1px solid; } + padding: 6px; } + section.week-edit > section.content > div section.modules ol li ol li.group, + section.week-new > section.content > div section.modules ol li ol li.group, + section.sequence-edit > section.content > div section.modules ol li ol li.group { + padding: 0; + border-left: 4px solid #999; } + section.week-edit > section.content > div section.modules ol li ol li.group header, + section.week-new > section.content > div section.modules ol li ol li.group header, + section.sequence-edit > section.content > div section.modules ol li ol li.group header { + padding: 3px 6px; + background: none; } + section.week-edit > section.content > div section.modules ol li ol li.group header h3, + section.week-new > section.content > div section.modules ol li ol li.group header h3, + section.sequence-edit > section.content > div section.modules ol li ol li.group header h3 { + text-transform: uppercase; + letter-spacing: 1px; + font-size: 12px; } + section.week-edit > section.content > div section.modules ol li ol li.group ol li:last-child, + section.week-new > section.content > div section.modules ol li ol li.group ol li:last-child, + section.sequence-edit > section.content > div section.modules ol li ol li.group ol li:last-child { + border-bottom: 0; } section.week-edit > section.content > div section.scratch-pad, section.week-new > section.content > div section.scratch-pad, section.sequence-edit > section.content > div section.scratch-pad { @@ -679,7 +764,8 @@ section.sequence-edit > section.content { -moz-box-sizing: border-box; box-sizing: border-box; display: table-cell; - width: 34.368%; } + width: 34.368%; + vertical-align: top; } section.week-edit > section.content > div section.scratch-pad ol, section.week-new > section.content > div section.scratch-pad ol, section.sequence-edit > section.content > div section.scratch-pad ol { @@ -702,40 +788,32 @@ section.sequence-edit > section.content { section.week-new > section.content > div section.scratch-pad ol li ul li, section.sequence-edit > section.content > div section.scratch-pad ol li ul li { padding: 6px; } + section.week-edit > section.content > div section.scratch-pad ol li ul li:last-child, + section.week-new > section.content > div section.scratch-pad ol li ul li:last-child, + section.sequence-edit > section.content > div section.scratch-pad ol li ul li:last-child { + border-bottom: 0; } + section.week-edit > section.content > div section.scratch-pad ol li ul li:hover a.draggable, + section.week-new > section.content > div section.scratch-pad ol li ul li:hover a.draggable, + section.sequence-edit > section.content > div section.scratch-pad ol li ul li:hover a.draggable { + opacity: 1; } + section.week-edit > section.content > div section.scratch-pad ol li ul li.empty, + section.week-new > section.content > div section.scratch-pad ol li ul li.empty, + section.sequence-edit > section.content > div section.scratch-pad ol li ul li.empty { + padding: 12px; } + section.week-edit > section.content > div section.scratch-pad ol li ul li.empty a, + section.week-new > section.content > div section.scratch-pad ol li ul li.empty a, + section.sequence-edit > section.content > div section.scratch-pad ol li ul li.empty a { + display: block; + text-align: center; } + section.week-edit > section.content > div section.scratch-pad ol li ul li a.draggable, + section.week-new > section.content > div section.scratch-pad ol li ul li a.draggable, + section.sequence-edit > section.content > div section.scratch-pad ol li ul li a.draggable { + float: right; + opacity: .3; } section.week-edit > section.content > div section.scratch-pad ol li ul li a, section.week-new > section.content > div section.scratch-pad ol li ul li a, section.sequence-edit > section.content > div section.scratch-pad ol li ul li a { color: #000; } - section.week-edit > section.content > div section.scratch-pad ol li.new-module, - section.week-new > section.content > div section.scratch-pad ol li.new-module, - section.sequence-edit > section.content > div section.scratch-pad ol li.new-module { - position: relative; } - section.week-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown, - section.week-new > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown, - section.sequence-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown { - list-style: none; } - section.week-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown li, - section.week-new > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown li, - section.sequence-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown li { - display: none; } - section.week-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown li:first-child, - section.week-new > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown li:first-child, - section.sequence-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown li:first-child { - display: block; } - section.week-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown:hover li, - section.week-new > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown:hover li, - section.sequence-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown:hover li { - display: block; - padding: 6px 0; } - section.week-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown:hover li:first-child, - section.week-new > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown:hover li:first-child, - section.sequence-edit > section.content > div section.scratch-pad ol li.new-module ul.new-dropdown:hover li:first-child { - padding-top: 0; } - section.week-edit > section.content > div section.scratch-pad p, - section.week-new > section.content > div section.scratch-pad p, - section.sequence-edit > section.content > div section.scratch-pad p { - padding: 6px; - border-bottom: 1px solid #666; } section.video-new > section section.upload, section.video-edit > section section.upload { padding: 6px; diff --git a/cms/static/img/drag-handle.png b/cms/static/img/drag-handle.png new file mode 100644 index 0000000000000000000000000000000000000000..3c9c3c1ebcee37ec1fcfd82aa204228ecd629598 GIT binary patch literal 98 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)N!3HEB$FfNSDNRoo$B>F!Z+i`a$~c&!Yh(WZ v_v73tWm2xNh|g`ZvcZL`KR=$S&zsN6c8$yMo{i8-pe6=SS3j3^P6 header ul { display: none; } + &:hover { + opacity: 1; + } + ol { li { @include box-sizing(border-box); diff --git a/cms/static/sass/_week.scss b/cms/static/sass/_week.scss index 1c03ff7962..de7b1e6f9e 100644 --- a/cms/static/sass/_week.scss +++ b/cms/static/sass/_week.scss @@ -86,6 +86,17 @@ section.sequence-edit { width: flex-grid(6, 9); border-right: 1px solid #333; + &.empty { + text-align: center; + vertical-align: middle; + + a { + @extend .button; + @include inline-block(); + margin-top: 10px; + } + } + ol { list-style: none; border-bottom: 1px solid #333; @@ -105,16 +116,30 @@ section.sequence-edit { list-style: none; li { - padding: 6px 0 6px 6px; + padding: 6px; - h3 { - text-transform: uppercase; - letter-spacing: 1px; - font-size: 12px; - } + &.group { + padding: 0; + border-left: 4px solid #999; - ol { - border-left: 1px solid; + header { + padding: 3px 6px; + background: none; + + h3 { + text-transform: uppercase; + letter-spacing: 1px; + font-size: 12px; + } + } + + ol { + li { + &:last-child { + border-bottom: 0; + } + } + } } } } @@ -126,6 +151,7 @@ section.sequence-edit { @include box-sizing(border-box); display: table-cell; width: flex-grid(3, 9) + flex-gutter(9); + vertical-align: top; ol { list-style: none; @@ -145,48 +171,41 @@ section.sequence-edit { li { padding: 6px; + &:last-child { + border-bottom: 0; + } + + &:hover { + a.draggable { + opacity: 1; + } + } + + &.empty { + padding: 12px; + + a { + @extend .button; + display: block; + text-align: center; + } + } + + a.draggable { + float: right; + opacity: .3; + } + a { color: #000; } } } - &.new-module { - position: relative; - - ul.new-dropdown { - list-style: none; - - li { - display: none; - - &:first-child { - display: block; - } - } - - &:hover { - li { - display: block; - padding: 6px 0; - - &:first-child { - padding-top: 0; - } - } - } - } - } } } - - p { - padding: 6px; - border-bottom: 1px solid #666; - } } } } } } - diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html index ec550fec37..49965e4026 100644 --- a/cms/templates/widgets/header.html +++ b/cms/templates/widgets/header.html @@ -1,6 +1,21 @@
    diff --git a/cms/templates/widgets/new-module.html b/cms/templates/widgets/new-module.html index 6b7794944a..8b12e5763a 100644 --- a/cms/templates/widgets/new-module.html +++ b/cms/templates/widgets/new-module.html @@ -1,5 +1,5 @@ ++ add new
      -
    1. Problem title 11
    2. -
    3. Problem title 13
    4. -
    5. Problem title 14
    6. -
    7. Video 3
    8. +
    9. + Problem title 11 + handle +
    10. +
    11. + Problem Group + handle +
    12. +
    13. + Problem title 14 + handle +
    14. +
    15. + Video 3 + handle +
  • @@ -68,7 +80,7 @@
      -
    1. +
    2. Problem group @@ -97,10 +109,22 @@

        -
      1. Problem title 11
      2. -
      3. Problem title 13
      4. -
      5. Problem title 14
      6. -
      7. Video 3
      8. +
      9. + Problem title 11 + handle +
      10. +
      11. + Problem Group + handle +
      12. +
      13. + Problem title 14 + handle +
      14. +
      15. + Video 3 + handle +
    3. diff --git a/cms/templates/widgets/week-new.html b/cms/templates/widgets/week-new.html index 46aba9b778..be08587755 100644 --- a/cms/templates/widgets/week-new.html +++ b/cms/templates/widgets/week-new.html @@ -1,23 +1,23 @@
      -

      Week 6

      +

      Week 3

      Weeks goals:

      -

      +

      +

      + new goal

      • -

        Create new goal

        -

        Goals are overarching themes for the week

        +

        Please add a goal for this section

      -
      +
      +
      • @@ -43,48 +43,59 @@
      • -
        - -
        +
      - -
      - -
      -
      -

      Weeks Content

      -
      +
      +
      +

      This are no groups or units in this section yet

      + Add a Group + Add a Unit
      -
      -
      -

      Scratch pad

      -
      +
      +
        +
      1. +
        +

        Section Scratch

        +
        + +
      2. +
      3. +
        +

        Course Scratch

        +
        + +
      4. -
          -
        • - <%include file="new-module.html"/> -
        • -
        -
      +
    4. + <%include file="new-module.html"/> +
    5. +
  • - -
    - +
    + From 93478d53dfa65008a09be1a62d79744b1bc2bc45 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Fri, 15 Jun 2012 10:11:04 -0400 Subject: [PATCH 65/80] Added scratch on the calendar view and added handles on the calendar view --- cms/static/css/base-style.css | 52 +++-- cms/static/sass/_base.scss | 2 + cms/static/sass/_week.scss | 33 ++- cms/templates/widgets/navigation.html | 100 ++++++-- cms/templates/widgets/week-edit.html | 317 +++++++++++++++----------- 5 files changed, 329 insertions(+), 175 deletions(-) diff --git a/cms/static/css/base-style.css b/cms/static/css/base-style.css index c4bfc6c415..abed82cc05 100644 --- a/cms/static/css/base-style.css +++ b/cms/static/css/base-style.css @@ -256,7 +256,9 @@ section.sequence-edit > section.content > div section.scratch-pad ol li ul li.em width: 7px; min-height: 14px; background: url("../img/drag-handle.png") no-repeat center; - text-indent: -9999px; } + text-indent: -9999px; + display: block; + float: right; } section.cal { -webkit-box-sizing: border-box; @@ -679,14 +681,27 @@ section.sequence-edit > section.content { section.week-new > section.content > div section header, section.sequence-edit > section.content > div section header { background: #eee; - padding: 10px; - border-bottom: 1px solid #ccc; } + padding: 6px; + border-bottom: 1px solid #ccc; + zoom: 1; } + section.week-edit > section.content > div section header:before, section.week-edit > section.content > div section header:after, + section.week-new > section.content > div section header:before, + section.week-new > section.content > div section header:after, + section.sequence-edit > section.content > div section header:before, + section.sequence-edit > section.content > div section header:after { + content: ""; + display: table; } + section.week-edit > section.content > div section header:after, + section.week-new > section.content > div section header:after, + section.sequence-edit > section.content > div section header:after { + clear: both; } section.week-edit > section.content > div section header h2, section.week-new > section.content > div section header h2, section.sequence-edit > section.content > div section header h2 { text-transform: uppercase; letter-spacing: 1px; - font-size: 12px; } + font-size: 12px; + float: left; } section.week-edit > section.content > div section.modules, section.week-new > section.content > div section.modules, section.sequence-edit > section.content > div section.modules { @@ -737,26 +752,37 @@ section.sequence-edit > section.content { section.week-new > section.content > div section.modules ol li ol li, section.sequence-edit > section.content > div section.modules ol li ol li { padding: 6px; } + section.week-edit > section.content > div section.modules ol li ol li:hover a.draggable, + section.week-new > section.content > div section.modules ol li ol li:hover a.draggable, + section.sequence-edit > section.content > div section.modules ol li ol li:hover a.draggable { + opacity: 1; } + section.week-edit > section.content > div section.modules ol li ol li a.draggable, + section.week-new > section.content > div section.modules ol li ol li a.draggable, + section.sequence-edit > section.content > div section.modules ol li ol li a.draggable { + float: right; + opacity: .5; } section.week-edit > section.content > div section.modules ol li ol li.group, section.week-new > section.content > div section.modules ol li ol li.group, section.sequence-edit > section.content > div section.modules ol li ol li.group { - padding: 0; - border-left: 4px solid #999; } + padding: 0; } section.week-edit > section.content > div section.modules ol li ol li.group header, section.week-new > section.content > div section.modules ol li ol li.group header, section.sequence-edit > section.content > div section.modules ol li ol li.group header { - padding: 3px 6px; + padding: 6px; background: none; } section.week-edit > section.content > div section.modules ol li ol li.group header h3, section.week-new > section.content > div section.modules ol li ol li.group header h3, section.sequence-edit > section.content > div section.modules ol li ol li.group header h3 { - text-transform: uppercase; - letter-spacing: 1px; - font-size: 12px; } - section.week-edit > section.content > div section.modules ol li ol li.group ol li:last-child, - section.week-new > section.content > div section.modules ol li ol li.group ol li:last-child, - section.sequence-edit > section.content > div section.modules ol li ol li.group ol li:last-child { + font-size: 14px; } + section.week-edit > section.content > div section.modules ol li ol li.group ol, + section.week-new > section.content > div section.modules ol li ol li.group ol, + section.sequence-edit > section.content > div section.modules ol li ol li.group ol { + border-left: 4px solid #999; border-bottom: 0; } + section.week-edit > section.content > div section.modules ol li ol li.group ol li:last-child, + section.week-new > section.content > div section.modules ol li ol li.group ol li:last-child, + section.sequence-edit > section.content > div section.modules ol li ol li.group ol li:last-child { + border-bottom: 0; } section.week-edit > section.content > div section.scratch-pad, section.week-new > section.content > div section.scratch-pad, section.sequence-edit > section.content > div section.scratch-pad { diff --git a/cms/static/sass/_base.scss b/cms/static/sass/_base.scss index 4bc24e662f..3a2ef86363 100644 --- a/cms/static/sass/_base.scss +++ b/cms/static/sass/_base.scss @@ -108,4 +108,6 @@ input[type="submit"], .button { min-height: 14px; background: url('../img/drag-handle.png') no-repeat center; text-indent: -9999px; + display: block; + float: right; } diff --git a/cms/static/sass/_week.scss b/cms/static/sass/_week.scss index de7b1e6f9e..e5283cbc55 100644 --- a/cms/static/sass/_week.scss +++ b/cms/static/sass/_week.scss @@ -67,16 +67,19 @@ section.sequence-edit { display: table; border: 1px solid; width: 100%; + section { header { background: #eee; - padding: 10px; + padding: 6px; border-bottom: 1px solid #ccc; + @include clearfix; h2 { text-transform: uppercase; letter-spacing: 1px; font-size: 12px; + float: left; } } @@ -118,22 +121,34 @@ section.sequence-edit { li { padding: 6px; + &:hover { + a.draggable { + opacity: 1; + } + } + + a.draggable { + float: right; + opacity: .5; + } + &.group { padding: 0; - border-left: 4px solid #999; header { - padding: 3px 6px; + padding: 6px; background: none; h3 { - text-transform: uppercase; - letter-spacing: 1px; - font-size: 12px; + font-size: 14px; } } + ol { + border-left: 4px solid #999; + border-bottom: 0; + li { &:last-child { border-bottom: 0; @@ -185,9 +200,9 @@ section.sequence-edit { padding: 12px; a { - @extend .button; - display: block; - text-align: center; + @extend .button; + display: block; + text-align: center; } } diff --git a/cms/templates/widgets/navigation.html b/cms/templates/widgets/navigation.html index 808c569e74..28b92979d9 100644 --- a/cms/templates/widgets/navigation.html +++ b/cms/templates/widgets/navigation.html @@ -45,10 +45,22 @@ @@ -61,10 +73,22 @@ @@ -77,9 +101,19 @@ @@ -93,10 +127,22 @@ @@ -137,6 +183,30 @@ <%include file="module-dropdown.html"/> +
  • +
    +

    Course Scratch Pad

    +
    + + +
  • diff --git a/cms/templates/widgets/week-edit.html b/cms/templates/widgets/week-edit.html index 6e59c44468..2e37520fde 100644 --- a/cms/templates/widgets/week-edit.html +++ b/cms/templates/widgets/week-edit.html @@ -10,160 +10,201 @@
    • -

      Goal title: This is the goal body and is wehre the goal will be further explained

      +

      Goal title: This is the goal body and is where the goal will be further explained

    -
    -
      -
    • - - -
    • - -
    • - - -
    • -
    • - -
    • - -
    • - Advanced filters -
    • - -
    • - -
    • -
    -
    -
    -
    -
      +
      +
    +
    -
    -
      -
    1. -
      -

      Section Scratch

      -
      -
        -
      • Problem title 11
      • -
      • Problem title 13
      • -
      • Problem title 14
      • -
      • Video 3
      • -
      -
    2. -
    3. -
      -

      Course Scratch

      -
      -
        -
      • Problem title 11
      • -
      • Problem title 13
      • -
      • Problem title 14
      • -
      • Video 3
      • -
      -
    4. +
      +
      +
        +
      1. +
        +

        Lecture Sequence

        + handle +
        -
      2. - <%include file="new-module.html"/> -
      3. -
      -
      +
        +
      1. + Problem title 11 + handle +
      2. +
      3. + Problem Group + handle +
      4. +
      5. + Problem title 14 + handle +
      6. +
      7. + Video 3 + handle +
      8. +
      + +
    5. +
      +

      Lecture Sequence

      + handle +
      + +
        +
      1. +
        +

        + Problem group + handle +

        +
        +
          +
        1. + Problem title 11 + handle +
        2. +
        3. + Problem title 11 + handle +
        4. +
        5. + Problem title 11 + handle +
        6. +
        +
      2. +
      3. + Problem title 13 + handle +
      4. +
      5. + Problem title 14 + handle +
      6. +
      7. + Video 3 + handle +
      8. +
      +
    6. +
    7. +
      +

      Homework 1a

      +
      + +
        +
      1. + Problem title 11 + handle +
      2. +
      3. + Problem Group + handle +
      4. +
      5. + Problem title 14 + handle +
      6. +
      7. + Video 3 + handle +
      8. +
      +
    8. + + + + +
    +
    + +
    +
      +
    1. +
      +

      Section Scratch

      +
      + +
    2. +
    3. +
      +

      Course Scratch

      +
      + + +
    4. + + + + +
    +
    From cb1f6838ba3dc6dd00d0f4baad98b9fe5bc76a47 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Fri, 15 Jun 2012 13:27:24 -0400 Subject: [PATCH 66/80] Added more styles and markup for sequence --- cms/static/css/base-style.css | 112 +++++++++---- cms/static/sass/_calendar.scss | 2 +- cms/static/sass/_week.scss | 68 +++++--- cms/templates/widgets/sequnce-edit.html | 204 ++++++++++++++++++------ cms/templates/widgets/week-edit.html | 129 +++++++++++++-- cms/templates/widgets/week-new.html | 10 +- 6 files changed, 407 insertions(+), 118 deletions(-) diff --git a/cms/static/css/base-style.css b/cms/static/css/base-style.css index abed82cc05..9ebc6bd839 100644 --- a/cms/static/css/base-style.css +++ b/cms/static/css/base-style.css @@ -460,7 +460,7 @@ section.cal { section.cal section.new-section section { display: none; position: absolute; - top: 32px; + top: 30px; background: rgba(0, 0, 0, 0.8); min-width: 300px; padding: 10px; @@ -575,46 +575,96 @@ section.sequence-edit > header { section.week-new > header:after, section.sequence-edit > header:after { clear: both; } - section.week-edit > header h1, - section.week-new > header h1, - section.sequence-edit > header h1 { - font-size: 18px; - margin: 8px 6px; - text-transform: uppercase; - letter-spacing: 1px; } + section.week-edit > header div, + section.week-new > header div, + section.sequence-edit > header div { + zoom: 1; + padding: 6px 20px; } + section.week-edit > header div:before, section.week-edit > header div:after, + section.week-new > header div:before, + section.week-new > header div:after, + section.sequence-edit > header div:before, + section.sequence-edit > header div:after { + content: ""; + display: table; } + section.week-edit > header div:after, + section.week-new > header div:after, + section.sequence-edit > header div:after { + clear: both; } + section.week-edit > header div h1, + section.week-new > header div h1, + section.sequence-edit > header div h1 { + font-size: 18px; + text-transform: uppercase; + letter-spacing: 1px; + float: left; } + section.week-edit > header div p, + section.week-new > header div p, + section.sequence-edit > header div p { + float: right; } + section.week-edit > header div.week, + section.week-new > header div.week, + section.sequence-edit > header div.week { + background: #eee; + font-size: 12px; + border-bottom: 1px solid #ccc; } + section.week-edit > header div.week h2, + section.week-new > header div.week h2, + section.sequence-edit > header div.week h2 { + font-size: 12px; + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + margin-right: 20px; } + section.week-edit > header div.week ul, + section.week-new > header div.week ul, + section.sequence-edit > header div.week ul { + list-style: none; + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; } + section.week-edit > header div.week ul li, + section.week-new > header div.week ul li, + section.sequence-edit > header div.week ul li { + display: -moz-inline-box; + -moz-box-orient: vertical; + display: inline-block; + vertical-align: baseline; + zoom: 1; + *display: inline; + *vertical-align: auto; + margin-right: 10px; } + section.week-edit > header div.week ul li p, + section.week-new > header div.week ul li p, + section.sequence-edit > header div.week ul li p { + float: none; } section.week-edit > header section.goals, section.week-new > header section.goals, section.sequence-edit > header section.goals { background: #eee; - padding: 6px; + padding: 6px 20px; border-top: 1px solid #ccc; } - section.week-edit > header section.goals header h2, - section.week-new > header section.goals header h2, - section.sequence-edit > header section.goals header h2 { - font-size: 14px; - display: -moz-inline-box; - -moz-box-orient: vertical; - display: inline-block; - vertical-align: baseline; - zoom: 1; - *display: inline; - *vertical-align: auto; } - section.week-edit > header section.goals header p, - section.week-new > header section.goals header p, - section.sequence-edit > header section.goals header p { - display: -moz-inline-box; - -moz-box-orient: vertical; - display: inline-block; - vertical-align: baseline; - zoom: 1; - *display: inline; - *vertical-align: auto; } section.week-edit > header section.goals ul, section.week-new > header section.goals ul, section.sequence-edit > header section.goals ul { list-style: none; - margin-top: 6px; color: #999; } + section.week-edit > header section.goals ul li, + section.week-new > header section.goals ul li, + section.sequence-edit > header section.goals ul li { + margin-bottom: 6px; } + section.week-edit > header section.goals ul li:last-child, + section.week-new > header section.goals ul li:last-child, + section.sequence-edit > header section.goals ul li:last-child { + margin-bottom: 0; } section.week-edit > section.content, section.week-new > section.content, section.sequence-edit > section.content { diff --git a/cms/static/sass/_calendar.scss b/cms/static/sass/_calendar.scss index ca91337366..fa10c65950 100644 --- a/cms/static/sass/_calendar.scss +++ b/cms/static/sass/_calendar.scss @@ -176,7 +176,7 @@ section.cal { section { display: none; - @include position(absolute, 32px 0 0 0); + @include position(absolute, 30px 0 0 0); background: rgba(#000, .8); min-width: 300px; padding: 10px; diff --git a/cms/static/sass/_week.scss b/cms/static/sass/_week.scss index e5283cbc55..b638a36f5c 100644 --- a/cms/static/sass/_week.scss +++ b/cms/static/sass/_week.scss @@ -6,34 +6,64 @@ section.sequence-edit { border-bottom: 2px solid #333; @include clearfix(); - h1 { - font-size: 18px; - margin: 8px 6px; - text-transform: uppercase; - letter-spacing: 1px; + div { + @include clearfix(); + padding: 6px 20px; + + h1 { + font-size: 18px; + text-transform: uppercase; + letter-spacing: 1px; + float: left; + } + + p { + float: right; + } + + &.week { + background: #eee; + font-size: 12px; + border-bottom: 1px solid #ccc; + + h2 { + font-size: 12px; + @include inline-block(); + margin-right: 20px; + } + + ul { + list-style: none; + @include inline-block(); + + li { + @include inline-block(); + margin-right: 10px; + + p { + float: none; + } + } + } + } } section.goals { background: #eee; - padding: 6px; + padding: 6px 20px; border-top: 1px solid #ccc; - header { - h2 { - font-size: 14px; - @include inline-block(); - } - - p { - @include inline-block(); - } - - } - ul { list-style: none; - margin-top: 6px; color: #999; + + li { + margin-bottom: 6px; + + &:last-child { + margin-bottom: 0; + } + } } } } diff --git a/cms/templates/widgets/sequnce-edit.html b/cms/templates/widgets/sequnce-edit.html index 75d4504b68..b69b523bc4 100644 --- a/cms/templates/widgets/sequnce-edit.html +++ b/cms/templates/widgets/sequnce-edit.html @@ -1,47 +1,20 @@ -<%block name="content">
    - Done -

    Lecture Sequence name

    - Settings +
    +

    Week 1

    +
      +
    • +

      Goal title: This is the goal body and is where the goal will be further explained

      +
    • +
    +
    +
    +

    Lecture sequence

    +

    Group type: Ordered Sequence

    +
    - - -
    -
    -

    Sequence Content

    -
    - -
    -
    - +
    -
    - -
    +
    +
    +
      +
    1. +
        +
      1. + Problem title 11 + handle +
      2. +
      3. + Problem Group + handle +
      4. +
      5. + Problem title 14 + handle +
      6. +
      7. + Video 3 + handle +
      8. +
      9. +
        +

        + Problem group + handle +

        +
        +
          +
        1. + Problem title 11 + handle +
        2. +
        3. + Problem title 11 + handle +
        4. +
        5. + Problem title 11 + handle +
        6. +
        +
      10. +
      11. + Problem title 13 + handle +
      12. +
      13. + Problem title 14 + handle +
      14. +
      15. + Video 3 + handle +
      16. +
      17. + Problem title 11 + handle +
      18. +
      19. + Problem Group + handle +
      20. +
      21. + Problem title 14 + handle +
      22. +
      23. + Video 3 + handle +
      24. +
      +
    2. + + + + +
    +
    + +
    +
      +
    1. +
      +

      Section Scratch

      +
      + +
    2. +
    3. +
      +

      Course Scratch

      +
      + + +
    4. + + + + +
    +
    +
    - diff --git a/cms/templates/widgets/week-edit.html b/cms/templates/widgets/week-edit.html index 2e37520fde..95ca631be0 100644 --- a/cms/templates/widgets/week-edit.html +++ b/cms/templates/widgets/week-edit.html @@ -1,16 +1,14 @@
    -

    Week 3

    +
    +

    Week 3

    +

    + new goal

    +
    -
    -

    Weeks goals:

    -

    + new goal

    -
    -
    • -

      Goal title: This is the goal body and is where the goal will be further explained

      +

      Goal title: This is the goal body and is where the goal will be further explained

    @@ -62,7 +60,40 @@ Problem title 11 handle -
  • +
  • +
    +

    + Problem group + handle +

    +
    +
      +
    1. + Problem title 11 + handle +
    2. +
    3. + Problem title 11 + handle +
    4. +
    5. + Problem title 11 + handle +
    6. +
    7. + Problem title 13 + handle +
    8. +
    9. + Problem title 14 + handle +
    10. +
    11. + Video 3 + handle +
    12. +
    +
  • Problem Group handle
  • @@ -70,11 +101,77 @@ Problem title 14 handle -
  • +
  • +
    +

    + Problem group + handle +

    +
    +
      +
    1. + Problem title 11 + handle +
    2. +
    3. + Problem title 11 + handle +
    4. +
    5. + Problem title 11 + handle +
    6. +
    7. + Problem title 13 + handle +
    8. +
    9. + Problem title 14 + handle +
    10. +
    11. + Video 3 + handle +
    12. +
    +
  • Video 3 handle
  • - +
  • +
    +

    + Problem group + handle +

    +
    +
      +
    1. + Problem title 11 + handle +
    2. +
    3. + Problem title 11 + handle +
    4. +
    5. + Problem title 11 + handle +
    6. +
    7. + Problem title 13 + handle +
    8. +
    9. + Problem title 14 + handle +
    10. +
    11. + Video 3 + handle +
    12. +
    +
  • @@ -103,6 +200,18 @@ Problem title 11 handle
  • +
  • + Problem title 13 + handle +
  • +
  • + Problem title 14 + handle +
  • +
  • + Video 3 + handle +
  • diff --git a/cms/templates/widgets/week-new.html b/cms/templates/widgets/week-new.html index be08587755..c62730c1bc 100644 --- a/cms/templates/widgets/week-new.html +++ b/cms/templates/widgets/week-new.html @@ -1,13 +1,11 @@
    -

    Week 3

    +
    +

    Week 3

    +

    + new goal

    +
    -
    -

    Weeks goals:

    -

    + new goal

    -
    -
    • Please add a goal for this section

      From 5ad2824c59a47a267d180e36286475a2d7c85d02 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Thu, 7 Jun 2012 17:16:56 -0400 Subject: [PATCH 67/80] fix typo in comment in student view --- lms/djangoapps/student/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/student/views.py b/lms/djangoapps/student/views.py index eb71f5ba6a..a157da7bef 100644 --- a/lms/djangoapps/student/views.py +++ b/lms/djangoapps/student/views.py @@ -89,7 +89,7 @@ def login_user(request, error=""): @ensure_csrf_cookie def logout_user(request): - ''' HTTP request to log in the user. Redirects to marketing page''' + ''' HTTP request to log out the user. Redirects to marketing page''' logout(request) return redirect('/') From 15ac575301eb4fb63ead0ca62c4ab497ed934505 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Thu, 14 Jun 2012 11:28:52 -0400 Subject: [PATCH 68/80] added rednose to requirements (adds color output to nose) --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 9dc67682fb..a62baad94b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,3 +25,4 @@ newrelic glob2 django_nose nosexcover +rednose From e061e8642433e95151c3b355efa09059d5f8a41f Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Thu, 14 Jun 2012 17:07:50 -0400 Subject: [PATCH 69/80] Clean and refactor courseware/views.py and module_render.py * Refactor index() so that it makes sense to me and hopefully others :) * Rename preloaded cache of student modules to student_module_cache * Fix line length and whitespace throughout * add docstrings and other comments * a few behavior-preserving tweaks to the code to make it clearer. * Separate codepaths for with-module and without-module in index view * Remove default chapter + section, since they don't exist anyway in course.xml --- lms/djangoapps/courseware/module_render.py | 227 +++++++++------- lms/djangoapps/courseware/views.py | 301 +++++++++++++-------- 2 files changed, 316 insertions(+), 212 deletions(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index fe6ebdd585..7c4de7d499 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -26,8 +26,29 @@ class I4xSystem(object): This is an abstraction such that x_modules can function independent of the courseware (e.g. import into other types of courseware, LMS, or if we want to have a sandbox server for user-contributed content) + + I4xSystem objects are passed to x_modules to provide access to system + functionality. ''' - def __init__(self, ajax_url, track_function, render_function, render_template, filestore=None): + def __init__(self, ajax_url, track_function, render_function, + render_template, filestore=None): + ''' + Create a closure around the system environment. + + ajax_url - the url where ajax calls to the encapsulating module go. + track_function - function of (event_type, event), intended for logging + or otherwise tracking the event. + TODO: Not used, and has inconsistent args in different + files. Update or remove. + render_function - function that takes (module_xml) and renders it, + returning a dictionary with a context for rendering the + module to html. Dictionary will contain keys 'content' + and 'type'. + render_template - a function that takes (template_file, context), and returns + rendered html. + filestore - A filestore ojbect. Defaults to an instance of OSFS based at + settings.DATA_DIR. + ''' self.ajax_url = ajax_url self.track_function = track_function if not filestore: @@ -35,37 +56,47 @@ class I4xSystem(object): else: self.filestore = filestore if settings.DEBUG: - log.info("[courseware.module_render.I4xSystem] filestore path = %s" % filestore) + log.info("[courseware.module_render.I4xSystem] filestore path = %s", + filestore) self.render_function = render_function self.render_template = render_template self.exception404 = Http404 self.DEBUG = settings.DEBUG - def get(self,attr): # uniform access to attributes (like etree) + def get(self, attr): + ''' provide uniform access to attributes (like etree).''' return self.__dict__.get(attr) - def set(self,attr,val): # uniform access to attributes (like etree) + + def set(self,attr,val): + '''provide uniform access to attributes (like etree)''' self.__dict__[attr] = val + def __repr__(self): return repr(self.__dict__) + def __str__(self): return str(self.__dict__) -def object_cache(cache, user, module_type, module_id): - # We don't look up on user -- all queries include user - # Additional lookup would require a DB hit the way Django - # is broken. +def smod_cache_lookup(cache, module_type, module_id): + ''' + Look for a student module with the given type and id in the cache. + + cache -- list of student modules + + returns first found object, or None + ''' for o in cache: - if o.module_type == module_type and \ - o.module_id == module_id: + if o.module_type == module_type and o.module_id == module_id: return o return None def make_track_function(request): ''' We want the capa problem (and other modules) to be able to track/log what happens inside them without adding dependencies on - Django or the rest of the codebase. We do this by passing a - tracking function to them. This generates a closure for each request - that gives a clean interface on both sides. + Django or the rest of the codebase. + + To do this in a clean way, we pass a tracking function to the module, + which calls it to log events. ''' import track.views @@ -75,85 +106,91 @@ def make_track_function(request): def grade_histogram(module_id): ''' Print out a histogram of grades on a given problem. - Part of staff member debug info. + Part of staff member debug info. ''' from django.db import connection cursor = connection.cursor() - cursor.execute("select courseware_studentmodule.grade,COUNT(courseware_studentmodule.student_id) from courseware_studentmodule where courseware_studentmodule.module_id=%s group by courseware_studentmodule.grade", [module_id]) + q = """SELECT courseware_studentmodule.grade, + COUNT(courseware_studentmodule.student_id) + FROM courseware_studentmodule + WHERE courseware_studentmodule.module_id=%s + GROUP BY courseware_studentmodule.grade""" + # Passing module_id this way prevents sql-injection. + cursor.execute(q, [module_id]) grades = list(cursor.fetchall()) - grades.sort(key=lambda x:x[0]) # Probably not necessary - if (len(grades) == 1 and grades[0][0] is None): + grades.sort(key=lambda x: x[0]) # Add ORDER BY to sql query? + if len(grades) == 1 and grades[0][0] is None: return [] return grades -def get_module(user, request, xml_module, module_object_preload, position=None): - ''' Get the appropriate xmodule and StudentModule. +def get_module(user, request, module_xml, student_module_cache, position=None): + ''' Get an instance of the xmodule class corresponding to module_xml, + setting the state based on an existing StudentModule, or creating one if none + exists. Arguments: - user : current django User - request : current django HTTPrequest - - xml_module : lxml etree of xml subtree for the current module - - module_object_preload : list of StudentModule objects, one of which may match this module type and id - - position : extra information from URL for user-specified position within module + - module_xml : lxml etree of xml subtree for the requested module + - student_module_cache : list of StudentModule objects, one of which may + match this module type and id + - position : extra information from URL for user-specified + position within module Returns: - a tuple (xmodule instance, student module, module type). - ''' - module_type=xml_module.tag - module_class=xmodule.get_module_class(module_type) - module_id=xml_module.get('id') #module_class.id_attribute) or "" + module_type = module_xml.tag + module_class = xmodule.get_module_class(module_type) + module_id = module_xml.get('id') - # Grab state from database - smod = object_cache(module_object_preload, - user, - module_type, - module_id) + # Grab xmodule state from StudentModule cache + smod = smod_cache_lookup(student_module_cache, module_type, module_id) + state = smod.state if smod else None - if not smod: # If nothing in the database... - state=None - else: - state = smod.state - - # get coursename if stored + # get coursename if present in request coursename = multicourse_settings.get_coursename_from_request(request) if coursename and settings.ENABLE_MULTICOURSE: - xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course + # path to XML for the course + xp = multicourse_settings.get_course_xmlpath(coursename) data_root = settings.DATA_DIR + xp else: data_root = settings.DATA_DIR - # Create a new instance - ajax_url = settings.MITX_ROOT_URL + '/modx/'+module_type+'/'+module_id+'/' + # Setup system context for module instance + ajax_url = settings.MITX_ROOT_URL + '/modx/' + module_type + '/' + module_id + '/' + def render_function(module_xml): + return render_x_module(user, request, module_xml, student_module_cache, position) system = I4xSystem(track_function = make_track_function(request), - render_function = lambda x: render_x_module(user, request, x, module_object_preload, position), + render_function = render_function, render_template = render_to_string, ajax_url = ajax_url, filestore = OSFS(data_root), ) - system.set('position',position) # pass URL specified position along to module, through I4xSystem - instance=module_class(system, - etree.tostring(xml_module), - module_id, - state=state) + # pass position specified in URL to module through I4xSystem + system.set('position', position) + instance = module_class(system, + etree.tostring(module_xml), + module_id, + state=state) - # If instance wasn't already in the database, and this - # isn't a guest user, create it + # If StudentModule for this instance wasn't already in the database, + # and this isn't a guest user, create it. if not smod and user.is_authenticated(): - smod=StudentModule(student=user, - module_type = module_type, - module_id=module_id, - state=instance.get_state()) + smod = StudentModule(student=user, module_type = module_type, + module_id=module_id, state=instance.get_state()) smod.save() - module_object_preload.append(smod) + # Add to cache. The caller and the system context have references + # to it, so the change persists past the return + student_module_cache.append(smod) return (instance, smod, module_type) -def render_x_module(user, request, xml_module, module_object_preload, position=None): +def render_x_module(user, request, module_xml, student_module_cache, position=None): ''' Generic module for extensions. This renders to HTML. modules include sequential, vertical, problem, video, html @@ -164,37 +201,36 @@ def render_x_module(user, request, xml_module, module_object_preload, position=N - user : current django User - request : current django HTTPrequest - - xml_module : lxml etree of xml subtree for the current module - - module_object_preload : list of StudentModule objects, one of which may match this module type and id + - module_xml : lxml etree of xml subtree for the current module + - student_module_cache : list of StudentModule objects, one of which may match this module type and id - position : extra information from URL for user-specified position within module Returns: - - dict which is context for HTML rendering of the specified module - + - dict which is context for HTML rendering of the specified module. Will have + key 'content', and will have 'type' key if passed a valid module. ''' - if xml_module==None : - return {"content":""} + if module_xml is None : + return {"content": ""} - (instance, smod, module_type) = get_module(user, request, xml_module, module_object_preload, position) + (instance, smod, module_type) = get_module( + user, request, module_xml, student_module_cache, position) - # Grab content content = instance.get_html() # special extra information about each problem, only for users who are staff if settings.MITX_FEATURES.get('DISPLAY_HISTOGRAMS_TO_STAFF') and user.is_staff: - module_id = xml_module.get('id') + module_id = module_xml.get('id') histogram = grade_histogram(module_id) render_histogram = len(histogram) > 0 - content=content+render_to_string("staff_problem_info.html", {'xml':etree.tostring(xml_module), - 'module_id' : module_id, - 'histogram': json.dumps(histogram), - 'render_histogram' : render_histogram}) + staff_context = {'xml': etree.tostring(module_xml), + 'module_id': module_id, + 'histogram': json.dumps(histogram), + 'render_histogram': render_histogram} + content += render_to_string("staff_problem_info.html", staff_context) - content = {'content':content, - 'type':module_type} - - return content + context = {'content': content, 'type': module_type} + return context def modx_dispatch(request, module=None, dispatch=None, id=None): ''' Generic view for extensions. This is where AJAX calls go. @@ -210,32 +246,38 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): - id -- the module id. Used to look up the student module. e.g. filenamexformularesponse ''' + # ''' (fix emacs broken parsing) if not request.user.is_authenticated(): return redirect('/') + # python concats adjacent strings + error_msg = ("We're sorry, this module is temporarily unavailable." + "Our staff is working to fix it as soon as possible") + + # Grab the student information for the module from the database s = StudentModule.objects.filter(student=request.user, module_id=id) - #s = StudentModule.get_with_caching(request.user, id) - if len(s) == 0 or s is None: - log.debug("Couldnt find module for user and id " + str(module) + " " + str(request.user) + " "+ str(id)) + + # s = StudentModule.get_with_caching(request.user, id) + if s is None or len(s) == 0: + log.debug("Couldn't find module '%s' for user '%s' and id '%s'", + module, request.user, id) raise Http404 s = s[0] oldgrade = s.grade oldstate = s.state - # TODO: if dispatch is left at default value None, this will go boom. What's the correct - # behavior? - dispatch=dispatch.split('?')[0] + # If there are arguments, get rid of them + if '?' in dispatch: + dispatch = dispatch.split('?')[0] - ajax_url = settings.MITX_ROOT_URL + '/modx/'+module+'/'+id+'/' - - # get coursename if stored + ajax_url = '{root}/modx/{module}/{id}'.format(root = settings.MITX_ROOT_URL, + module=module, id=id) coursename = multicourse_settings.get_coursename_from_request(request) - if coursename and settings.ENABLE_MULTICOURSE: - xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course + xp = multicourse_settings.get_course_xmlpath(coursename) data_root = settings.DATA_DIR + xp else: data_root = settings.DATA_DIR @@ -244,11 +286,13 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): try: xml = content_parser.module_xml(request.user, module, 'id', id, coursename) except: - log.exception("Unable to load module during ajax call. module=%s, dispatch=%s, id=%s" % (module, dispatch, id)) + log.exception( + "Unable to load module during ajax call. module=%s, dispatch=%s, id=%s", + module, dispatch, id) if accepts(request, 'text/html'): return render_to_response("module-error.html", {}) else: - response = HttpResponse(json.dumps({'success': "We're sorry, this module is temporarily unavailable. Our staff is working to fix it as soon as possible"})) + response = HttpResponse(json.dumps({'success': error_msg})) return response # Create the module @@ -260,24 +304,23 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): ) try: - instance=xmodule.get_module_class(module)(system, - xml, - id, - state=oldstate) + module_class = xmodule.get_module_class(module) + instance = module_class(system, xml, id, state=oldstate) except: log.exception("Unable to load module instance during ajax call") if accepts(request, 'text/html'): return render_to_response("module-error.html", {}) else: - response = HttpResponse(json.dumps({'success': "We're sorry, this module is temporarily unavailable. Our staff is working to fix it as soon as possible"})) + response = HttpResponse(json.dumps({'success': error_msg})) return response # Let the module handle the AJAX - ajax_return=instance.handle_ajax(dispatch, request.POST) + ajax_return = instance.handle_ajax(dispatch, request.POST) + # Save the state back to the database - s.state=instance.get_state() + s.state = instance.get_state() if instance.get_score(): - s.grade=instance.get_score()['score'] + s.grade = instance.get_score()['score'] if s.grade != oldgrade or s.state != oldstate: s.save() # Return whatever the module wanted to return to the client/caller diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index fcd0104455..7bc8b323ce 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -41,66 +41,71 @@ def gradebook(request): coursename = multicourse_settings.get_coursename_from_request(request) student_objects = User.objects.all()[:100] - student_info = [{'username' :s.username, - 'id' : s.id, + student_info = [{'username': s.username, + 'id': s.id, 'email': s.email, - 'grade_info' : grades.grade_sheet(s,coursename), - 'realname' : UserProfile.objects.get(user = s).name + 'grade_info': grades.grade_sheet(s, coursename), + 'realname': UserProfile.objects.get(user = s).name } for s in student_objects] - return render_to_response('gradebook.html',{'students':student_info}) + return render_to_response('gradebook.html', {'students': student_info}) @login_required @cache_control(no_cache=True, no_store=True, must_revalidate=True) -def profile(request, student_id = None): +def profile(request, student_id=None): ''' User profile. Show username, location, etc, as well as grades . We need to allow the user to change some of these settings .''' if student_id is None: student = request.user - else: + else: if 'course_admin' not in content_parser.user_groups(request.user): raise Http404 student = User.objects.get( id = int(student_id)) - user_info = UserProfile.objects.get(user=student) # request.user.profile_cache # + user_info = UserProfile.objects.get(user=student) # request.user.profile_cache # coursename = multicourse_settings.get_coursename_from_request(request) - context={'name':user_info.name, - 'username':student.username, - 'location':user_info.location, - 'language':user_info.language, - 'email':student.email, - 'format_url_params' : content_parser.format_url_params, - 'csrf':csrf(request)['csrf_token'] - } - context.update(grades.grade_sheet(student,coursename)) + context = {'name': user_info.name, + 'username': student.username, + 'location': user_info.location, + 'language': user_info.language, + 'email': student.email, + 'format_url_params': content_parser.format_url_params, + 'csrf': csrf(request)['csrf_token'] + } + context.update(grades.grade_sheet(student, coursename)) return render_to_response('profile.html', context) -def render_accordion(request,course,chapter,section): + +def render_accordion(request, course, chapter, section): ''' Draws navigation bar. Takes current position in accordion as parameter. Returns (initialization_javascript, content)''' if not course: course = "6.002 Spring 2012" - toc=content_parser.toc_from_xml(content_parser.course_file(request.user,course), chapter, section) - active_chapter=1 + toc = content_parser.toc_from_xml( + content_parser.course_file(request.user, course), chapter, section) + + active_chapter = 1 for i in range(len(toc)): if toc[i]['active']: - active_chapter=i - context=dict([['active_chapter',active_chapter], - ['toc',toc], - ['course_name',course], - ['format_url_params',content_parser.format_url_params], - ['csrf',csrf(request)['csrf_token']]] + \ + active_chapter = i + + context=dict([('active_chapter', active_chapter), + ('toc', toc), + ('course_name', course), + ('format_url_params', content_parser.format_url_params), + ('csrf', csrf(request)['csrf_token'])] + template_imports.items()) - return render_to_string('accordion.html',context) + return render_to_string('accordion.html', context) + @cache_control(no_cache=True, no_store=True, must_revalidate=True) def render_section(request, section): - ''' TODO: Consolidate with index + ''' TODO: Consolidate with index ''' user = request.user if not settings.COURSEWARE_ENABLED: @@ -120,15 +125,15 @@ def render_section(request, section): } module_ids = dom.xpath("//@id") - + if user.is_authenticated(): - module_object_preload = list(StudentModule.objects.filter(student=user, + student_module_cache = list(StudentModule.objects.filter(student=user, module_id__in=module_ids)) else: - module_object_preload = [] - + student_module_cache = [] + try: - module = render_x_module(user, request, dom, module_object_preload) + module = render_x_module(user, request, dom, student_module_cache) except: log.exception("Unable to load module") context.update({ @@ -138,18 +143,67 @@ def render_section(request, section): return render_to_response('courseware.html', context) context.update({ - 'init':module.get('init_js', ''), - 'content':module['content'], + 'init': module.get('init_js', ''), + 'content': module['content'], }) result = render_to_response('courseware.html', context) return result +def get_course(request, course): + ''' Figure out what the correct course is. + + Needed to preserve backwards compatibility with non-multi-course version. + TODO: Can this go away once multicourse becomes standard? + ''' + + if course==None: + if not settings.ENABLE_MULTICOURSE: + course = "6.002 Spring 2012" + elif 'coursename' in request.session: + course = request.session['coursename'] + else: + course = settings.COURSE_DEFAULT + return course + +def get_module_xml(user, course, chapter, section): + ''' Look up the module xml for the given course/chapter/section path. + + Takes the user to look up the course file. + + Returns None if there was a problem, or the lxml etree for the module. + ''' + try: + # this is the course.xml etree + dom = content_parser.course_file(user, course) + except: + log.exception("Unable to parse courseware xml") + return None + + # this is the module's parent's etree + path = "//course[@name=$course]/chapter[@name=$chapter]//section[@name=$section]" + dom_module = dom.xpath(path, course=course, chapter=chapter, section=section) + + module_wrapper = dom_module[0] if len(dom_module) > 0 else None + if module_wrapper is None: + module = None + elif module_wrapper.get("src"): + module = content_parser.section_file( + user=user, section=module_wrapper.get("src"), coursename=course) + else: + # Copy the element out of the module's etree + module = etree.XML(etree.tostring(module_wrapper[0])) + return module + @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) -def index(request, course=None, chapter="Using the System", section="Hints",position=None): +def index(request, course=None, chapter=None, section=None, + position=None): ''' Displays courseware accordion, and any associated content. + If course, chapter, and section aren't all specified, just returns + the accordion. If they are specified, returns an error if they don't + point to a valid module. Arguments: @@ -162,110 +216,113 @@ def index(request, course=None, chapter="Using the System", section="Hints",posi Returns: - HTTPresponse + ''' + def clean(s): + ''' Fixes URLs -- we convert spaces to _ in URLs to prevent + funny encoding characters and keep the URLs readable. This undoes + that transformation. - ''' - user = request.user + TODO: Properly replace underscores. (Q: what is properly?) + ''' + return s.replace('_', ' ') + + def get_submodule_ids(module_xml): + ''' + Get a list with ids of the modules within this module. + ''' + return module_xml.xpath("//@id") + + def preload_student_modules(module_xml): + ''' + Find any StudentModule objects for this user that match + one of the given module_ids. Used as a cache to avoid having + each rendered module hit the db separately. + + Returns the list, or None on error. + ''' + if request.user.is_authenticated(): + module_ids = get_submodule_ids(module_xml) + return list(StudentModule.objects.filter(student=request.user, + module_id__in=module_ids)) + else: + return [] + + def get_module_context(): + ''' + Look up the module object and render it. If all goes well, returns + {'init': module-init-js, 'content': module-rendered-content} + + If there's an error, returns + {'content': module-error message} + ''' + # Can't modify variables of outer scope, so need new ones + chapter_ = clean(chapter) + section_ = clean(section) + + user = request.user + + module_xml = get_module_xml(user, course, chapter_, section_) + if module_xml is None: + log.exception("couldn't get module_xml: course/chapter/section: '%s/%s/%s'", + course, chapter_, section_) + return {'content' : render_to_string("module-error.html", {})} + + student_module_cache = preload_student_modules(module_xml) + + try: + module_context = render_x_module(user, request, module_xml, + student_module_cache, position) + except: + log.exception("Unable to load module") + return {'content' : render_to_string("module-error.html", {})} + + return {'init': module_context.get('init_js', ''), + 'content': module_context['content']} + if not settings.COURSEWARE_ENABLED: return redirect('/') - if course==None: - if not settings.ENABLE_MULTICOURSE: - course = "6.002 Spring 2012" - elif 'coursename' in request.session: - course = request.session['coursename'] - else: - course = settings.COURSE_DEFAULT - - # Fixes URLs -- we don't get funny encoding characters from spaces - # so they remain readable - ## TODO: Properly replace underscores - course=course.replace("_"," ") - chapter=chapter.replace("_"," ") - section=section.replace("_"," ") - - # use multicourse module to determine if "course" is valid - #if course!=settings.COURSE_NAME.replace('_',' '): + course = clean(get_course(request, course)) if not multicourse_settings.is_valid_course(course): return redirect('/') - request.session['coursename'] = course # keep track of current course being viewed in django's request.session - - try: - # this is the course.xml etree - dom = content_parser.course_file(user,course) # also pass course to it, for course-specific XML path - except: - log.exception("Unable to parse courseware xml") - return render_to_response('courseware-error.html', {}) - - # this is the module's parent's etree - dom_module = dom.xpath("//course[@name=$course]/chapter[@name=$chapter]//section[@name=$section]", - course=course, chapter=chapter, section=section) - - #print "DM", dom_module - - if len(dom_module) == 0: - module_wrapper = None - else: - module_wrapper = dom_module[0] - - if module_wrapper is None: - module = None - elif module_wrapper.get("src"): - module = content_parser.section_file(user=user, section=module_wrapper.get("src"), coursename=course) - else: - # this is the module's etree - module = etree.XML(etree.tostring(module_wrapper[0])) # Copy the element out of the tree - - module_ids = [] - if module is not None: - module_ids = module.xpath("//@id", - course=course, chapter=chapter, section=section) - - if user.is_authenticated(): - module_object_preload = list(StudentModule.objects.filter(student=user, - module_id__in=module_ids)) - else: - module_object_preload = [] + # keep track of current course being viewed in django's request.session + request.session['coursename'] = course context = { 'csrf': csrf(request)['csrf_token'], 'accordion': render_accordion(request, course, chapter, section), - 'COURSE_TITLE':multicourse_settings.get_course_title(course), + 'COURSE_TITLE': multicourse_settings.get_course_title(course), + 'init': '', + 'content': '' } - try: - module_context = render_x_module(user, request, module, module_object_preload, position) - except: - log.exception("Unable to load module") - context.update({ - 'init': '', - 'content': render_to_string("module-error.html", {}), - }) - return render_to_response('courseware.html', context) - - context.update({ - 'init': module_context.get('init_js', ''), - 'content': module_context['content'], - }) + look_for_module = chapter is not None and section is not None + if look_for_module: + context.update(get_module_context()) result = render_to_response('courseware.html', context) return result def jump_to(request, probname=None): ''' - Jump to viewing a specific problem. The problem is specified by a problem name - currently the filename (minus .xml) - of the problem. Maybe this should change to a more generic tag, eg "name" given as an attribute in . + Jump to viewing a specific problem. The problem is specified by a + problem name - currently the filename (minus .xml) of the problem. + Maybe this should change to a more generic tag, eg "name" given as + an attribute in . - We do the jump by (1) reading course.xml to find the first instance of with the given filename, then - (2) finding the parent element of the problem, then (3) rendering that parent element with a specific computed position - value (if it is ). + We do the jump by (1) reading course.xml to find the first + instance of with the given filename, then (2) finding + the parent element of the problem, then (3) rendering that parent + element with a specific computed position value (if it is + ). ''' # get coursename if stored coursename = multicourse_settings.get_coursename_from_request(request) # begin by getting course.xml tree - xml = content_parser.course_file(request.user,coursename) + xml = content_parser.course_file(request.user, coursename) # look for problem of given name pxml = xml.xpath('//problem[@filename="%s"]' % probname) @@ -279,12 +336,16 @@ def jump_to(request, probname=None): section = None branch = parent for k in range(4): # max depth of recursion - if branch.tag=='section': section = branch.get('name') - if branch.tag=='chapter': chapter = branch.get('name') + if branch.tag == 'section': + section = branch.get('name') + if branch.tag == 'chapter': + chapter = branch.get('name') branch = branch.getparent() position = None - if parent.tag=='sequential': - position = parent.index(pxml)+1 # position in sequence - - return index(request,course=coursename,chapter=chapter,section=section,position=position) + if parent.tag == 'sequential': + position = parent.index(pxml) + 1 # position in sequence + + return index(request, + course=coursename, chapter=chapter, + section=section, position=position) From fe45de3833ebc0ab06d9ed6fff696ee0387177f0 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 10:08:31 -0400 Subject: [PATCH 70/80] Read week headings from mongodb --- .../management/commands/import.py | 2 +- cms/djangoapps/contentstore/views.py | 13 +- cms/lib/keystore/__init__.py | 7 +- cms/lib/keystore/mongo.py | 19 ++- cms/templates/widgets/navigation.html | 123 +----------------- common/lib/xmodule/seq_module.py | 8 ++ common/lib/xmodule/setup.py | 14 ++ common/lib/xmodule/x_module.py | 75 +++++++++-- requirements.txt | 1 + 9 files changed, 115 insertions(+), 147 deletions(-) create mode 100644 common/lib/xmodule/setup.py diff --git a/cms/djangoapps/contentstore/management/commands/import.py b/cms/djangoapps/contentstore/management/commands/import.py index 690e3dbea0..3e0ccdd5e8 100644 --- a/cms/djangoapps/contentstore/management/commands/import.py +++ b/cms/djangoapps/contentstore/management/commands/import.py @@ -82,7 +82,7 @@ class Command(BaseCommand): def handle_list(e): if e.attrib.get("class", None) == "tutorials": return - children = [{'url':le.attrib['url']} for le in e.getchildren()] + children = [le.attrib['url'] for le in e.getchildren()] results[e.attrib['url']] = {'children':children} def handle_video(e): diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 429fb6c26b..64bde14869 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -3,11 +3,10 @@ from keystore.django import keystore from django.contrib.auth.decorators import login_required -@login_required -def calendar(request, org, course): - weeks = keystore.get_children_for_item(['i4x', org, course, 'Course', None]) - return render_to_response('calendar.html', {'weeks': weeks}) - - def index(request): - return render_to_response('index.html', {}) + # FIXME (cpennington): These need to be read in from the active user + org = 'mit.edu' + course = '6002xs12' + course = keystore.get_item(['i4x', org, course, 'Course', None]) + weeks = course.get_children() + return render_to_response('index.html', {'weeks': weeks}) diff --git a/cms/lib/keystore/__init__.py b/cms/lib/keystore/__init__.py index d0a24be797..61c797241d 100644 --- a/cms/lib/keystore/__init__.py +++ b/cms/lib/keystore/__init__.py @@ -37,7 +37,7 @@ class Location(object): self.update(location.list()) def url(self): - return "i4x://{org}/{course}/{category}/{name}".format(**self.dict()) + return "{tag}://{org}/{course}/{category}/{name}".format(**self.dict()) def list(self): return [self.tag, self.org, self.course, self.category, self.name] @@ -54,10 +54,9 @@ class Location(object): class KeyStore(object): - def get_children_for_item(self, location): + def get_item(self, location): """ - Returns the children for the most recent revision of the object - with the specified location. + Returns an XModuleDescriptor instance for the item at location If no object is found at that location, raises keystore.exceptions.ItemNotFoundError diff --git a/cms/lib/keystore/mongo.py b/cms/lib/keystore/mongo.py index d29afb4bd2..d9760909c9 100644 --- a/cms/lib/keystore/mongo.py +++ b/cms/lib/keystore/mongo.py @@ -1,6 +1,7 @@ import pymongo from . import KeyStore, Location from .exceptions import ItemNotFoundError, InsufficientSpecificationError +from xmodule.x_module import XModuleDescriptor class MongoKeyStore(KeyStore): @@ -12,11 +13,22 @@ class MongoKeyStore(KeyStore): host=host, port=port )[db][collection] - + # Force mongo to report errors, at the expense of performance self.collection.safe = True - def get_children_for_item(self, location): + def get_item(self, location): + """ + Returns an XModuleDescriptor instance for the item at location + + If no object is found at that location, raises keystore.exceptions.ItemNotFoundError + + Searches for all matches of a partially specifed location, but raises an + keystore.exceptions.InsufficientSpecificationError if more + than a single object matches the query. + + location: Something that can be passed to Location + """ query = dict( ('location.{key}'.format(key=key), val) for (key, val) @@ -25,7 +37,6 @@ class MongoKeyStore(KeyStore): ) items = self.collection.find( query, - fields={'children': True}, sort=[('revision', pymongo.ASCENDING)], limit=1, ) @@ -35,7 +46,7 @@ class MongoKeyStore(KeyStore): if items.count() == 0: raise ItemNotFoundError(location) - return items[0]['children'] + return XModuleDescriptor.load_from_json(items[0], self.get_item) def create_item(self, location, editor): """ diff --git a/cms/templates/widgets/navigation.html b/cms/templates/widgets/navigation.html index 28b92979d9..75d581dd73 100644 --- a/cms/templates/widgets/navigation.html +++ b/cms/templates/widgets/navigation.html @@ -35,9 +35,10 @@
      + % for week in weeks:
    1. -

      Week 1

      +

      ${week.name}

      • Goal title: This is a goal that will be in the header of the week
      • Goal title two: This is another goal for this week so that students have two things to learn
      • @@ -64,125 +65,7 @@ <%include file="module-dropdown.html"/>
    2. -
    3. -
      -

      Week 2

      -
        -
      • Another title This is the goal for the week
      • -
      -
      - - -
    4. -
    5. -
      -

      Week 3

      -
        -
      • Another title This is the goal for the week
      • -
      -
      - - -
    6. -
    7. -
      -

      Week 4

      -
        -
      • Another title This is the goal for the week
      • -
      • Goal title two: This is another fgoal for this week so that students have two things to learn
      • -
      -
      - - -
    8. - -
    9. -
      -

      Week 5

      -
        -
      • Please create a learning goal for this week
      • -
      -
      - -
        - <%include file="module-dropdown.html"/> -
      -
    10. -
    11. -
      -

      Week 6

      -
        -
      • Please create a learning goal for this week
      • -
      -
      - -
        - <%include file="module-dropdown.html"/> -
      -
    12. -
    13. -
      -

      Week 7

      -
        -
      • Please create a learning goal for this week
      • -
      -
      - -
        - <%include file="module-dropdown.html"/> -
      -
    14. + %endfor
    15. Course Scratch Pad

      diff --git a/common/lib/xmodule/seq_module.py b/common/lib/xmodule/seq_module.py index f643eaab4a..4ae4fb3813 100644 --- a/common/lib/xmodule/seq_module.py +++ b/common/lib/xmodule/seq_module.py @@ -95,3 +95,11 @@ class Module(XModule): self.position = int(system.get('position')) self.rendered = False + + +class CourseModuleDescriptor(XModuleDescriptor): + pass + + +class ChapterModuleDescriptor(XModuleDescriptor): + pass diff --git a/common/lib/xmodule/setup.py b/common/lib/xmodule/setup.py new file mode 100644 index 0000000000..6a659b6852 --- /dev/null +++ b/common/lib/xmodule/setup.py @@ -0,0 +1,14 @@ +from setuptools import setup, find_packages + +setup( + name="XModule", + version="0.1", + packages=find_packages(), + install_requires=['distribute'], + entry_points={ + 'xmodule.v1': [ + "Course = seq_module:CourseModuleDescriptor", + "Chapter = seq_module:ChapterModuleDescriptor", + ] + } +) diff --git a/common/lib/xmodule/x_module.py b/common/lib/xmodule/x_module.py index d783694fee..23025df50b 100644 --- a/common/lib/xmodule/x_module.py +++ b/common/lib/xmodule/x_module.py @@ -1,8 +1,34 @@ from lxml import etree +import pkg_resources +import logging +from keystore import Location + +log = logging.getLogger('mitx.' + __name__) def dummy_track(event_type, event): pass + +class ModuleMissingError(Exception): + pass + + +class Plugin(object): + @classmethod + def load_class(cls, identifier): + classes = list(pkg_resources.iter_entry_points(cls.entry_point, name=identifier)) + if len(classes) > 1: + log.warning("Found multiple classes for {entry_point} with identifier {id}: {classes}. Returning the first one.".format( + entry_point=cls.entry_point, + id=identifier, + classes=", ".join([class_.module_name for class_ in classes]))) + + if len(classes) == 0: + raise ModuleMissingError(identifier) + + return classes[0].load() + + class XModule(object): ''' Implements a generic learning module. Initialized on access with __init__, first time with state=None, and @@ -24,8 +50,8 @@ class XModule(object): or a CAPA input type ''' return ['xmodule'] - def get_name(): - name = self.__xmltree.get(name) + def get_name(self): + name = self.__xmltree.get('name') if name: return name else: @@ -98,15 +124,42 @@ class XModule(object): return "" -class XModuleDescriptor(object): - def __init__(self, xml = None, json = None): - if not xml and not json: - raise "XModuleDescriptor must be initalized with XML or JSON" - if not xml: - raise NotImplementedError("Code does not have support for JSON yet") - - self.xml = xml - self.json = json +class XModuleDescriptor(Plugin): + + entry_point = "xmodule.v1" + + @staticmethod + def load_from_json(json_data, load_item): + class_ = XModuleDescriptor.load_class(json_data['location']['category']) + return class_.from_json(json_data, load_item) + + @classmethod + def from_json(cls, json_data, load_item): + """ + Creates an instance of this descriptor from the supplied json_data. + + json_data: Json data specifying the data, children, and metadata for the descriptor + load_item: A function that takes an i4x url and returns a module descriptor + """ + return cls(load_item=load_item, **json_data) + + def __init__(self, + load_item, + data=None, + children=None, + **kwargs): + self.load_item = load_item + self.data = data if data is not None else {} + self.children = children if children is not None else [] + self.name = Location(kwargs.get('location')).name + self._child_instances = None + + def get_children(self): + """Returns a list of XModuleDescriptor instances for the children of this module""" + if self._child_instances is None: + self._child_instances = [self.load_item(child) for child in self.children] + return self._child_instances + def get_xml(self): ''' For conversions between JSON and legacy XML representations. diff --git a/requirements.txt b/requirements.txt index 5e95e1bf9e..85cc16b828 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,3 +24,4 @@ sympy newrelic glob2 pymongo +-e common/lib/xmodule From e67dfb70e4d54da8e078dee94c37fd34a5d9d39c Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 11:09:11 -0400 Subject: [PATCH 71/80] Add categories and XModuleDescriptors for all module types that are used at the top level of a course --- .../management/commands/import.py | 27 +++++++++++++------ cms/templates/widgets/navigation.html | 25 ++++++----------- common/lib/xmodule/seq_module.py | 19 ++++++++++--- common/lib/xmodule/setup.py | 11 ++++++-- common/lib/xmodule/video_module.py | 4 +++ common/lib/xmodule/x_module.py | 9 +++++-- 6 files changed, 63 insertions(+), 32 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/import.py b/cms/djangoapps/contentstore/management/commands/import.py index 3e0ccdd5e8..8b33f32b94 100644 --- a/cms/djangoapps/contentstore/management/commands/import.py +++ b/cms/djangoapps/contentstore/management/commands/import.py @@ -32,7 +32,7 @@ class Command(BaseCommand): elements = list(course.iter()) - tag_to_category = {# Inside HTML ==> Skip these + tag_to_category = { # Custom tags 'videodev': 'Custom', 'slides': 'Custom', @@ -40,33 +40,44 @@ class Command(BaseCommand): 'image': 'Custom', 'discuss': 'Custom', # Simple lists - 'chapter': 'Chapter', + 'chapter': 'Week', 'course': 'Course', 'sequential': 'LectureSequence', 'vertical': 'ProblemSet', - 'section': 'Section', + 'section': { + 'Lab': 'Lab', + 'Lecture Sequence': 'LectureSequence', + 'Homework': 'Homework', + 'Tutorial Index': 'TutorialIndex', + 'Video': 'VideoSegment', + 'Midterm': 'Exam', + 'Final': 'Exam', + None: 'Section', + }, # True types 'video': 'VideoSegment', 'html': 'HTML', 'problem': 'Problem', } - - name_index=0 + name_index = 0 for e in elements: name = e.attrib.get('name', None) for f in elements: if f != e and f.attrib.get('name', None) == name: name = None if not name: - name = "{tag}_{index}".format(tag = e.tag,index = name_index) + name = "{tag}_{index}".format(tag=e.tag, index=name_index) name_index = name_index + 1 if e.tag in tag_to_category: category = tag_to_category[e.tag] + if isinstance(category, dict): + category = category[e.get('format')] category = category.replace('/', '-') name = name.replace('/', '-') - e.set('url', 'i4x://mit.edu/6002xs12/{category}/{name}'.format(category = category, - name = name)) + e.set('url', 'i4x://mit.edu/6002xs12/{category}/{name}'.format( + category=category, + name=name)) def handle_skip(e): diff --git a/cms/templates/widgets/navigation.html b/cms/templates/widgets/navigation.html index 75d581dd73..1f75dab470 100644 --- a/cms/templates/widgets/navigation.html +++ b/cms/templates/widgets/navigation.html @@ -40,28 +40,19 @@

      ${week.name}

        -
      • Goal title: This is a goal that will be in the header of the week
      • -
      • Goal title two: This is another goal for this week so that students have two things to learn
      • + % for goal in week.get_goals(): +
      • ${goal.name}:${goal.data}
      • + % endfor
    16. diff --git a/common/lib/xmodule/seq_module.py b/common/lib/xmodule/seq_module.py index 4ae4fb3813..91ff6d2671 100644 --- a/common/lib/xmodule/seq_module.py +++ b/common/lib/xmodule/seq_module.py @@ -97,9 +97,22 @@ class Module(XModule): self.rendered = False -class CourseModuleDescriptor(XModuleDescriptor): - pass +class WeekDescriptor(XModuleDescriptor): + + def get_goals(self): + """ + Return a list of Goal XModuleDescriptors that are children + of this Week + """ + return [child for child in self.get_children() if child.type == 'Goal'] + + def get_non_goals(self): + """ + Return a list of non-Goal XModuleDescriptors that are children of + this Week + """ + return [child for child in self.get_children() if child.type != 'Goal'] -class ChapterModuleDescriptor(XModuleDescriptor): +class SectionDescriptor(XModuleDescriptor): pass diff --git a/common/lib/xmodule/setup.py b/common/lib/xmodule/setup.py index 6a659b6852..1140037259 100644 --- a/common/lib/xmodule/setup.py +++ b/common/lib/xmodule/setup.py @@ -7,8 +7,15 @@ setup( install_requires=['distribute'], entry_points={ 'xmodule.v1': [ - "Course = seq_module:CourseModuleDescriptor", - "Chapter = seq_module:ChapterModuleDescriptor", + "Course = seq_module:SectionDescriptor", + "Week = seq_module:WeekDescriptor", + "Section = seq_module:SectionDescriptor", + "LectureSequence = seq_module:SectionDescriptor", + "Lab = seq_module:SectionDescriptor", + "Homework = seq_module:SectionDescriptor", + "TutorialIndex = seq_module:SectionDescriptor", + "Exam = seq_module:SectionDescriptor", + "VideoSegment = video_module:VideoSegmentDescriptor", ] } ) diff --git a/common/lib/xmodule/video_module.py b/common/lib/xmodule/video_module.py index 8f8a2c2ffd..d7c7f80291 100644 --- a/common/lib/xmodule/video_module.py +++ b/common/lib/xmodule/video_module.py @@ -57,3 +57,7 @@ class Module(XModule): self.annotations=[(e.get("name"),self.render_function(e)) \ for e in xmltree] + + +class VideoSegmentDescriptor(XModuleDescriptor): + pass diff --git a/common/lib/xmodule/x_module.py b/common/lib/xmodule/x_module.py index 23025df50b..3560eecbdc 100644 --- a/common/lib/xmodule/x_module.py +++ b/common/lib/xmodule/x_module.py @@ -152,13 +152,18 @@ class XModuleDescriptor(Plugin): self.data = data if data is not None else {} self.children = children if children is not None else [] self.name = Location(kwargs.get('location')).name + self.type = Location(kwargs.get('location')).category self._child_instances = None - def get_children(self): + def get_children(self, categories=None): """Returns a list of XModuleDescriptor instances for the children of this module""" if self._child_instances is None: self._child_instances = [self.load_item(child) for child in self.children] - return self._child_instances + + if categories is None: + return self._child_instances + else: + return [child for child in self._child_instances if child.type in categories] def get_xml(self): From 96cbb3d33b146ae5be7d13a63a0a50ba96b942aa Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Mon, 18 Jun 2012 12:04:10 -0400 Subject: [PATCH 72/80] Small cleanups in response to Calen + Piotr's comments --- lms/djangoapps/courseware/module_render.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 7c4de7d499..87892e8fec 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -29,6 +29,9 @@ class I4xSystem(object): I4xSystem objects are passed to x_modules to provide access to system functionality. + + Note that these functions can be closures over e.g. a django request + and user, or other environment-specific info. ''' def __init__(self, ajax_url, track_function, render_function, render_template, filestore=None): @@ -91,12 +94,9 @@ def smod_cache_lookup(cache, module_type, module_id): return None def make_track_function(request): - ''' We want the capa problem (and other modules) to be able to - track/log what happens inside them without adding dependencies on - Django or the rest of the codebase. - - To do this in a clean way, we pass a tracking function to the module, - which calls it to log events. + ''' + Make a tracking function that logs what happened. + For use in I4xSystem. ''' import track.views @@ -162,11 +162,11 @@ def get_module(user, request, module_xml, student_module_cache, position=None): # Setup system context for module instance ajax_url = settings.MITX_ROOT_URL + '/modx/' + module_type + '/' + module_id + '/' - def render_function(module_xml): + def render_x_module_wrapper(module_xml): return render_x_module(user, request, module_xml, student_module_cache, position) system = I4xSystem(track_function = make_track_function(request), - render_function = render_function, + render_function = render_x_module_wrapper, render_template = render_to_string, ajax_url = ajax_url, filestore = OSFS(data_root), @@ -251,7 +251,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): return redirect('/') # python concats adjacent strings - error_msg = ("We're sorry, this module is temporarily unavailable." + error_msg = ("We're sorry, this module is temporarily unavailable. " "Our staff is working to fix it as soon as possible") @@ -259,7 +259,6 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): s = StudentModule.objects.filter(student=request.user, module_id=id) - # s = StudentModule.get_with_caching(request.user, id) if s is None or len(s) == 0: log.debug("Couldn't find module '%s' for user '%s' and id '%s'", module, request.user, id) @@ -270,8 +269,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): oldstate = s.state # If there are arguments, get rid of them - if '?' in dispatch: - dispatch = dispatch.split('?')[0] + dispatch, _, _ = dispatch.partition('?') ajax_url = '{root}/modx/{module}/{id}'.format(root = settings.MITX_ROOT_URL, module=module, id=id) From f391e9c51c58ff8cd595099673647c321e4d76cd Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Mon, 14 May 2012 18:43:21 -0400 Subject: [PATCH 73/80] Courseware can have same random seed in multiple problems for exam. Slight hack. --- common/lib/xmodule/capa_module.py | 2 ++ lms/djangoapps/courseware/module_render.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/capa_module.py b/common/lib/xmodule/capa_module.py index c7b52ae8ba..55534f8a3e 100644 --- a/common/lib/xmodule/capa_module.py +++ b/common/lib/xmodule/capa_module.py @@ -222,6 +222,8 @@ class Module(XModule): self.weight=only_one(dom2.xpath('/problem/@weight')) if self.rerandomize == 'never': seed = 1 + elif self.rerandomize == "per_student" and hasattr(system, 'id'): + seed = system.id else: seed = None try: diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 7c4de7d499..3b42ac51e7 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -31,7 +31,7 @@ class I4xSystem(object): functionality. ''' def __init__(self, ajax_url, track_function, render_function, - render_template, filestore=None): + render_template, request=None, filestore=None): ''' Create a closure around the system environment. @@ -46,6 +46,7 @@ class I4xSystem(object): and 'type'. render_template - a function that takes (template_file, context), and returns rendered html. + request - the request in progress filestore - A filestore ojbect. Defaults to an instance of OSFS based at settings.DATA_DIR. ''' @@ -62,6 +63,7 @@ class I4xSystem(object): self.render_template = render_template self.exception404 = Http404 self.DEBUG = settings.DEBUG + self.id = request.user.id if request is not None else 0 def get(self, attr): ''' provide uniform access to attributes (like etree).''' @@ -169,6 +171,7 @@ def get_module(user, request, module_xml, student_module_cache, position=None): render_function = render_function, render_template = render_to_string, ajax_url = ajax_url, + request = request, filestore = OSFS(data_root), ) # pass position specified in URL to module through I4xSystem @@ -300,6 +303,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): render_function = None, render_template = render_to_string, ajax_url = ajax_url, + request = request, filestore = OSFS(data_root), ) From 328b2df7c5571f5e38e53e96a413c6964f0fa8ce Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 12:21:12 -0400 Subject: [PATCH 74/80] Ignore .egg-info directories --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ebf06998b1..ef28575da5 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ log/ reports/ /src/ \#*\# +*.egg-info From 7e73f0ede09debeebba547f8e15ec43ecab11463 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Mon, 18 Jun 2012 13:12:47 -0400 Subject: [PATCH 75/80] put lambda function back in, as requested during code review --- lms/djangoapps/courseware/module_render.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 87892e8fec..214d53bbb4 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -162,11 +162,10 @@ def get_module(user, request, module_xml, student_module_cache, position=None): # Setup system context for module instance ajax_url = settings.MITX_ROOT_URL + '/modx/' + module_type + '/' + module_id + '/' - def render_x_module_wrapper(module_xml): - return render_x_module(user, request, module_xml, student_module_cache, position) - + system = I4xSystem(track_function = make_track_function(request), - render_function = render_x_module_wrapper, + render_function = lambda xml: render_x_module( + user, request, xml, student_module_cache, position), render_template = render_to_string, ajax_url = ajax_url, filestore = OSFS(data_root), From 5404345b1ff38d7ecd21432835dd739a63ee3a79 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 13:21:06 -0400 Subject: [PATCH 76/80] Make tests pass when running on cms --- .../management/commands/ftpserve.py | 61 ------------------- cms/envs/dev.py | 2 +- cms/envs/test.py | 54 ++++++++++++++++ .../{lib => djangoapps}/cache_toolbox/COPYING | 0 .../cache_toolbox/README.rst | 0 .../cache_toolbox/__init__.py | 0 .../cache_toolbox/app_settings.py | 0 .../{lib => djangoapps}/cache_toolbox/core.py | 0 .../cache_toolbox/middleware.py | 0 .../cache_toolbox/model.py | 0 .../cache_toolbox/relation.py | 0 .../cache_toolbox/templatetags/__init__.py | 0 .../templatetags/cache_toolbox.py | 0 common/{lib => djangoapps}/util/__init__.py | 0 common/{lib => djangoapps}/util/cache.py | 0 common/{lib => djangoapps}/util/memcache.py | 0 common/{lib => djangoapps}/util/middleware.py | 0 common/{lib => djangoapps}/util/models.py | 0 common/{lib => djangoapps}/util/tests.py | 0 common/{lib => djangoapps}/util/views.py | 0 {cms => common}/lib/keystore/__init__.py | 0 {cms => common}/lib/keystore/django.py | 0 {cms => common}/lib/keystore/exceptions.py | 0 {cms => common}/lib/keystore/mongo.py | 0 lms/envs/dev.py | 2 +- rakefile | 2 +- 26 files changed, 57 insertions(+), 64 deletions(-) delete mode 100644 cms/djangoapps/contentstore/management/commands/ftpserve.py create mode 100644 cms/envs/test.py rename common/{lib => djangoapps}/cache_toolbox/COPYING (100%) rename common/{lib => djangoapps}/cache_toolbox/README.rst (100%) rename common/{lib => djangoapps}/cache_toolbox/__init__.py (100%) rename common/{lib => djangoapps}/cache_toolbox/app_settings.py (100%) rename common/{lib => djangoapps}/cache_toolbox/core.py (100%) rename common/{lib => djangoapps}/cache_toolbox/middleware.py (100%) rename common/{lib => djangoapps}/cache_toolbox/model.py (100%) rename common/{lib => djangoapps}/cache_toolbox/relation.py (100%) rename common/{lib => djangoapps}/cache_toolbox/templatetags/__init__.py (100%) rename common/{lib => djangoapps}/cache_toolbox/templatetags/cache_toolbox.py (100%) rename common/{lib => djangoapps}/util/__init__.py (100%) rename common/{lib => djangoapps}/util/cache.py (100%) rename common/{lib => djangoapps}/util/memcache.py (100%) rename common/{lib => djangoapps}/util/middleware.py (100%) rename common/{lib => djangoapps}/util/models.py (100%) rename common/{lib => djangoapps}/util/tests.py (100%) rename common/{lib => djangoapps}/util/views.py (100%) rename {cms => common}/lib/keystore/__init__.py (100%) rename {cms => common}/lib/keystore/django.py (100%) rename {cms => common}/lib/keystore/exceptions.py (100%) rename {cms => common}/lib/keystore/mongo.py (100%) diff --git a/cms/djangoapps/contentstore/management/commands/ftpserve.py b/cms/djangoapps/contentstore/management/commands/ftpserve.py deleted file mode 100644 index f0a1c19dbf..0000000000 --- a/cms/djangoapps/contentstore/management/commands/ftpserve.py +++ /dev/null @@ -1,61 +0,0 @@ -from django.core.management.base import BaseCommand -from django.contrib.auth.models import User -import contentstore.tasks - -from pyftpdlib import ftpserver -import os - -class DjangoAuthorizer(object): - def validate_authentication(self, username, password): - try: - u=User.objects.get(username=username) - except User.DoesNotExist: - return False - # TODO: Check security groups - return u.check_password(password) - def has_user(self, username): - print "????",username - return True - def has_perm(self, username, perm, path=None): - print "!!!!!",username, perm, path - return True - def get_home_dir(self, username): - d = "/tmp/ftp/"+username - try: - os.mkdir(d) - except OSError: - pass - return "/tmp/ftp/"+username - def get_perms(self, username): - return 'elradfmw' - def get_msg_login(self, username): - return 'Hello' - def get_msg_quit(self, username): - return 'Goodbye' - def __init__(self): - pass - def impersonate_user(self, username, password): - pass - def terminate_impersonation(self, username): - pass - -def on_upload(ftp_handler, filename): - source = ftp_handler.remote_ip - author = ftp_handler.username - print filename, author, source - # We pass on this for now: - # contentstore.tasks.on_upload - # It is a changing API, and it makes testing the FTP server slow. - -class Command(BaseCommand): - help = \ -''' Run FTP server.''' - def handle(self, *args, **options): - authorizer = DjangoAuthorizer() #ftpserver.DummyAuthorizer() - handler = ftpserver.FTPHandler - handler.on_file_received = on_upload - - handler.authorizer = authorizer - address = ("127.0.0.1", 2121) - ftpd = ftpserver.FTPServer(address, handler) - ftpd.serve_forever() diff --git a/cms/envs/dev.py b/cms/envs/dev.py index f7277b3d3f..332f52f145 100644 --- a/cms/envs/dev.py +++ b/cms/envs/dev.py @@ -38,6 +38,6 @@ CACHES = { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', 'KEY_PREFIX': 'general', 'VERSION': 4, - 'KEY_FUNCTION': 'util.cache.memcache_safe_key', + 'KEY_FUNCTION': 'util.memcache.safe_key', } } diff --git a/cms/envs/test.py b/cms/envs/test.py new file mode 100644 index 0000000000..1a20d9e6f8 --- /dev/null +++ b/cms/envs/test.py @@ -0,0 +1,54 @@ +""" +This config file runs the simplest dev environment using sqlite, and db-based +sessions. Assumes structure: + +/envroot/ + /db # This is where it'll write the database file + /mitx # The location of this repo + /log # Where we're going to write log files +""" +from .common import * +import os + +# Nose Test Runner +INSTALLED_APPS += ('django_nose',) +NOSE_ARGS = ['--cover-erase', '--with-xunit', '--with-xcoverage', '--cover-html', '--cover-inclusive'] +for app in os.listdir(PROJECT_ROOT / 'djangoapps'): + NOSE_ARGS += ['--cover-package', app] +TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' + +KEYSTORE = { + 'host': 'localhost', + 'db': 'mongo_base', + 'collection': 'key_store', +} + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': ENV_ROOT / "db" / "mitx.db", + } +} + +CACHES = { + # This is the cache used for most things. Askbot will not work without a + # functioning cache -- it relies on caching to load its settings in places. + # In staging/prod envs, the sessions also live here. + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'mitx_loc_mem_cache', + 'KEY_FUNCTION': 'util.memcache.safe_key', + }, + + # The general cache is what you get if you use our util.cache. It's used for + # things like caching the course.xml file for different A/B test groups. + # We set it to be a DummyCache to force reloading of course.xml in dev. + # In staging environments, we would grab VERSION from data uploaded by the + # push process. + 'general': { + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', + 'KEY_PREFIX': 'general', + 'VERSION': 4, + 'KEY_FUNCTION': 'util.memcache.safe_key', + } +} diff --git a/common/lib/cache_toolbox/COPYING b/common/djangoapps/cache_toolbox/COPYING similarity index 100% rename from common/lib/cache_toolbox/COPYING rename to common/djangoapps/cache_toolbox/COPYING diff --git a/common/lib/cache_toolbox/README.rst b/common/djangoapps/cache_toolbox/README.rst similarity index 100% rename from common/lib/cache_toolbox/README.rst rename to common/djangoapps/cache_toolbox/README.rst diff --git a/common/lib/cache_toolbox/__init__.py b/common/djangoapps/cache_toolbox/__init__.py similarity index 100% rename from common/lib/cache_toolbox/__init__.py rename to common/djangoapps/cache_toolbox/__init__.py diff --git a/common/lib/cache_toolbox/app_settings.py b/common/djangoapps/cache_toolbox/app_settings.py similarity index 100% rename from common/lib/cache_toolbox/app_settings.py rename to common/djangoapps/cache_toolbox/app_settings.py diff --git a/common/lib/cache_toolbox/core.py b/common/djangoapps/cache_toolbox/core.py similarity index 100% rename from common/lib/cache_toolbox/core.py rename to common/djangoapps/cache_toolbox/core.py diff --git a/common/lib/cache_toolbox/middleware.py b/common/djangoapps/cache_toolbox/middleware.py similarity index 100% rename from common/lib/cache_toolbox/middleware.py rename to common/djangoapps/cache_toolbox/middleware.py diff --git a/common/lib/cache_toolbox/model.py b/common/djangoapps/cache_toolbox/model.py similarity index 100% rename from common/lib/cache_toolbox/model.py rename to common/djangoapps/cache_toolbox/model.py diff --git a/common/lib/cache_toolbox/relation.py b/common/djangoapps/cache_toolbox/relation.py similarity index 100% rename from common/lib/cache_toolbox/relation.py rename to common/djangoapps/cache_toolbox/relation.py diff --git a/common/lib/cache_toolbox/templatetags/__init__.py b/common/djangoapps/cache_toolbox/templatetags/__init__.py similarity index 100% rename from common/lib/cache_toolbox/templatetags/__init__.py rename to common/djangoapps/cache_toolbox/templatetags/__init__.py diff --git a/common/lib/cache_toolbox/templatetags/cache_toolbox.py b/common/djangoapps/cache_toolbox/templatetags/cache_toolbox.py similarity index 100% rename from common/lib/cache_toolbox/templatetags/cache_toolbox.py rename to common/djangoapps/cache_toolbox/templatetags/cache_toolbox.py diff --git a/common/lib/util/__init__.py b/common/djangoapps/util/__init__.py similarity index 100% rename from common/lib/util/__init__.py rename to common/djangoapps/util/__init__.py diff --git a/common/lib/util/cache.py b/common/djangoapps/util/cache.py similarity index 100% rename from common/lib/util/cache.py rename to common/djangoapps/util/cache.py diff --git a/common/lib/util/memcache.py b/common/djangoapps/util/memcache.py similarity index 100% rename from common/lib/util/memcache.py rename to common/djangoapps/util/memcache.py diff --git a/common/lib/util/middleware.py b/common/djangoapps/util/middleware.py similarity index 100% rename from common/lib/util/middleware.py rename to common/djangoapps/util/middleware.py diff --git a/common/lib/util/models.py b/common/djangoapps/util/models.py similarity index 100% rename from common/lib/util/models.py rename to common/djangoapps/util/models.py diff --git a/common/lib/util/tests.py b/common/djangoapps/util/tests.py similarity index 100% rename from common/lib/util/tests.py rename to common/djangoapps/util/tests.py diff --git a/common/lib/util/views.py b/common/djangoapps/util/views.py similarity index 100% rename from common/lib/util/views.py rename to common/djangoapps/util/views.py diff --git a/cms/lib/keystore/__init__.py b/common/lib/keystore/__init__.py similarity index 100% rename from cms/lib/keystore/__init__.py rename to common/lib/keystore/__init__.py diff --git a/cms/lib/keystore/django.py b/common/lib/keystore/django.py similarity index 100% rename from cms/lib/keystore/django.py rename to common/lib/keystore/django.py diff --git a/cms/lib/keystore/exceptions.py b/common/lib/keystore/exceptions.py similarity index 100% rename from cms/lib/keystore/exceptions.py rename to common/lib/keystore/exceptions.py diff --git a/cms/lib/keystore/mongo.py b/common/lib/keystore/mongo.py similarity index 100% rename from cms/lib/keystore/mongo.py rename to common/lib/keystore/mongo.py diff --git a/lms/envs/dev.py b/lms/envs/dev.py index 17e1e96f45..decd92d136 100644 --- a/lms/envs/dev.py +++ b/lms/envs/dev.py @@ -44,7 +44,7 @@ CACHES = { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', 'KEY_PREFIX': 'general', 'VERSION': 4, - 'KEY_FUNCTION': 'util.cache.memcache_safe_key', + 'KEY_FUNCTION': 'util.memcache.safe_key', } } diff --git a/rakefile b/rakefile index 6bd582783e..43f5697bb8 100644 --- a/rakefile +++ b/rakefile @@ -66,7 +66,7 @@ end desc "Run all django tests on our djangoapps for the #{system}" task task_name => report_dir do ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml") - sh(django_admin(:lms, :test, 'test', *Dir['lms/djangoapps'].each)) + sh(django_admin(system, :test, 'test', *Dir["#{system}/djangoapps/*"].each)) end task :test => task_name From 79e81d69b4be8c6d082aa25626f6f442df830ddb Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 13:41:53 -0400 Subject: [PATCH 77/80] Delay initializition of the MongoKeyStore until required --- .../contentstore/management/commands/import.py | 7 +++---- cms/djangoapps/contentstore/views.py | 2 +- common/lib/keystore/django.py | 11 ++++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/import.py b/cms/djangoapps/contentstore/management/commands/import.py index 8b33f32b94..d6064e1e3d 100644 --- a/cms/djangoapps/contentstore/management/commands/import.py +++ b/cms/djangoapps/contentstore/management/commands/import.py @@ -160,9 +160,8 @@ class Command(BaseCommand): element_actions[e.tag](e) for k in results: - print k - keystore.create_item(k, 'Piotr Mitros') + keystore().create_item(k, 'Piotr Mitros') if 'data' in results[k]: - keystore.update_item(k, results[k]['data']) + keystore().update_item(k, results[k]['data']) if 'children' in results[k]: - keystore.update_children(k, results[k]['children']) + keystore().update_children(k, results[k]['children']) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 64bde14869..e29c41ea59 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -7,6 +7,6 @@ def index(request): # FIXME (cpennington): These need to be read in from the active user org = 'mit.edu' course = '6002xs12' - course = keystore.get_item(['i4x', org, course, 'Course', None]) + course = keystore().get_item(['i4x', org, course, 'Course', None]) weeks = course.get_children() return render_to_response('index.html', {'weeks': weeks}) diff --git a/common/lib/keystore/django.py b/common/lib/keystore/django.py index b6ffb83b5c..b88c74b8a3 100644 --- a/common/lib/keystore/django.py +++ b/common/lib/keystore/django.py @@ -9,4 +9,13 @@ from __future__ import absolute_import from django.conf import settings from .mongo import MongoKeyStore -keystore = MongoKeyStore(**settings.KEYSTORE) +_KEYSTORE = None + + +def keystore(): + global _KEYSTORE + + if _KEYSTORE is None: + _KEYSTORE = MongoKeyStore(**settings.KEYSTORE) + + return _KEYSTORE From f8434b3a6d7d29372aaddab8c62cadf3ca1fb027 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 13:48:26 -0400 Subject: [PATCH 78/80] Move libraries that can only be imported in the context of django into common/djangoapps --- common/{lib => djangoapps}/django_future/__init__.py | 0 common/{lib => djangoapps}/django_future/csrf.py | 0 common/{lib => djangoapps}/monitoring/__init__.py | 0 common/{lib => djangoapps}/monitoring/exceptions.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename common/{lib => djangoapps}/django_future/__init__.py (100%) rename common/{lib => djangoapps}/django_future/csrf.py (100%) rename common/{lib => djangoapps}/monitoring/__init__.py (100%) rename common/{lib => djangoapps}/monitoring/exceptions.py (100%) diff --git a/common/lib/django_future/__init__.py b/common/djangoapps/django_future/__init__.py similarity index 100% rename from common/lib/django_future/__init__.py rename to common/djangoapps/django_future/__init__.py diff --git a/common/lib/django_future/csrf.py b/common/djangoapps/django_future/csrf.py similarity index 100% rename from common/lib/django_future/csrf.py rename to common/djangoapps/django_future/csrf.py diff --git a/common/lib/monitoring/__init__.py b/common/djangoapps/monitoring/__init__.py similarity index 100% rename from common/lib/monitoring/__init__.py rename to common/djangoapps/monitoring/__init__.py diff --git a/common/lib/monitoring/exceptions.py b/common/djangoapps/monitoring/exceptions.py similarity index 100% rename from common/lib/monitoring/exceptions.py rename to common/djangoapps/monitoring/exceptions.py From 9ff0effd718664b0ccd29d92cb389825776470e9 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 14:08:15 -0400 Subject: [PATCH 79/80] Remove copy/paste instructor module. It was a bad idea anyway. =) --- cms/djangoapps/instructor/__init__.py | 0 cms/djangoapps/instructor/models.py | 61 --------------------------- cms/djangoapps/instructor/tests.py | 16 ------- cms/djangoapps/instructor/views.py | 49 --------------------- 4 files changed, 126 deletions(-) delete mode 100644 cms/djangoapps/instructor/__init__.py delete mode 100644 cms/djangoapps/instructor/models.py delete mode 100644 cms/djangoapps/instructor/tests.py delete mode 100644 cms/djangoapps/instructor/views.py diff --git a/cms/djangoapps/instructor/__init__.py b/cms/djangoapps/instructor/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cms/djangoapps/instructor/models.py b/cms/djangoapps/instructor/models.py deleted file mode 100644 index 906aeee2f1..0000000000 --- a/cms/djangoapps/instructor/models.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -WE'RE USING MIGRATIONS! - -If you make changes to this model, be sure to create an appropriate migration -file and check it in at the same time as your model changes. To do that, - -1. Go to the mitx dir -2. ./manage.py schemamigration user --auto description_of_your_change -3. Add the migration file created in mitx/courseware/migrations/ -""" -import uuid - -from django.db import models -from django.contrib.auth.models import User - - -class UserProfile(models.Model): - class Meta: - db_table = "auth_userprofile" - - ## CRITICAL TODO/SECURITY - # Sanitize all fields. - # This is not visible to other users, but could introduce holes later - user = models.OneToOneField(User, unique=True, db_index=True, related_name='profile') - name = models.CharField(blank=True, max_length=255, db_index=True) - org = models.CharField(blank=True, max_length=255, db_index=True) - - -class Registration(models.Model): - ''' Allows us to wait for e-mail before user is registered. A - registration profile is created when the user creates an - account, but that account is inactive. Once the user clicks - on the activation key, it becomes active. ''' - class Meta: - db_table = "auth_registration" - - user = models.ForeignKey(User, unique=True) - activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) - - def register(self, user): - # MINOR TODO: Switch to crypto-secure key - self.activation_key = uuid.uuid4().hex - self.user = user - self.save() - - def activate(self): - self.user.is_active = True - self.user.save() - #self.delete() - - -class PendingNameChange(models.Model): - user = models.OneToOneField(User, unique=True, db_index=True) - new_name = models.CharField(blank=True, max_length=255) - rationale = models.CharField(blank=True, max_length=1024) - - -class PendingEmailChange(models.Model): - user = models.OneToOneField(User, unique=True, db_index=True) - new_email = models.CharField(blank=True, max_length=255, db_index=True) - activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) diff --git a/cms/djangoapps/instructor/tests.py b/cms/djangoapps/instructor/tests.py deleted file mode 100644 index 501deb776c..0000000000 --- a/cms/djangoapps/instructor/tests.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". - -Replace this with more appropriate tests for your application. -""" - -from django.test import TestCase - - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.assertEqual(1 + 1, 2) diff --git a/cms/djangoapps/instructor/views.py b/cms/djangoapps/instructor/views.py deleted file mode 100644 index fbb341b468..0000000000 --- a/cms/djangoapps/instructor/views.py +++ /dev/null @@ -1,49 +0,0 @@ -import logging - -from django.views.decorators.http import require_http_methods, require_POST, require_GET -from django.contrib.auth import logout, authenticate, login -from django.shortcuts import redirect -from mitxmako.shortcuts import render_to_response - -from django_future.csrf import ensure_csrf_cookie - -log = logging.getLogger("mitx.student") - - -@require_http_methods(['GET', 'POST']) -def do_login(request): - if request.method == 'POST': - return post_login(request) - elif request.method == 'GET': - return get_login(request) - - -@require_POST -@ensure_csrf_cookie -def post_login(request): - username = request.POST['username'] - password = request.POST['password'] - user = authenticate(username=username, password=password) - if user is not None: - if user.is_active: - login(request, user) - return redirect(request.POST.get('next', '/')) - else: - raise Exception("Can't log in, account disabled") - else: - raise Exception("Can't log in, invalid authentication") - - -@require_GET -@ensure_csrf_cookie -def get_login(request): - return render_to_response('login.html', { - 'next': request.GET.get('next') - }) - - -@ensure_csrf_cookie -def logout_user(request): - ''' HTTP request to log in the user. Redirects to marketing page''' - logout(request) - return redirect('/') From 605b1ae0fd16bc3fec0fd4becb321f79f7644dab Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 18 Jun 2012 14:24:45 -0400 Subject: [PATCH 80/80] Remove old template that is no longer relevant --- cms/templates/calendar.html | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 cms/templates/calendar.html diff --git a/cms/templates/calendar.html b/cms/templates/calendar.html deleted file mode 100644 index 05b2f88806..0000000000 --- a/cms/templates/calendar.html +++ /dev/null @@ -1,3 +0,0 @@ -% for week in weeks: -${week} -% endfor