diff --git a/DynamoDB.py b/DynamoDB.py index b9c52f1..8012a16 100644 --- a/DynamoDB.py +++ b/DynamoDB.py @@ -1,25 +1,50 @@ from boto3 import resource from boto3.dynamodb.conditions import Attr, Key +import math course_table = resource('dynamodb').Table('Courses') -def insert(): +def insert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseStartTime, courseEndTime, courseIsOpen): courseInsertion = course_table.put_item( Item = { - 'CourseId' : 'CSE1010', # partition key - 'Section' : '001L', # sort key? - 'Level' : '1000', # useful attribute for searching - 'Department' : 'CSE', # useful attribute for searching - 'Professor' : 'Gregory Jackson', # TODO: support multiple instructors - 'StudentsEnrolled' : 0, # useful attribute for professor - 'StartTime' : 1630, # is storing times in the form of 24-hour time easier? it's simple to convert when necessary - 'EndTime' : 1720, - 'OpenStatus' : True # this attribute could be useful for hiding unavailable courses + 'CourseId' : courseId, # partition key + 'Section' : courseSection, # sort key? + 'Level' : courseLevel, # useful attribute for searching + 'Department' : courseDepartment, # useful attribute for searching + 'Professor' : courseProfessor, # TODO: support multiple instructors + 'StudentsEnrolled' : courseEnrolledStudents, # useful attribute for professor + 'MaxStudents' : courseMaxStudents, # can calculate OpenStatus using some logic + 'StartTime' : courseStartTime, # is storing times in the form of 24-hour time easier? it's simple to convert when necessary + 'EndTime' : courseEndTime, + 'OpenStatus' : courseIsOpen # this attribute could be useful for hiding unavailable courses } ) print(f"Insert response: {courseInsertion}") if __name__ == '__main__': - insert() + + # NONE OF THE INFO COLLECTING WILL LIKELY BE DONE IN PYTHON, THIS IS PROBABLY VUE STUFF. JUST FOR DEMO + courseDepartment = input("Enter department: ").upper() + courseNumber = int(input("\nEnter course number: ")) # TODO: Error handling for invalid inputs + courseSection = input("\nEnter course section: ") + if len(courseSection) == 1: + courseSection = '00' + courseSection + elif len(courseSection) == 2: + courseSection = '0' + courseSection + courseType = input("\nSelect the type of course if needed: Laboratory, Discussion: ") + if courseType == "Laboratory": + courseSection += 'L' + elif courseType == "Discussion": + courseSection += 'D' + courseLevel = math.floor(courseNumber / 1000) * 1000 + courseId = courseDepartment + str(courseNumber) + courseProfessor = input("\nEnter professor: ") # TODO: support multiple instructors + courseMaxStudents = int(input("\nEnrollment slots: ")) + courseStartTime = input("\nStart time: ") # TODO: Turn 12-hour time into 24-hour time integer + courseEndTime = input("\nEnd time: ") # TODO: Turn 12-hour time into 24-hour time integer + courseEnrolledStudents = 0 + courseIsOpen = bool(courseMaxStudents - courseEnrolledStudents) + + insert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseStartTime, courseEndTime, courseIsOpen)