Commit a7b5433c by Piotr Mitros

Minor cleanups. Javascript only called once. Hidden sections now work

parent e21b9191
......@@ -102,34 +102,26 @@ class LoncapaModule(XModule):
self.max_attempts = None
self.due_date = None
#dom=parseString(xml)
#dom2 = libxml2.parseMemory(xml, len(xml))
dom2 = etree.fromstring(xml)
#node=dom.childNodes[0]
#self.due_date=node.getAttribute("due")
self.due_date=content_parser.item(dom2.xpath('/problem/@due'))#dom2.xpathEval('/problem/@due'))
self.due_date=content_parser.item(dom2.xpath('/problem/@due'))
if len(self.due_date)>0:
self.due_date=dateutil.parser.parse(self.due_date)
else:
self.due_date=None
#self.max_attempts=node.getAttribute("attempts")
self.max_attempts=content_parser.item(dom2.xpath('/problem/@attempts'))
if len(self.max_attempts)>0:
self.max_attempts=int(self.max_attempts)
else:
self.max_attempts=None
#self.show_answer=node.getAttribute("showanswer")
self.show_answer=content_parser.item(dom2.xpath('/problem/@showanswer'))
if self.show_answer=="":
self.show_answer="closed"
self.rerandomize=content_parser.item(dom2.xpath('/problem/@rerandomize'))
#self.rerandomize=node.getAttribute("rerandomize")
if self.rerandomize=="":
self.rerandomize=True
elif self.rerandomize=="false":
......@@ -145,10 +137,7 @@ class LoncapaModule(XModule):
self.attempts=state['attempts']
self.filename=content_parser.item(dom2.xpath('/problem/@filename'))
#self.filename=node.getAttribute("filename")
#print self.filename
filename=settings.DATA_DIR+"problems/"+self.filename+".xml"
#self.name=node.getAttribute("name")
self.name=content_parser.item(dom2.xpath('/problem/@name'))
self.lcp=LoncapaProblem(filename, self.item_id, state)
......
......@@ -27,7 +27,6 @@ def course_file(user):
def module_xml(coursefile, module, id_tag, module_id):
''' Get XML for a module based on module and module_id. Assumes
module occurs once in courseware XML file.. '''
#doc = libxml2.parseFile(coursefile)
doc = etree.parse(coursefile)
# Sanitize input
......@@ -35,7 +34,7 @@ def module_xml(coursefile, module, id_tag, module_id):
raise Exception("Module is not alphanumeric")
if not module_id.isalnum():
raise Exception("Module ID is not alphanumeric")
xpath_search='//*/{module}[@{id_tag} = "{id}"]'.format(module=module,
xpath_search='//*/{module}[(@{id_tag} = "{id}") or (@id = "{id}")]'.format(module=module,
id_tag=id_tag,
id=module_id)
#result_set=doc.xpathEval(xpath_search)
......
......@@ -21,3 +21,4 @@ class HtmlModule(XModule):
def __init__(self, xml, item_id, ajax_url=None, track_url=None, state=None):
XModule.__init__(self, xml, item_id, ajax_url, track_url, state)
print xml
......@@ -51,7 +51,6 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
ajax_url = '/modx/'+module+'/'+id+'/'
id_tag=modx_modules[module].id_attribute
#print "X",s.xml, "Y",content_parser.module_xml(module, id_tag, id)
xml = content_parser.module_xml(content_parser.course_file(request.user), module, id_tag, id)
......@@ -97,7 +96,7 @@ def seq_module(request, module):
for e in module.childNodes \
if e.nodeType==1]
js="".join([e[1]['init_js'] for e in contents if 'init_js' in e[1]])
js=""
iid=uuid.uuid1().hex
......
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