Skip to content

Update quiz set and quiz edit form UI #3153

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Puppychan
Copy link
Collaborator

No description provided.

Copy link

graphite-app bot commented Jun 21, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

coderabbitai bot commented Jun 21, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feat/upskii/quiz-set-form

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jun 21, 2025

Codecov Report

Attention: Patch coverage is 0.08587% with 2327 lines in your changes missing coverage. Please review.

Project coverage is 0.87%. Comparing base (4e3c5af) to head (b1dbbde).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
apps/upskii/src/components/quiz/quiz-set-form.tsx 0.19% 514 Missing ⚠️
...hboard)/[wsId]/quiz-sets/[setId]/quiz-add-card.tsx 0.00% 427 Missing and 1 partial ⚠️
[...ale]/(dashboard)/[wsId]/quiz-sets/[setId]/page.tsx](https://app.codecov.io/gh/tutur3u/platform/pull/3153?src=pr&el=tree&filepath=apps%2Fupskii%2Fsrc%2Fapp%2F%5Blocale%5D%2F%28dashboard%29%2F%5BwsId%5D%2Fquiz-sets%2F%5BsetId%5D%2Fpage.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tutur3u#diff-YXBwcy91cHNraWkvc3JjL2FwcC9bbG9jYWxlXS8oZGFzaGJvYXJkKS9bd3NJZF0vcXVpei1zZXRzL1tzZXRJZF0vcGFnZS50c3g=) 0.00% 408 Missing ⚠️
.../upskii/src/components/quiz/multi-quizzes-form.tsx 0.34% 290 Missing ⚠️
.../src/app/api/v1/workspaces/[wsId]/quizzes/route.ts 0.00% 174 Missing ⚠️
...)/[wsId]/quiz-sets/[setId]/paste-confirm-modal.tsx 0.00% 129 Missing and 1 partial ⚠️
.../src/app/api/v1/workspaces/[wsId]/quizzes/route.ts 0.00% 73 Missing ⚠️
...hboard)/[wsId]/quiz-sets/[setId]/edit-set/page.tsx 0.00% 63 Missing and 1 partial ⚠️
...p/api/v1/workspaces/[wsId]/quizzes/single/route.ts 0.00% 53 Missing and 1 partial ⚠️
...odules/[moduleId]/quiz-sets/instruction-editor.tsx 0.00% 52 Missing and 1 partial ⚠️
... and 17 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3153      +/-   ##
==========================================
- Coverage    0.87%    0.87%   -0.01%     
==========================================
  Files        2574     2584      +10     
  Lines      332704   334697    +1993     
  Branches     3135     3148      +13     
==========================================
+ Hits         2909     2916       +7     
- Misses     327600   329580    +1980     
- Partials     2195     2201       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @Puppychan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience for managing quiz sets by introducing a comprehensive, multi-section form UI. It transitions the creation and editing workflows to dedicated pages, allowing for more detailed configuration of quiz parameters such as timing, attempt limits, and instructional content. The changes are fully internationalized and supported by corresponding backend API updates.

Highlights

  • Comprehensive UI for Quiz Sets: Introduced a new, detailed user interface for creating and editing quiz sets, featuring multiple sections for basic information, timing and limits, scheduling, and various settings. This includes fields for attempt limits, time limits, availability dates, due dates, explanation modes, and result visibility options.
  • Dedicated Create/Edit Pages: The creation and editing of quiz sets have been transitioned from modal forms to dedicated full-page experiences, improving the user flow for managing complex quiz set configurations. This involved creating new create/page.tsx and edit/page.tsx routes.
  • Rich Text Editor for Instructions: Integrated a rich text editor for quiz set instructions, allowing authors to provide detailed and formatted guidance to participants. A new instruction-editor.tsx component handles this functionality, including client-side saving to local storage.
  • Internationalization Support: Added extensive new localization keys in both English (en.json) and Vietnamese (vi.json) to support all the new UI elements and form fields introduced for quiz set management.
  • Backend API Updates: The backend API for quiz sets (route.ts) has been updated to accommodate the new configuration fields, ensuring proper data persistence and retrieval. The logic for generating unique quiz set names has also been refined.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new UI for creating and editing quiz sets. The new form is well-structured with many new options for configuring quizzes.

Review focused on:

  • Internationalization (i18n): Inconsistencies and potential copy-paste errors in the translation files.
  • Component Implementation: Opportunities to improve UI components for correctness, accessibility, and to remove redundant code.
  • Navigation: Redirection logic after form submission takes the user out of the current course context.

Addressing these points will improve the quality and maintainability of the new features.

