Skip to content

Commit

Permalink
automated to populate and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Couillard authored and Nicholas Couillard committed Oct 11, 2023
1 parent 66ae00d commit 98ff31c
Showing 1 changed file with 55 additions and 33 deletions.
88 changes: 55 additions & 33 deletions CourseFunctions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from boto3 import resource
from boto3.dynamodb.conditions import Attr, Key
import math
import random

course_table = resource('dynamodb').Table('Courses')
# NOTE: another table for users and professors may be necessary. In order to do this we might need functionality to introduce salt and hashing for security

def courseInsert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseIsOpen, courseFormat, prerequisites, courseStartTime=0, courseEndTime=0, courseScheduledDays='None', courseLocation='None'):
def courseInsert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseIsOpen, courseFormat, prerequisites='None', courseStartTime=0, courseEndTime=0, courseScheduledDays='None', courseLocation='None'):
courseInsertion = course_table.put_item(
Item = {
'CourseId' : courseId, # partition key
Expand All @@ -15,12 +16,12 @@ def courseInsert(courseId, courseSection, courseLevel, courseDepartment, courseP
'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
'CourseFormat' : courseFormat,
'Prerequisites' : prerequisites, # this will be a list of courses
'StartTime' : courseStartTime, # is storing times in the form of 24-hour time easier? it's simple to convert when necessary
'EndTime' : courseEndTime,
'CourseScheduledDays' : courseScheduledDays, # this will likely be a list, but im lazy so for now it's a string
'PreRequisites' : prerequisites, # this will be a list of courses
'CourseLocation' : courseLocation # could increase functionality by separating into building and room number, to allow searching by building
}
)
Expand Down Expand Up @@ -73,34 +74,55 @@ def enrollStudent(courseId, courseSection):

if __name__ == '__main__':

# NOTE: 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: ")) # NOTE: In vue, make text box that only accepts integers to avoid errors
# 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: "))
# courseFormat = input("\nIs the course online asynchronous, online synchronous, or in-person?: ") # this will be easier to integrate with a few select vue options
# if courseFormat == "In-person" or courseFormat == "Online synchronous":
# courseScheduledDays = input("\nDays the course will meet: ")
# courseStartTime = input("\nStart time: ") # TODO: Turn 12-hour time into 24-hour time integer. Will be easy with vue
# courseEndTime = input("\nEnd time: ") # TODO: Turn 12-hour time into 24-hour time integer. Will be easy with vue
# courseEnrolledStudents = 0
# courseIsOpen = bool(courseMaxStudents - courseEnrolledStudents)
# if courseFormat == "In-person":
# courseLocation = input("Where will the course be held?: ")
#NOTE: NONE OF THE INFO COLLECTING WILL LIKELY BE DONE IN PYTHON, THIS IS PROBABLY VUE STUFF. JUST FOR DEMO
for i in range(1000):
courseDepartment = random.choice(['CSE', 'COMM', 'ANTH', 'STAT', 'SPAN', 'GERM', 'ERTH'])
courseNumber = random.randint(1000,5000)
courseSection = 1
if len(str(courseSection)) == 1:
courseSection = '00' + str(courseSection)
elif len(str(courseSection)) == 2:
courseSection = '0' + str(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 = random.choice(['Ariana Grande', 'Jeff Bezos', 'Samuel Alito', 'Greg Jackson', 'Nicholas Couillard', 'Miley Cirus', 'Joe Biden', 'Barack Obama', 'Gabe Vincent', 'Stephen Curry', 'Kamala Harris', '6ix9ine', 'Ghandi'])
courseMaxStudents = random.randint(0,200)
courseFormat = random.choice(["In-person", "Online asynchronous", "Online synchronous"])
if courseFormat == "In-person" or courseFormat == "Online synchronous":
numDaysTest = random.randint(0,3)
counter = 0
courseScheduledDays = []
weekDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
while counter < numDaysTest:
counter += 1
choice = random.choice(weekDays)
courseScheduledDays.append(choice)
weekDays.remove(choice)
times = [["9:05AM","9:55AM"], ["10:10AM","11:00AM"], ["11:15AM","12:05PM"], ["12:20PM","1:10PM"], ["1:25PM","2:15PM"], ["2:30PM","3:20PM"], ["3:35PM","4:25PM"]]
option = random.randint(0,6)
timeSelected = times[option]
courseStartTime = timeSelected[0]
courseEndTime = timeSelected[1]

else:
courseScheduledDays = "None"
courseStartTime = "None"
courseEndTime = "None"
courseEnrolledStudents = random.randint(0,courseMaxStudents)
courseIsOpen = bool(courseMaxStudents - courseEnrolledStudents)
if courseFormat == "In-person":
courseLocation = random.choice(["MCHU 101", "E2 306", "ITE 114", "MONT 319", "GANT 109", "ARJ 114", "ROWE 307", "ITE 332"])
else:
courseLocation = "Online"

coursePrereqs = "None"

# courseInsert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseStartTime, courseEndTime, courseIsOpen, courseFormat, courseScheduledDays, courseLocation)
courseInsert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseIsOpen, courseFormat, coursePrereqs, courseStartTime, courseEndTime, courseScheduledDays, courseLocation)

#courseRemove('COMM1000', '001D')
enrollStudent('CSE1010', '001L')
#courseRemove('CSE2102', '001')
#enrollStudent('CSE1010', '001L')

0 comments on commit 98ff31c

Please sign in to comment.