Skip to content

Commit f0770b6

Browse files
committed
feat(GenerateMcqMrqConversation): add Enhance Mode and Create Mode
1 parent 07aa2a8 commit f0770b6

File tree

14 files changed

+248
-89
lines changed

14 files changed

+248
-89
lines changed

app/services/course/assessment/question/mrq_generation_service.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def initialize(assessment, params)
4646
# @return [Hash] The LLM's generation response containing multiple questions.
4747
def generate_questions
4848
messages = build_messages
49-
5049
response = self.class.llm.chat(
5150
messages: messages,
5251
response_format: {
@@ -71,11 +70,10 @@ def build_messages
7170
formatted_user_prompt = user_prompt.format(
7271
custom_prompt: @custom_prompt,
7372
number_of_questions: @number_of_questions,
74-
source_question_title: @source_question_data&.dig(:title) || '',
75-
source_question_description: @source_question_data&.dig(:description) || '',
76-
source_question_options: format_source_options(@source_question_data&.dig(:options) || [])
73+
source_question_title: @source_question_data&.dig('title') || '',
74+
source_question_description: @source_question_data&.dig('description') || '',
75+
source_question_options: format_source_options(@source_question_data&.dig('options') || [])
7776
)
78-
7977
[
8078
{ role: 'system', content: formatted_system_prompt },
8179
{ role: 'user', content: formatted_user_prompt }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"_type": "prompt",
33
"input_variables": ["format_instructions"],
4-
"template": "You are an expert educational content creator specializing in multiple choice questions (MCQ).\n\nYour task is to generate high-quality multiple choice questions based on the provided instructions and context.\n\nKey requirements for MCQ generation:\n1. Create questions that have exactly ONE correct answer. Each question should have only one option that is correct.\n2. Ensure all options are plausible and well-written\n3. Try to create 4 options per question. If that is not feasible, ensure at least 2 options are provided.\n4. Questions should be clear, concise, and educational\n5. Options should be mutually exclusive and cover different aspects\n6. Avoid obvious incorrect answers\n7. Use an appropriate difficulty level for the target audience\n8. Make sure distractors (incorrect options) are plausible but clearly wrong\n\nWhen provided with a source question, you may use it as inspiration or reference, but create original questions.\n\n{format_instructions}"
4+
"template": "You are an expert educational content creator specializing in multiple choice questions (MCQ).\n\nYour task is to generate high-quality multiple choice questions based on the provided instructions and context.\n\nKey requirements for MCQ generation:\n1. Each question must have exactly ONE correct answer.\n2. Ensure all options are plausible and well-written.\n3. Try to create 4 options per question. If that is not feasible, ensure at least 2 options are provided.\n4. Questions should be clear, concise, and educational.\n5. Options should be mutually exclusive and cover different aspects.\n6. Avoid obvious or trivially incorrect distractors.\n7. Use an appropriate difficulty level for the target audience.\n8. Make sure distractors (incorrect options) are plausible but clearly wrong.\n\nInstructions for source question use:\n- If a source question is provided, you **must use it as the base** and **refine or improve** upon it using the provided custom instructions. Do **not** create an unrelated or entirely new question.\n- If the source question is **not provided** or is empty, you may generate a **new, original** question that aligns with the custom instructions.\n\n{format_instructions}"
55
}

app/services/course/assessment/question/prompts/mcq_generation_user_prompt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"source_question_description",
88
"source_question_options"
99
],
10-
"template": "Please generate {number_of_questions} multiple choice question(s) based on the following instructions:\n\nCustom Instructions: {custom_prompt}\n\nSource Question Context (for reference only):\nTitle: {source_question_title}\nDescription: {source_question_description}\nOptions:\n{source_question_options}\n\nGenerate {number_of_questions} high-quality multiple choice question(s) that:\n- Have clear, educational content\n- Include at least 2 options per question\n- Have exactly ONE correct answer per question\n- Are appropriate for educational assessment\n- Follow the custom instructions provided\n\nEach question should be original and well-structured for educational use."
10+
"template": "Please generate {number_of_questions} multiple choice question(s) based on the following instructions:\n\nCustom Instructions: {custom_prompt}\n\nSource Question Context:\nTitle: {source_question_title}\nDescription: {source_question_description}\nOptions:\n{source_question_options}\n\nGeneration Rules:\n- If the source question fields (title, description, or options) are provided and meaningful, you **must build upon and improve** the existing question. Do **not** create an unrelated question.\n- If the source question is empty or missing, then you may create a **new, original** question based solely on the custom instructions.\n\nAll questions must:\n- Have clear, educational content\n- Include at least 2 options per question (ideally 4 if possible)\n- Have exactly ONE correct answer per question\n- Be appropriate for educational assessment\n- Follow the custom instructions strictly\n- Provide well-written, plausible, and mutually exclusive options\n\nEach question should be well-structured and educationally valuable."
1111
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"_type": "prompt",
33
"input_variables": ["format_instructions"],
4-
"template": "You are an expert educational content creator specializing in multiple response questions (MRQ).\n\nYour task is to generate high-quality multiple response questions based on the provided instructions and context.\n\nKey requirements for MRQ generation:\n1. Create questions that may have one or more correct answers. It is acceptable for some questions to have only one correct answer, or for options like \"None of the above\" to be correct.\n2. Ensure all options are plausible and well-written\n3. Try to create 4 options per question. If that is not feasible, ensure at least 2 options are provided.\n4. Questions should be clear, concise, and educational\n5. Options should be mutually exclusive when possible\n6. Avoid obvious incorrect answers\n7. Use an appropriate difficulty level for the target audience\n\nWhen provided with a source question, you may use it as inspiration or reference, but create original questions.\n\n{format_instructions}"
4+
"template": "You are an expert educational content creator specializing in multiple response questions (MRQ).\n\nYour task is to generate high-quality multiple response questions based on the provided instructions and context.\n\nKey requirements for MRQ generation:\n1. Each question may have one or more correct answers. It is acceptable for some questions to have only one correct answer, or for options like \"None of the above\" to be correct.\n2. Ensure all options are plausible and well-written.\n3. Try to create 4 options per question. If that is not feasible, ensure at least 2 options are provided.\n4. Questions should be clear, concise, and educational.\n5. Options should be mutually exclusive when possible.\n6. Avoid obvious or trivially incorrect distractors.\n\nInstruction for source question use:\n- If a source question is provided, you **must use it as the base** and **refine or improve** upon it using the provided custom instructions. Do not generate an unrelated or entirely new question.\n- If the source question is **not provided** or is empty, you may generate a new, original question that aligns with the custom instructions.\n\n{format_instructions}"
55
}

