Merged in release/async (pull request #38)
trueFalse added to listening
This commit is contained in:
@@ -55,6 +55,7 @@ class ListeningExerciseType(str, Enum):
|
|||||||
writeBlanksQuestions = "writeBlanksQuestions"
|
writeBlanksQuestions = "writeBlanksQuestions"
|
||||||
writeBlanksFill = "writeBlanksFill"
|
writeBlanksFill = "writeBlanksFill"
|
||||||
writeBlanksForm = "writeBlanksForm"
|
writeBlanksForm = "writeBlanksForm"
|
||||||
|
trueFalse = "trueFalse"
|
||||||
|
|
||||||
class LevelExerciseType(str, Enum):
|
class LevelExerciseType(str, Enum):
|
||||||
multipleChoice = "multipleChoice"
|
multipleChoice = "multipleChoice"
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ from .multiple_choice import MultipleChoice
|
|||||||
from .write_blank_forms import WriteBlankForms
|
from .write_blank_forms import WriteBlankForms
|
||||||
from .write_blanks import WriteBlanks
|
from .write_blanks import WriteBlanks
|
||||||
from .write_blank_notes import WriteBlankNotes
|
from .write_blank_notes import WriteBlankNotes
|
||||||
|
from ..shared import TrueFalse
|
||||||
|
|
||||||
|
|
||||||
class ListeningService(IListeningService):
|
class ListeningService(IListeningService):
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ class ListeningService(IListeningService):
|
|||||||
self._write_blanks_forms = WriteBlankForms(llm)
|
self._write_blanks_forms = WriteBlankForms(llm)
|
||||||
self._write_blanks_notes = WriteBlankNotes(llm)
|
self._write_blanks_notes = WriteBlankNotes(llm)
|
||||||
self._import = ImportListeningModule(llm)
|
self._import = ImportListeningModule(llm)
|
||||||
|
self._true_false = TrueFalse(llm)
|
||||||
self._sections = {
|
self._sections = {
|
||||||
"section_1": {
|
"section_1": {
|
||||||
"topic": EducationalContent.TWO_PEOPLE_SCENARIOS,
|
"topic": EducationalContent.TWO_PEOPLE_SCENARIOS,
|
||||||
@@ -153,6 +156,12 @@ class ListeningService(IListeningService):
|
|||||||
question["variant"] = "form"
|
question["variant"] = "form"
|
||||||
self._logger.info(f"Added write blanks form: {question}")
|
self._logger.info(f"Added write blanks form: {question}")
|
||||||
return 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
|
||||||
|
|
||||||
|
|
||||||
# ==================================================================================================================
|
# ==================================================================================================================
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from app.services.abc import IReadingService, ILLMService
|
|||||||
from .fill_blanks import FillBlanks
|
from .fill_blanks import FillBlanks
|
||||||
from .idea_match import IdeaMatch
|
from .idea_match import IdeaMatch
|
||||||
from .paragraph_match import ParagraphMatch
|
from .paragraph_match import ParagraphMatch
|
||||||
from .true_false import TrueFalse
|
from ..shared import TrueFalse
|
||||||
from .import_reading import ImportReadingModule
|
from .import_reading import ImportReadingModule
|
||||||
from .write_blanks import WriteBlanks
|
from .write_blanks import WriteBlanks
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ class ReadingService(IReadingService):
|
|||||||
|
|
||||||
elif req_exercise.type == "trueFalse":
|
elif req_exercise.type == "trueFalse":
|
||||||
question = await self._true_false.gen_true_false_not_given_exercise(
|
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}")
|
self._logger.info(f"Added trueFalse: {question}")
|
||||||
return question
|
return question
|
||||||
|
|||||||
5
app/services/impl/exam/shared/__init__.py
Normal file
5
app/services/impl/exam/shared/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from .true_false import TrueFalse
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"TrueFalse"
|
||||||
|
]
|
||||||
@@ -10,7 +10,7 @@ class TrueFalse:
|
|||||||
def __init__(self, llm: ILLMService):
|
def __init__(self, llm: ILLMService):
|
||||||
self._llm = llm
|
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 = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
@@ -41,9 +41,15 @@ class TrueFalse:
|
|||||||
for i, question in enumerate(questions, start=start_id):
|
for i, question in enumerate(questions, start=start_id):
|
||||||
question["id"] = str(i)
|
question["id"] = str(i)
|
||||||
|
|
||||||
|
tail = (
|
||||||
|
"the information given in the Reading Passage"
|
||||||
|
if module == "reading" else
|
||||||
|
"what you've heard"
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"id": str(uuid.uuid4()),
|
"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,
|
"questions": questions,
|
||||||
"type": "trueFalse"
|
"type": "trueFalse"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user