Fix issue with duplicate submits
This commit is contained in:
@ -6,25 +6,10 @@ window.common = (function(global) {
|
|||||||
common = { init: [] }
|
common = { init: [] }
|
||||||
} = global;
|
} = global;
|
||||||
|
|
||||||
common.showCompletion = function showCompletion() {
|
function submitChallengeHandler(e) {
|
||||||
|
e.preventDefault();
|
||||||
ga(
|
|
||||||
'send',
|
|
||||||
'event',
|
|
||||||
'Challenge',
|
|
||||||
'solved',
|
|
||||||
common.gaName,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
var solution = common.editor.getValue();
|
var solution = common.editor.getValue();
|
||||||
var didCompleteWith = $('#completed-with').val() || null;
|
|
||||||
|
|
||||||
$('#complete-courseware-dialog').modal('show');
|
|
||||||
$('#complete-courseware-dialog .modal-header').click();
|
|
||||||
|
|
||||||
$('#submit-challenge').click(function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
$('#submit-challenge')
|
$('#submit-challenge')
|
||||||
.attr('disabled', 'true')
|
.attr('disabled', 'true')
|
||||||
@ -60,7 +45,6 @@ window.common = (function(global) {
|
|||||||
const data = JSON.stringify({
|
const data = JSON.stringify({
|
||||||
id: common.challengeId,
|
id: common.challengeId,
|
||||||
name: common.challengeName,
|
name: common.challengeName,
|
||||||
completedWith: didCompleteWith,
|
|
||||||
challengeType: +common.challengeType,
|
challengeType: +common.challengeType,
|
||||||
solution,
|
solution,
|
||||||
timezone
|
timezone
|
||||||
@ -82,7 +66,24 @@ window.common = (function(global) {
|
|||||||
.fail(function() {
|
.fail(function() {
|
||||||
window.location.replace(window.location.href);
|
window.location.replace(window.location.href);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
common.showCompletion = function showCompletion() {
|
||||||
|
|
||||||
|
ga(
|
||||||
|
'send',
|
||||||
|
'event',
|
||||||
|
'Challenge',
|
||||||
|
'solved',
|
||||||
|
common.gaName,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$('#complete-courseware-dialog').modal('show');
|
||||||
|
$('#complete-courseware-dialog .modal-header').click();
|
||||||
|
|
||||||
|
$('#submit-challenge').off('click');
|
||||||
|
$('#submit-challenge').on('click', submitChallengeHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
return common;
|
return common;
|
||||||
|
Reference in New Issue
Block a user