ENCOA-255 gpt was grouping parts by sections and the reading passages were not updated with text.content instead of the old context field
This commit is contained in:
@@ -54,7 +54,6 @@ async def import_level(
|
|||||||
):
|
):
|
||||||
return await level_controller.upload_level(exercises, solutions)
|
return await level_controller.upload_level(exercises, solutions)
|
||||||
|
|
||||||
|
|
||||||
@level_router.post(
|
@level_router.post(
|
||||||
'/custom/',
|
'/custom/',
|
||||||
dependencies=[Depends(Authorized([IsAuthenticatedViaBearerToken]))]
|
dependencies=[Depends(Authorized([IsAuthenticatedViaBearerToken]))]
|
||||||
|
|||||||
@@ -47,10 +47,13 @@ class FillBlanksExercise(BaseModel):
|
|||||||
|
|
||||||
Exercise = Union[MultipleChoiceExercise, FillBlanksExercise]
|
Exercise = Union[MultipleChoiceExercise, FillBlanksExercise]
|
||||||
|
|
||||||
|
class Text(BaseModel):
|
||||||
|
content: str
|
||||||
|
title: str
|
||||||
|
|
||||||
class Part(BaseModel):
|
class Part(BaseModel):
|
||||||
exercises: List[Exercise]
|
exercises: List[Exercise]
|
||||||
context: Optional[str] = Field(default=None)
|
text: Optional[Text] = Field(default=None)
|
||||||
|
|
||||||
|
|
||||||
class Exam(BaseModel):
|
class Exam(BaseModel):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from pydantic import ValidationError
|
|||||||
from app.dtos.exams.level import (
|
from app.dtos.exams.level import (
|
||||||
MultipleChoiceExercise,
|
MultipleChoiceExercise,
|
||||||
FillBlanksExercise,
|
FillBlanksExercise,
|
||||||
Part, Exam
|
Part, Exam, Text
|
||||||
)
|
)
|
||||||
from app.dtos.sheet import Sheet, Option, MultipleChoiceQuestion, FillBlanksWord
|
from app.dtos.sheet import Sheet, Option, MultipleChoiceQuestion, FillBlanksWord
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ class LevelMapper:
|
|||||||
parts = []
|
parts = []
|
||||||
for part in response['parts']:
|
for part in response['parts']:
|
||||||
part_exercises = part['exercises']
|
part_exercises = part['exercises']
|
||||||
context = part.get('context', None)
|
text = part.get('text', None)
|
||||||
|
|
||||||
exercises = []
|
exercises = []
|
||||||
for exercise in part_exercises:
|
for exercise in part_exercises:
|
||||||
@@ -32,8 +32,13 @@ class LevelMapper:
|
|||||||
exercises.append(exercise_model)
|
exercises.append(exercise_model)
|
||||||
|
|
||||||
part_kwargs = {"exercises": exercises}
|
part_kwargs = {"exercises": exercises}
|
||||||
if context is not None:
|
if text is not None and text.get('content', None):
|
||||||
part_kwargs["context"] = context
|
title = text.get('title', 'Untitled')
|
||||||
|
if title == '':
|
||||||
|
title = 'Untitled'
|
||||||
|
part_kwargs["text"] = Text(title=title, content=text['content'])
|
||||||
|
else:
|
||||||
|
part_kwargs["text"] = None
|
||||||
|
|
||||||
part_model = Part(**part_kwargs)
|
part_model = Part(**part_kwargs)
|
||||||
parts.append(part_model)
|
parts.append(part_model)
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ class UploadLevelModule:
|
|||||||
return {
|
return {
|
||||||
"parts": [
|
"parts": [
|
||||||
{
|
{
|
||||||
"context": "<this attribute is optional you may exclude it if not required>",
|
"text": {
|
||||||
|
"content": "<this attribute is mandatory if there is a text passage else this 'text' field is omitted>",
|
||||||
|
"title": "<this attribute is optional you may exclude it if not required>",
|
||||||
|
},
|
||||||
"exercises": [
|
"exercises": [
|
||||||
self._multiple_choice_html(),
|
self._multiple_choice_html(),
|
||||||
self._passage_blank_space_html()
|
self._passage_blank_space_html()
|
||||||
@@ -86,7 +89,7 @@ class UploadLevelModule:
|
|||||||
"role": "system",
|
"role": "system",
|
||||||
"content": (
|
"content": (
|
||||||
'You are GPT Scraper and your job is to clean dirty html into clean usable JSON formatted data.'
|
'You are GPT Scraper and your job is to clean dirty html into clean usable JSON formatted data.'
|
||||||
'Your current task is to scrape html english questions sheets.\n\n'
|
'Your current task is to scrape html english questions sheets and structure them into parts NOT sections.\n\n'
|
||||||
|
|
||||||
'In the question sheet you will only see 4 types of question:\n'
|
'In the question sheet you will only see 4 types of question:\n'
|
||||||
'- blank space multiple choice\n'
|
'- blank space multiple choice\n'
|
||||||
@@ -111,23 +114,24 @@ class UploadLevelModule:
|
|||||||
'out the best paragraph separation possible.'
|
'out the best paragraph separation possible.'
|
||||||
|
|
||||||
'You will place all the information in a single JSON: '
|
'You will place all the information in a single JSON: '
|
||||||
'{"parts": [{"exercises": [{...}], "context": ""}]}\n '
|
'{"parts": [{"exercises": [{...}], "text": {"title": "", "content": ""} ]}\n '
|
||||||
'Where {...} are the exercises templates for each part of a question sheet and the optional field '
|
'Where {...} are the exercises templates for each part of a question sheet and the optional field '
|
||||||
'context.'
|
'text, which contains the reading passages that are required in order to solve the part questions, '
|
||||||
|
'(if there are passages) place them in text.content and if there is a title place it in text.title '
|
||||||
'IMPORTANT: The question sheet may be divided by sections but you need to only consider the parts, '
|
'else omit the title field.\n'
|
||||||
'so that you can group the exercises by the parts that are in the html, this is crucial since only '
|
|
||||||
'reading passage multiple choice require context and if the context is included in parts where it '
|
'IMPORTANT: As stated earlier your job is to structure the questions into PARTS not SECTION, this means '
|
||||||
'is not required the UI will be messed up. Some make sure to correctly group the exercises by parts.\n'
|
'that if there is for example: Section 1, Part 1 and Part 2, Section 2, Part 1 and Part 2, you MUST '
|
||||||
|
'place in the parts array 4 parts NOT 2 parts with the exercises of both parts! You must strictly '
|
||||||
|
'adhere to this instruction, do not mistake sections for parts!\n'
|
||||||
|
|
||||||
'The templates for the exercises are the following:\n'
|
'The templates for the exercises are the following:\n'
|
||||||
'- blank space multiple choice, underline multiple choice and reading passage multiple choice: '
|
'- blank space multiple choice, underline multiple choice and reading passage multiple choice: '
|
||||||
f'{self._multiple_choice_html()}\n'
|
f'{self._multiple_choice_html()}\n'
|
||||||
f'- reading passage blank space multiple choice: {self._passage_blank_space_html()}\n'
|
f'- reading passage blank space multiple choice: {self._passage_blank_space_html()}\n'
|
||||||
|
|
||||||
'IMPORTANT: For the reading passage multiple choice the context field must be set with the reading '
|
'IMPORTANT: The text.content field must be set with the reading passages of a part (if there is one)'
|
||||||
'passages without paragraphs or line numbers, with 2 newlines between paragraphs, for the other '
|
'without paragraphs or line numbers, with 2 newlines between paragraphs.'
|
||||||
'exercises exclude the context field.'
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,30 +139,19 @@ class UploadLevelModule:
|
|||||||
def _multiple_choice_html():
|
def _multiple_choice_html():
|
||||||
return {
|
return {
|
||||||
"type": "multipleChoice",
|
"type": "multipleChoice",
|
||||||
"prompt": "Select the appropriate option.",
|
"prompt": "<general instructions for this section>",
|
||||||
"questions": [
|
"questions": [
|
||||||
{
|
{
|
||||||
"id": "<the question id>",
|
"id": "<question number as string>",
|
||||||
"prompt": "<the question>",
|
"prompt": "<question text>",
|
||||||
"solution": "<the option id solution>",
|
|
||||||
"options": [
|
"options": [
|
||||||
{
|
{
|
||||||
"id": "A",
|
"id": "<A/B/C/D>",
|
||||||
"text": "<the a option>"
|
"text": "<option text>"
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "B",
|
|
||||||
"text": "<the b option>"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "C",
|
|
||||||
"text": "<the c option>"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "D",
|
|
||||||
"text": "<the d option>"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"solution": "<correct option letter>",
|
||||||
|
"variant": "text"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user