-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpagegen.py
60 lines (52 loc) · 1.83 KB
/
pagegen.py
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
import json
from glob import glob
with open("index.html", "w", 1024, 'utf-8') as html_file:
html_file.write('''
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta charset="utf-8">
<title>CSN eksāmens</title>
<link rel="stylesheet" href="css/csn.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<style>
.image_zoom {
width: 100% !important;
height: 100% !important;
z-index: 1000;
}
</style>
</head><body>
''')
for file_name in glob("data/*.json"):
with open(file_name) as json_file:
data = json.load(json_file)
### TEXT
html_file.write('''
<img height=50% onclick="$(this).toggleClass('image_zoom');" src="{img}"; cursor: default;"/>
<div id="ex_left">
<div id="ex_pic_container"
style="background-image: url({img}); cursor: default;"></div>
<div id="ex_text_container">
<div id="test_text"><small>[{file}]</small> {text}</div>
</div>
</div>
<div id="ex_right">
<div id="test_table">
<div id="ex_q_container">'''.format(img=data['picturedata'], file=file_name, text=data['text'], ))
### QQQQ
for idx, val in enumerate(data['answ']):
addclass = ''
if data['coransw'] == idx + 1:
addclass = ' correct_answer'
html_file.write('''
<div id="EX_Q_A{num}" class="ex_q_variant";">{num}</div>
<div id="EX_Q_B{num}" class="ex_q_question {addclass}";">{ans}</div>
'''.format(num=idx+1, ans=val, addclass = addclass))
### FOOTER
html_file.write('''
<button onClick='$(".correct_answer").toggleClass("ex_q_question_neytral_cor")'>Show correct</button>
</div>
</div>
</div>
''')