-
Notifications
You must be signed in to change notification settings - Fork 1
/
result.js
140 lines (110 loc) · 3.93 KB
/
result.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
let { PythonShell } = require("python-shell");
const { ipcRenderer } = require("electron");
var path = require("path");
function fade(element) {
var op = 1; // initial opacity
var timer = setInterval(function () {
if (op <= 0.1){
clearInterval(timer);
element.style.display = 'none';
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ")";
op -= op * 0.1;
}, 50);
}
function goHome(){
document.getElementById("loading").style.display="block";
ipcRenderer.send("go-home", "home");
window.close();
console.log("ipc message sent");
}
function loadResultData() {
console.log("Loading Test data");
var options = {
pythonPath: 'python',
scriptPath: path.join(__dirname, "/../python/"),
args: ["loadResultData"],
};
let pyshell = new PythonShell("main.py", options);
pyshell.on("message", function (message) {
console.log(message)
const output = eval(message)
console.log(output);
const subject = output[0];
const nOfQues = parseInt(output[1], 10);
const totalMarks = parseInt(output[2], 10);
const finalMarks = parseInt(output[3], 10);
const arrayLength = output.length;
let q = 1;
let n = 0;
let a = 1;
let box = 25;
document.body.style.backgroundColor = ""
if (subject === "Chemistry") {
document.body.style.backgroundColor = "#EA4335";
} else if (subject === "Physics") {
document.body.style.backgroundColor = "#FBBC05";
} else if (subject === "Maths") {
document.body.style.backgroundColor = "#4285F4";
} else if (subject === "Biology") {
document.body.style.backgroundColor = "#34A853";
} else if (subject === "IP") {
document.body.style.backgroundColor = "#4285F4";
} else if (subject === "English"){
document.body.style.backgroundColor = "#FBBC05";
}
buttonColor = document.body.style.backgroundColor;
document.getElementById('blob1A').style.backgroundColor = buttonColor;
document.getElementById('blob2A').style.backgroundColor = buttonColor;
document.getElementById('blob3A').style.backgroundColor = buttonColor;
document.getElementById('blob4A').style.backgroundColor = buttonColor;
console.log("bg:"+buttonColor)
//this value must be tweaked after backend
let offset1 = 4;
let offset2 = (nOfQues*4)+( offset1 + nOfQues);
console.log(nOfQues);
document.getElementById("test-subject-name").innerHTML = subject + " Test";
document.getElementById("totalMarks").innerHTML = totalMarks;
document.getElementById("finalMarks").innerHTML = finalMarks;
for (let index = 4; index < nOfQues + 4; index++) {
let question = output[index];
let id = "q" + q;
document.getElementById(id).innerHTML = question;
q++;
}
for (let i = offset1 + nOfQues; i < offset2; i++) {
let answer = output[i];
document.getElementById(a).innerHTML = answer;
a++;
}
for (let r = offset2; r < offset2+nOfQues; r++) {
let option = String(output[r]);
console.log(option)
if(option !== "undefined"){
let element = document.getElementById(option);
element.checked = true;
}
}
for (let c = offset2+nOfQues; c < offset2+(nOfQues*2); c++) {
let option =String(output[c]);
console.log(option)
let element = document.getElementById(option);
if(option !== "undefined"){
element.checked = true;
let color =document.getElementById(output[c]+"b");
console.log(output[c]+"b")
color.classList.remove("inputGroup");
color.classList.add("inputGroup-correct")
}
}
for (let b = 25 - nOfQues; b > 0; b--) {
let qc = "qc-" + box;
document.getElementById(qc).style.display = "none";
box = box - 1;
console.log(qc);
}
let overlay = document.getElementById("overlay");
fade(overlay)
});
}