check degrees

This commit is contained in:
Coding with Peter 2023-05-22 13:35:47 -07:00
parent 484cc4235f
commit e339795c94
2 changed files with 113 additions and 38 deletions

View File

@ -1,5 +1,5 @@
from lark import Lark, Transformer, v_args from lark import Lark, Transformer, v_args
import json import json, sys, re
@ -155,7 +155,7 @@ grammar = """
""" """
def parser():
dsl = """ dsl = """
course CSIS1 2 units course CSIS1 2 units
course CSIS2 4 units course CSIS2 4 units
@ -198,6 +198,54 @@ print()
print() print()
[print(d) for d in transformer.degrees] [print(d) for d in transformer.degrees]
def rule_check_units():
# Define the course units and passing grades
course_units = {
"A": 1,
"B": 2,
"C": 1,
"D": 3
}
# Define the students and their passed courses
students = {
"Peter": ["A", "B", "C"],
"Mark": ["D", "B"],
"Susan": ["A", "B"]
}
# Define the minimum units required to graduate
min_units_to_graduate = 4
calcs = {}
for student, passed_courses in students.items():
print("\n", student, passed_courses)
for c in passed_courses:
print(f"\t{c:15} {course_units[c]}")
print(f"\t{'Total':15} {sum(course_units[c] for c in passed_courses)}")
# Determine the graduating students
graduating_students = [
student for student, passed_courses in students.items()
if sum(course_units[course] for course in passed_courses) >= min_units_to_graduate
]
# Print the graduating students
if graduating_students:
print("The graduating students are:", ", ".join(graduating_students))
else:
print("No students meet the graduation requirements.")
""" """
@ -218,3 +266,29 @@ def compute_degree_progress(student_courses, degree):
return progress_percent return progress_percent
""" """
if __name__ == "__main__":
options = { 1: ['parsing example',parser] ,
2: ['rule check by units',rule_check_units] ,
}
print ('')
if len(sys.argv) > 1 and re.search(r'^\d+',sys.argv[1]):
resp = int(sys.argv[1])
print("\n\nPerforming: %s\n\n" % options[resp][0])
else:
print ('')
for key in options:
print(str(key) + '.\t' + options[key][0])
print('')
resp = input('Choose: ')
# Call the function in the options dict
options[ int(resp)][1]()

View File

@ -41,7 +41,7 @@ last_4_semesters_ids = [168, 65, 64, 62]
log_default_startdate = "2021-08-23T00:00:00-07:00" log_default_startdate = "2021-08-23T00:00:00-07:00"
lds_stamp = parser.parse(log_default_startdate) lds_stamp = parser.parse(log_default_startdate)
recvd_date = '2021-08-23T00:00:00Z' recvd_date = '2023-01-01T00:00:00Z'
num_threads = 25 num_threads = 25
max_log_count = 250000 max_log_count = 250000
@ -1789,8 +1789,9 @@ def track_user(id=0,qid=0):
url_addition = "" url_addition = ""
if 1: # hard code dates if 1: # hard code dates
start_date = "2023-01-01T00:00:00-07:00"
url_addition = "?start_time=%s&end_time=%s" % ( '2022-06-15T00:00:00-07:00', '2022-12-31T00:00:00-07:00' ) end_date = "2023-08-01T00:00:00-07:00"
url_addition = f"?start_time={start_date}&end_time={end_date}"
elif 'last_days_log' in info: elif 'last_days_log' in info:
print("There's existing log data for %s (%s)" % (info['name'] , info['sis_user_id'])) print("There's existing log data for %s (%s)" % (info['name'] , info['sis_user_id']))
print("Last day logged was: %s" % info['last_days_log']) print("Last day logged was: %s" % info['last_days_log'])