Skip to content

Commit

Permalink
enhance: add possibility to switch between different activities of th…
Browse files Browse the repository at this point in the history
…e same course on quiz dashboard
  • Loading branch information
sjschlapbach committed Dec 22, 2024
1 parent dfc6c1f commit c2d50a9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,84 @@
import { useQuery } from '@apollo/client'
import { faChevronLeft } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { GetCourseActivitiesDocument } from '@klicker-uzh/graphql/dist/ops'
import Loader from '@klicker-uzh/shared-components/src/Loader'
import { SelectField } from '@uzh-bf/design-system'
import { useTranslations } from 'next-intl'
import Link from 'next/link'
import { useRouter } from 'next/router'

function QuizAnalyticsNavigation({ courseId }: { courseId: string }) {
function QuizAnalyticsNavigation({
courseId,
activityId,
}: {
courseId: string
activityId: string
}) {
const { data, loading } = useQuery(GetCourseActivitiesDocument, {
variables: { courseId },
})
const t = useTranslations()
const router = useRouter()

if (loading) {
return <Loader />
}

return (
<div className="flex w-full flex-row justify-between">
<div className="mb-6 grid w-full grid-cols-3">
<Link
href={`/analytics/${courseId}/quizzes`}
className="mb-6 flex flex-row items-center gap-2"
className="flex flex-row items-center gap-2"
>
<FontAwesomeIcon icon={faChevronLeft} size="lg" />
<div className="flex flex-row items-center gap-0.5">
{t('manage.analytics.backToActivitySelection')}
</div>
</Link>
<div className="flex justify-center">
<SelectField
label={`${t('shared.generic.activity')}:`}
labelType="large"
value={activityId}
groups={[
...(data?.getCourseActivities?.practiceQuizzes &&
data.getCourseActivities.practiceQuizzes.length > 0
? [
{
label: `${t('shared.generic.practiceQuizzes')}:`,
items:
data?.getCourseActivities?.practiceQuizzes?.map(
(activity) => ({
label: activity.name,
value: activity.id,
})
) ?? [],
},
]
: []),
...(data?.getCourseActivities?.microLearnings &&
data.getCourseActivities.microLearnings.length > 0
? [
{
label: `${t('shared.generic.microlearnings')}:`,
items:
data?.getCourseActivities?.microLearnings?.map(
(activity) => ({
label: activity.name,
value: activity.id,
})
) ?? [],
},
]
: []),
]}
onChange={(value) => {
router.push({ pathname: `/analytics/${courseId}/quizzes/${value}` })
}}
className={{ select: { trigger: 'h-8' } }}
/>
</div>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function QuizAnalytics() {
skip: !activityId,
})

const navigation = <QuizAnalyticsNavigation courseId={courseId} />
const navigation = (
<QuizAnalyticsNavigation courseId={courseId} activityId={activityId} />
)
const analytics = data?.getActivityAnalytics

const chartColors = {
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/messages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default {
q3: 'Q3',
weeks: 'Wochen',
student: 'Studierende(r)',
activity: 'Aktivität',
},
contentInput: {
boldStyle:
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/messages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default {
q3: 'Q3',
weeks: 'Weeks',
student: 'Student',
activity: 'Activity',
},
contentInput: {
boldStyle:
Expand Down

0 comments on commit c2d50a9

Please sign in to comment.