Skip to content

Commit

Permalink
Less random class times
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhxNguyen7 committed Jan 26, 2024
1 parent 79836ba commit 6982d32
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions apps/antalmanac/src/lib/tourExampleGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let sampleClassesSectionCodes: Array<string> = [];
export function addSampleClasses() {
if (AppStore.getAddedCourses().length > 0) return;

const sampleClasses: Array<ScheduleCourse> = [
const sampleClassesOptions: sampleClassOptions[] = [
{
courseTitle: 'Nice',
deptCode: 'GEN&SEX',
Expand Down Expand Up @@ -53,7 +53,9 @@ export function addSampleClasses() {
},
],
},
].map(sampleClassFactory);
];

const sampleClasses: Array<ScheduleCourse> = sampleClassesOptions.map(sampleClassFactory);

sampleClasses.forEach((sampleClass) => {
AppStore.addCourse(sampleClass);
Expand Down Expand Up @@ -81,6 +83,15 @@ function randomClasstime(): HourMinute {
};
}

function randomStartEndTime(duration: number): [HourMinute, HourMinute] {
const start = randomClasstime();
const end = {
hour: start.hour + duration / 60,
minute: start.minute + (duration % 60),
};
return [start, end];
}

export function sampleMeetingsFactory({
bldg = ['DBH 1200'],
days = 'MWF',
Expand All @@ -93,7 +104,7 @@ export function sampleMeetingsFactory({
minute: 50,
},
timeIsTBA = false,
}: Partial<WebsocSectionMeeting>) {
}: Partial<WebsocSectionMeeting>): WebsocSectionMeeting[] {
return [
{
bldg,
Expand Down Expand Up @@ -131,13 +142,17 @@ export function sampleFinalExamFactory({
bldg,
};

const [randomStartTime, randomEndTime] = randomStartEndTime(120);
startTime = startTime ?? randomStartTime;
endTime = endTime ?? randomEndTime;

return {
examStatus,
dayOfWeek: dayOfWeek ?? randomWeekday(),
month,
day,
startTime: startTime ?? randomClasstime(),
endTime: endTime ?? randomClasstime(),
startTime: startTime,
endTime: endTime,
bldg,
};
}
Expand Down

0 comments on commit 6982d32

Please sign in to comment.