Comment on lines 138 to 141
router.push(`/${wsId}/quiz-sets/${newSet.setId}`);
} else {
router.push(`/${wsId}/quiz-sets/${values.id}`);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

After form submission, the user is redirected to /${wsId}/quiz-sets/${setId}, outside the current course and module context. Redirect back to a page within that context, such as the module's quiz set list: /${wsId}/courses/${courseId}/modules/${moduleId}/quiz-sets.

Comment on lines 481 to 506
<FormItem className="flex flex-col space-y-3 rounded-lg border border-dynamic-purple/20 bg-dynamic-light-purple/5 p-4">
<label>
<div className="flex items-center space-x-3">
<FormControl>
<Checkbox
checked={field.value}
onCheckedChange={field.onChange}
className="border-dynamic-purple data-[state=checked]:border-dynamic-purple data-[state=checked]:bg-dynamic-purple"
/>
</FormControl>
<Eye className="h-4 w-4 text-dynamic-purple" />
</div>
<div>
<FormLabel className="font-semibold text-dynamic-purple">
{t(
'ws-quiz-sets.form-fields.allow_view_results.title'
)}
</FormLabel>
<FormDescription className="text-sm text-muted-foreground">
{t(
'ws-quiz-sets.form-fields.allow_view_results.description'
)}
</FormDescription>
</div>
</label>
</FormItem>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This form field's structure is invalid: it nests <label> tags, causing accessibility issues. Remove the outer <label> tag and restructure the component to correctly associate the label text with the checkbox. Apply a similar fix to the other checkbox fields (resultsReleased and allowViewOldAttempts).

                        <FormItem className="flex flex-col space-y-3 rounded-lg border border-dynamic-purple/20 bg-dynamic-light-purple/5 p-4">
                          <div className="flex items-center space-x-3">
                            <FormControl>
                              <Checkbox
                                checked={field.value}
                                onCheckedChange={field.onChange}
                                className="border-dynamic-purple data-[state=checked]:border-dynamic-purple data-[state=checked]:bg-dynamic-purple"
                              />
                            </FormControl>
                            <Eye className="h-4 w-4 text-dynamic-purple" />
                          </div>
                          <div>
                            <FormLabel className="font-semibold text-dynamic-purple">
                              {t(
                                'ws-quiz-sets.form-fields.allow_view_results.title'
                              )}
                            </FormLabel>
                            <FormDescription className="text-sm text-muted-foreground">
                              {t(
                                'ws-quiz-sets.form-fields.allow_view_results.description'
                              )}
                            </FormDescription>
                          </div>
                        </FormItem>

Comment on lines 15 to 47
export default function InstructionEditor({ quizSetId, instruction, setInstruction }: InstructionEditorProps) {
const t = useTranslations()
const [saving, setSaving] = useState(false)

const INSTRUCTION_EDITOR_KEY = `instruction-quiz-set-${quizSetId}`

const handleSave = async () => {
setSaving(true)
if (instruction) {
localStorage.setItem(INSTRUCTION_EDITOR_KEY, JSON.stringify(instruction))
}
setSaving(false)
}

return (
<div className="w-full">
<div className="rounded-lg overflow-hidden bg-dynamic-purple/10">
<RichTextEditor content={instruction} onChange={setInstruction} />
</div>

<div className="mt-4">
<Button
onClick={handleSave}
disabled={saving}
className="bg-dynamic-purple/30 border border-dynamic-purple text-secondary-foreground hover:bg-dynamic-purple/50"
size="sm"
>
{saving ? t("ws-quiz-sets.form-fields.instruction.saving") || "Saving..." : t("ws-quiz-sets.form-fields.instruction.save")}
</Button>
</div>
</div>
)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The handleSave function and "Save Instruction" button are misleading, as the function saves content to localStorage which is never read back or used. The main form submission persists the instructions. Remove the handleSave function, the saving state, and the button to simplify the component. The onChange prop already updates the form state correctly. Also, handleSave is marked as async but contains no await calls, making the async keyword unnecessary.

export default function InstructionEditor({ quizSetId, instruction, setInstruction }: InstructionEditorProps) {
  const INSTRUCTION_EDITOR_KEY = `instruction-quiz-set-${quizSetId}`

  return (
    <div className="w-full">
      <div className="rounded-lg overflow-hidden bg-dynamic-purple/10">
        <RichTextEditor content={instruction} onChange={setInstruction} />
      </div>
    </div>
  )
}

Comment on lines +3845 to +3847
"timing-limit": {
"title": "Basic Information",
"subtitle": "Set up the fundamental details of your quiz"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The timing-limit section's title and subtitle are the same as the basic section. Consider a more descriptive title and subtitle specific to timing and attempt limits.

      "timing-limit": {
        "title": "Timing & Limits",
        "subtitle": "Set attempt and time limits for the quiz"
      },

Comment on lines +3846 to +3848
"timing-limit": {
"title": "Thông tin cơ bản",
"subtitle": "Thiết lập các chi tiết cơ bản cho bài kiểm tra của bạn"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The timing-limit section's title and subtitle are the same as the basic section. Update these to be more descriptive for Vietnamese-speaking users.

      "timing-limit": {
        "title": "Thời gian & Giới hạn",
        "subtitle": "Thiết lập giới hạn về số lần làm bài và thời gian cho bài kiểm tra của bạn"
      },

Comment on lines +3893 to +3896
"instruction": {
"title": "Hướng dẫn",
"description": "Cung cấp hướng dẫn chi tiết cho học sinh bằng trình soạn thảo văn bản đa dạng thức, hiển thị trước khi bắt đầu bài kiểm tra."
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The instruction object is missing the save and saving keys, which are present in the en.json file. Add these translations for consistency.

      "instruction": {
        "title": "Hướng dẫn",
        "description": "Cung cấp hướng dẫn chi tiết cho học sinh bằng trình soạn thảo văn bản đa dạng thức, hiển thị trước khi bắt đầu bài kiểm tra.",
        "save": "Lưu Hướng dẫn",
        "saving": "Đang lưu..."
      },

: null,
instruction: instruction, // No need to JSON.parse since it's already JSONContent
};
// console.log('Payload', payload, values.timeLimitMinutes != null && values.timeLimitMinutes <=0, "hello");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Remove this console.log statement before merging.

@vhpx vhpx changed the title Add UI for quiz set form and quizzes Update quiz set and quiz edit form UI Jun 21, 2025
@vhpx vhpx added the upskii label Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants