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 = Flask(__name__)
|
||||||
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
||||||
|
|
||||||
|
# Global quiz object
|
||||||
|
questions = dict()
|
||||||
|
|
||||||
|
|
||||||
@ app.route('/')
|
@ app.route('/')
|
||||||
def index():
|
def index():
|
||||||
@ -24,7 +27,6 @@ def quiz():
|
|||||||
""" Handle upload and conversion of file + other stuff """
|
""" Handle upload and conversion of file + other stuff """
|
||||||
|
|
||||||
UPLOAD_STATUS = False
|
UPLOAD_STATUS = False
|
||||||
questions = dict()
|
|
||||||
|
|
||||||
# Make directory to store uploaded files, if not exists
|
# Make directory to store uploaded files, if not exists
|
||||||
if not os.path.isdir('./pdf'):
|
if not os.path.isdir('./pdf'):
|
||||||
@ -45,7 +47,6 @@ def quiz():
|
|||||||
# Get contents of file
|
# Get contents of file
|
||||||
uploaded_content = pdf2text(file_path, file_exten)
|
uploaded_content = pdf2text(file_path, file_exten)
|
||||||
questions = txt2questions(uploaded_content)
|
questions = txt2questions(uploaded_content)
|
||||||
print(questions)
|
|
||||||
|
|
||||||
# File upload + convert success
|
# File upload + convert success
|
||||||
if uploaded_content is not None:
|
if uploaded_content is not None:
|
||||||
@ -59,5 +60,13 @@ def quiz():
|
|||||||
size=len(questions))
|
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__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|||||||
@ -6,8 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<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" 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="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"
|
<link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&v=4" type="image/x-icon">
|
||||||
type="image/x-icon">
|
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css" />
|
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>
|
<script src="https://kit.fontawesome.com/22be60108b.js" crossorigin="anonymous"></script>
|
||||||
@ -20,7 +19,6 @@
|
|||||||
font-family: helvetica;
|
font-family: helvetica;
|
||||||
src: "{{ url_for('static', filename='fonts/helvetica.ttf')}}"
|
src: "{{ url_for('static', filename='fonts/helvetica.ttf')}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<nav class="navbar is-dark is-fixed-top has-text-centered" role="navigation" aria-label="main navigation">
|
<nav class="navbar is-dark is-fixed-top has-text-centered" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
@ -35,7 +33,6 @@
|
|||||||
<span></span>
|
<span></span>
|
||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</nav>
|
</nav>
|
||||||
<main role="main">
|
<main role="main">
|
||||||
<div class="hero">
|
<div class="hero">
|
||||||
|
|||||||
@ -28,7 +28,6 @@
|
|||||||
font-family: helvetica;
|
font-family: helvetica;
|
||||||
src: "{{ url_for('static', filename='fonts/helvetica.ttf')}}"
|
src: "{{ url_for('static', filename='fonts/helvetica.ttf')}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<nav class="navbar is-dark is-fixed-top has-text-centered" role="navigation" aria-label="main navigation">
|
<nav class="navbar is-dark is-fixed-top has-text-centered" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
@ -47,6 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
{% if uploaded == true %}
|
{% if uploaded == true %}
|
||||||
|
<form action="http://localhost:5000/result" method="POST">
|
||||||
{% for i in range(size) %}
|
{% for i in range(size) %}
|
||||||
<section class="section-1" id="section-1">
|
<section class="section-1" id="section-1">
|
||||||
<main>
|
<main>
|
||||||
@ -54,7 +54,6 @@
|
|||||||
<div class="scp-quizzes-data">
|
<div class="scp-quizzes-data">
|
||||||
<h3 class="is-size-6 has-text-weight-bold">{{ i+1 }}. {{ questions[i+1]['question'] }}</h3>
|
<h3 class="is-size-6 has-text-weight-bold">{{ i+1 }}. {{ questions[i+1]['question'] }}</h3>
|
||||||
<br />
|
<br />
|
||||||
<form>
|
|
||||||
{% for op in questions[i+1]['options'] %}
|
{% for op in questions[i+1]['options'] %}
|
||||||
{% if op == questions[i+1]['answer'] %}
|
{% if op == questions[i+1]['answer'] %}
|
||||||
<input type="radio" id="{{ questions[i+1]['answer'] }}" name="question{{ i+1 }}">
|
<input type="radio" id="{{ questions[i+1]['answer'] }}" name="question{{ i+1 }}">
|
||||||
@ -65,19 +64,20 @@
|
|||||||
<label> {{ op }}</label><br />
|
<label> {{ op }}</label><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</section>
|
</section>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<section class="section-1" id="section-1">
|
<section class="section-1" id="section-1">
|
||||||
<h1>Could not upload file</h1>
|
<h1>Could not upload file</h1>
|
||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="has-text-white has-text-centered"
|
<div class="has-text-white has-text-centered" style="margin-top: 50px; background-color: #363636; padding: 10px;">
|
||||||
style="margin-top: 50px; background-color: #363636; padding: 10px;">
|
|
||||||
MIT License © Copyright 2020 Fantastic Falcons
|
MIT License © Copyright 2020 Fantastic Falcons
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
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