Commit 59defd33 by Victor Shnayder

Formatting and little bugfixes

* add course and org to full/course.xml
* fix error path in clean_xml script
* commit rakefile change needed by c5334f150c
parent cb308507
...@@ -530,11 +530,13 @@ class CapaModule(XModule): ...@@ -530,11 +530,13 @@ class CapaModule(XModule):
self.lcp.do_reset() self.lcp.do_reset()
if self.rerandomize == "always": if self.rerandomize == "always":
# reset random number generator seed (note the self.lcp.get_state() in next line) # reset random number generator seed (note the self.lcp.get_state()
# in next line)
self.lcp.seed = None self.lcp.seed = None
self.lcp = LoncapaProblem(self.definition['data'], self.lcp = LoncapaProblem(self.definition['data'],
self.location.html_id(), self.lcp.get_state(), system=self.system) self.location.html_id(), self.lcp.get_state(),
system=self.system)
event_info['new_state'] = self.lcp.get_state() event_info['new_state'] = self.lcp.get_state()
self.system.track_function('reset_problem', event_info) self.system.track_function('reset_problem', event_info)
......
...@@ -74,7 +74,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): ...@@ -74,7 +74,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem):
etree.tostring(xml_data), self, org, etree.tostring(xml_data), self, org,
course, xmlstore.default_class) course, xmlstore.default_class)
log.debug('==> importing module location %s' % repr(module.location)) #log.debug('==> importing module location %s' % repr(module.location))
module.metadata['data_dir'] = course_dir module.metadata['data_dir'] = course_dir
xmlstore.modules[module.location] = module xmlstore.modules[module.location] = module
...@@ -130,13 +130,14 @@ class XMLModuleStore(ModuleStore): ...@@ -130,13 +130,14 @@ class XMLModuleStore(ModuleStore):
self.default_class = None self.default_class = None
else: else:
module_path, _, class_name = default_class.rpartition('.') module_path, _, class_name = default_class.rpartition('.')
log.debug('module_path = %s' % module_path) #log.debug('module_path = %s' % module_path)
class_ = getattr(import_module(module_path), class_name) class_ = getattr(import_module(module_path), class_name)
self.default_class = class_ self.default_class = class_
# TODO (cpennington): We need a better way of selecting specific sets of debug messages to enable. These were drowning out important messages # TODO (cpennington): We need a better way of selecting specific sets of
log.debug('XMLModuleStore: eager=%s, data_dir = %s' % (eager, self.data_dir)) # debug messages to enable. These were drowning out important messages
log.debug('default_class = %s' % self.default_class) #log.debug('XMLModuleStore: eager=%s, data_dir = %s' % (eager, self.data_dir))
#log.debug('default_class = %s' % self.default_class)
# If we are specifically asked for missing courses, that should # If we are specifically asked for missing courses, that should
# be an error. If we are asked for "all" courses, find the ones # be an error. If we are asked for "all" courses, find the ones
...@@ -162,6 +163,7 @@ class XMLModuleStore(ModuleStore): ...@@ -162,6 +163,7 @@ class XMLModuleStore(ModuleStore):
returns a CourseDescriptor for the course returns a CourseDescriptor for the course
""" """
log.debug('========> Starting course import from {0}'.format(course_dir))
with open(self.data_dir / course_dir / "course.xml") as course_file: with open(self.data_dir / course_dir / "course.xml") as course_file:
...@@ -192,7 +194,7 @@ class XMLModuleStore(ModuleStore): ...@@ -192,7 +194,7 @@ class XMLModuleStore(ModuleStore):
self.error_handler) self.error_handler)
course_descriptor = system.process_xml(etree.tostring(course_data)) course_descriptor = system.process_xml(etree.tostring(course_data))
log.debug('========> Done with course import') log.debug('========> Done with course import from {0}'.format(course_dir))
return course_descriptor return course_descriptor
def get_item(self, location, depth=0): def get_item(self, location, depth=0):
......
...@@ -60,7 +60,7 @@ class VideoModule(XModule): ...@@ -60,7 +60,7 @@ class VideoModule(XModule):
return None return None
def get_instance_state(self): def get_instance_state(self):
log.debug(u"STATE POSITION {0}".format(self.position)) #log.debug(u"STATE POSITION {0}".format(self.position))
return json.dumps({'position': self.position}) return json.dumps({'position': self.position})
def video_list(self): def video_list(self):
......
<course filename="6.002_Spring_2012" slug="6.002_Spring_2012" graceperiod="1 day 12 hours 59 minutes 59 seconds" showanswer="attempted" rerandomize="never" name="6.002 Spring 2012" start="2015-07-17T12:00" /> <course filename="6.002_Spring_2012" slug="6.002_Spring_2012" graceperiod="1 day 12 hours 59 minutes 59 seconds" showanswer="attempted" rerandomize="never" name="6.002 Spring 2012" start="2015-07-17T12:00" course="full" org="edx"/>
...@@ -104,7 +104,7 @@ def import_with_checks(course_dir, verbose=True): ...@@ -104,7 +104,7 @@ def import_with_checks(course_dir, verbose=True):
if n != 1: if n != 1:
print 'ERROR: Expect exactly 1 course. Loaded {n}: {lst}'.format( print 'ERROR: Expect exactly 1 course. Loaded {n}: {lst}'.format(
n=n, lst=courses) n=n, lst=courses)
return return (False, None)
course = courses[0] course = courses[0]
......
...@@ -119,16 +119,18 @@ def get_module(user, request, location, student_module_cache, position=None): ...@@ -119,16 +119,18 @@ def get_module(user, request, location, student_module_cache, position=None):
instance_module is a StudentModule specific to this module for this student, instance_module is a StudentModule specific to this module for this student,
or None if this is an anonymous user or None if this is an anonymous user
shared_module is a StudentModule specific to all modules with the same shared_module is a StudentModule specific to all modules with the same
'shared_state_key' attribute, or None if the module doesn't elect to 'shared_state_key' attribute, or None if the module does not elect to
share state share state
''' '''
descriptor = modulestore().get_item(location) descriptor = modulestore().get_item(location)
instance_module = student_module_cache.lookup(descriptor.category, descriptor.location.url()) instance_module = student_module_cache.lookup(descriptor.category,
descriptor.location.url())
shared_state_key = getattr(descriptor, 'shared_state_key', None) shared_state_key = getattr(descriptor, 'shared_state_key', None)
if shared_state_key is not None: if shared_state_key is not None:
shared_module = student_module_cache.lookup(descriptor.category, shared_state_key) shared_module = student_module_cache.lookup(descriptor.category,
shared_state_key)
else: else:
shared_module = None shared_module = None
...@@ -138,10 +140,12 @@ def get_module(user, request, location, student_module_cache, position=None): ...@@ -138,10 +140,12 @@ def get_module(user, request, location, student_module_cache, position=None):
# TODO (vshnayder): fix hardcoded urls (use reverse) # TODO (vshnayder): fix hardcoded urls (use reverse)
# Setup system context for module instance # Setup system context for module instance
ajax_url = settings.MITX_ROOT_URL + '/modx/' + descriptor.location.url() + '/' ajax_url = settings.MITX_ROOT_URL + '/modx/' + descriptor.location.url() + '/'
xqueue_callback_url = settings.MITX_ROOT_URL + '/xqueue/' + str(user.id) + '/' + descriptor.location.url() + '/' xqueue_callback_url = (settings.MITX_ROOT_URL + '/xqueue/' +
str(user.id) + '/' + descriptor.location.url() + '/')
def _get_module(location): def _get_module(location):
(module, _, _, _) = get_module(user, request, location, student_module_cache, position) (module, _, _, _) = get_module(user, request, location,
student_module_cache, position)
return module return module
# TODO (cpennington): When modules are shared between courses, the static # TODO (cpennington): When modules are shared between courses, the static
......
...@@ -6,16 +6,16 @@ MITX_FEATURES[...]. Modules that extend this one can change the feature ...@@ -6,16 +6,16 @@ MITX_FEATURES[...]. Modules that extend this one can change the feature
configuration in an environment specific config file and re-calculate those configuration in an environment specific config file and re-calculate those
values. values.
We should make a method that calls all these config methods so that you just 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 make one call at the end of your site-specific dev file to reset all the
dependent variables (like INSTALLED_APPS) for you. dependent variables (like INSTALLED_APPS) for you.
Longer TODO: Longer TODO:
1. Right now our treatment of static content in general and in particular 1. Right now our treatment of static content in general and in particular
course-specific static content is haphazard. course-specific static content is haphazard.
2. We should have a more disciplined approach to feature flagging, even if it 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. 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 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. multiple sites, but we do need a way to map their data assets.
""" """
import sys import sys
...@@ -42,7 +42,7 @@ MITX_FEATURES = { ...@@ -42,7 +42,7 @@ MITX_FEATURES = {
'SAMPLE' : False, 'SAMPLE' : False,
'USE_DJANGO_PIPELINE' : True, 'USE_DJANGO_PIPELINE' : True,
'DISPLAY_HISTOGRAMS_TO_STAFF' : True, 'DISPLAY_HISTOGRAMS_TO_STAFF' : True,
'REROUTE_ACTIVATION_EMAIL' : False, # nonempty string = address for all activation emails 'REROUTE_ACTIVATION_EMAIL' : False, # nonempty string = address for all activation emails
'DEBUG_LEVEL' : 0, # 0 = lowest level, least verbose, 255 = max level, most verbose 'DEBUG_LEVEL' : 0, # 0 = lowest level, least verbose, 255 = max level, most verbose
## DO NOT SET TO True IN THIS FILE ## DO NOT SET TO True IN THIS FILE
...@@ -85,7 +85,7 @@ MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates', ...@@ -85,7 +85,7 @@ MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates',
COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates', COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates'] COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates']
# This is where Django Template lookup is defined. There are a few of these # This is where Django Template lookup is defined. There are a few of these
# still left lying around. # still left lying around.
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
PROJECT_ROOT / "templates", PROJECT_ROOT / "templates",
...@@ -103,8 +103,8 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -103,8 +103,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
) )
# FIXME: # FIXME:
# We should have separate S3 staged URLs in case we need to make changes to # We should have separate S3 staged URLs in case we need to make changes to
# these assets and test them. # these assets and test them.
LIB_URL = '/static/js/' LIB_URL = '/static/js/'
...@@ -120,7 +120,7 @@ STATIC_GRAB = False ...@@ -120,7 +120,7 @@ STATIC_GRAB = False
DEV_CONTENT = True DEV_CONTENT = True
# FIXME: Should we be doing this truncation? # FIXME: Should we be doing this truncation?
TRACK_MAX_EVENT = 10000 TRACK_MAX_EVENT = 10000
DEBUG_TRACK_LOG = False DEBUG_TRACK_LOG = False
MITX_ROOT_URL = '' MITX_ROOT_URL = ''
...@@ -129,7 +129,7 @@ COURSE_NAME = "6.002_Spring_2012" ...@@ -129,7 +129,7 @@ COURSE_NAME = "6.002_Spring_2012"
COURSE_NUMBER = "6.002x" COURSE_NUMBER = "6.002x"
COURSE_TITLE = "Circuits and Electronics" COURSE_TITLE = "Circuits and Electronics"
### Dark code. Should be enabled in local settings for devel. ### Dark code. Should be enabled in local settings for devel.
ENABLE_MULTICOURSE = False # set to False to disable multicourse display (see lib.util.views.mitxhome) ENABLE_MULTICOURSE = False # set to False to disable multicourse display (see lib.util.views.mitxhome)
QUICKEDIT = False QUICKEDIT = False
...@@ -211,9 +211,9 @@ USE_L10N = True ...@@ -211,9 +211,9 @@ USE_L10N = True
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
#################################### AWS ####################################### #################################### AWS #######################################
# S3BotoStorage insists on a timeout for uploaded assets. We should make it # S3BotoStorage insists on a timeout for uploaded assets. We should make it
# permanent instead, but rather than trying to figure out exactly where that # permanent instead, but rather than trying to figure out exactly where that
# setting is, I'm just bumping the expiration time to something absurd (100 # setting is, I'm just bumping the expiration time to something absurd (100
# years). This is only used if DEFAULT_FILE_STORAGE is overriden to use S3 # years). This is only used if DEFAULT_FILE_STORAGE is overriden to use S3
# in the global settings.py # in the global settings.py
AWS_QUERYSTRING_EXPIRE = 10 * 365 * 24 * 60 * 60 # 10 years AWS_QUERYSTRING_EXPIRE = 10 * 365 * 24 * 60 * 60 # 10 years
...@@ -279,7 +279,7 @@ MIDDLEWARE_CLASSES = ( ...@@ -279,7 +279,7 @@ MIDDLEWARE_CLASSES = (
# Instead of AuthenticationMiddleware, we use a cached backed version # Instead of AuthenticationMiddleware, we use a cached backed version
#'django.contrib.auth.middleware.AuthenticationMiddleware', #'django.contrib.auth.middleware.AuthenticationMiddleware',
'cache_toolbox.middleware.CacheBackedAuthenticationMiddleware', 'cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'track.middleware.TrackMiddleware', 'track.middleware.TrackMiddleware',
'mitxmako.middleware.MakoMiddleware', 'mitxmako.middleware.MakoMiddleware',
...@@ -502,7 +502,7 @@ INSTALLED_APPS = ( ...@@ -502,7 +502,7 @@ INSTALLED_APPS = (
# For testing # For testing
'django_jasmine', 'django_jasmine',
# For Askbot # For Askbot
'django.contrib.sitemaps', 'django.contrib.sitemaps',
'django.contrib.admin', 'django.contrib.admin',
'django_countries', 'django_countries',
......
...@@ -51,6 +51,7 @@ default_options = { ...@@ -51,6 +51,7 @@ default_options = {
task :predjango do task :predjango do
sh("find . -type f -name *.pyc -delete") sh("find . -type f -name *.pyc -delete")
sh('pip install -e common/lib/xmodule') sh('pip install -e common/lib/xmodule')
sh('git submodule update --init')
end end
[:lms, :cms, :common].each do |system| [:lms, :cms, :common].each do |system|
...@@ -150,14 +151,14 @@ end ...@@ -150,14 +151,14 @@ end
task :package do task :package do
FileUtils.mkdir_p(BUILD_DIR) FileUtils.mkdir_p(BUILD_DIR)
Dir.chdir(BUILD_DIR) do Dir.chdir(BUILD_DIR) do
afterremove = Tempfile.new('afterremove') afterremove = Tempfile.new('afterremove')
afterremove.write <<-AFTERREMOVE.gsub(/^\s*/, '') afterremove.write <<-AFTERREMOVE.gsub(/^\s*/, '')
#! /bin/bash #! /bin/bash
set -e set -e
set -x set -x
# to be a little safer this rm is executed # to be a little safer this rm is executed
# as the makeitso user # as the makeitso user
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment