Commit 257fcc03 by Nimisha Asthagiri

Fix CAPA progress display flakiness

parent fda2ceac
...@@ -604,7 +604,7 @@ ...@@ -604,7 +604,7 @@
case 'incorrect': case 'incorrect':
case 'correct': case 'correct':
window.SR.readTexts(that.get_sr_status(response.contents)); window.SR.readTexts(that.get_sr_status(response.contents));
that.el.trigger('contentChanged', [that.id, response.contents]); that.el.trigger('contentChanged', [that.id, response.contents, response]);
that.render(response.contents, that.focus_on_submit_notification); that.render(response.contents, that.focus_on_submit_notification);
that.updateProgress(response); that.updateProgress(response);
break; break;
...@@ -662,7 +662,7 @@ ...@@ -662,7 +662,7 @@
id: this.id id: this.id
}, function(response) { }, function(response) {
if (response.success) { if (response.success) {
that.el.trigger('contentChanged', [that.id, response.html]); that.el.trigger('contentChanged', [that.id, response.html, response]);
that.render(response.html, that.scroll_to_problem_meta); that.render(response.html, that.scroll_to_problem_meta);
that.updateProgress(response); that.updateProgress(response);
return window.SR.readText(gettext('This problem has been reset.')); return window.SR.readText(gettext('This problem has been reset.'));
...@@ -773,7 +773,7 @@ ...@@ -773,7 +773,7 @@
var saveMessage; var saveMessage;
saveMessage = response.msg; saveMessage = response.msg;
if (response.success) { if (response.success) {
that.el.trigger('contentChanged', [that.id, response.html]); that.el.trigger('contentChanged', [that.id, response.html, response]);
edx.HtmlUtils.setHtml( edx.HtmlUtils.setHtml(
that.el.find('.notification-save .notification-message'), that.el.find('.notification-save .notification-message'),
edx.HtmlUtils.HTML(saveMessage) edx.HtmlUtils.HTML(saveMessage)
......
...@@ -45,23 +45,24 @@ class @Sequence ...@@ -45,23 +45,24 @@ class @Sequence
hookUpContentStateChangeEvent: -> hookUpContentStateChangeEvent: ->
$('.problems-wrapper').bind( $('.problems-wrapper').bind(
'contentChanged', 'contentChanged',
(event, problem_id, new_content_state) => (event, problem_id, new_content_state, new_state) =>
@addToUpdatedProblems problem_id, new_content_state @addToUpdatedProblems problem_id, new_content_state, new_state
) )
addToUpdatedProblems: (problem_id, new_content_state) => addToUpdatedProblems: (problem_id, new_content_state, new_state) =>
# Used to keep updated problem's state temporarily. # Used to keep updated problem's state temporarily.
# params: # params:
# 'problem_id' is problem id. # 'problem_id' is problem id.
# 'new_content_state' is updated problem's state. # 'new_content_state' is the updated content of the problem.
# 'new_state' is the updated state of the problem.
# initialize for the current sequence if there isn't any updated problem # initialize for the current sequence if there isn't any updated problem
# for this position. # for this position.
if not @anyUpdatedProblems @position if not @anyUpdatedProblems @position
@updatedProblems[@position] = {} @updatedProblems[@position] = {}
# Now, put problem content against problem id for current active sequence. # Now, put problem content and score against problem id for current active sequence.
@updatedProblems[@position][problem_id] = new_content_state @updatedProblems[@position][problem_id] = [new_content_state, new_state]
anyUpdatedProblems:(position) -> anyUpdatedProblems:(position) ->
# check for the updated problems for given sequence position. # check for the updated problems for given sequence position.
...@@ -161,10 +162,15 @@ class @Sequence ...@@ -161,10 +162,15 @@ class @Sequence
# update the data-attributes with latest contents only for updated problems. # update the data-attributes with latest contents only for updated problems.
if @anyUpdatedProblems new_position if @anyUpdatedProblems new_position
$.each @updatedProblems[new_position], (problem_id, latest_content) => $.each @updatedProblems[new_position], (problem_id, latest_data) =>
latest_content = latest_data[0]
latest_response = latest_data[1]
@content_container @content_container
.find("[data-problem-id='#{ problem_id }']") .find("[data-problem-id='#{ problem_id }']")
.data('content', latest_content) .data('content', latest_content)
.data('problem-score', latest_response.current_score)
.data('problem-total-possible', latest_response.total_possible)
.data('attempts-used', latest_response.attempts_used)
XBlock.initializeBlocks(@content_container, @requestToken) XBlock.initializeBlocks(@content_container, @requestToken)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment