Skip to content

feat(GenerateMcqMrqQuestion): add generate MCQ/MRQ questions with AI #8019

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 4 commits into from
Aug 14, 2025

Conversation

craigtonlian
Copy link
Contributor

@craigtonlian craigtonlian commented Jul 14, 2025

This PR introduces a new feature for generating multiple-choice (MCQ) and multiple-response (MRQ) questions using a language model (LLM), along with associated updates to the backend and frontend to support this functionality.

Frontend Enhancements for Question Generation:

  • Added new GenerateMcqMrqQuestionPage.tsx to allow users to generate both MCQ and MRQ question in a similar page layout.
  • Increased user prompt character count to 10,000 characters.
  • Added Enhance Mode and Create Mode with tooltip to clarify that Enhance Mode builds on an existing question, while Create Mode generates new questions from scratch.
  • Hides Number of Questions field when Create Mode is selected.
  • Fixed a bug on active conversation title not syncing with Title field in prototype form.
  • Added Show/Hide Options expandable in GenerateMcqMrqExportDialog.tsx for users to easily confirm question details before exporting.
  • Added en, zh, ko translation support for labels.

Backend Enhancements for Question Generation:

  • Added a new generate action in app/controllers/course/assessment/question/multiple_responses_controller.rb to handle question generation requests, validate parameters, and return formatted responses.
  • Introduced Course::Assessment::Question::MrqGenerationService to encapsulate the logic for generating MCQ/MRQ questions using LLM prompts and parsing responses.
  • Added JSON schemas and prompt templates for MCQ and MRQ generation to define the structure of generated questions and guide LLM behavior.

API and Frontend Updates:

  • Updated the create and update methods in McqMrqAPI to return a RedirectWithEditUrl object, which includes both a redirect URL and an optional edit URL.
  • Added a new generate method in McqMrqAPI to call the backend's generate action for question generation.
  • Enhanced the GenerateTabs component in the frontend to improve UI responsiveness and display metadata for generated questions.

Controller Improvements:

  • Modified the create and update actions in app/controllers/course/assessment/question/multiple_responses_controller.rb to include redirectEditUrl in the JSON response for easier navigation to the edit page.

View Enhancements:

  • Updated show.json.jbuilder to include URLs for generating MCQ and MRQ questions in the assessment view.
  • Added support for generating MRQ questions from existing ones in _question_assessment.json.jbuilder.

@craigtonlian craigtonlian force-pushed the craigtonlian/add-generate-mcq branch 9 times, most recently from e7a9330 to afe1295 Compare July 20, 2025 11:59
@craigtonlian craigtonlian marked this pull request as ready for review July 20, 2025 12:01
@craigtonlian craigtonlian force-pushed the craigtonlian/add-generate-mcq branch 9 times, most recently from 80aebc4 to f0770b6 Compare July 25, 2025 02:37
@craigtonlian craigtonlian changed the title feat(GenerateMrqQuestion): add generate MRQ questions with AI feat(GenerateMrqQuestion): add generate MCQ/MRQ questions with AI Jul 27, 2025
@craigtonlian craigtonlian changed the title feat(GenerateMrqQuestion): add generate MCQ/MRQ questions with AI feat(GenerateMcqMrqQuestion): add generate MCQ/MRQ questions with AI Jul 27, 2025
@craigtonlian craigtonlian force-pushed the craigtonlian/add-generate-mcq branch 9 times, most recently from db8e2ec to b38e658 Compare July 31, 2025 06:37
@craigtonlian craigtonlian force-pushed the craigtonlian/add-generate-mcq branch 8 times, most recently from f3ee22f to 62b5202 Compare August 1, 2025 03:12
Copy link
Contributor

@adi-herwana-nus adi-herwana-nus left a comment

Choose a reason for hiding this comment

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

few minor changes needed

@craigtonlian craigtonlian force-pushed the craigtonlian/add-generate-mcq branch 2 times, most recently from a0c8044 to a3fdc6a Compare August 4, 2025 01:18
@adi-herwana-nus adi-herwana-nus force-pushed the craigtonlian/add-generate-mcq branch from a3fdc6a to 4a77eb3 Compare August 14, 2025 15:32
@adi-herwana-nus adi-herwana-nus merged commit df574fe into master Aug 14, 2025
14 checks passed
@adi-herwana-nus adi-herwana-nus deleted the craigtonlian/add-generate-mcq branch August 14, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants