Skip to content

Commit

Permalink
Merge 94f151a into 218bdee
Browse files Browse the repository at this point in the history
  • Loading branch information
sjschlapbach authored Nov 4, 2024
2 parents 218bdee + 94f151a commit c308884
Show file tree
Hide file tree
Showing 60 changed files with 1,373 additions and 1,389 deletions.
28 changes: 14 additions & 14 deletions apps/frontend-control/src/components/sessions/SessionBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { faClock, faPlay } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import {
QuestionInstance,
SessionBlockStatus,
SessionBlock as SessionBlockType,
ElementBlock,
ElementBlockStatus,
ElementInstance,
} from '@klicker-uzh/graphql/dist/ops'
import { CycleCountdown, UserNotification } from '@uzh-bf/design-system'
import dayjs from 'dayjs'
Expand All @@ -12,10 +12,10 @@ import { useMemo } from 'react'
import { twMerge } from 'tailwind-merge'

interface SessionBlockProps {
block?: Omit<SessionBlockType, 'instances'> & {
instances?:
| (Omit<QuestionInstance, 'questionData'> & {
questionData?: { name: string } | null
block?: Omit<ElementBlock, 'elements'> & {
elements?:
| (Omit<ElementInstance, 'elementData' | 'type' | 'elementType'> & {
elementData?: { name: string } | null
})[]
| null
}
Expand All @@ -28,7 +28,7 @@ function SessionBlock({ block, active = false }: SessionBlockProps) {
// compute the time until expiration in seconds + 20 seconds buffer from now
const untilExpiration = useMemo(() => {
if (!block) return -1
if (block.status === SessionBlockStatus.Executed) {
if (block.status === ElementBlockStatus.Executed) {
return -1
}
return block.expiresAt
Expand Down Expand Up @@ -73,12 +73,12 @@ function SessionBlock({ block, active = false }: SessionBlockProps) {
key={`${block.expiresAt}-${block.status}`}
overrideSize={15}
isStatic={
!block.expiresAt || block.status === SessionBlockStatus.Executed
!block.expiresAt || block.status === ElementBlockStatus.Executed
}
expiresAt={expirationTime}
strokeWidthRem={0.2}
totalDuration={
block.status !== SessionBlockStatus.Executed
block.status !== ElementBlockStatus.Executed
? untilExpiration
: 0
}
Expand All @@ -88,18 +88,18 @@ function SessionBlock({ block, active = false }: SessionBlockProps) {
}}
/>
)}
{block.status === SessionBlockStatus.Scheduled && (
{block.status === ElementBlockStatus.Scheduled && (
<FontAwesomeIcon icon={faClock} />
)}
{block.status === SessionBlockStatus.Active && (
{block.status === ElementBlockStatus.Active && (
<FontAwesomeIcon icon={faPlay} />
)}
</div>
</div>
<div className="flex flex-col p-1">
{block.instances?.map((instance) => (
{block.elements?.map((instance) => (
<div key={instance.id} className="line-clamp-1">
- {instance.questionData?.name}
- {instance.elementData?.name}
</div>
))}
</div>
Expand Down
24 changes: 12 additions & 12 deletions apps/frontend-control/src/pages/session/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import {
ActivateSessionBlockDocument,
DeactivateSessionBlockDocument,
ElementBlockStatus,
EndSessionDocument,
GetControlSessionDocument,
GetControlLiveQuizDocument,
GetUserRunningLiveQuizzesDocument,
SessionBlockStatus,
} from '@klicker-uzh/graphql/dist/ops'
import Loader from '@klicker-uzh/shared-components/src/Loader'
import { Button, H3, UserNotification } from '@uzh-bf/design-system'
Expand Down Expand Up @@ -56,7 +56,7 @@ function RunningSession() {
loading: sessionLoading,
error: sessionError,
data: sessionData,
} = useQuery(GetControlSessionDocument, {
} = useQuery(GetControlLiveQuizDocument, {
variables: {
id: router.query.id as string,
},
Expand All @@ -65,28 +65,28 @@ function RunningSession() {
})

useEffect(() => {
setCurrentBlockOrder(sessionData?.controlSession?.activeBlock?.order)
setCurrentBlockOrder(sessionData?.controlLiveQuiz?.activeBlock?.order)
}, [
sessionData?.controlSession?.id,
sessionData?.controlSession?.activeBlock,
sessionData?.controlLiveQuiz?.id,
sessionData?.controlLiveQuiz?.activeBlock,
])

useEffect(() => {
if (!sessionData?.controlSession?.blocks) return
if (!sessionData?.controlLiveQuiz?.blocks) return

const sortedBlocks = sort(
sessionData?.controlSession?.blocks,
sessionData?.controlLiveQuiz?.blocks,
(a, b) => a.order - b.order
)

if (!sortedBlocks) return
const scheduledNext = sortedBlocks.find(
(block) => block.status === SessionBlockStatus.Scheduled
(block) => block.status === ElementBlockStatus.Scheduled
)
setNextBlockOrder(
typeof scheduledNext === 'undefined' ? -1 : scheduledNext.order
)
}, [sessionData?.controlSession?.blocks])
}, [sessionData?.controlLiveQuiz?.blocks])

if (sessionLoading) {
return (
Expand All @@ -96,7 +96,7 @@ function RunningSession() {
)
}

if (!sessionData?.controlSession || sessionError) {
if (!sessionData?.controlLiveQuiz || sessionError) {
return (
<Layout title={t('control.session.sessionControl')}>
<UserNotification
Expand All @@ -107,7 +107,7 @@ function RunningSession() {
)
}

const { id, name, course, blocks } = sessionData?.controlSession
const { id, name, course, blocks } = sessionData?.controlLiveQuiz

if (!blocks) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import CourseManipulationModal, {
interface CourseOverviewHeaderProps {
course: Omit<
Course,
'leaderboard' | 'sessions' | 'practiceQuizzes' | 'microLearnings'
'leaderboard' | 'liveQuizzes' | 'practiceQuizzes' | 'microLearnings'
>
name: string
pinCode: number
Expand Down
Loading

0 comments on commit c308884

Please sign in to comment.