generate_mcqs
Create multiple-choice questions for educational topics using EduChain's QnA engine. Specify a topic and number of questions to generate structured MCQs with correct answers and distractors.
Instructions
Generate multiple-choice questions (MCQs) for a given educational topic.
This function leverages EduChain's QnA engine to create well-structured
multiple-choice questions with correct answers and plausible distractors.
Each question includes four options with one correct answer.
Args:
topic (str): The educational topic or subject area for which to generate
questions. Should be specific enough to generate focused questions.
Examples: "Photosynthesis", "World War II", "Python Programming"
num_questions (int, optional): The number of questions to generate.
Defaults to 5. Must be between 1 and 20.
Returns:
Dict[str, Any]: A dictionary containing the generated questions and metadata.
On success, includes:
- questions: List of question objects with options and correct answers
- topic: The input topic
- count: Number of questions generated
On error, includes:
- error: Error message describing what went wrong
Raises:
ValueError: If num_questions is not in the valid range (1-20)
Example:
>>> generate_mcqs("Photosynthesis", 3)
{
"questions": [
{
"question": "What is the primary purpose of photosynthesis?",
"options": ["A) ...", "B) ...", "C) ...", "D) ..."],
"correct_answer": "B"
},
...
],
"topic": "Photosynthesis",
"count": 3
}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | ||
| num_questions | No |