From 68c155b2687a3e372a2a821867be5141b9d78f39 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 3 Jul 2012 09:57:51 -0400 Subject: [PATCH 1/3] Don't use __dict__ for namedtuples, because it doesn't work in python 2.7.1 --- common/lib/xmodule/xmodule/modulestore/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 00b3b13bb0..faee5ce303 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -122,7 +122,7 @@ class Location(_LocationBase): return "-".join(str(v) for v in self.list() if v is not None).replace('.', '_') def dict(self): - return self.__dict__ + return self._asdict() def list(self): return list(self) From 42cef5b7885abe68a7da48c9b573924dbab22536 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 3 Jul 2012 14:19:51 -0400 Subject: [PATCH 2/3] Get rid of references to self.filename in capa_module, as it no longer exists --- common/lib/xmodule/xmodule/capa_module.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index b7f8e68b5e..06029b5e3f 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -141,7 +141,7 @@ class CapaModule(XModule): msg = '

%s

' % msg.replace('<', '<') msg += '

%s

' % traceback.format_exc().replace('<', '<') # create a dummy problem with error message instead of failing - problem_text = 'Problem file %s has an error:%s' % (self.filename, msg) + problem_text = 'Problem %s has an error:%s' % (self.location.url(), msg) self.lcp = LoncapaProblem(problem_text, self.location.html_id(), instance_state, seed=seed, system=self.system) else: raise @@ -368,7 +368,7 @@ class CapaModule(XModule): ''' event_info = dict() event_info['state'] = self.lcp.get_state() - event_info['filename'] = self.filename + event_info['problem_id'] = self.location.url() answers = self.make_dict_of_responses(get) @@ -394,13 +394,13 @@ class CapaModule(XModule): correct_map = self.lcp.grade_answers(answers) except StudentInputError as inst: # TODO (vshnayder): why is this line here? - self.lcp = LoncapaProblem(self.system.filestore.open(self.filename).read(), + self.lcp = LoncapaProblem(self.definition['data'], id=lcp_id, state=old_state, system=self.system) traceback.print_exc() return {'success': inst.message} except: # TODO: why is this line here? - self.lcp = LoncapaProblem(self.system.filestore.open(self.filename).read(), + self.lcp = LoncapaProblem(self.definition['data'], id=lcp_id, state=old_state, system=self.system) traceback.print_exc() raise Exception("error in capa_module") @@ -434,7 +434,7 @@ class CapaModule(XModule): ''' event_info = dict() event_info['state'] = self.lcp.get_state() - event_info['filename'] = self.filename + event_info['problem_id'] = self.location.url() answers = self.make_dict_of_responses(get) event_info['answers'] = answers @@ -468,7 +468,7 @@ class CapaModule(XModule): ''' event_info = dict() event_info['old_state'] = self.lcp.get_state() - event_info['filename'] = self.filename + event_info['problem_id'] = self.location.url() if self.closed(): event_info['failure'] = 'closed' @@ -485,7 +485,7 @@ class CapaModule(XModule): # reset random number generator seed (note the self.lcp.get_state() in next line) self.lcp.seed = None - self.lcp = LoncapaProblem(self.system.filestore.open(self.filename).read(), + self.lcp = LoncapaProblem(self.definition['data'], self.location.html_id(), self.lcp.get_state(), system=self.system) event_info['new_state'] = self.lcp.get_state() From 207777fbe12269d3e1e8605df1daf27c8a05c85d Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 3 Jul 2012 14:20:11 -0400 Subject: [PATCH 3/3] Fix up problem display to use the new metadata that's available --- common/lib/xmodule/xmodule/capa_module.py | 2 +- lms/templates/problem.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 06029b5e3f..3cafcbde3d 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -194,7 +194,7 @@ class CapaModule(XModule): as necessary based on the problem config and state.''' html = self.lcp.get_html() - content = {'name': self.name, + content = {'name': self.metadata['display_name'], 'html': html, 'weight': self.weight, } diff --git a/lms/templates/problem.html b/lms/templates/problem.html index 3f79be3b3a..36fcb1bc66 100644 --- a/lms/templates/problem.html +++ b/lms/templates/problem.html @@ -1,7 +1,7 @@ <%namespace name='static' file='static_content.html'/>

${ problem['name'] } - % if problem['weight']: + % if problem['weight'] != 1: : ${ problem['weight'] } points % endif