Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
Quizzer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomaskmatthew
Quizzer
Commits
30227ed9
Commit
30227ed9
authored
4 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Prefer method parameters over field accesses.
parent
6326d043
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+23
-7
23 additions, 7 deletions
main.py
quizzer.kv
+6
-6
6 additions, 6 deletions
quizzer.kv
with
29 additions
and
13 deletions
main.py
+
23
−
7
View file @
30227ed9
...
@@ -67,6 +67,10 @@ PAUSE_TIME = 0.75 # seconds
...
@@ -67,6 +67,10 @@ PAUSE_TIME = 0.75 # seconds
class
QuizzerApp
(
App
):
class
QuizzerApp
(
App
):
DEFAULT_QUESTION
=
(
'
What is your favourite color?
'
,
(
'
Blue
'
,
'
Blue
'
,
'
Blue
'
,
'
Blue
'
),
'
Blue
'
)
DEFAULT_QUESTION
=
(
'
What is your favourite color?
'
,
(
'
Blue
'
,
'
Blue
'
,
'
Blue
'
,
'
Blue
'
),
'
Blue
'
)
include_gui_topic
=
BooleanProperty
(
True
)
include_color_topic
=
BooleanProperty
(
False
)
include_tree_topic
=
BooleanProperty
(
False
)
questions
=
ListProperty
([])
questions
=
ListProperty
([])
paused
=
BooleanProperty
(
False
)
paused
=
BooleanProperty
(
False
)
correct
=
BooleanProperty
(
False
)
correct
=
BooleanProperty
(
False
)
...
@@ -74,20 +78,32 @@ class QuizzerApp(App):
...
@@ -74,20 +78,32 @@ class QuizzerApp(App):
def
build
(
self
):
def
build
(
self
):
inspector
.
create_inspector
(
Window
,
self
)
inspector
.
create_inspector
(
Window
,
self
)
def
on_start
(
self
):
self
.
reshuffle
()
def
reshuffle
(
self
):
def
reshuffle
(
self
):
questions
=
[]
questions
=
[]
# Use a plain list, not a list property, for the computations.
if
self
.
root
.
ids
.
gui
.
active
:
if
self
.
include_gui_topic
:
questions
+=
GUI_QUESTIONS
questions
+=
GUI_QUESTIONS
elif
self
.
root
.
ids
.
color
.
active
:
elif
self
.
include_color_topic
:
questions
+=
COLOR_QUESTIONS
questions
+=
COLOR_QUESTIONS
elif
self
.
root
.
ids
.
tree
.
active
:
elif
self
.
include_tree_topic
:
questions
+=
TREE_QUESTIONS
questions
+=
TREE_QUESTIONS
shuffle
(
questions
)
shuffle
(
questions
)
self
.
questions
=
questions
self
.
questions
=
questions
def
on_start
(
self
):
self
.
reshuffle
()
def
toggle_gui_topic
(
self
,
include_gui_topic
):
self
.
include_gui_topic
=
include_gui_topic
self
.
reshuffle
()
def
toggle_color_topic
(
self
,
include_color_topic
):
self
.
include_color_topic
=
include_color_topic
self
.
reshuffle
()
def
toggle_tree_topic
(
self
,
include_tree_topic
):
self
.
include_tree_topic
=
include_tree_topic
self
.
reshuffle
()
def
answer
(
self
,
answer
):
def
answer
(
self
,
answer
):
question
=
self
.
questions
[
-
1
]
if
len
(
self
.
questions
)
>
0
else
self
.
DEFAULT_QUESTION
question
=
self
.
questions
[
-
1
]
if
len
(
self
.
questions
)
>
0
else
self
.
DEFAULT_QUESTION
self
.
paused
=
True
self
.
paused
=
True
...
...
This diff is collapsed.
Click to expand it.
quizzer.kv
+
6
−
6
View file @
30227ed9
...
@@ -12,10 +12,10 @@ ScreenManager:
...
@@ -12,10 +12,10 @@ ScreenManager:
CheckBox:
CheckBox:
id: gui
id: gui
group: 'categories'
group: 'categories'
active:
True
active:
app.include_gui_topic
size_hint: (None, None)
size_hint: (None, None)
size: (sp(32), gui_label.height)
size: (sp(32), gui_label.height)
on_active: app.
reshuffle(
)
on_active: app.
toggle_gui_topic(self.active
)
Label:
Label:
id: gui_label
id: gui_label
text: 'Graphical User Interfaces'
text: 'Graphical User Interfaces'
...
@@ -28,10 +28,10 @@ ScreenManager:
...
@@ -28,10 +28,10 @@ ScreenManager:
CheckBox:
CheckBox:
id: color
id: color
group: 'categories'
group: 'categories'
active:
False
active:
app.include_color_topic
size_hint: (None, None)
size_hint: (None, None)
size: (sp(32), color_label.height)
size: (sp(32), color_label.height)
on_active: app.
reshuffle(
)
on_active: app.
toggle_color_topic(self.active
)
Label:
Label:
id: color_label
id: color_label
text: 'RGBA Quadruples'
text: 'RGBA Quadruples'
...
@@ -44,10 +44,10 @@ ScreenManager:
...
@@ -44,10 +44,10 @@ ScreenManager:
CheckBox:
CheckBox:
id: tree
id: tree
group: 'categories'
group: 'categories'
active:
False
active:
app.include_tree_topic
size_hint: (None, None)
size_hint: (None, None)
size: (sp(32), tree_label.height)
size: (sp(32), tree_label.height)
on_active: app.
reshuffle(
)
on_active: app.
toggle_tree_topic(self.active
)
Label:
Label:
id: tree_label
id: tree_label
text: 'Containment Hierarchies'
text: 'Containment Hierarchies'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment