Skip to content

Commit 827e9db

Browse files
Log45shaeespringLilyanCSEC
committed
First working session is done: starting to objectify the scheduler and optimize design
Co-authored-by: Shaela Spring <[email protected]> Co-authored-by: Lilyan <[email protected]>
1 parent 2e2ffca commit 827e9db

File tree

7 files changed

+288
-0
lines changed

7 files changed

+288
-0
lines changed

buckets.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from student import Student
2+
3+
class Buckets:
4+
#3 lists for each of the three types
5+
#begining intermediate high
6+
#1. english
7+
#2. math
8+
#3. ASL
9+
#listed in priorty order.
10+
# this assumes a list sorted by name, english, math, asl is students.
11+
beginningEnglish: list = []
12+
intermediateEnglish: list = []
13+
advancedEnglish: list = []
14+
15+
beginningMath: list = []
16+
intermediateMath: list = []
17+
advancedMath: list = []
18+
19+
beginningASL: list = []
20+
intermediateASL: list = []
21+
advancedASL: list = []
22+
23+
24+
def sortcourses(self, students: object):
25+
26+
for student in students:
27+
# Put into proper Enlish bucket
28+
if student.english <= 4:
29+
self.beginningEnglish.append(student)
30+
elif student.math >= 8:
31+
self.advancedEnglish.append(student)
32+
else:
33+
self.intermediateEnglish.append(student)
34+
35+
# Put into proper Math bucket
36+
if student.math <= 4:
37+
self.beginningMath.append(student)
38+
elif student.math >= 8:
39+
self.advancedMath.append(student)
40+
else:
41+
self.intermediateMath.append(student)
42+
43+
#put into proper ASL bucket.
44+
if student.asl <= 4:
45+
self.beginningASL.append(student)
46+
elif student.asl >= 8:
47+
self.advancedASL.append(student)
48+
else:
49+
self.intermediateASL.append(student)
50+

