Fix - Formatted code

This commit is contained in:
PragatiVerma18 2020-10-11 14:06:59 +05:30
parent 657c995596
commit e45a7e0a4b
7 changed files with 197 additions and 159 deletions

10
app.py
View File

@ -35,7 +35,9 @@ def quiz():
# Retrieve file from request
uploaded_file = request.files['file']
file_path = os.path.join(
app.config['UPLOAD_FOLDER'], secure_filename(uploaded_file.filename))
app.config['UPLOAD_FOLDER'],
secure_filename(
uploaded_file.filename))
file_exten = uploaded_file.filename.rsplit('.', 1)[1].lower()
# Save uploaded file
@ -50,7 +52,11 @@ def quiz():
UPLOAD_STATUS = True
except Exception as e:
print(e)
return render_template('quiz.html', uploaded=UPLOAD_STATUS, questions=questions, size=len(questions))
return render_template(
'quiz.html',
uploaded=UPLOAD_STATUS,
questions=questions,
size=len(questions))
if __name__ == "__main__":

View File

@ -9,6 +9,7 @@ from nltk.tokenize import sent_tokenize, word_tokenize
import random
import numpy as np
class IncorrectAnswerGenerator:
''' This class contains the methods
for generating the incorrect answers
@ -35,14 +36,14 @@ class IncorrectAnswerGenerator:
for i in range(1, num_options + 1):
options_dict[i] = similar_words[i - 1][0]
except:
except BaseException:
self.all_sim = []
for word in self.all_words:
if word not in answer:
try:
self.all_sim.append(
(self.model.similarity(answer, word), word))
except:
except BaseException:
self.all_sim.append(
(0.0, word))
else:
@ -50,8 +51,8 @@ class IncorrectAnswerGenerator:
self.all_sim.sort(reverse=True)
for i in range(1, num_options+1):
options_dict[i] = self.all_sim[i-1][1]
for i in range(1, num_options + 1):
options_dict[i] = self.all_sim[i - 1][1]
replacement_idx = random.randint(1, num_options)

View File

@ -56,6 +56,7 @@ main {
input[type="radio"] {
display: none;
}
input[type="radio"] + label {
display: inline-block;
width: 100%;
@ -64,9 +65,11 @@ input[type="radio"] + label {
margin-bottom: 10px;
cursor: pointer;
}
input[type="radio"] + label:hover {
border: 1px solid #000000;
}
input[type="radio"]:checked + label {
background-image: none;
background-color: #0c0;

View File

@ -13,6 +13,7 @@ body {
font-family: "helvetica", sans-serif !important;
overflow-x: hidden !important;
}
.card {
border-radius: 10px;
margin-top: 100px !important;
@ -26,6 +27,7 @@ body {
justify-content: center;
align-items: center;
}
.card.has-text-centered h1 {
font-size: 1.75rem;
font-weight: bold;
@ -34,9 +36,11 @@ body {
.navbar {
margin-bottom: 20px !important;
}
.hide {
display: none;
}
.button {
position: relative;
display: flex;
@ -55,6 +59,7 @@ body {
overflow: hidden;
font-family: "Open Sans", sans-serif !important;
}
.button:before {
position: absolute;
content: "";
@ -64,68 +69,86 @@ body {
height: 100%;
background-color: #54d98c;
}
.button span {
position: absolute;
line-height: 0;
}
.button span i {
transform-origin: center center;
}
.button span:nth-of-type(1) {
top: 50%;
transform: translateY(-50%);
}
.button span:nth-of-type(2) {
top: 100%;
transform: translateY(0%);
font-size: 24px;
}
.button span:nth-of-type(3) {
display: none;
}
.active {
background-color: #2ecc71;
}
.active:before {
width: 100%;
transition: width 30s linear !important;
}
.active span:nth-of-type(1) {
top: -100%;
transform: translateY(-50%);
}
.active span:nth-of-type(2) {
top: 50%;
transform: translateY(-50%);
}
.active span:nth-of-type(2) i {
animation: loading 10000ms linear infinite !important;
}
.active span:nth-of-type(3) {
display: none;
}
.finished {
background-color: #54d98c;
}
.finished .submit {
display: none;
}
.finished .loading {
display: none;
}
.finished .check {
display: block !important;
font-size: 24px;
animation: scale 0.5s linear;
}
.finished .check i {
transform-origin: center center;
}
@keyframes loading {
100% {
transform: rotate(360deg);
}
}
@keyframes scale {
0% {
transform: scale(10);

View File

@ -1,27 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/style.css') }}" />
<link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" type="image/x-icon">
<link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4"
type="image/x-icon">
<script src="https://kit.fontawesome.com/22be60108b.js" crossorigin="anonymous"></script>
<title>MLH Quizzet</title>
</head>
</head>
<body>
<body>
<style type="text/css">
@font-face {
font-family: helvetica;
src:
"{{ url_for('static', filename='fonts/helvetica.ttf')}}"
src: "{{ url_for('static', filename='fonts/helvetica.ttf')}}"
}
</style>
<nav class="navbar is-dark is-fixed-top has-text-centered" role="navigation" aria-label="main navigation">
<div class="navbar-brand"><img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32"
width="64" style="margin: 10px">
<div class="navbar-brand">
<img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32" width="64"
style="margin: 10px">
<a class="navbar-item has-text-centered" href="{{ url_for('index') }}"><strong
class="is-size-3 has-text-centered">MLH Quizzet</strong></a>
<div class="navbar-burger" data-target="navMenu">
@ -48,7 +50,6 @@
<span class="file-name"> No file uploaded </span>
</label>
</div>
<script>
const fileInput = document.querySelector(
"#file-js-example input[type=file]"
@ -83,7 +84,8 @@
button.addEventListener('click', toggleClass);
button.addEventListener('transitionend', toggleClass);
button.addEventListener('transitionend', addClass);</script>
</body>
button.addEventListener('transitionend', addClass);
</script>
</body>
</html>

View File

@ -1,12 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/quiz.css') }}" />
<link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" type="image/x-icon">
<link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4"
type="image/x-icon">
<title>MLH Quizzet</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type='text/javascript'></script>
<script type="text/javascript">
@ -17,18 +18,20 @@
});
});
</script>
</head>
</head>
<body>
<body>
<style type="text/css">
@font-face {
font-family: helvetica;
src: "{{ url_for('static', filename='fonts/helvetica.ttf')}}"
}
</style>
<nav class="navbar is-dark is-fixed-top has-text-centered" role="navigation" aria-label="main navigation">
<div class="navbar-brand"><img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32"
width="64" style="margin: 7px">
<div class="navbar-brand">
<img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32" width="64"
style="margin: 7px">
<a class="navbar-item has-text-centered" href="{{ url_for('index') }}"><strong
class="is-size-3 has-text-centered">MLH
Quizzet</strong></a>
@ -69,10 +72,10 @@
<h1>Could not upload file</h1>
</section>
{% endif %}
<div class="has-text-white has-text-centered" style="margin-top: 50px; background-color: #363636; padding: 10px;">
MIT License © Copyright 2020 Fantastic Falcons
</div>
</body>
<div class="has-text-white has-text-centered"
style="margin-top: 50px; background-color: #363636; padding: 10px;">
MIT License © Copyright 2020 Fantastic Falcons
</div>
</body>
</html>

View File

@ -31,8 +31,8 @@ def txt2questions(doc: str, n=5, o=4) -> dict:
q = qGen.generate_questions_dict(doc)
for i in range(len(q)):
temp = []
for j in range(len(q[i+1]['options'])):
temp.append(q[i+1]['options'][j+1])
for j in range(len(q[i + 1]['options'])):
temp.append(q[i + 1]['options'][j + 1])
# print(temp)
q[i+1]['options'] = temp
q[i + 1]['options'] = temp
return q