Skip to content

Commit

Permalink
updated ui and added subject support
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhav-rm committed Dec 28, 2024
1 parent 44d31d8 commit f38115a
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 57 deletions.
95 changes: 85 additions & 10 deletions dectquiz.kv
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
text: 'Back to Home'
on_release: app.root.current = 'home'


<AboutScreen>:
canvas.before:
Color:
Expand All @@ -99,23 +100,96 @@
text: 'About DECT Quiz'
font_size: '28sp'
color: utils.get_color_from_hex('#333333')
size_hint_y: 0.1
size_hint_y: None
height: dp(40)
valign: 'middle'

Label:
text: 'DECT Quiz is an interactive quiz application designed to test your knowledge on various topics.'
font_size: '18sp'
color: utils.get_color_from_hex('#666666')
text_size: self.width, None
size_hint_y: 0.5
halign: 'center'
valign: 'middle'
ScrollView:
size_hint_y: 0.8
do_scroll_x: False
do_scroll_y: True

BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height
spacing: dp(15)
padding: [0, 0, 0, dp(20)]

Label:
text: 'DECT Quiz is an interactive quiz application designed to test your knowledge on various topics.'
font_size: '18sp'
color: utils.get_color_from_hex('#666666')
text_size: self.width, None
size_hint_y: None
height: self.texture_size[1]
halign: 'center'
valign: 'middle'

Label:
text: f'Total Questions: {root.total_questions}'
font_size: '18sp'
color: utils.get_color_from_hex('#333333')
size_hint_y: None
height: self.texture_size[1]
halign: 'left'

Label:
text: 'Questions per Subject:'
font_size: '18sp'
color: utils.get_color_from_hex('#333333')
size_hint_y: None
height: self.texture_size[1]
halign: 'left'

BoxLayout:
id: subject_counts_box
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height
spacing: dp(5)

Widget:
size_hint_y: None
height: dp(20)

Label:
text: 'GitHub Repository:'
font_size: '18sp'
color: utils.get_color_from_hex('#333333')
size_hint_y: None
height: self.texture_size[1]
halign: 'left'

Button:
text: 'https://github.com/vaibhav-rm/Dcet-prep-app'
font_size: '16sp'
size_hint_y: None
height: dp(40)
background_color: (0.2, 0.6, 1, 1)
on_release: root.open_github_link()

Widget:
size_hint_y: None
height: dp(20)

Label:
text: 'Made by Vaibhav\nGovernment Polytechnic Vijaypur'
font_size: '16sp'
color: utils.get_color_from_hex('#666666')
size_hint_y: None
height: self.texture_size[1]
halign: 'center'
valign: 'middle'

NavigationButton:
text: 'Back to Home'
size_hint_y: 0.1
size_hint_y: None
height: dp(50)
on_release: app.root.current = 'home'



<QuizScreen>:
canvas.before:
Color:
Expand Down Expand Up @@ -244,3 +318,4 @@
NavigationButton:
text: "Back to Home"
on_release: app.root.current = 'home'

31 changes: 29 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import webbrowser # Add this import at the top of the file
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.properties import StringProperty, ListProperty, NumericProperty
from kivy.properties import StringProperty, ListProperty, NumericProperty, DictProperty
from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
from kivy.animation import Animation
from kivy.clock import Clock
import random
from questions import questions_list
from collections import Counter

class HomeScreen(Screen):
pass
Expand All @@ -16,7 +18,32 @@ class StartQuizScreen(Screen):
pass

class AboutScreen(Screen):
pass
subject_counts = DictProperty()
total_questions = NumericProperty()

def on_pre_enter(self):
self.update_subject_counts()

def update_subject_counts(self):
subjects = [q.subject for q in questions_list]
self.subject_counts = dict(Counter(subjects))
self.total_questions = len(questions_list)
self.ids.subject_counts_box.clear_widgets()
for subject, count in self.subject_counts.items():
self.ids.subject_counts_box.add_widget(
Label(
text=f'{subject}: {count}',
font_size='16sp',
color=(0.4, 0.4, 0.4, 1),
size_hint_y=None,
height='30dp',
halign='left',
valign='middle'
)
)

def open_github_link(self):
webbrowser.open('https://github.com/vaibhav-rm/Dcet-prep-app')

class QuizScreen(Screen):
question_text = StringProperty()
Expand Down
Loading

0 comments on commit f38115a

Please sign in to comment.