Skip to content

MBS-10581: Build new prompt template system#64

Merged
marcusgreen merged 6 commits intomarcusgreen:mainfrom
bycs-lp:MBS-10581_Build_new_prompt_template_system
Feb 10, 2026
Merged

MBS-10581: Build new prompt template system#64
marcusgreen merged 6 commits intomarcusgreen:mainfrom
bycs-lp:MBS-10581_Build_new_prompt_template_system

Conversation

@PM84
Copy link
Copy Markdown
Contributor

@PM84 PM84 commented Feb 6, 2026

Fixes #63

This PR introduces a structured prompt template system for the AI Text question type, replacing the legacy [[placeholder]] syntax with a more flexible {{placeholder}} system. The new architecture provides clear separation between admin-configured templates and question-specific content.

Changes

New Features

  • Structured Prompt Template System: Admins can now configure a central prompt template with placeholders ({{role}}, {{questiontext}}, {{aiprompt}}, {{markscheme}}, {{defaultmark}}, {{response}}, {{jsonprompt}}, {{language}})
  • Role Prompt Setting: New admin setting for defining the AI's role/persona
  • Expert Mode: Question authors can take full control of the prompt by including {{response}} in their AI prompt, bypassing the admin template
  • Expert Mode Template Button: UI button in the question edit form to easily insert the admin template for customization
  • Confirmation Dialog: Detailed explanation of expert mode with all available placeholders when activating

Migration

  • Automatic database migration (upgrade step 2026020601) converts legacy prompts:
    • [[expert]] → removed (was only a mode indicator)
    • [[response]]{{response}}
    • [[questiontext]]{{questiontext}}
    • [[userlang]]{{language}}

Testing

  • All 39 unit tests passing
  • Codechecker clean
  • Manual testing of:
    • Standard mode prompt generation
    • Expert mode with {{response}} detection
    • Expert mode template button and confirmation dialog
    • Legacy prompt migration

Breaking Changes

Questions using the old [[expert]]/[[response]] syntax will be automatically migrated during upgrade. No manual intervention required.

@PM84 PM84 force-pushed the MBS-10581_Build_new_prompt_template_system branch 5 times, most recently from 160a79f to 065824a Compare February 6, 2026 11:24
@PM84 PM84 force-pushed the MBS-10581_Build_new_prompt_template_system branch from 065824a to 20bcfc0 Compare February 6, 2026 11:28
@marcusgreen
Copy link
Copy Markdown
Owner

Reading through code

@PM84 PM84 force-pushed the MBS-10581_Build_new_prompt_template_system branch from e39a91c to 1959d23 Compare February 6, 2026 13:24
@marcusgreen
Copy link
Copy Markdown
Owner

I have started reading through this and done a few tests, it looks good. I like the replacement of [[ ]] with {{ }}. The former was a legacy of me working with Moodle question types whereas the new approach is in line with the way most people deal with LLM systems. My tests so far have shown an unexpected improvement in responses, probably because the prompts are more like what an LLM expects. Back to testing.

@PM84 PM84 force-pushed the MBS-10581_Build_new_prompt_template_system branch from 373adb1 to fa1adb8 Compare February 9, 2026 21:37
@PM84 PM84 force-pushed the MBS-10581_Build_new_prompt_template_system branch from f67bfce to e61f176 Compare February 10, 2026 09:05
@marcusgreen marcusgreen merged commit 9113088 into marcusgreen:main Feb 10, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Structured Prompt Template System for AI Grading

2 participants