Skip to content

Commit

Permalink
feature: display enrolled user lab usage
Browse files Browse the repository at this point in the history
  • Loading branch information
edeleastar committed Jan 17, 2023
1 parent b45c4a6 commit 6cd33da
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps/time/src/routes/time/[courseid]/[...userid]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import NavBar from "$lib/navigators/NavBar.svelte";
import CalendarTime from "$lib/time/CalendarTime.svelte";
import { authService } from "tutors-reader-lib/src/services/auth-service";
import { page } from "$app/stores";
export let data: PageData;
const storeTab: Writable<string> = writable("Labs");
Expand Down Expand Up @@ -44,6 +45,9 @@
<Tab value="Calendar">Calendar</Tab>
{#if instructorMode}
<Tab value="allLabs">Labs All Students</Tab>
{#if data.course.hasEnrollment()}
<Tab value="allEnrolledLabs">Labs All Enrolled Students</Tab>
{/if}
<Tab value="allLabsChart">Labs All Students - Chart</Tab>
<Tab value="allCalendar">Calendar All Students</Tab>
{/if}
Expand All @@ -60,6 +64,9 @@
{#if $storeTab === "allLabs"}
<InstructorLabTime userMap="{data.users}" allLabs="{data.allLabs}" chart="{false}" />
{/if}
{#if $storeTab === "allEnrolledLabs"}
<InstructorLabTime userMap="{data.enrolledUsers}" allLabs="{data.allLabs}" chart="{false}" />
{/if}
{#if $storeTab === "allLabsChart"}
<InstructorLabTime userMap="{data.users}" allLabs="{data.allLabs}" chart="{true}" />
{/if}
Expand Down
15 changes: 14 additions & 1 deletion apps/time/src/routes/time/[courseid]/[...userid]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ export const load: PageLoad = async ({ params }) => {
const user: UserMetric = await fetchUserById(params.courseid, params.userid, allLabs);
currentUser.set(user);
const users: Map<string, UserMetric> = await fetchAllUsers(params.courseid, allLabs);
const enrolledUsers: Map<string, UserMetric> = new Map<string, UserMetric>();
if (course.hasEnrollment()) {
const students = course.getEnrolledStudentIds();
for (const githubId of users.keys()) {
if (students.includes(githubId)) {
const enrolledUser = users.get(githubId);
if (enrolledUser) {
enrolledUsers.set(githubId, enrolledUser);
}
}
}
}
return {
user: user,
course: course,
allLabs: course.walls.get("lab"),
calendar: course.calendar,
ignorePin: course.lo.properties?.ignorepin?.toString(),
users: users
users: users,
enrolledUsers
};
};

0 comments on commit 6cd33da

Please sign in to comment.