Commit 2c2072da by Piotr Mitros

Converted to use more semantic tags. Working snapshot.

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