From 85079da3a75e14b90d2433a33a73e648910e0beb Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Sat, 12 May 2012 15:03:20 -0400 Subject: [PATCH] Minor bug fix/conflict between grades and i4xsystem --- djangoapps/courseware/grades.py | 6 +++++- djangoapps/courseware/module_render.py | 3 ++- djangoapps/courseware/modules/x_module.py | 11 +++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/djangoapps/courseware/grades.py b/djangoapps/courseware/grades.py index 8b4cb22c2f..74102e78d1 100644 --- a/djangoapps/courseware/grades.py +++ b/djangoapps/courseware/grades.py @@ -135,7 +135,11 @@ def get_score(user, problem, cache): if id in cache and response.max_grade != None: total = response.max_grade else: - total=float(courseware.modules.capa_module.Module(etree.tostring(problem), "id").max_score()) + ## HACK 1: We shouldn't specifically reference capa_module + ## HACK 2: Backwards-compatibility: This should be written when a grade is saved, and removed from the system + from module_render import I4xSystem + system = I4xSystem(None, None, None) + total=float(courseware.modules.capa_module.Module(system, etree.tostring(problem), "id").max_score()) response.max_grade = total response.save() diff --git a/djangoapps/courseware/module_render.py b/djangoapps/courseware/module_render.py index c38aa9b4fc..9bb7872a66 100644 --- a/djangoapps/courseware/module_render.py +++ b/djangoapps/courseware/module_render.py @@ -25,7 +25,8 @@ class I4xSystem(object): def __init__(self, ajax_url, track_function, render_function, filestore=None): self.ajax_url = ajax_url self.track_function = track_function - self.filestore = OSFS(settings.DATA_DIR) + if not filestore: + self.filestore = OSFS(settings.DATA_DIR) self.render_function = render_function self.exception404 = Http404 diff --git a/djangoapps/courseware/modules/x_module.py b/djangoapps/courseware/modules/x_module.py index b21894b36b..9e70a16891 100644 --- a/djangoapps/courseware/modules/x_module.py +++ b/djangoapps/courseware/modules/x_module.py @@ -51,8 +51,11 @@ class XModule(object): self.item_id = item_id self.state = state - self.ajax_url = system.ajax_url - self.tracker = system.track_function - self.filestore = system.filestore - self.render_function = system.render_function + if system: + ## These are temporary; we really should go + ## through self.system. + self.ajax_url = system.ajax_url + self.tracker = system.track_function + self.filestore = system.filestore + self.render_function = system.render_function self.system = system