Listening part 3 and 4.

This commit is contained in:
Cristiano Ferreira
2024-06-27 22:03:59 +01:00
parent 9a696bbeb5
commit a3cd1cdf59
3 changed files with 14 additions and 7 deletions

2
app.py
View File

@@ -116,7 +116,7 @@ def get_listening_section_3_question():
difficulty = request.args.get("difficulty", default=random.choice(difficulties)) difficulty = request.args.get("difficulty", default=random.choice(difficulties))
if (len(req_exercises) == 0): if (len(req_exercises) == 0):
req_exercises = random.sample(LISTENING_EXERCISE_TYPES, 1) req_exercises = random.sample(LISTENING_3_EXERCISE_TYPES, 1)
number_of_exercises_q = divide_number_into_parts(TOTAL_LISTENING_SECTION_3_EXERCISES, len(req_exercises)) number_of_exercises_q = divide_number_into_parts(TOTAL_LISTENING_SECTION_3_EXERCISES, len(req_exercises))

View File

@@ -22,6 +22,8 @@ LISTENING_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlan
LISTENING_1_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksFill', LISTENING_1_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksFill',
'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm'] 'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm']
LISTENING_2_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions'] LISTENING_2_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions']
LISTENING_3_EXERCISE_TYPES = ['multipleChoice3Options', 'writeBlanksQuestions']
LISTENING_4_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksForm']
TOTAL_READING_PASSAGE_1_EXERCISES = 13 TOTAL_READING_PASSAGE_1_EXERCISES = 13
TOTAL_READING_PASSAGE_2_EXERCISES = 13 TOTAL_READING_PASSAGE_2_EXERCISES = 13

View File

@@ -410,7 +410,7 @@ def generate_listening_4_monologue(topic: str):
{ {
"role": "user", "role": "user",
"content": ( "content": (
'Generate a comprehensive monologue on the academic subject ' 'Generate a comprehensive and complex monologue on the academic subject '
'of: "' + topic + '". Make sure that the generated monologue does not contain forbidden subjects in ' 'of: "' + topic + '". Make sure that the generated monologue does not contain forbidden subjects in '
'muslim countries.') 'muslim countries.')
@@ -477,7 +477,12 @@ def generate_listening_conversation_exercises(conversation: str, req_exercises:
if req_exercise == "multipleChoice": if req_exercise == "multipleChoice":
question = gen_multiple_choice_exercise_listening_conversation(conversation, number_of_exercises, start_id, question = gen_multiple_choice_exercise_listening_conversation(conversation, number_of_exercises, start_id,
difficulty) difficulty, 4)
exercises.append(question)
print("Added multiple choice: " + str(question))
elif req_exercise == "multipleChoice3Options":
question = gen_multiple_choice_exercise_listening_conversation(conversation, number_of_exercises, start_id,
difficulty, 3)
exercises.append(question) exercises.append(question)
print("Added multiple choice: " + str(question)) print("Added multiple choice: " + str(question))
elif req_exercise == "writeBlanksQuestions": elif req_exercise == "writeBlanksQuestions":
@@ -733,7 +738,7 @@ def assign_letters_to_paragraphs(paragraphs):
return result return result
def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty): def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty, n_options=4):
messages = [ messages = [
{ {
"role": "system", "role": "system",
@@ -747,7 +752,7 @@ def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int
{ {
"role": "user", "role": "user",
"content": ( "content": (
'Generate ' + str(quantity) + ' ' + difficulty + ' difficulty multiple choice questions of 4 options ' 'Generate ' + str(quantity) + ' ' + difficulty + ' difficulty multiple choice questions of ' + str(n_options) + ' options '
'of for this conversation:\n"' + text + '"') 'of for this conversation:\n"' + text + '"')
} }
@@ -763,7 +768,7 @@ def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int
} }
def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty): def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty, n_options=4):
messages = [ messages = [
{ {
"role": "system", "role": "system",
@@ -778,7 +783,7 @@ def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, s
"role": "user", "role": "user",
"content": ( "content": (
'Generate ' + str( 'Generate ' + str(
quantity) + ' ' + difficulty + ' difficulty multiple choice questions of 4 options ' quantity) + ' ' + difficulty + ' difficulty multiple choice questions of ' + str(n_options) + ' options '
'of for this monologue:\n"' + text + '"') 'of for this monologue:\n"' + text + '"')
} }