Add question db insert.

This commit is contained in:
Cristiano Ferreira
2023-08-24 21:28:59 +01:00
parent 18bf6d59e0
commit ca6094c3e7
11 changed files with 1257 additions and 62 deletions

View File

@@ -2,6 +2,10 @@ from enum import Enum
class QuestionType(Enum):
LISTENING_SECTION_1 = "Listening Section 1"
LISTENING_SECTION_2 = "Listening Section 2"
LISTENING_SECTION_3 = "Listening Section 3"
LISTENING_SECTION_4 = "Listening Section 4"
WRITING_TASK_1 = "Writing Task 1"
WRITING_TASK_2 = "Writing Task 2"
SPEAKING_1 = "Speaking Task Part 1"
@@ -172,7 +176,93 @@ def get_grading_messages(question_type: QuestionType, question: str, answer: str
def get_question_gen_messages(question_type: QuestionType):
if QuestionType.WRITING_TASK_2 == question_type:
if QuestionType.LISTENING_SECTION_1 == question_type:
return [
{
"role": "user",
"content": "You are a IELTS program that generates questions for the exams.",
},
{
"role": "user",
"content": "Provide me with a transcript similar to the ones in ielts exam Listening Section 1. "
"Create an engaging transcript simulating a conversation related to a unique type of service "
"that requires getting the customer's details. Make sure to include specific details "
"and descriptions to bring"
"the scenario to life. After the transcript, please "
"generate a 'form like' fill in the blanks exercise with 6 form fields (ex: name, date of birth)"
" to fill related to the customer's details. Finally, "
"provide the answers for the exercise. The response must be a json following this format: "
"{ 'type': '<type of registration (ex: hotel, gym, english course, etc)>', "
"'transcript': '<transcript of just the conversation about a registration of some sort, "
"identify the person talking in each speech line>', "
"'exercise': { 'form field': { '1': '<form field 1>', '2': '<form field 2>', "
"'3': '<form field 3>', '4': '<form field 4>', "
"'5': '<form field 5>', '6': '<form field 5>' }, "
"'answers': {'1': '<answer to fill blank space in form field 1>', '2': '<answer to fill blank "
"space in form field 2>', '3': '<answer to fill blank space in form field 3>', "
"'4': '<answer to fill blank space in form field 4>', '5': '<answer to fill blank space in form field 5>',"
" '6': '<answer to fill blank space in form field 6>'}}}",
}
]
elif QuestionType.LISTENING_SECTION_2 == question_type:
return [
{
"role": "user",
"content": "You are a IELTS program that generates questions for the exams.",
},
{
"role": "user",
"content": "Provide me with a transcript similar to the ones in ielts exam Listening section 2. After the transcript, please "
"generate a fill in the blanks exercise with 6 statements related to the text content. Finally, "
"provide the answers for the exercise. The response must be a json following this format: "
"{ 'transcript': 'transcript about some subject', 'exercise': { 'statements': { '1': 'statement 1 "
"with a blank space to fill', '2': 'statement 2 with a blank space to fill', '3': 'statement 3 with a "
"blank space to fill', '4': 'statement 4 with a blank space to fill', '5': 'statement 5 with a blank "
"space to fill', '6': 'statement 6 with a blank space to fill' }, "
"'answers': {'1': 'answer to fill blank space in statement 1', '2': 'answer to fill blank "
"space in statement 2', '3': 'answer to fill blank space in statement 3', "
"'4': 'answer to fill blank space in statement 4', '5': 'answer to fill blank space in statement 5',"
" '6': 'answer to fill blank space in statement 6'}}}",
}
]
elif QuestionType.LISTENING_SECTION_3 == question_type:
return [
{
"role": "user",
"content": "You are a IELTS program that generates questions for the exams.",
},
{
"role": "user",
"content": "Provide me with a transcript similar to the ones in ielts exam Listening section 3. After the transcript, please "
"generate 4 multiple choice questions related to the text content. Finally, "
"provide the answers for the exercise. The response must be a json following this format: "
"{ 'transcript': 'generated transcript similar to the ones in ielts exam Listening section 3', "
"'exercise': { 'questions': [ { 'question': "
"'question 1', 'options': ['option 1', 'option 2', 'option 3', 'option 4'], 'answer': 1}, "
"{'question': 'question 2', 'options': ['option 1', 'option 2', 'option 3', 'option 4'], "
"'answer': 3}, {'question': 'question 3', 'options': ['option 1', 'option 2', 'option 3', "
"'option 4'], 'answer': 0}, {'question': 'question 4', 'options': ['option 1', 'option 2', "
"'option 3', 'option 4'], 'answer': 2}]}}",
}
]
elif QuestionType.LISTENING_SECTION_4 == question_type:
return [
{
"role": "user",
"content": "You are a IELTS program that generates questions for the exams.",
},
{
"role": "user",
"content": "Provide me with a transcript similar to the ones in ielts exam Listening section 4. After the transcript, please "
"generate 4 completion-type questions related to the text content to complete with 1 word. Finally, "
"provide the answers for the exercise. The response must be a json following this format: "
"{ 'transcript': 'generated transcript similar to the ones in ielts exam Listening section 4', "
"'exercise': [ { 'question': 'question 1', 'answer': 'answer 1'}, "
"{'question': 'question 2', 'answer': 'answer 2'}, {'question': 'question 3', 'answer': 'answer 3'}, "
"{'question': 'question 4', 'answer': 'answer 4'}]}",
}
]
elif QuestionType.WRITING_TASK_2 == question_type:
return [
{
"role": "user",