diff --git a/courseware/capa_module.py b/courseware/capa_module.py index 72efae286a..fe9f37ad83 100644 --- a/courseware/capa_module.py +++ b/courseware/capa_module.py @@ -24,10 +24,6 @@ class LoncapaModule(XModule): xml_tags = ["problem"] id_attribute = "filename" - attempts = 0 - max_attempts = None - - due_date = None def get_state(self): state = self.lcp.get_state() @@ -94,6 +90,11 @@ class LoncapaModule(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) + + self.attempts = 0 + self.max_attempts = None + self.due_date = None + dom=parseString(xml) node=dom.childNodes[0] diff --git a/courseware/capa_problem.py b/courseware/capa_problem.py index a63433d1af..c4e1739323 100644 --- a/courseware/capa_problem.py +++ b/courseware/capa_problem.py @@ -44,8 +44,19 @@ class LoncapaProblem(): seed will provide the random seed. Alternatively, passing context will bypass all script execution, and use the given execution context. ''' + self.done=False + self.text="" + self.context=dict() # Execution context from loncapa/python + self.questions=dict() # Detailed info about questions in problem instance. TODO: Should be by id and not lid. + self.answers=dict() # Student answers + self.correct_map=dict() + self.seed=None + self.gid="" # ID of the problem + self.lid=-1 # ID of the field within the problem + + if state==None: - state={} + state=dict() self.gid=id if 'done' in state: @@ -66,7 +77,7 @@ class LoncapaProblem(): self.correct_map=state['correct_map'] random.seed(self.seed) dom=parse(filename).childNodes[0] - + g={'random':random,'numpy':numpy,'math':math,'scipy':scipy} # Buffer stores HTML for problem @@ -77,7 +88,6 @@ class LoncapaProblem(): # Loop through the nodes of the problem, and for e in dom.childNodes: if e.localName=='script': - #print e.childNodes[0].data exec e.childNodes[0].data in g,self.context elif e.localName=='endouttext': ot=False @@ -97,16 +107,6 @@ class LoncapaProblem(): self.text=self.contextualize_text(self.text) self.filename=filename - done=False - text="" - context={} # Execution context from loncapa/python - questions={} # Detailed info about questions in problem instance. TODO: Should be by id and not lid. - answers={} # Student answers - correct_map={} - seed=None - gid="" # ID of the problem - lid=-1 # ID of the field within the problem - def get_context(self): ''' Return the execution context ''' return self.context @@ -131,14 +131,12 @@ class LoncapaProblem(): correct_map[id]='incorrect' # Should always be there else: grader=self.graders[self.questions[key]['type']] - print grader correct_map[id]=grader(self, self.questions[key], self.answers[id]) self.correct_map=correct_map return correct_map def handle_schem(self, element): - print element height = element.getAttribute('height') width = element.getAttribute('width') if height=="": @@ -151,7 +149,6 @@ class LoncapaProblem(): html='' html = html.format(height=height, width=width, id=id, value="") - print html return html @@ -196,7 +193,6 @@ class LoncapaProblem(): return html def grade_fr(self, question, answer): - print question, answer correct = True for i in range(question['samples_count']): instructor_variables = strip_dict(dict(self.context)) @@ -207,7 +203,6 @@ class LoncapaProblem(): student_variables[str(var)] = value instructor_result = evaluator(instructor_variables,{},str(question['answer'])) student_result = evaluator(student_variables,{},str(answer)) - print student_result, instructor_result if math.isnan(student_result) or math.isinf(student_result): return "incorrect" if abs( student_result - instructor_result ) > question['tolerance']: diff --git a/courseware/module_render.py b/courseware/module_render.py index c41d457d58..a8f506209a 100644 --- a/courseware/module_render.py +++ b/courseware/module_render.py @@ -70,7 +70,6 @@ def seq_module(request, module): params={'items':contents, 'id':"seq"} - print module.nodeName if module.nodeName == 'sequential': return {'init_js':js+render_to_string('seq_module.js',params), "destroy_js":"", @@ -145,7 +144,6 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): id_tag=modx_modules[module].id_attribute #print "X",s.xml, "Y",content_parser.module_xml(module, id_tag, id) - print xml = content_parser.module_xml(content_parser.course_file(request.user), module, id_tag, id)