-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add Quiz Taking UI #3103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Quiz Taking UI #3103
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b9f5560
style (Taking Quiz): update style for taking quiz [page
Puppychan 4289697
style (Taking Quiz UI): add styling for before taking quiz
Puppychan 8cdede6
feat (Taking Quiz UI): add taking quiz button, dark light styling
Puppychan 1d0ce00
feat (Taking Quiz UI): add translation
Puppychan 0d51335
ops (Taking Quiz UI): fix deploy
Puppychan ba85695
ops (Taking Quiz UI): fix deploy
Puppychan c682863
ops (Taking Quiz UI): fix deploy
Puppychan c4e13b3
Merge branch 'main' into feat/upskii/taking-quiz-ui
Puppychan 05f7737
style: apply prettier formatting
Puppychan 40fb721
style: apply prettier formatting for feat/upskii/taking-quiz-ui (#3104)
Puppychan b625bf7
fix (Taking Quiz UI): fix UI displayed when max attempt limit reached
Puppychan 574faea
Merge remote-tracking branch 'origin/feat/upskii/taking-quiz-ui' into…
Puppychan d218347
style(Taking Quiz UI - Answering Question): styling for input and que…
Puppychan 6c92781
style(Taking Quiz UI - Answering Question): styling for displaying sc…
Puppychan 90fc234
fix (Taking Quiz UI): fix deploy
Puppychan e1c7076
fix (Taking Quiz UI): duration not recorded to backend
Puppychan a025cae
revert(Taking Quiz UI): revert working form
Puppychan d465f77
style: apply prettier formatting
Puppychan ee415ea
style: apply prettier formatting for feat/upskii/taking-quiz-ui (#3114)
Puppychan d762d19
Merge branch 'main' into feat/upskii/taking-quiz-ui
vhpx cc0b7f2
chore(db): consolidate database schema
vhpx e2d71dd
refactor: standardize customer ID naming and update database schema f…
vhpx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
apps/db/supabase/migrations/20250615100747_new_migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
alter table "public"."workspace_quiz_attempts" add column "duration_seconds" integer; | ||
|
||
alter table "public"."workspace_quiz_attempts" add column "submitted_at" timestamp with time zone not null default now(); | ||
|
||
alter table "public"."workspace_quiz_sets" add column "available_date" timestamp with time zone not null default now(); | ||
|
||
alter table "public"."workspace_quiz_sets" add column "explanation_mode" smallint not null default 0; | ||
|
||
alter table "public"."workspace_quiz_sets" add column "instruction" jsonb; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
alter table "public"."workspace_quizzes" add column "instruction" jsonb; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
alter table "public"."workspace_quiz_sets" add column "results_released" boolean not null default false; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
alter table "public"."workspace_quiz_sets" drop column "release_points_immediately"; | ||
|
||
alter table "public"."workspace_quiz_sets" add column "allow_view_old_attempts" boolean not null default true; | ||
vhpx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
...dules/[moduleId]/quiz-sets/[setId]/result/display-results/show-attempt-detail-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// File: app/[locale]/(dashboard)/[wsId]/quiz-sets/[setId]/result/show-attempt-detail-section.tsx | ||
'use client'; | ||
|
||
import { Card, CardContent, CardHeader, CardTitle } from '@tuturuuu/ui/card'; | ||
import { CheckCircle, Circle, XCircle } from 'lucide-react'; | ||
|
||
// File: app/[locale]/(dashboard)/[wsId]/quiz-sets/[setId]/result/show-attempt-detail-section.tsx | ||
|
||
export interface AttemptDetailDTO { | ||
attemptId: string; | ||
attemptNumber: number; | ||
totalScore: number; | ||
maxPossibleScore: number; | ||
startedAt: string; | ||
completedAt: string | null; | ||
durationSeconds: number; | ||
explanationMode: 0 | 1 | 2; | ||
questions: Array<{ | ||
quizId: string; | ||
question: string; | ||
scoreWeight: number; | ||
/** Now optional */ | ||
selectedOptionId?: string | null; | ||
isCorrect: boolean; | ||
scoreAwarded: number; | ||
options: Array<{ | ||
id: string; | ||
value: string; | ||
isCorrect: boolean; | ||
explanation: string | null; | ||
}>; | ||
}>; | ||
} | ||
|
||
export interface ShowAttemptDetailProps { | ||
t: (key: string) => string; | ||
detail: AttemptDetailDTO; | ||
} | ||
|
||
export default function ShowAttemptDetailSection({ | ||
t, | ||
detail, | ||
}: ShowAttemptDetailProps) { | ||
const fmtDate = (iso: string | null) => | ||
iso ? new Date(iso).toLocaleString() : '—'; | ||
const fmtDuration = (secs: number) => { | ||
const m = Math.floor(secs / 60) | ||
.toString() | ||
.padStart(2, '0'); | ||
const s = (secs % 60).toString().padStart(2, '0'); | ||
return `${m}:${s}`; | ||
}; | ||
|
||
return ( | ||
<div className="space-y-8"> | ||
{/* Metadata */} | ||
<div className="space-y-1 text-sm text-secondary-foreground"> | ||
<div> | ||
{t('ws-quizzes.started_at') || 'Started at'}:{' '} | ||
{fmtDate(detail.startedAt)} | ||
</div> | ||
{detail.completedAt && ( | ||
<div> | ||
{t('ws-quizzes.completed_at') || 'Completed at'}:{' '} | ||
{fmtDate(detail.completedAt)} | ||
</div> | ||
)} | ||
<div> | ||
{t('ws-quizzes.duration') || 'Duration'}:{' '} | ||
{fmtDuration(detail.durationSeconds)} | ||
</div> | ||
</div> | ||
|
||
{/* Questions */} | ||
{detail.questions.map((q, idx) => { | ||
const selId = q.selectedOptionId ?? null; | ||
return ( | ||
<Card | ||
key={q.quizId} | ||
className={ | ||
!q.isCorrect | ||
? 'border-dynamic-light-red/40 bg-dynamic-light-pink/15' | ||
: '' | ||
} | ||
> | ||
<CardHeader> | ||
<CardTitle> | ||
{idx + 1}. {q.question}{' '} | ||
<span className="text-sm text-muted-foreground"> | ||
({t('ws-quizzes.points') || 'Points'}: {q.scoreWeight}) | ||
</span> | ||
</CardTitle> | ||
</CardHeader> | ||
<CardContent className="space-y-2 md:space-y-4"> | ||
{q.options.map((opt) => { | ||
const chosen = selId === opt.id; | ||
return ( | ||
<div | ||
key={opt.id} | ||
className="flex items-center space-x-2 rounded-md border border-dynamic-purple/40 p-2 transition-colors hover:bg-secondary/10 md:space-x-4 md:p-4" | ||
aria-label={`${opt.value} ${ | ||
opt.isCorrect | ||
? t('ws-quizzes.correct_option') || '(Correct)' | ||
: chosen | ||
? t('ws-quizzes.your_answer') || '(Your answer)' | ||
: '' | ||
}`} | ||
> | ||
{opt.isCorrect ? ( | ||
<CheckCircle className="h-5 w-5 text-green-500" /> | ||
) : chosen ? ( | ||
<XCircle className="h-5 w-5 text-dynamic-light-red" /> | ||
) : ( | ||
<Circle className="h-5 w-5 text-gray-400" /> | ||
)} | ||
<div className="flex flex-col"> | ||
<span className={chosen ? 'font-semibold' : undefined}> | ||
{opt.value}{' '} | ||
{opt.isCorrect && ( | ||
<small className="text-green-600"> | ||
{t('ws-quizzes.correct') || '(Correct)'} | ||
</small> | ||
)} | ||
{chosen && !opt.isCorrect && ( | ||
<small className="text-dynamic-light-red"> | ||
{t('ws-quizzes.your_answer') || '(Your answer)'} | ||
</small> | ||
)} | ||
</span> | ||
{opt.explanation && ( | ||
<p className="mt-1 text-sm text-primary"> | ||
{opt.explanation} | ||
</p> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
})} | ||
|
||
<div className={`mt-3 text-sm text-center md:text-right ${q.isCorrect ? "text-green-600" : "text-dynamic-light-red"}`}> | ||
{t('ws-quizzes.score_awarded') || 'Score Awarded'}:{' '} | ||
<strong> | ||
{q.scoreAwarded} / {q.scoreWeight} | ||
</strong> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.