-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathquiz.js
More file actions
49 lines (44 loc) · 1.19 KB
/
quiz.js
File metadata and controls
49 lines (44 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { get_response_message } from '../../helper/response';
window.jQuery(document).ready(($) => {
const { __ } = wp.i18n;
/**
* Quiz Frontend Review Action
* @since 1.4.0
*/
$(document).on('click', '.quiz-manual-review-action', function(e) {
e.preventDefault();
var $that = $(this);
var attempt_id = $that.attr('data-attempt-id');
var attempt_answer_id = $that.attr('data-attempt-answer-id');
var question_id = $that.attr('data-question-id');
var mark_as = $that.attr('data-mark-as');
var context = $that.attr('data-context');
var back_url = $that.attr('data-back-url');
$.ajax({
url: _tutorobject.ajaxurl,
type: 'POST',
data: {
attempt_id,
attempt_answer_id,
question_id,
mark_as,
context,
back_url,
action: 'review_quiz_answer',
},
beforeSend: function() {
$that.addClass('is-loading');
},
success: function(data) {
if (data.success && (data.data || {}).html) {
$that.closest('.tutor-quiz-attempt-details-wrapper').html(data.data.html);
return;
}
tutor_toast(__('Error!', 'tutor'), get_response_message(data), 'error');
},
complete: function() {
$that.removeClass('is-loading');
},
});
});
});