Feat: Discern Essay format types and load initial text templates

This commit is contained in:
2026-04-18 01:39:20 +02:00
parent 9cab0155b1
commit c3bc3bbcdd
6 changed files with 25 additions and 5 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@ You are an expert quiz solver.
Please solve the provided question based on its type and provide the correct result. Please solve the provided question based on its type and provide the correct result.
- For choice questions, output the exact index(es) of the correct answer(s). - For choice questions, output the exact index(es) of the correct answer(s).
- For text/numerical questions, provide the exact wording or number. - For text/numerical questions, provide the exact wording or number.
- For essay questions, provide a highly detailed and complete response. - For essay questions, provide a highly detailed and complete response, adapting exactly to the requested 'format' (HTML vs plain text) and building upon any 'initial_text' template if supplied.
Always output strict JSON according to the requested schema block. Always output strict JSON according to the requested schema block.
`.trim(); `.trim();
+20 -2
View File
@@ -96,10 +96,28 @@ export function parseMoodleQuestion(
} }
if (container.classList.contains('essay')) { if (container.classList.contains('essay')) {
return { let format: 'plain_text' | 'html' = 'plain_text';
let initial_text = '';
const editorDiv = container.querySelector('.qtype_essay_editor');
if (editorDiv) format = 'html';
const textarea = container.querySelector<HTMLTextAreaElement>('textarea');
if (textarea) {
initial_text = textarea.value || textarea.textContent || '';
initial_text = normalizeText(initial_text);
}
const payload: MoodleQuestionQuery = {
question_type: MoodleQuestionType.ESSAY, question_type: MoodleQuestionType.ESSAY,
question_text: normalizedQuestionText question_text: normalizedQuestionText,
format
}; };
if (initial_text) {
(payload as any).initial_text = initial_text;
}
return payload;
} }
if (container.classList.contains('match')) { if (container.classList.contains('match')) {
+2
View File
@@ -49,6 +49,8 @@ export interface NumericalQuery {
export interface EssayQuery { export interface EssayQuery {
question_type: MoodleQuestionType.ESSAY; question_type: MoodleQuestionType.ESSAY;
question_text: string; question_text: string;
format: 'plain_text' | 'html';
initial_text?: string;
} }
export interface MatchQuery { export interface MatchQuery {