diff --git a/djangoapps/courseware/content_parser.py b/djangoapps/courseware/content_parser.py index d557e5ac36..9d8811307f 100644 --- a/djangoapps/courseware/content_parser.py +++ b/djangoapps/courseware/content_parser.py @@ -218,6 +218,7 @@ def section_file(user, section, coursename=None, dironly=False): Given a user and the name of a section, return that section. This is done specific to each course. If dironly=True then return the sections directory. + TODO: This is a bit weird; dironly should be scrapped. ''' filename = section+".xml" diff --git a/djangoapps/courseware/modules/seq_module.py b/djangoapps/courseware/modules/seq_module.py index 210c11d451..af41d0e8da 100644 --- a/djangoapps/courseware/modules/seq_module.py +++ b/djangoapps/courseware/modules/seq_module.py @@ -21,7 +21,7 @@ class Module(XModule): @classmethod def get_xml_tags(c): obsolete_tags = ["sequential", 'tab'] - modern_tags = ["problemset", "videosequence"] + modern_tags = ["videosequence"] return obsolete_tags + modern_tags def get_html(self): @@ -83,7 +83,8 @@ class Module(XModule): params={'items':self.contents, 'id':self.item_id, 'position': self.position, - 'titles':self.titles} + 'titles':self.titles, + 'tag':self.xmltree.tag} # TODO/BUG: Destroy JavaScript should only be called for the active view # This calls it for all the views @@ -92,7 +93,7 @@ class Module(XModule): # IDs to sequences. destroy_js="".join([e['destroy_js'] for e in self.contents if 'destroy_js' in e]) - if self.xmltree.tag == 'sequential': + if self.xmltree.tag in ['sequential', 'videosequence']: self.init_js=js+render_to_string('seq_module.js',params) self.destroy_js=destroy_js self.content=render_to_string('seq_module.html',params) diff --git a/djangoapps/courseware/modules/vertical_module.py b/djangoapps/courseware/modules/vertical_module.py index f64e45fe7f..e57a58e33e 100644 --- a/djangoapps/courseware/modules/vertical_module.py +++ b/djangoapps/courseware/modules/vertical_module.py @@ -13,7 +13,7 @@ class Module(XModule): @classmethod def get_xml_tags(c): - return ["vertical"] + return ["vertical", "problemset"] def get_html(self): return render_to_string('vert_module.html',{'items':self.contents}) diff --git a/djangoapps/courseware/modules/x_module.py b/djangoapps/courseware/modules/x_module.py index 0d0ce707e7..b475fd0280 100644 --- a/djangoapps/courseware/modules/x_module.py +++ b/djangoapps/courseware/modules/x_module.py @@ -17,7 +17,7 @@ class XModule(object): ''' Tags in the courseware file guaranteed to correspond to the module ''' return [] - @classmethod(c): + @classmethod def get_usage_tags(c): ''' We should convert to a real module system For now, this tells us whether we use this as an xmodule, a CAPA response type diff --git a/djangoapps/courseware/views.py b/djangoapps/courseware/views.py index 313259bdb7..014f759ed1 100644 --- a/djangoapps/courseware/views.py +++ b/djangoapps/courseware/views.py @@ -60,7 +60,6 @@ def profile(request, student_id = None): if student_id == None: student = request.user else: - print content_parser.user_groups(request.user) if 'course_admin' not in content_parser.user_groups(request.user): raise Http404 student = User.objects.get( id = int(student_id)) @@ -184,16 +183,28 @@ def index(request, course=None, chapter="Using the System", section="Hints"): log.exception("Unable to parse courseware xml") return render_to_response('courseware-error.html', {}) - dom_module = dom.xpath("//course[@name=$course]/chapter[@name=$chapter]//section[@name=$section]/*[1]", + #dom_module = dom.xpath("//course[@name=$course]/chapter[@name=$chapter]//section[@name=$section]/*[1]", + 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 = None + module_wrapper = None else: - module = dom_module[0] + module_wrapper = dom_module[0] - module_ids = dom.xpath("//course[@name=$course]/chapter[@name=$chapter]//section[@name=$section]//@id", - course=course, chapter=chapter, section=section) + if module_wrapper == None: + module = None + elif module_wrapper.get("src"): + module = content_parser.section_file(user=user, section=module_wrapper.get("src"), coursename=course) + else: + module = etree.XML(etree.tostring(module_wrapper[0])) # Copy the element out of the tree + + module_ids = [] + if module: + module_ids = module.xpath("//@id", + course=course, chapter=chapter, section=section) if user.is_authenticated(): module_object_preload = list(StudentModule.objects.filter(student=user, @@ -305,7 +316,7 @@ def quickedit(request, id=None): Maybe this should be moved into capa/views.py Or this should take a "module" argument, and the quickedit moved into capa_module. ''' - print "WARNING: UNDEPLOYABLE CODE. FOR DEV USE ONLY." + print "WARNING: UNDEPLOYABLE CODE. FOR CONTENT DEV USE ONLY." print "In deployed use, this will only edit on one server" print "We need a setting to disable for production where there is" print "a load balanacer" diff --git a/templates/seq_module.js b/templates/seq_module.js index 5fa4070fca..691cbb5544 100644 --- a/templates/seq_module.js +++ b/templates/seq_module.js @@ -53,7 +53,7 @@ function disablePrev() { function ${ id }goto(i) { log_event("seq_goto", {'old':${id}loc, 'new':i,'id':'${id}'}); - postJSON('${ MITX_ROOT_URL }/modx/sequential/${ id }/goto_position', + postJSON('${ MITX_ROOT_URL }/modx/${tag}/${ id }/goto_position', {'position' : i }); if (${ id }loc!=-1)