diff options
| -rw-r--r-- | src/components/Sidebar.svelte | 2 | ||||
| -rw-r--r-- | src/components/TamuOutput.svelte | 12 | ||||
| -rw-r--r-- | src/models/PeerTeacher.ts | 9 | ||||
| -rw-r--r-- | src/util/parser.ts | 26 |
4 files changed, 44 insertions, 5 deletions
diff --git a/src/components/Sidebar.svelte b/src/components/Sidebar.svelte index 7a71191..39c005e 100644 --- a/src/components/Sidebar.svelte +++ b/src/components/Sidebar.svelte @@ -15,7 +15,7 @@ { name: "Labs", component: Labs }, { name: "Active Peer Teachers", component: null }, // TODO { name: "Stats", component: null }, // TODO - { name: "TAMU Html Output", component: TamuOutput }, + { name: "TAMU HTML Output", component: TamuOutput }, ]; let selected = sections[0]; diff --git a/src/components/TamuOutput.svelte b/src/components/TamuOutput.svelte index 48bb5e1..2ce93e6 100644 --- a/src/components/TamuOutput.svelte +++ b/src/components/TamuOutput.svelte @@ -32,7 +32,7 @@ class="flex flex-col overflow-y-auto h-full overflow-x-hidden mx-[25%] pt-10" > {#each peerTeachers as pt} - <div class="flex-none h-40"> + <div class="pb-4"> <hr /> <p> <img @@ -66,6 +66,16 @@ {/each} </ul> {/if} + {#if pt.office_hours != undefined && pt.office_hours.length > 0} + <p> + <strong class="text-lg">Office Hours:</strong> + </p> + <ul class="text-lg"> + {#each pt.office_hours as ofh} + <li>{ofh.longInfo}</li> + {/each} + </ul> + {/if} </div> {/each} </div> diff --git a/src/models/PeerTeacher.ts b/src/models/PeerTeacher.ts index 080b3c0..eae1984 100644 --- a/src/models/PeerTeacher.ts +++ b/src/models/PeerTeacher.ts @@ -23,6 +23,11 @@ interface PeerTeacherSerializeInfo { new_ret: string, prof_pic_url: string, schedule_url: string, + office_hours: { + days: string, + start: number, + end: number + }[] } export default class PeerTeacher { @@ -55,10 +60,11 @@ export default class PeerTeacher { this.events = []; this.labs = new Set(); this.email = email; + this.events = []; } static fromJSON(qt: PeerTeacherSerializeInfo) { - const { id, firstname, lastname, events, labs, email } = qt; + const { id, firstname, lastname, events, labs, email, office_hours } = qt; const pt = new PeerTeacher(id, firstname, lastname, email); pt.events = events.map(e => EventInfo.fromJSON(e)); pt.labs = new Set(labs); @@ -73,6 +79,7 @@ export default class PeerTeacher { pt.new_ret = qt.new_ret; pt.prof_pic_url = qt.prof_pic_url; pt.schedule_url = qt.schedule_url; + pt.office_hours = office_hours.map(e => EventInfo.fromJSON(e)); return pt; } diff --git a/src/util/parser.ts b/src/util/parser.ts index 1daf113..0e2ebbf 100644 --- a/src/util/parser.ts +++ b/src/util/parser.ts @@ -266,10 +266,32 @@ export function parseOfficeHours(csv: string) { for (let i = begin + 1; i < end; i++) { const pt_uin = parseInt(sheet[i][0]); const pt = pts.get(pt_uin); - if (pt != undefined || pt != null) { + if (pt != undefined && pt != null) pt.office_hours = parseStrawpollTimesEntry(sheet[i], sheet[begin]); - } } + + + // Merge office hours that take place during the same time of day + pts.forEach((pt) => { + if (pt.office_hours != undefined && pt.office_hours != null) { + const flag = {}; + const unique: EventInfo[] = []; + pt.office_hours.forEach((curr_event) => { + const key = `${curr_event.start}${curr_event.end}`; + if (!flag[key]) { + flag[key] = true; + unique.push(curr_event); + } + else { + const head_event = unique.find((val) => { + return val.start === curr_event.start && val.end === curr_event.end; + }) + head_event.days += curr_event.days; + } + }) + pt.office_hours = unique; + } + }); } /** |
