Commit 257fcc03 by Nimisha Asthagiri

Fix CAPA progress display flakiness

parent fda2ceac
......@@ -604,7 +604,7 @@
case 'incorrect':
case 'correct':
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.updateProgress(response);
break;
......@@ -662,7 +662,7 @@
id: this.id
}, function(response) {
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.updateProgress(response);
return window.SR.readText(gettext('This problem has been reset.'));
......@@ -773,7 +773,7 @@
var saveMessage;
saveMessage = response.msg;
if (response.success) {
that.el.trigger('contentChanged', [that.id, response.html]);
that.el.trigger('contentChanged', [that.id, response.html, response]);
edx.HtmlUtils.setHtml(
that.el.find('.notification-save .notification-message'),
edx.HtmlUtils.HTML(saveMessage)
......
......@@ -45,23 +45,24 @@ class @Sequence
hookUpContentStateChangeEvent: ->
$('.problems-wrapper').bind(
'contentChanged',
(event, problem_id, new_content_state) =>
@addToUpdatedProblems problem_id, new_content_state
(event, problem_id, new_content_state, new_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.
# params:
# '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
# for this position.
if not @anyUpdatedProblems @position
@updatedProblems[@position] = {}
# Now, put problem content against problem id for current active sequence.
@updatedProblems[@position][problem_id] = new_content_state
# Now, put problem content and score against problem id for current active sequence.
@updatedProblems[@position][problem_id] = [new_content_state, new_state]
anyUpdatedProblems:(position) ->
# check for the updated problems for given sequence position.
......@@ -161,10 +162,15 @@ class @Sequence
# update the data-attributes with latest contents only for updated problems.
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
.find("[data-problem-id='#{ problem_id }']")
.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)
......
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