Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/20041540MichaelKelly…
Browse files Browse the repository at this point in the history
…/tutors into feat/toc-companions-walls-cypress-test#393
  • Loading branch information
20041540MichaelKelly committed Sep 6, 2023
2 parents 17a7011 + 21b96de commit 80f5eb5
Showing 13 changed files with 65 additions and 80 deletions.
5 changes: 3 additions & 2 deletions app/src/lib/services/models/lo-types.ts
Original file line number Diff line number Diff line change
@@ -60,8 +60,8 @@ export type Panels = {
};

export type Units = {
units: Lo[];
sides: Lo[];
units: Unit[];
sides: Unit[];
standardLos: Lo[];
};

@@ -177,6 +177,7 @@ export type Course = Composite & {
areLabStepsAutoNumbered: boolean;
hasEnrollment: boolean;
hasWhiteList: boolean;
ignorePin: string;
companions: IconNavBar;
wallBar: IconNavBar;
};
1 change: 1 addition & 0 deletions app/src/lib/services/models/lo-utils.ts
Original file line number Diff line number Diff line change
@@ -151,4 +151,5 @@ export function loadPropertyFlags(course:Course) {
course.authLevel = course.properties.auth as unknown as number;
course.hasEnrollment = false;
course.hasWhiteList = false;
course.ignorePin = course.properties?.ignorepin?.toString();
}
8 changes: 4 additions & 4 deletions app/src/lib/ui/legacy/Atoms/Image/Image.svelte
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
};
}
if (lo.icon) {
if (lo?.icon) {
if (!isColour(lo.icon.color)) {
colourPrefix = "#";
}
@@ -49,8 +49,8 @@
onDestroy(unsubscribe);
</script>

{#if lo.icon}
<Iconify icon={lo.icon.type} color="{colourPrefix}{lo.icon.color}" height={iconHeight} />
{#if lo?.icon}
<Iconify icon={lo?.icon.type} color="{colourPrefix}{lo.icon.color}" height={iconHeight} />
{:else}
<Avatar src={lo.img} alt={lo.title} width={imageHeight} rounded="rounded-xl" background="none" />
<Avatar src={lo?.img} alt={lo?.title} width={imageHeight} rounded="rounded-xl" background="none" />
{/if}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<script lang="ts">
import { currentCourse, currentLo } from "$lib/stores";
import { Icon } from "$lib/ui/legacy";
import type { Lo } from "$lib/services/models/lo-types";
let truncated = [true, true, true, true, true, true, true];
let unitId = "";
function getUnitId(type: string, id: string) {
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Topic } from "$lib/services/models/topic";
import type { Lo } from "$lib/services/types/lo";
import type { Topic } from "$lib/services/models/lo-types";
import type { Lo } from "$lib/services/models/lo-types";
import { Image, TopicNavigator } from "$lib/ui/legacy";
import { currentLo, layout } from "$lib/stores";
import { onDestroy } from "svelte";
@@ -29,7 +29,7 @@
</script>

<div class="card {cardWidths} px-4 py-2">
<h3 class="px-4 py-2 text-center {headingText}">{topic?.lo?.title}</h3>
<h3 class="px-4 py-2 text-center {headingText}">{topic?.title}</h3>
<div class="card-body">
<figure class="flex justify-center p-2">
<Image {lo} />
9 changes: 2 additions & 7 deletions app/src/lib/ui/legacy/Molecules/NavTitle/NavTitle.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { currentCourse, currentLo } from "$lib/stores";
import { Image } from "$lib/ui/legacy";
import type { Lo } from "$lib/services/types/lo";
import type { Lo } from "$lib/services/models/lo-types";
import { getIcon } from "../../Atoms/Icon/themes";
import Icon from "@iconify/svelte";
import { onDestroy } from "svelte";
@@ -26,12 +26,7 @@
{#if !wall}
<Image {lo} miniImage={true} />
{:else}
<Icon
icon={getIcon(lo.type).icon}
class="text-{getIcon(lo.type).colour}"
width="40"
height="40"
/>
<Icon icon={getIcon(lo.type).icon} class="text-{getIcon(lo.type).colour}" width="40" height="40" />
{/if}
</div>
</div>
50 changes: 32 additions & 18 deletions app/src/lib/ui/legacy/Organisms/CardDeck/CardDeck.svelte
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
<script lang="ts">
import { onMount } from "svelte";
import { currentCourse } from "$lib/stores";
import { Card } from "$lib/ui/legacy";
import type { Lo } from "$lib/services/models/lo-types";
export let los: Lo[] = [];
export let border: boolean = false;
export let disableSort = false;
let orderedLos = los;
let unOrderedLos: Lo[] = [];
if (!disableSort) {
orderedLos = los.filter((lo) => lo?.frontMatter?.order);
unOrderedLos = los.filter((lo) => !lo?.frontMatter?.order);
orderedLos.sort((a, b) => Number(a.frontMatter?.order) - Number(b.frontMatter?.order));
}
let bordered = "border-[1px] border-surface-200-700-token";
let unbordered = "";
let pinBuffer = "";
let ignorePin = "";
let refresh = true;
function keypressInput(e: { key: string }) {
pinBuffer = pinBuffer.concat(e.key);
if (pinBuffer === ignorePin) {
los.forEach((lo) => {
lo.hide = false;
});
refresh = !refresh;
}
}
onMount(async () => {
if ($currentCourse?.properties.ignorepin) {
ignorePin = $currentCourse.properties.ignorepin.toString();
window.addEventListener("keydown", keypressInput);
}
});
</script>

{#if los.length > 0}
<div class="bg-surface-100-800-token mx-auto mb-2 place-items-center overflow-hidden rounded-xl p-4 {border ? bordered : unbordered}">
<div class="flex flex-wrap justify-center">
{#each orderedLos as lo}
<Card {lo} />
{/each}
{#each unOrderedLos as lo}
<Card {lo} />
<div class="bg-surface-100-800-token mx-auto mb-2 place-items-center overflow-hidden rounded-xl p-4 {border ? bordered : unbordered}">
<div class="flex flex-wrap justify-center">
{#key refresh}
{#each los as lo}
{#if !lo.hide}
<Card {lo} />
{/if}
{/each}
</div>
{/key}
</div>
{/if}
</div>
22 changes: 0 additions & 22 deletions app/src/lib/ui/legacy/Organisms/CardDeck/TopDeck.svelte
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
<script lang="ts">
import { onMount } from "svelte";
import { currentCourse } from "$lib/stores";
import { CardDeck } from "$lib/ui/legacy";
import PanelDeck from "./PanelDeck.svelte";
import UnitDeck from "./UnitDeck.svelte";
import type { Composite } from "$lib/services/models/lo-types";
import UnitCard from "./UnitCard.svelte";
export let composite: Composite;
let pinBuffer = "";
let ignorePin = "";
function keypressInput(e: { key: string }) {
pinBuffer = pinBuffer.concat(e.key);
if (pinBuffer === ignorePin) {
//$currentCourse.showAllLos();
//$currentCourse.standardLos = $currentCourse.allLos;
//standardDeck = !standardDeck;
}
}
onMount(async () => {
// if ($currentCourse.properties.ignorepin) {
// ignorePin = $currentCourse.properties.ignorepin.toString();
// window.addEventListener("keydown", keypressInput);
// }
});
</script>

{#if composite.units?.sides?.length > 0}
2 changes: 1 addition & 1 deletion app/src/lib/ui/legacy/Organisms/CardDeck/UnitCard.svelte
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
<h2 id={unit.id} class="p-2 {text}">
{unit.title}
</h2>
<Image lo={$currentCourse} miniImage={true} />
<Image lo={unit.parentTopic} miniImage={true} />
</div>
<PanelDeck panels={unit.panels} />
<div class="flex flex-wrap justify-center">
2 changes: 1 addition & 1 deletion app/src/lib/ui/legacy/Organisms/CardDeck/UnitDeck.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { UnitCard } from "$lib/ui/legacy";
import type { Unit } from "$lib/services/models/lo-types";
import type { Unit, Lo } from "$lib/services/models/lo-types";
export let units: Unit[];
</script>

Original file line number Diff line number Diff line change
@@ -36,15 +36,15 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ag-grid-community/styles/ag-grid.css" />
</svelte:head>

<div in:fade={{ duration: 500 }} class="bg-base-200 mt-3 ">
<div in:fade={{ duration: 500 }} class="bg-base-200 mt-3">
<TabGroup selected={storeTab}>
<Tab bind:group={tabSet} name="Labs" value={0}>Labs</Tab>
<Tab bind:group={tabSet} name="LabsChart" value={1}>LabsChart</Tab>
<Tab bind:group={tabSet} name="Calendar" value={2}>Calendar</Tab>

{#if instructorMode}
<Tab bind:group={tabSet} name="LabsAllStudent" value={3}>Labs All Student</Tab>
{#if data.course.hasEnrollment()}
{#if data.course?.hasEnrollment}
<Tab bind:group={tabSet} name="LabsAllStudent" value={4}>Labs All Enrolled Student</Tab>
{/if}
<Tab bind:group={tabSet} name="allLabsChart" value={5}>Labs All Students - Chart</Tab>
24 changes: 12 additions & 12 deletions app/src/routes/(time)/time/[courseid]/[...userid]/+page.ts
Original file line number Diff line number Diff line change
@@ -23,24 +23,24 @@ export const load: PageLoad = async ({ parent, params, fetch }) => {
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();
if (isStringArray(students)) {
for (const githubId of users.keys()) {
if (students.includes(githubId)) {
const enrolledUser = users.get(githubId);
if (enrolledUser) {
enrolledUsers.set(githubId, enrolledUser);
}
}
}
}
// const students = course.getEnrolledStudentIds();
// if (isStringArray(students)) {
// 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.wallMap?.get("lab"),
calendar: course.calendar,
ignorePin: course.lo.properties?.ignorepin?.toString(),
ignorePin: course.ignorePin,
users: users,
enrolledUsers
};
10 changes: 4 additions & 6 deletions app/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -156,8 +156,8 @@
userId={data.session.user.id}
onlineStatus={isNotCourseRoute ? undefined : status}
usersOnline={isNotCourseRoute ? undefined : $studentsOnline.toString()}
currentCourseId={$currentCourse?.id}
currentCourseUrl={$currentCourse?.url}
currentCourseId={$currentCourse?.courseId}
currentCourseUrl={$currentCourse?.courseUrl}
{handleClick}
{handleSignOut}
{onlineDrawerOpen}
@@ -181,11 +181,9 @@
{/if}
</svelte:fragment>
<slot />
<svelte:fragment slot="pageFooter">\
<svelte:fragment slot="pageFooter">
{#if $page.url.pathname !== "/"}
<div
class="bg-surface-100-800-token border-t-[1px] border-surface-200-700-token bottom-0 mt-2"
>
<div class="bg-surface-100-800-token border-t-[1px] border-surface-200-700-token bottom-0 mt-2">
<Footer />
</div>
{/if}

0 comments on commit 80f5eb5

Please sign in to comment.