Resolve issues with persistence and sequential bar

This commit is contained in:
Renzo Lucioni
2013-07-18 16:52:02 -04:00
parent 1fc4ac864e
commit 9af87e41ba
4 changed files with 18 additions and 22 deletions

View File

@@ -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):

View File

@@ -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'

View File

@@ -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

View File

@@ -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):