From 2b4929562a046d4d7a1fa2954309fd4397c797a2 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Mon, 14 Jan 2013 10:39:58 -0500 Subject: [PATCH] Fix up rubric rendering --- .../lib/xmodule/xmodule/combined_open_ended_rubric.py | 10 +++++++--- common/lib/xmodule/xmodule/self_assessment_module.py | 6 +++++- lms/templates/self_assessment_rubric.html | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/combined_open_ended_rubric.py b/common/lib/xmodule/xmodule/combined_open_ended_rubric.py index 445d066416..2dd3eb587b 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_rubric.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_rubric.py @@ -2,9 +2,13 @@ from mitxmako.shortcuts import render_to_string class CombinedOpenEndedRubric: - def render_rubric(self, rubric_xml): - rubric_categories = CombinedOpenEndedRubric.extract_rubric_categories(rubric_xml) - html = render_to_string('open_ended_rubric.html', {'rubric_categories' : rubric_categories}) + @staticmethod + def render_rubric(rubric_xml): + try: + rubric_categories = CombinedOpenEndedRubric.extract_rubric_categories(rubric_xml) + html = render_to_string('open_ended_rubric.html', {'rubric_categories' : rubric_categories}) + except: + html = rubric_xml return html @staticmethod diff --git a/common/lib/xmodule/xmodule/self_assessment_module.py b/common/lib/xmodule/xmodule/self_assessment_module.py index 870f3ea169..940b61c557 100644 --- a/common/lib/xmodule/xmodule/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/self_assessment_module.py @@ -21,6 +21,8 @@ from .xml_module import XmlDescriptor from xmodule.modulestore import Location import openendedchild +from combined_open_ended_rubric import CombinedOpenEndedRubric + log = logging.getLogger("mitx.courseware") class SelfAssessmentModule(openendedchild.OpenEndedChild): @@ -120,8 +122,10 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): if self.state == self.INITIAL: return '' + rubric_html = CombinedOpenEndedRubric.render_rubric(self.rubric) + # we'll render it - context = {'rubric': self.rubric, + context = {'rubric': rubric_html, 'max_score': self._max_score, } diff --git a/lms/templates/self_assessment_rubric.html b/lms/templates/self_assessment_rubric.html index 5bcb3bba93..2d32ffe8d3 100644 --- a/lms/templates/self_assessment_rubric.html +++ b/lms/templates/self_assessment_rubric.html @@ -1,7 +1,7 @@

Self-assess your answer with this rubric:

- ${rubric} + ${rubric | n }
% if not read_only: