-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexams.js
56 lines (50 loc) · 1.83 KB
/
exams.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(function() {
data = exams;
printQuestions = function(subject){
window.scrollTo(0, 0);
$("#brand").text("Back to subjects!");
$(".subjects-table").hide();
$("#subject-title").text(subject);
for (var i = 0; i < data[subject]["questions"].length; i++) {
badge = document.createElement('table');
badge.className = 'subject-question table table-curved';
badge.innerHTML = '<tr class="question-row table-light">' +
'<td class="question">' + data[subject]["questions"][i].question + '</td>' +
'</tr><tr class="question-row">' +
'<td class="answer-text answer-row table-hidden">' + data[subject]["questions"][i].answer + '<br>' +
'Source: ' + data[subject]["questions"][i].sources + '</td>' +
'<td class="alt-text answer-row">Click here to reveal answer</td>' +
'</tr>';
document.getElementById(subject).appendChild(badge);
}
$(".answer-row").click(function(){
$(this).toggleClass('table-hidden');
$(this).siblings().toggleClass('table-hidden');
});
$(".navbar-brand").click(function(){
$('.navbar-brand').off('click');
$('#brand').text("Welcome!");
$(".subjects-table").show();
showSubjects(subject);
});
}
showSubjects = function(){
window.scrollTo(0, 0);
$("table").remove(".subject-question");
$("#subject-title").text("click on a subject");
}
for (var subject in data) {
var questions = data[subject]["questions"].length;
var badge = document.createElement('tr');
badge.className = subject;
badge.innerHTML = '<td class="subject">' + subject + '</td>' +
'<td class="questions">' + questions + '</td>' +
'<td class="importance">' + data[subject].importance + '</td>';
document.getElementById("subjects").appendChild(badge);
let str = subject
console.log("adding " + str);
$("."+str).click(function(){
printQuestions(str);
});
}
})();