optionally save student schedules to docx

This commit is contained in:
SowinskiBraeden committed 2022-11-15 16:43:31 -08:00
1 parent 5c75ee10a2
commit 3f1c4dff16
4 files changed
+25 -4

No files matched your search

+6 -2
View File
@@ -17,7 +17,8 @@ def start(
class_cap: int, class_cap: int,
block_class_limit: int, block_class_limit: int,
total_blocks: int, total_blocks: int,
) -> dict: save_student_schedules: bool
) -> Error.__dict__: # Return Error dataclass as dict
raw_data_dir = './output/temp/course_selection_data.csv' raw_data_dir = './output/temp/course_selection_data.csv'
raw_json_dir = './output/raw/json' raw_json_dir = './output/raw/json'
@@ -28,11 +29,13 @@ def start(
if not os.path.exists('output'): os.makedirs('output') if not os.path.exists('output'): os.makedirs('output')
if not os.path.exists('output/temp'): os.makedirs('output/temp') if not os.path.exists('output/temp'): os.makedirs('output/temp')
if not os.path.exists('output/final'): os.makedirs('output/final') if not os.path.exists('output/final'): os.makedirs('output/final')
if not os.path.exists('output/final/student_schedules'): os.makedirs('output/final/student_schedules')
if not os.path.exists('output/raw'): os.makedirs('output/raw') if not os.path.exists('output/raw'): os.makedirs('output/raw')
if not os.path.exists('output/raw/json'): os.makedirs('output/raw/json') if not os.path.exists('output/raw/json'): os.makedirs('output/raw/json')
if not os.path.exists('output/raw/csv'): os.makedirs('output/raw/csv') if not os.path.exists('output/raw/csv'): os.makedirs('output/raw/csv')
# Only ensure folder exists if we want to save student schedules to docx files
if save_student_schedules and not os.path.exists('output/final/student_schedules'): os.makedirs('output/final/student_schedules')
# save raw file data to local file # save raw file data to local file
eel.post_data('Saving raw data to local file...') eel.post_data('Saving raw data to local file...')
with open(raw_data_dir, 'w') as raw_file: with open(raw_data_dir, 'w') as raw_file:
@@ -90,6 +93,7 @@ def start(
writeCoursesToCSV(courses, output_dir='./output/raw/csv/courses.csv') writeCoursesToCSV(courses, output_dir='./output/raw/csv/courses.csv')
eel.post_data('Writing timetables to .docx files...') eel.post_data('Writing timetables to .docx files...')
if save_student_schedules:
for student in students: for student in students:
putScheduleToWord(courses, student, './output/final/student_schedules') putScheduleToWord(courses, student, './output/final/student_schedules')
+9
View File
@@ -30,6 +30,15 @@
accept=".csv" accept=".csv"
> >
<label style="display: inline-block" for="save_student_schedules">Save Student Schedules to .docx</label>
<input
style="margin-left: 5px;transform:scale(1.5)"
type="checkbox"
id="save_student_schedules"
name="save_student_schedules"
value="save_student_schedules"
>
<label for="classrooms">Number of classrooms (20-100)</label> <label for="classrooms">Number of classrooms (20-100)</label>
<input <input
required required
+9 -1
View File
@@ -6,6 +6,7 @@ function start() {
let classCap = document.getElementById("class_cap").value; let classCap = document.getElementById("class_cap").value;
let blockClassLimit = document.getElementById("classrooms").value; let blockClassLimit = document.getElementById("classrooms").value;
let totalBlocks = document.getElementById("total_blocks").value; let totalBlocks = document.getElementById("total_blocks").value;
let saveStudentSchedules = document.getElementById("save_student_schedules").checked;
// ensure data is passed before continuing // ensure data is passed before continuing
if (!e(file) || !e(minReq) || !e(classCap) || !e(blockClassLimit) || !e(totalBlocks)) return alert('Please ensure all fields aren\'t empty.'); if (!e(file) || !e(minReq) || !e(classCap) || !e(blockClassLimit) || !e(totalBlocks)) return alert('Please ensure all fields aren\'t empty.');
@@ -17,7 +18,14 @@ function start() {
let reader = new FileReader() let reader = new FileReader()
reader.addEventListener("load", () => { reader.addEventListener("load", () => {
let raw = reader.result; let raw = reader.result;
eel.start(raw, minReq, classCap, blockClassLimit, totalBlocks)(finish_callback); eel.start(
raw,
minReq,
classCap,
blockClassLimit,
totalBlocks,
saveStudentSchedules
)(finish_callback);
}, false); }, false);
if (file) { if (file) {
+1 -1
View File
@@ -42,7 +42,7 @@ body{
bottom: -80px; bottom: -80px;
} }
.main{ .main{
height: 600px; height: 640px;
width: 400px; width: 400px;
background-color: rgba(255,255,255,0.13); background-color: rgba(255,255,255,0.13);
position: absolute; position: absolute;