Skip to content
Snippets Groups Projects
Commit c31990ea authored by skhourshed2's avatar skhourshed2
Browse files

Reset score and progress bar after answering 5 questions

parent 1e4d8ae4
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ from kivy.clock import Clock
from kivy.properties import BooleanProperty, ListProperty, NumericProperty
from kivy.modules import inspector
from kivy.core.window import Window
from kivy.uix.popup import Popup
GUI_QUESTIONS = [
......@@ -108,13 +109,16 @@ class QuizzerApp(App):
self.reshuffle()
def answer(self, answer):
self.questions_answered += 1
question = self.questions[-1] if len(self.questions) > 0 else QuizzerApp.DEFAULT_QUESTION
self.paused = True
self.correct = answer == question[2]
if self.correct:
self.score += 10
Clock.schedule_once(lambda delta: self.unpause(), PAUSE_TIME)
self.questions_answered += 1
if self.questions_answered == 5:
self.score = 0
self.questions_answered = 0
def unpause(self):
self.paused = False
......
......@@ -89,6 +89,8 @@ ScreenManager:
text_size: (self.width, None)
halign: 'center'
color: (0.0, 0.0, 0.75, 1.0) if not app.paused else ((0.0, 1.0, 0.0, 1.0) if app.correct else (0.5, 0.0, 0.0, 1.0))
Label:
text: f'You answered {app.questions_answered} questions'
ProgressBar:
value: app.questions_answered
max: 5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment