This commit is contained in:
louiscklaw
2025-02-01 02:00:51 +08:00
parent a767348238
commit dc9c9468ce
124 changed files with 3736 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
# TEST CASE:
- Name: Import data to MySQL database server
- Procedure
- Configure DB connection by editing `constants.py`
- Run `main_db.py`
- Start DBMS of your choice and validate the result. (phpmyadmin)
- Expected output
- Python file ran without errors and the database,
- tables and records are successfully created in database.
- Name: GUI startup
- Procedure
- Run application via `main_gui.py`
- do nothing
- Expected output
- show "Please select" at programme option menu
- show "Please select" at Semester option menu
- a empty list of module shown
- Name: Select programme
- Procedure
- Run application via `main_gui.py`
- click programme option menu
- watch option available in option menu
- Expected output
- show a list of programme available in DB
- Name: after user select programme, user proceed to Select semester
- Procedure
- Run application via `main_gui.py`
- click programme option menu
- select "Higher Diploma in Cybersecurity" in option menu
- watch options available in "Semester"
- Expected output
- 1,2,4,5 should be available in semester list
- Name: user Selected semester, user proceed to input Grade
- Procedure
- run procedure "after user select programme, user proceed to Select semester"
- select semester "1"
- Expected output
- the modules available to semester should be listed in the "Modules" frame
- the "Please Select" should be shown in every "Grade" option menu.
- a empty box should be displayed in the Module, Credit and Grade for every modules row for the rest
- Name: user input grade, get total GPA
- Procedure
- run procedure "user Selected semester, user proceed to input Grade"
- input all gpa
- Expected output
- watch the label at the bottom of the form.
- when not all gpa got answered, the gpa won't be updated (keep 0.00)
- when app gpa answered, the result gpa will be displayed (1.23)
- Name: Screen update
- Procedure
- Run same procedure as stated in "GPA Calculation Test #2"
- re-select "Semester" to 2
- re-select "Semester" to 4
- Expected output
- when "Semester" is 2
- Module list should be updated (3 -> 2 items)
- Credit list should be updated (3 -> 2 items)
- Grade list should be selected "Please select"
- when "Semester" is 4
- Module list should be updated (2 -> 1 items)
- Credit list should be updated (2 -> 1 items)
- Grade list should be selected "Please select"
- Name: GPA Calculation Test #1
- Procedure
- Run application via `main_gui.py`
- Perform semester GPA calculation with the input data stated in excepted output.
- Validate the result with expected output.
- Input:
- Programme: Higher Diploma in Cybersecurity; Semester: 2
- Subjects:
- "Vocational Chinese Communication: Putonghua Presentations, Administrative and Technical Text Writing" → A-
- "English & Communication: Reports" → C+
- Expected output
- Semester GPA: 3.00 shown at bottom
- Name: GPA Calculation Test #2
- Procedure
- Run application via `main_gui.py`
- Perform semester GPA calculation with the input data stated in excepted output.
- Validate the result with expected output.
- Input:
- Programme: Higher Diploma in AI and Smart Technology; Semester: 1
- Subjects:
- "Vocational Chinese Communication: Putonghua Conversation and Reports" → A
- "English & Communication: Workplace Interaction" → C-
- "English & Communication: Workplace Correspondance" → B+
- Expected output
- Semester GPA: 3.00 shown at bottom

View File

@@ -0,0 +1 @@
print('helloworld')

View File

@@ -0,0 +1,35 @@
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
options = ['Option 1', 'Option 2', 'Option 3']
variable = tk.StringVar(value=options[0])
def on_option_changed(*args):
print('helloworld')
# This function will be called whenever the selected option changes
# We will use it to update the option list based on the selected option
# Get the selected option
selected_option = variable.get()
# Update the option list based on the selected option
if selected_option == 'Option 1':
new_options = ['Option 1', 'Option 2', 'Option 3']
elif selected_option == 'Option 2':
new_options = ['Option 4', 'Option 5', 'Option 6']
else:
new_options = ['Option 7', 'Option 8', 'Option 9']
# Update the option list in the widget
combobox.configure(values=new_options)
# Create the widget
combobox = ttk.Combobox(root, textvariable=variable, values=options)
combobox.pack()
# Bind the on_option_changed function to the variable
variable.trace('w', on_option_changed)
root.mainloop()

View File

@@ -0,0 +1,41 @@
import tkinter as tk
from tkinter import ttk
from tkinter.messagebox import showinfo
from calendar import month_name
root = tk.Tk()
# config the root window
root.geometry('300x200')
root.resizable(False, False)
root.title('Combobox Widget')
# label
label = ttk.Label(text="Please select a month:")
label.pack(fill=tk.X, padx=5, pady=5)
# create a combobox
selected_month = tk.StringVar()
month_cb = ttk.Combobox(root, textvariable=selected_month)
# get first 3 letters of every month name
month_cb['values'] = [month_name[m][0:3] for m in range(1, 13)]
# prevent typing a value
month_cb['state'] = 'readonly'
# place the widget
month_cb.pack(fill=tk.X, padx=5, pady=5)
# bind the selected value changes
def month_changed(event):
""" handle the month changed event """
showinfo(
title='Result',
message=f'You selected {selected_month.get()}!'
)
month_cb.bind('<<ComboboxSelected>>', month_changed)
root.mainloop()

View File

@@ -0,0 +1,32 @@
from pprint import pprint
import constants
from db import MySQLConnection
from models import Programme
from models import Module
db = MySQLConnection(
host=constants.DB_HOST,
user=constants.DB_USER,
password=constants.DB_PASS
)
list_program = Programme.fetchall(db)
list_module = Module.fetchall(db)
# print(list_program[0].get_modules())
# print(list_program[0].get_modules_by_semester(1))
# print(list_program[0].get_name())
# __eq__
# print(list_program[0] == list_program[0])
# modules
# print(list_program[0].get_modules()[1][0][0].get_id())
# pprint(list_program[0].get_modules())
# pprint(list_program[0].get_modules_by_semester(1)[0])
# print(list_program[0].get_modules()[1][0][0].get_credit())
db.close()
#

Binary file not shown.