diff --git a/app.py b/app.py index c25bd80..1ee0138 100644 --- a/app.py +++ b/app.py @@ -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__": diff --git a/incorrect_answer_generation.py b/incorrect_answer_generation.py index b1e0f4f..149dd43 100644 --- a/incorrect_answer_generation.py +++ b/incorrect_answer_generation.py @@ -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) diff --git a/static/css/quiz.css b/static/css/quiz.css index e4ef607..a1845dc 100644 --- a/static/css/quiz.css +++ b/static/css/quiz.css @@ -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; diff --git a/static/css/style.css b/static/css/style.css index 31dec16..76b4d54 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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); diff --git a/templates/index.html b/templates/index.html index 7244376..66062c2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,89 +1,91 @@ -
- - - - - - -