Fix - Merge Conflict Resolved

This commit is contained in:
PragatiVerma18 2020-10-11 22:14:03 +05:30
commit 420b620d18
4 changed files with 159 additions and 139 deletions

13
app.py
View File

@ -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)

View File

@ -1,40 +1,37 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<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&amp;v=4" <link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;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> <title>MLH Quizzet</title>
<title>MLH Quizzet</title> </head>
</head>
<body> <body>
<style type="text/css"> <style type="text/css">
@font-face { @font-face {
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"> <img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32" width="64"
<img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32" width="64" style="margin: 10px">
style="margin: 10px"> <a class="navbar-item has-text-centered" href="{{ url_for('index') }}"><strong
<a class="navbar-item has-text-centered" href="{{ url_for('index') }}"><strong class="is-size-3 has-text-centered">MLH Quizzet</strong></a>
class="is-size-3 has-text-centered">MLH Quizzet</strong></a> <a class="github-fork-ribbon" href="https://github.com/PragatiVerma18/Fantastic-Falcons-1.0"
<a class="github-fork-ribbon" href="https://github.com/PragatiVerma18/Fantastic-Falcons-1.0" data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a> <div class="navbar-burger" data-target="navMenu">
<div class="navbar-burger" data-target="navMenu"> <span></span>
<span></span> <span></span>
<span></span> <span></span>
<span></span>
</div>
</div> </div>
</nav> </nav>
<main role="main"> <main role="main">
@ -56,45 +53,45 @@
</span> </span>
<span class="file-label"> Choose a file… </span> <span class="file-label"> Choose a file… </span>
</span> </span>
<span class="file-name"> No file uploaded </span> <span class="file-name"> No file uploaded </span>
</label> </label>
</div> </div>
<script> <script>
const fileInput = document.querySelector( const fileInput = document.querySelector(
"#file-js-example input[type=file]" "#file-js-example input[type=file]"
); );
fileInput.onchange = () => { fileInput.onchange = () => {
if (fileInput.files.length > 0) { if (fileInput.files.length > 0) {
const fileName = document.querySelector( const fileName = document.querySelector(
"#file-js-example .file-name" "#file-js-example .file-name"
); );
fileName.textContent = fileInput.files[0].name; fileName.textContent = fileInput.files[0].name;
} }
}; };
</script> </script>
<button class="button has-text-centered is-large is-fullwidth is-dark"> <button class="button has-text-centered is-large is-fullwidth is-dark">
<span class="submit has-text-centered" type="submit" name="upload file">Submit</span> <span class="submit has-text-centered" type="submit" name="upload file">Submit</span>
<span class="loading"><i class="fa fa-refresh"></i></span> <span class="loading"><i class="fa fa-refresh"></i></span>
<span class="check"><i class="fa fa-check"></i></span> <span class="check"><i class="fa fa-check"></i></span>
</button> </button>
</form> </form>
</div> </div>
</main> </main>
<script>const button = document.querySelector('.button'); <script>const button = document.querySelector('.button');
const submit = document.querySelector('.submit'); const submit = document.querySelector('.submit');
function toggleClass() { function toggleClass() {
this.classList.toggle('active'); this.classList.toggle('active');
} }
function addClass() { function addClass() {
this.classList.add('finished'); this.classList.add('finished');
} }
button.addEventListener('click', toggleClass); button.addEventListener('click', toggleClass);
button.addEventListener('transitionend', toggleClass); button.addEventListener('transitionend', toggleClass);
button.addEventListener('transitionend', addClass); button.addEventListener('transitionend', addClass);
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,52 +1,52 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<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/quiz.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" <link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;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" />
<title>MLH Quizzet</title> <title>MLH Quizzet</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type='text/javascript'></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type='text/javascript'></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$('label').click(function () { $('label').click(function () {
$('label').removeClass('worngans'); $('label').removeClass('worngans');
$(this).addClass('worngans'); $(this).addClass('worngans');
});
}); });
</script> });
</head> </script>
</head>
<body> <body>
<style type="text/css"> <style type="text/css">
@font-face { @font-face {
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"> <img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32" width="64"
<img src="https://avatars0.githubusercontent.com/u/65834464?s=200&amp;v=4" height="32" width="64" style="margin: 7px">
style="margin: 7px"> <a class="navbar-item has-text-centered" href="{{ url_for('index') }}"><strong
<a class="navbar-item has-text-centered" href="{{ url_for('index') }}"><strong class="is-size-3 has-text-centered">MLH
class="is-size-3 has-text-centered">MLH Quizzet</strong></a>
Quizzet</strong></a> <a class="github-fork-ribbon" href="https://github.com/PragatiVerma18/Fantastic-Falcons-1.0"
<a class="github-fork-ribbon" href="https://github.com/PragatiVerma18/Fantastic-Falcons-1.0" data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a> <div class="navbar-burger" data-target="navMenu">
<div class="navbar-burger" data-target="navMenu"> <span></span>
<span></span> <span></span>
<span></span> <span></span>
<span></span>
</div>
</div> </div>
</nav> </div>
{% if uploaded == true %} </nav>
{% 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,32 +54,32 @@
<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 }}"> <label for="{{ questions[i+1]['answer'] }}">
<label for="{{ questions[i+1]['answer'] }}"> {{ op }}</label><br />
{{ op }}</label><br /> {% else %}
{% else %} <input type="radio" name="question{{ i+1 }}">
<input type="radio" name="question{{ i+1 }}"> <label> {{ op }}</label><br />
<label> {{ op }}</label><br /> {% endif %}
{% endif %} {% endfor %}
{% endfor %}
</form>
</div> </div>
</div> </div>
</main> </main>
</section> </section>
{% endfor %} {% endfor %}
{% else %} <button type="submit">Submit</button>
<section class="section-1" id="section-1"> </form>
<h1>Could not upload file</h1>
</section> {% else %}
{% endif %} <section class="section-1" id="section-1">
<div class="has-text-white has-text-centered" <h1>Could not upload file</h1>
style="margin-top: 50px; background-color: #363636; padding: 10px;"> </section>
MIT License © Copyright 2020 Fantastic Falcons {% endif %}
</div> <div class="has-text-white has-text-centered" style="margin-top: 50px; background-color: #363636; padding: 10px;">
</body> MIT License © Copyright 2020 Fantastic Falcons
</div>
</body>
</html> </html>

14
templates/result.html Normal file
View 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>