app/services/course/assessment/question/prompts/mrq_generation_user_prompt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"source_question_description",
88
"source_question_options"
99
],
10-
"template": "Please generate {number_of_questions} multiple response question(s) based on the following instructions:\n\nCustom Instructions: {custom_prompt}\n\nSource Question Context (for reference only):\nTitle: {source_question_title}\nDescription: {source_question_description}\nOptions:\n{source_question_options}\n\nGenerate {number_of_questions} high-quality multiple response question(s) that:\n- Have clear, educational content\n- Include at least 2 options per question\n- Are appropriate for educational assessment\n- Follow the custom instructions provided\n\nEach question should be original and well-structured for educational use."
10+
"template": "Please generate {number_of_questions} multiple response question(s) based on the following instructions:\n\nCustom Instructions:\n{custom_prompt}\n\nSource Question Context:\nTitle: {source_question_title}\nDescription: {source_question_description}\nOptions:\n{source_question_options}\n\nGeneration Rules:\n- If the source question fields (title, description, or options) are provided and meaningful, you **must build upon and improve** the existing question. Do **not** create an unrelated question.\n- If the source question is empty or missing, then you may create a **new, original** question based solely on the custom instructions.\n\nAll questions must:\n- Have clear, educational content\n- Include at least 2 options per question (ideally 4 if possible)\n- Be appropriate for educational assessment\n- Follow the custom instructions strictly\n- Provide well-written, plausible, and mutually exclusive options\n\nEach question should be well-structured and educationally valuable."
1111
}

0 commit comments

Comments
 (0)