-
Notifications
You must be signed in to change notification settings - Fork 0
/
round3.py
235 lines (208 loc) · 8.11 KB
/
round3.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import os
# File Paths
input_questions = 'questions.txt'
input_answers = 'answers.txt'
output_file = 'main1.html'
html_content = ""
# The main html stuff
html_content += """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rectangles in Reveal.js</title>
<link rel="stylesheet" href="./dist/reveal.css">
<link rel="stylesheet" href="./dist/theme/white.css">
<style>
:root {
--rectangle-width: 100%;
--rectangle-height: 100%;
}
.main-slide{
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(4, 1fr);
gap: 0px;
margin-top: -2.5%;
margin-left: -10%;
width: 105vw;
height: 105vh;
}
.rectangle {
background-color: #007bff;
color: white;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
height: var(--rectangle-height); /* Full height of grid cell */
width: var(--rectangle-width); /* Full width of grid cell */
transition: transform 0.3s ease, background-color 0.3s ease;
}
.rectangle:hover {
transform: scale(1.05);
}
.rectangle.transparent {
background-color: transparent;
opacity: 0; /* Adjust opacity as needed */
}
.option-buttons {
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
margin-top: 20px;
}
.option-buttons button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.disabled-link {
pointer-events: none;
color: grey;
text-decoration: none;
}
.remove-rectangle{
background-color: #4CAF50; /* Green background */
border: none; /* Remove border */
color: white; /* White text */
padding: 15px 32px; /* Padding */
text-align: center; /* Center text */
text-decoration: none; /* Remove underline */
display: inline-block; /* Display inline-block */
font-size: 16px; /* Font size */
margin: 4px 2px; /* Margin */
cursor: pointer; /* Pointer cursor on hover */
border-radius: 12px; /* Rounded corners */
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); /* Add shadow */
transition: 0.3s; /* Smooth transition for shadow and hover */
}
/* Hover effects */
.remove-rectangle:hover {
background-color: #45a049; /* Darker green background */
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); /* Change shadow */
}
/* Active state */
.remove-rectangle:active {
background-color: #3e8e41; /* Even darker green background */
transform: translateY(2px); /* Move down a bit when clicked */
}
/* Add focus outline */
.remove-rectangle:focus {
outline: none; /* Remove default focus outline */
box-shadow: 0 0 8px rgba(0, 140, 186, 0.5); /* Add custom focus outline */
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<!-- Main Slide with rectangles -->
"""
#Reading Questions
z1 = -1
questions = ["" for _ in range(16)]
with open(input_questions, 'r') as file:
lines1 = file.readlines()
for i in range(len(lines1)):
if (lines1[i].startswith('-')):
z1 += 1
questions[z1] += lines1[i]
#Reading Answers
z2 = -1
answers = ["" for _ in range(16)]
with open(input_answers, 'r') as file:
lines2 = file.readlines()
for i in range(len(lines2)):
if (lines2[i].startswith('-')):
z2 += 1
answers[z2] += lines2[i]
#Reading images
questions_with_images = -1
images = []
n_images = []
for i in range(0, len(questions)-1):
if questions[i][len(questions[i]) - 3] == '#':
questions_with_images += 1
images.append(i)
n_images.append(int(questions[i][len(questions[i]) - 2]))
print(images)
print(n_images)
# Rectangle Generation, Main Slide
html_content += '<section data-background="Round3BG.png">\n<div class="main-slide">\n'
for i in range(0,16):
html_content += '<div class="rectangle" data-link="a'+str(i+2)+'" data-index="'+str(i+1)+'" data-one-time="true">'+str(i+1)+'</div>'
html_content += '</div>\n</section>\n'
# Question Slide generation
for x in range(0, 16):
html_content += '<section id="a'+str(x+2)+'">\n'
html_content += '<section data-background="logoslides/logoslides.png"><h4>Question ' +str(x+ 1)+ '</h4><p class="r-fit-text">'+questions[x]+'</p></section>\n'
if x in images:
html_content += '<section data-background=images/image'+str(x)+'-0.png data-background-size="contain">\n'
html_content += '</section>\n'
html_content += '<section data-background="safety/safety0.png"></section>\n'
html_content += '<section><p>' + answers[x] + '</p>\n<div class="option-buttons"><button class="remove-rectangle" data-index="'+str(x+1)+'">Correct!(Removes Box)</button>\n</section>\n'
html_content += '</section>\n'
#Closing the html file off, adding some script
html_content += """
</div>
</div>
<script src="./dist/reveal.js"></script>
<script>
Reveal.initialize();
document.addEventListener('DOMContentLoaded', () => {
const mainSlide = document.querySelector('.main-slide');
mainSlide.addEventListener('click', (event) => {
const rectangle = event.target.closest('.rectangle');
if (rectangle) {
const link = rectangle.getAttribute('data-link');
const targetSlide = document.querySelector(`#${link}`);
if (targetSlide) {
const slideIndex = [...document.querySelectorAll('.slides > section')].indexOf(targetSlide);
Reveal.slide(slideIndex);
}
}
});
function addOptionEventListeners() {
const removeButtons = document.querySelectorAll('.remove-rectangle');
const changeColorButtons = document.querySelectorAll('.change-color');
removeButtons.forEach(button => {
button.addEventListener('click', () => {
const index = button.getAttribute('data-index') - 1;
const rectangle = mainSlide.querySelector(`.rectangle[data-index="${index + 1}"]`);
if (rectangle) {
rectangle.classList.add('transparent'); // Make rectangle transparent
}
});
});
changeColorButtons.forEach(button => {
button.addEventListener('click', () => {
const index = button.getAttribute('data-index') - 1;
const rectangle = mainSlide.querySelector(`.rectangle[data-index="${index + 1}"]`);
if (rectangle) {
rectangle.style.backgroundColor = 'red'; // Change to desired color
}
});
});
}
addOptionEventListeners();
const links = document.querySelectorAll('[data-one-time="true"]');
links.forEach(link => {
link.addEventListener('click', (event) => {
// Allow the link to function once
setTimeout(() => {
link.classList.add('disabled-link');
link.removeAttribute('data-link');
}, 100);
});
});
});
</script>
</body>
</html>
"""
#Adding to main file
with open(output_file, 'w') as file:
file.write(html_content)