main.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
""" Priority Scheduler:
2+
3+
1. Schedule each student by the lowest test score first
4+
2. If not, schedule in this order:
5+
- English
6+
- Math
7+
- ASL
8+
9+
"""
10+
from typing import Dict, List, Tuple, Union
11+
from math import average
12+
import os
13+
from student import Student
14+
15+
def load_csv(file_name) -> List[Student]:
16+
"""
17+
CSV Format:
18+
Name, Reading, Writing, Math, ASL
19+
20+
Returns:
21+
{
22+
"Name": {
23+
"English": int,
24+
"Math": int,
25+
"ASL": int
26+
}
27+
}
28+
"""
29+
with open(file_name, 'r') as file:
30+
data = file.readlines()
31+
data = [line.strip().split(',') for line in data]
32+
students_to_score = [Student(line[0], (int(line[1]) + int(line[2])) // 2, int(line[3]), int(line[4])) for line in data]
33+
return students_to_score
34+
35+
def return_scores(students_to_score: List[Student]) -> List[Student]:
36+
"""
37+
Returns a list of test scores for each student.
38+
"""
39+
return [(student_to_score.english, student_to_score.math, student_to_score.asl) for student_to_score in students_to_score]
40+
41+
def sort_students(students_to_score: List[Student]) -> List[Student]:
42+
"""
43+
Returns a list of student names in the order they should be scheduled.
44+
"""
45+
sorted_students = sorted(students_to_score, key=(min(return_scores(students_to_score)), return_scores(students_to_score)))
46+
return sorted_students

main_test.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from main import load_csv, sort_students
2+
3+
def test_student_sort():
4+
5+
#Student Name,Reading Ability Level,Writing Ability Level,Math Ability Level,ASL Ability Level
6+
# Jackie Abbott,5,5,4,7
7+
# Diana Lemke,9,9,7,8
8+
# Odell Padberg,6,6,6,5
9+
# Jadon Gleason,5,5,2,7
10+
# Skye Braun,9,9,9,2
11+
12+
#If not, schedule in this order:
13+
#- English
14+
#- Math
15+
#- ASL
16+
17+
students = [{"name": "Jackie Abbott", "Reading": 5, "Writing": 5, "Math": 4, "ASL": 7},
18+
{"name": "Diana Lemke", "Reading": 9, "Writing": 9, "Math": 7, "ASL": 8},
19+
{"name": "Odell Padberg", "Reading": 6, "Writing": 6, "Math": 6, "ASL": 5},
20+
{"name": "Jadon Gleason", "Reading": 5, "Writing": 5, "Math": 2, "ASL": 7},
21+
{"name": "Skye Braun", "Reading": 9, "Writing": 9, "Math": 9, "ASL": 2}]
22+
actual = [
23+
{"name": "Jadon Gleason", "Reading": 5, "Writing": 5, "Math": 2, "ASL": 7},
24+
{"name": "Jackie Abbott", "Reading": 5, "Writing": 5, "Math": 4, "ASL": 7},
25+
{"name": "Odell Padberg", "Reading": 6, "Writing": 6, "Math": 6, "ASL": 5},
26+
{"name": "Diana Lemke", "Reading": 9, "Writing": 9, "Math": 7, "ASL": 8},
27+
{"name": "Skye Braun", "Reading": 9, "Writing": 9, "Math": 9, "ASL": 2}]
28+
29+
assert student_sort(students) == actual
30+
31+
32+
# Test student sort

notes.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
How do we block them into the different levels?
2+
- How many levels?
3+
- Assuming three:
4+
- Beginner: 1 - 4
5+
- Intermediate: 5-7
6+
- Advanced: 8-10

sanity.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From CSV - creat
2+
students for each line (dictionary)
3+
Weighted graph, keeping the order Reading, math, then asl (lowest to highest)
4+
5+
Schedule:
6+
1 hour blocks for each class
7+
1 hour break for lunch
8+
Schedule from 8 am to 4 pm
9+
10+
11+
Blocks:
12+
8am - 9am
13+
9:15 am - 10:15 am
14+
10:30 am - 11:30 am
15+
Lunch 11:45 am - 12:45 pm
16+
1:00pm - 2:00pm
17+
2:15pm - 3:15pm
18+
3:30pm - 4:30pm
19+
20+
21+
Teachers:
22+
Also needs 1 hour breaks
23+
24+
25+
26+
Courses:
27+
28+
3 lists for each of the three types
29+
begining intermediate high
30+
1. english
31+
2. math
32+
3. ASL
33+
listed in priorty order.
34+

schedule.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import datetime
2+
from buckets import Buckets
3+
from student import Student
4+
def available_times():
5+
## Eventually, times will be replaced by variable names given by csv (not available yet)
6+
#
7+
classes ={
8+
"BReading": ["8am", "9:15", "10:30"],
9+
"IReading": ["8am", "9:15", "10:30"],
10+
"AReading": ["8am", "9:15", "10:30"],
11+
"BMath": ["9:15", "10:30", "1:00"],
12+
"IMath": ["9:15", "10:30", "1:00"],
13+
"AMath": ["9:15", "10:30", "1:00"],
14+
"BASL": ["10:30", "1:00", "2:15"],
15+
"IASL": ["10:30", "1:00", "2:15"],
16+
"AASL": ["10:30", "1:00", "2:15"],
17+
"Presentations": ["1:00", "2:15","3:30"],
18+
"Lunch" : ["11:45"],
19+
"Mentoring": ["8am", "9:15am", "2:15"]
20+
}
21+
# using the above dictionary, create a new dict using time objects
22+
available_times = {}
23+
for key in classes:
24+
for time in classes[key]:
25+
available_times[datetime.datetime.strptime(time, "%I:%M%p")] = key
26+
27+
28+
def assignment(student: Student):
29+
## English
30+
if student.english == beginner:
31+
NAN = 0
32+
##choose one BReading time
33+
#class cannot be full
34+
##time cannot be taken on the students schedule
35+
elif student.english == intermediate:
36+
NAN = 1
37+
##choose one IReading time
38+
#class cannot be full
39+
##time cannot be taken on the students schedule
40+
elif student.english == advanced:
41+
NAN = 2
42+
##choose one AReading time
43+
#class cannot be full
44+
##time cannot be taken on the students schedule
45+
46+
## Math
47+
if student.math == beginner:
48+
NAN = 0
49+
##choose one BMath time
50+
#class cannot be full
51+
##time cannot be taken on the students schedule
52+
elif student.math == intermediate:
53+
NAN = 1
54+
##choose one IMath time
55+
#class cannot be full
56+
##time cannot be taken on the students schedule
57+
elif student.math == advanced:
58+
NAN = 2
59+
##choose one AMath time
60+
#class cannot be full
61+
##time cannot be taken on the students schedule
62+
63+
## ASL
64+
if student.ASL == beginner:
65+
NAN = 0
66+
##choose one BASL time
67+
#class cannot be full
68+
##time cannot be taken on the students schedule
69+
elif student.ASL == intermediate:
70+
NAN = 1
71+
##choose one IASL time
72+
#class cannot be full
73+
##time cannot be taken on the students schedule
74+
elif student.ASL == advanced:
75+
NAN = 2
76+
##choose one AASL time
77+
#class cannot be full
78+
##time cannot be taken on the students schedule
79+
80+
##choose one presentation time
81+
##choose one mentoring time
82+
##all students will have lunch at 11:45
83+
84+
85+
86+
87+
## Students need ONE CLASS from EACH SUBJECT

student.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Dict, List, Tuple, Union, Student
2+
3+
class Student:
4+
'''CSV Format:
5+
Name, Reading, Writing, Math, ASL'''
6+
7+
name = None
8+
english = None
9+
math = None
10+
asl = None
11+
schedule = None
12+
13+
def __init__(self, name, english, math, asl):
14+
self.name = name
15+
self.english = english
16+
self.math = math
17+
self.asl = asl
18+
self.schedule = []
19+
20+
def add_class(self, course):
21+
self.schedule.append(course)
22+
23+
def remove_class(self, course):
24+
self.schedule.remove(course)
25+
26+
def get_schedule(self):
27+
return self.schedule
28+
29+
def return_scores(students_to_score: List[Student]) -> List[Student]:
30+
"""
31+
Returns a list of test scores for each student.
32+
"""
33+
return [(student_to_score.english, student_to_score.math, student_to_score.asl) for student_to_score in students_to_score]

0 commit comments

Comments
 (0)