Skip to content
Snippets Groups Projects
Commit 80b003b1 authored by reed.lawrence's avatar reed.lawrence
Browse files

Added a progress bar to track the number of questions answered by the user....

Added a progress bar to track the number of questions answered by the user. Added a new variable 'number_questions' that tracks the number of questions that the user has attempted.
parent 4fd001a1
No related branches found
No related tags found
No related merge requests found
...@@ -73,6 +73,7 @@ class QuizzerApp(App): ...@@ -73,6 +73,7 @@ class QuizzerApp(App):
correct = BooleanProperty(False) correct = BooleanProperty(False)
score = NumericProperty(0) score = NumericProperty(0)
number_questions = NumericProperty(0)
def build(self): def build(self):
inspector.create_inspector(Window, self) inspector.create_inspector(Window, self)
...@@ -97,6 +98,7 @@ class QuizzerApp(App): ...@@ -97,6 +98,7 @@ class QuizzerApp(App):
self.correct = answer == question[2] self.correct = answer == question[2]
if self.correct: if self.correct:
self.score += 1 self.score += 1
self.number_questions += 1
Clock.schedule_once(lambda delta: self.unpause(), PAUSE_TIME) Clock.schedule_once(lambda delta: self.unpause(), PAUSE_TIME)
def unpause(self): def unpause(self):
......
...@@ -86,6 +86,11 @@ ScreenManager: ...@@ -86,6 +86,11 @@ ScreenManager:
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)) 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: Label:
text: f'Score: {app.score}' text: f'Score: {app.score}'
ProgressBar:
id: progress_bar
min: 0
max: 5
value: app.number_questions
GridLayout: GridLayout:
rows: 2 rows: 2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment