-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_mc.js
33 lines (28 loc) · 1001 Bytes
/
check_mc.js
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
$(".choice").on("click", function() {
event.preventDefault();
var question_id = $(this).attr("question_id");
var choice_text = $(this).text();
if (window[question_id].answer === choice_text) {
$(this).addClass("pure-button-primary");
var exp_id = "#exp" + question_id;
$(exp_id).html(formatAnswer(window[question_id].explanation));
}
});
function formatHint(hint_text) {
return "<b>Hint:</b> " + hint_text;
}
function formatAnswer(ans_text) {
return "<b>Explanation:</b> " + ans_text;
}
$(".hint-button").on("click", function() {
event.preventDefault();
var question_id = $(this).attr("question_id");
var hint_id = "#hint" + question_id;
$(hint_id).html(formatHint(window[question_id].hint));
});
$(".exp-button").on("click", function() {
event.preventDefault();
var question_id = $(this).attr("question_id");
var exp_id = "#exp" + question_id;
$(exp_id).html(formatAnswer(window[question_id].explanation));
});