Fix - Merge Conflict Resolved
This commit is contained in:
commit
420b620d18
13
app.py
13
app.py
@ -12,6 +12,9 @@ UPLOAD_FOLDER = './pdf/'
|
||||
app = Flask(__name__)
|
||||
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
||||
|
||||
# Global quiz object
|
||||
questions = dict()
|
||||
|
||||
|
||||
@ app.route('/')
|
||||
def index():
|
||||
@ -24,7 +27,6 @@ def quiz():
|
||||
""" Handle upload and conversion of file + other stuff """
|
||||
|
||||
UPLOAD_STATUS = False
|
||||
questions = dict()
|
||||
|
||||
# Make directory to store uploaded files, if not exists
|
||||
if not os.path.isdir('./pdf'):
|
||||
@ -45,7 +47,6 @@ def quiz():
|
||||
# Get contents of file
|
||||
uploaded_content = pdf2text(file_path, file_exten)
|
||||
questions = txt2questions(uploaded_content)
|
||||
print(questions)
|
||||
|
||||
# File upload + convert success
|
||||
if uploaded_content is not None:
|
||||
@ -59,5 +60,13 @@ def quiz():
|
||||
size=len(questions))
|
||||
|
||||
|
||||
@app.route('/result', methods=['POST', 'GET'])
|
||||
def result():
|
||||
correct_q = 0
|
||||
for k, v in request.form.items():
|
||||
correct_q += 1
|
||||
return render_template('result.html', total=5, correct=correct_q)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
|
||||
@ -1,26 +1,24 @@
|
||||
<!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&v=4"
|
||||
type="image/x-icon">
|
||||
<link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&v=4" type="image/x-icon">
|
||||
<link rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css" />
|
||||
<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')}}"
|
||||
}
|
||||
|
||||
</style>
|
||||
<nav class="navbar is-dark is-fixed-top has-text-centered" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
@ -35,7 +33,6 @@
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<main role="main">
|
||||
<div class="hero">
|
||||
@ -95,6 +92,6 @@
|
||||
button.addEventListener('transitionend', toggleClass);
|
||||
button.addEventListener('transitionend', addClass);
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -1,7 +1,7 @@
|
||||
<!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" />
|
||||
@ -20,15 +20,14 @@
|
||||
});
|
||||
});
|
||||
</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">
|
||||
@ -47,6 +46,7 @@
|
||||
</div>
|
||||
</nav>
|
||||
{% if uploaded == true %}
|
||||
<form action="http://localhost:5000/result" method="POST">
|
||||
{% for i in range(size) %}
|
||||
<section class="section-1" id="section-1">
|
||||
<main>
|
||||
@ -54,7 +54,6 @@
|
||||
<div class="scp-quizzes-data">
|
||||
<h3 class="is-size-6 has-text-weight-bold">{{ i+1 }}. {{ questions[i+1]['question'] }}</h3>
|
||||
<br />
|
||||
<form>
|
||||
{% for op in questions[i+1]['options'] %}
|
||||
{% if op == questions[i+1]['answer'] %}
|
||||
<input type="radio" id="{{ questions[i+1]['answer'] }}" name="question{{ i+1 }}">
|
||||
@ -65,21 +64,22 @@
|
||||
<label> {{ op }}</label><br />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</section>
|
||||
{% endfor %}
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
{% else %}
|
||||
<section class="section-1" id="section-1">
|
||||
<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;">
|
||||
<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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
14
templates/result.html
Normal file
14
templates/result.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1> You got {{ correct }}/{{ total }} right !</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user