Commit ba92bdc2 by Victor Shnayder

Merge pull request #708 from MITx/feature/cale/cms-bug-fixes

Feature/cale/cms bug fixes
parents 0df20006 c0ed7939
...@@ -207,7 +207,7 @@ def preview_module_system(request, preview_id, descriptor): ...@@ -207,7 +207,7 @@ def preview_module_system(request, preview_id, descriptor):
descriptor: An XModuleDescriptor descriptor: An XModuleDescriptor
""" """
return ModuleSystem( return ModuleSystem(
ajax_url=reverse('preview_dispatch', args=[preview_id, descriptor.location.url(), '']), ajax_url=reverse('preview_dispatch', args=[preview_id, descriptor.location.url(), '']).rstrip('/'),
# TODO (cpennington): Do we want to track how instructors are using the preview problems? # TODO (cpennington): Do we want to track how instructors are using the preview problems?
track_function=lambda type, event: None, track_function=lambda type, event: None,
filestore=descriptor.system.resources_fs, filestore=descriptor.system.resources_fs,
......
...@@ -22,9 +22,6 @@ class CourseDescriptor(SequenceDescriptor): ...@@ -22,9 +22,6 @@ class CourseDescriptor(SequenceDescriptor):
self.book_url = book_url self.book_url = book_url
self.table_of_contents = self._get_toc_from_s3() self.table_of_contents = self._get_toc_from_s3()
@classmethod
def from_xml_object(cls, xml_object):
return cls(xml_object.get('title'), xml_object.get('book_url'))
@property @property
def table_of_contents(self): def table_of_contents(self):
...@@ -57,10 +54,18 @@ class CourseDescriptor(SequenceDescriptor): ...@@ -57,10 +54,18 @@ class CourseDescriptor(SequenceDescriptor):
return table_of_contents return table_of_contents
def __init__(self, system, definition=None, **kwargs): def __init__(self, system, definition=None, **kwargs):
super(CourseDescriptor, self).__init__(system, definition, **kwargs) super(CourseDescriptor, self).__init__(system, definition, **kwargs)
self.textbooks = self.definition['data']['textbooks']
self.textbooks = []
for title, book_url in self.definition['data']['textbooks']:
try:
self.textbooks.append(self.Textbook(title, book_url))
except:
# If we can't get to S3 (e.g. on a train with no internet), don't break
# the rest of the courseware.
log.exception("Couldn't load textbook ({0}, {1})".format(title, book_url))
continue
self.wiki_slug = self.definition['data']['wiki_slug'] or self.location.course self.wiki_slug = self.definition['data']['wiki_slug'] or self.location.course
...@@ -82,7 +87,6 @@ class CourseDescriptor(SequenceDescriptor): ...@@ -82,7 +87,6 @@ class CourseDescriptor(SequenceDescriptor):
# disable the syllabus content for courses that do not provide a syllabus # disable the syllabus content for courses that do not provide a syllabus
self.syllabus_present = self.system.resources_fs.exists(path('syllabus')) self.syllabus_present = self.system.resources_fs.exists(path('syllabus'))
def set_grading_policy(self, policy_str): def set_grading_policy(self, policy_str):
"""Parse the policy specified in policy_str, and save it""" """Parse the policy specified in policy_str, and save it"""
try: try:
...@@ -94,19 +98,11 @@ class CourseDescriptor(SequenceDescriptor): ...@@ -94,19 +98,11 @@ class CourseDescriptor(SequenceDescriptor):
# the error log. # the error log.
self._grading_policy = {} self._grading_policy = {}
@classmethod @classmethod
def definition_from_xml(cls, xml_object, system): def definition_from_xml(cls, xml_object, system):
textbooks = [] textbooks = []
for textbook in xml_object.findall("textbook"): for textbook in xml_object.findall("textbook"):
try: textbooks.append((textbook.get('title'), textbook.get('book_url')))
txt = cls.Textbook.from_xml_object(textbook)
except:
# If we can't get to S3 (e.g. on a train with no internet), don't break
# the rest of the courseware.
log.exception("Couldn't load textbook")
continue
textbooks.append(txt)
xml_object.remove(textbook) xml_object.remove(textbook)
#Load the wiki tag if it exists #Load the wiki tag if it exists
......
...@@ -316,3 +316,9 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -316,3 +316,9 @@ class MongoModuleStore(ModuleStoreBase):
{'_id': True}) {'_id': True})
return [i['_id'] for i in items] return [i['_id'] for i in items]
def get_errored_courses(self):
"""
This function doesn't make sense for the mongo modulestore, as courses
are loaded on demand, rather than up front
"""
return {}
"""
Settings for the LMS that runs alongside the CMS on AWS
"""
from ..dev import *
MODULESTORE = {
'default': {
'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
'OPTIONS': {
'default_class': 'xmodule.raw_module.RawDescriptor',
'host': 'localhost',
'db': 'xmodule',
'collection': 'modulestore',
'fs_root': DATA_DIR,
'render_template': 'mitxmako.shortcuts.render_to_string',
}
}
}
...@@ -125,8 +125,8 @@ TEST_TASKS = [] ...@@ -125,8 +125,8 @@ TEST_TASKS = []
end end
# Per environment tasks # Per environment tasks
Dir["#{system}/envs/*.py"].each do |env_file| Dir["#{system}/envs/**/*.py"].each do |env_file|
env = File.basename(env_file).gsub(/\.py/, '') env = env_file.gsub("#{system}/envs/", '').gsub(/\.py/, '').gsub('/', '.')
desc "Attempt to import the settings file #{system}.envs.#{env} and report any errors" desc "Attempt to import the settings file #{system}.envs.#{env} and report any errors"
task "#{system}:check_settings:#{env}" => :predjango do task "#{system}:check_settings:#{env}" => :predjango do
sh("echo 'import #{system}.envs.#{env}' | #{django_admin(system, env, 'shell')}") sh("echo 'import #{system}.envs.#{env}' | #{django_admin(system, env, 'shell')}")
......
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