From 9af87e41ba939c7fbbd6ada4d8ce4c1325c05140 Mon Sep 17 00:00:00 2001 From: Renzo Lucioni Date: Thu, 18 Jul 2013 16:52:02 -0400 Subject: [PATCH] Resolve issues with persistence and sequential bar --- common/lib/xmodule/xmodule/capa_module.py | 13 ++++++++++--- .../xmodule/xmodule/js/src/capa/display.coffee | 9 ++++++--- .../xmodule/js/src/sequence/display.coffee | 2 +- .../xmodule/xmodule/tests/test_capa_module.py | 16 +--------------- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index a7062b9f1d..78a94941cc 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -614,6 +614,13 @@ class CapaModule(CapaFields, XModule): return False def is_submitted(self): + """ + Used to decide to show or hide RESET or CHECK buttons. + + Means that student submitted problem and nothing more. + Problem can be completely wrong. + Pressing RESET button makes this function to return False. + """ # used by conditional module return self.lcp.done @@ -756,7 +763,7 @@ class CapaModule(CapaFields, XModule): Used if we want to reconfirm we have the right thing e.g. after several AJAX calls. """ - return {'html': self.get_problem_html()} + return {'html': self.get_problem_html(encapsulate=False)} @staticmethod @@ -936,7 +943,7 @@ class CapaModule(CapaFields, XModule): self.system.psychometrics_handler(self.get_state_for_lcp()) # render problem into HTML - html = self.get_problem_html() + html = self.get_problem_html(encapsulate=False) return {'success': success, 'contents': html, @@ -1103,7 +1110,7 @@ class CapaModule(CapaFields, XModule): self.system.track_function('reset_problem', event_info) return {'success': True, - 'html': self.get_problem_html()} + 'html': self.get_problem_html(encapsulate=False)} class CapaDescriptor(CapaFields, RawDescriptor): diff --git a/common/lib/xmodule/xmodule/js/src/capa/display.coffee b/common/lib/xmodule/xmodule/js/src/capa/display.coffee index b38cdb3695..09a398dd7a 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/capa/display.coffee @@ -35,16 +35,19 @@ class @Problem @$('input.math').each (index, element) => MathJax.Hub.Queue [@refreshMath, null, element] - renderProgressState: () => + renderProgressState: => detail = @el.data('progress_detail') status = @el.data('progress_status') + # i18n progress = "(#{detail} points)" if status == 'none' and detail? and detail.indexOf('/') > 0 a = detail.split('/') possible = parseInt(a[1]) if possible == 1 + # i18n progress = "(#{possible} point possible)" else + # i18n progress = "(#{possible} points possible)" @$('.problem-progress').html(progress) @@ -129,7 +132,7 @@ class @Problem @setupInputTypes() @bind() @queueing() - @renderProgressState() + @forceUpdate response # TODO add hooks for problem types here by inspecting response.html and doing # stuff if a div w a class is found @@ -256,7 +259,7 @@ class @Problem analytics.track "Problem Checked", problem_id: @id answers: @answers - + $.postWithPrefix "#{@url}/problem_check", @answers, (response) => switch response.success when 'incorrect', 'correct' diff --git a/common/lib/xmodule/xmodule/js/src/sequence/display.coffee b/common/lib/xmodule/xmodule/js/src/sequence/display.coffee index 495b734785..bae1b89bab 100644 --- a/common/lib/xmodule/xmodule/js/src/sequence/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/sequence/display.coffee @@ -45,7 +45,7 @@ class @Sequence new_progress = "NA" _this = this $('.problems-wrapper').each (index) -> - progress = $(this).attr 'progress' + progress = $(this).data 'progress_status' new_progress = _this.mergeProgress progress, new_progress @progressTable[@position] = new_progress diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index 468bb87520..80c4e41e8f 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -1248,20 +1248,6 @@ class CapaModuleTest(unittest.TestCase): other_module.get_progress() mock_progress.assert_called_with(1, 1) - - @patch('xmodule.capa_module.Progress') - def test_get_progress_calculate_progress_fraction(self, mock_progress): - """ - Check that score and total are calculated correctly for the progress fraction. - """ - module = CapaFactory.create() - module.get_progress() - mock_progress.assert_called_with(0,1) - - other_module = CapaFactory.create(correct=True) - other_module.get_progress() - mock_progress.assert_called_with(1,1) - def test_get_html(self): """ Check that get_html() calls get_progress() with no arguments. @@ -1276,7 +1262,7 @@ class CapaModuleTest(unittest.TestCase): Check that get_problem() returns the expected dictionary. """ module = CapaFactory.create() - self.assertEquals(module.get_problem("data"), {'html': module.get_problem_html()}) + self.assertEquals(module.get_problem("data"), {'html': module.get_problem_html(encapsulate=False)}) class ComplexEncoderTest(unittest.TestCase):