-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractise-questions.js
More file actions
109 lines (69 loc) · 2.63 KB
/
practise-questions.js
File metadata and controls
109 lines (69 loc) · 2.63 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var firebaseConfig = {
apiKey: "AIzaSyCgRDhjFb26u8iiMkoJP3TpfSlZnU96P-w",
authDomain: "medicodes-77362.firebaseapp.com",
projectId: "medicodes-77362",
storageBucket: "medicodes-77362.appspot.com",
messagingSenderId: "387859315681",
appId: "1:387859315681:web:23df9db36792f34e2930a0",
measurementId: "G-0RZHG2KT93"
};
firebase.initializeApp(firebaseConfig);
firebase.analytics;
//Get the Student ID
//Get the list of questions
//Get the list of questions solved by student
var id = sessionStorage.getItem("email");
var database = firebase.database();
ref = database.ref("Practise_Questions/");
ref.on('value', getdatacontest, errdata);
function getdatacontest(data) {
console.log(id);
firebase.database().ref("students/" + id).once('value').then(function (snapshot) {
var arr = snapshot.val().Practise_questions.split(" ");
const db = data.val();
const keys = Object.keys(db);
for (let i = 0; i < keys.length; i++) {
var k = keys[i];
var QuestionName = db[k].Question_name;
var table = document.getElementById("practise-table");
var a = document.createElement("tr");
var b = document.createElement("th");
var c = document.createElement("td");
var d = document.createElement("td");
var e = document.createElement("td");
var g = document.createElement("a");
var h = document.createElement("i");
if(arr.includes(k)){
a.className = "done";
g.className = "btn btn-success";
h.className = "fa fa-thumbs-up";
}
else{
a.className = "not-done";
g.className = "btn btn-danger";
h.className = "fa fa-question-circle";
}
a.id = k
a.onclick = function (){
sessionStorage.setItem("Question-type", "Practise_Questions");
sessionStorage.setItem("id", this.id);
location.href = "question.html";
}
b.innerText = i +1;
b.scope = "row";
c.innerText = QuestionName;
d.innerText = 100;
//btn btn-success
// fa fa-thumbs-up
e.appendChild(g);
g.appendChild(h);
a.appendChild(b);
a.appendChild(c);
a.appendChild(d);
a.appendChild(e);
table.appendChild(a);
}
});
}
function errdata(){
}