trueFalse added to listening

This commit is contained in:
Carlos-Mesquita
2024-11-13 20:36:12 +00:00
parent 6daab0d9a7
commit 229dbe3e29
5 changed files with 25 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ class ListeningExerciseType(str, Enum):
writeBlanksQuestions = "writeBlanksQuestions"
writeBlanksFill = "writeBlanksFill"
writeBlanksForm = "writeBlanksForm"
trueFalse = "trueFalse"
class LevelExerciseType(str, Enum):
multipleChoice = "multipleChoice"

View File

@@ -18,6 +18,8 @@ from .multiple_choice import MultipleChoice
from .write_blank_forms import WriteBlankForms
from .write_blanks import WriteBlanks
from .write_blank_notes import WriteBlankNotes
from ..shared import TrueFalse
class ListeningService(IListeningService):
@@ -48,6 +50,7 @@ class ListeningService(IListeningService):
self._write_blanks_forms = WriteBlankForms(llm)
self._write_blanks_notes = WriteBlankNotes(llm)
self._import = ImportListeningModule(llm)
self._true_false = TrueFalse(llm)
self._sections = {
"section_1": {
"topic": EducationalContent.TWO_PEOPLE_SCENARIOS,
@@ -153,6 +156,12 @@ class ListeningService(IListeningService):
question["variant"] = "form"
self._logger.info(f"Added write blanks form: {question}")
return question
elif req_exercise.type == "trueFalse":
question = await self._true_false.gen_true_false_not_given_exercise(
text, req_exercise.quantity, start_id, difficulty, "listening"
)
self._logger.info(f"Added trueFalse: {question}")
return question
# ==================================================================================================================

View File

@@ -10,7 +10,7 @@ from app.services.abc import IReadingService, ILLMService
from .fill_blanks import FillBlanks
from .idea_match import IdeaMatch
from .paragraph_match import ParagraphMatch
from .true_false import TrueFalse
from ..shared import TrueFalse
from .import_reading import ImportReadingModule
from .write_blanks import WriteBlanks
@@ -88,7 +88,7 @@ class ReadingService(IReadingService):
elif req_exercise.type == "trueFalse":
question = await self._true_false.gen_true_false_not_given_exercise(
text, req_exercise.quantity, start_id, difficulty
text, req_exercise.quantity, start_id, difficulty, "reading"
)
self._logger.info(f"Added trueFalse: {question}")
return question

View File

@@ -0,0 +1,5 @@
from .true_false import TrueFalse
__all__ = [
"TrueFalse"
]

View File

@@ -10,7 +10,7 @@ class TrueFalse:
def __init__(self, llm: ILLMService):
self._llm = llm
async def gen_true_false_not_given_exercise(self, text: str, quantity: int, start_id: int, difficulty: str):
async def gen_true_false_not_given_exercise(self, text: str, quantity: int, start_id: int, difficulty: str, module: str):
messages = [
{
"role": "system",
@@ -41,9 +41,15 @@ class TrueFalse:
for i, question in enumerate(questions, start=start_id):
question["id"] = str(i)
tail = (
"the information given in the Reading Passage"
if module == "reading" else
"what you've heard"
)
return {
"id": str(uuid.uuid4()),
"prompt": "Do the following statements agree with the information given in the Reading Passage?",
"prompt": f"Do the following statements agree with {tail}?",
"questions": questions,
"type": "trueFalse"
}