My Moodle AI Agent

by Rikaz Sheriff -
Number of replies: 4

Hi everyone,

This week, I moved from planning to building a working first version of my Moodle AI agent, the CPD & Ethics AI Assistant, on my individual server sandbox (sandbox14.nelliemuller.com) running Moodle 5.3.1, PHP 8.3, and MySQL 8.4.

1️⃣ The Problem & Teaching Context

To test my agent in a realistic setting, I built a three-part sample course titled Continuing Professional Development (CPD) & Medical Ethics. Clinicians and learners in online CPD courses often face two hurdles: decoding dense, bureaucratic clinical governance policies, and getting timely, constructive ethical feedback on case discussions. My agent is a native Moodle Block plugin (block_cpd_assistant) that sits right inside the course drawer to translate dense policy text into plain-language takeaways and provide formative ethical feedback on student discussion posts.

2️⃣ How the Agent Currently Works & Architecture

Working step by step with AgentLab and Gemini's Guided Learning feature, I built a clean, modular Moodle block architecture inside public_html/blocks/cpd_assistant/ and connected it live to the OpenAI API:

🔵 version.php declares the component name (block_cpd_assistant), release version, and Moodle 5.3 compatibility.
🔵 db/access.php sets up the Moodle permissions for adding the block to courses and dashboards.
🔵 lang/en/block_cpd_assistant.php stores all interface labels and descriptions cleanly.
🔵 settings.php uses Moodle's admin_setting_configpasswordunmask class so my OpenAI API key is saved securely in the mdl_config_plugins database table, masked on screen, and kept strictly server-side.
🔵 block_cpd_assistant.php renders the interactive block interface (with "Simplify Course Content" and "Give Ethics Feedback" actions), reads the saved key via get_config(), and sends server-side POST requests using Moodle's native curl helper to OpenAI's Chat Completions API (using gpt-5-nano).

3️⃣ How AgentLab & Gemini's Guided Learning Supported My Development

Using AgentLab alongside Gemini's Guided Learning feature gave me a structured, step-by-step coaching workflow rather than just handing over bulk code:

🔵 AgentLab helped me verify Moodle 5.3's architectural standards, security requirements, and plugin conventions.
🔵 Gemini's Guided Learning broke down each build milestone into clear, interactive steps—helping me understand why block plugins separate root class files from language files, walking me through server configuration and API billing setup, and guiding me through debugging PHP curl payloads in real time.

4️⃣ Challenges Encountered & How I Addressed Them

I ran into three realistic technical hurdles and resolved each one:

🔵 PHP Environment Limits: Moodle's installer flagged max_input_vars (which needed to be raised from 1000 to 5000). I updated max_input_vars in my Webuzo PHP INI editor and completed the database upgrade cleanly.
🔵 Plugin File Structure & Settings Visibility: During installation, Moodle threw a missing block class exception because the root block_cpd_assistant.php file and the lang/en/ language file were mixed up, and access.php needed to sit inside db/. Later, the Settings link did not appear until I added public function has_config() { return true; } to the block class and purged Moodle caches.
🔵 Model Parameter Compatibility: Once connected to OpenAI using gpt-5-nano, the API returned an error rejecting a custom temperature parameter (since nano reasoning models only support the default value and use reasoning_effort). I updated my PHP payload logic to conditionally apply reasoning_effort for GPT-5 models, and live responses began rendering immediately inside the block.


My Moodle AI agent has a working foundation and is ready to become more agentic.

My Moodle AI Agent

by Dr. Nellie Deutsch -

Hi Rikaz,

 

Thank you for sharing how your CPD & Ethics AI Assistant currently handles learner input in your Moodle sandbox. It is encouraging to see that your assistant is already generating structured formative feedback, identifying strengths, and suggesting areas for improvement.

Looking at your screenshot, I noticed something worth exploring. You entered the statement, "I think ethics needs to become much simpler for people to understand," and the assistant responded with feedback about your ideas. This demonstrates that the Give Ethics Feedback feature is working, but it would be useful to test whether the assistant can distinguish between a general opinion, a request for clarification, and an ethical dilemma requiring deeper reflection.

For example, when a learner expresses an opinion about making ethics easier to understand, the assistant could acknowledge the idea and ask a follow-up question such as, "Can you think of a clinical situation where simplifying ethical guidelines might help healthcare professionals make better decisions?" This would encourage the learner to connect the concept to a real-world situation.

You could also experiment with making the two features behave differently. Simplify Course Content could focus on translating complex medical and regulatory language into accessible explanations while preserving essential meaning. Give Ethics Feedback could act more like a reflective learning coach, asking questions, presenting alternative perspectives, and encouraging learners to justify their ethical decisions rather than immediately evaluating their responses.

Since you are using AgentLab and Gemini Guided Learning, you could ask both tools to help you refine the instructions sent to the AI model for each feature. You may not need to change the Moodle block architecture at all. Adjusting the prompts in your existing PHP code could be enough to improve how the assistant responds. I would suggest testing several different learner inputs before making further changes so you can compare the responses and identify what needs improvement.

Another interesting possibility would be to help learners explore ethical dilemmas involving patient autonomy, informed consent, confidentiality, and professional responsibility. The assistant could guide them through the decision-making process without making clinical judgments on their behalf.

I am particularly interested in seeing how you develop the formative feedback feature because it has considerable potential to support critical thinking and meaningful engagement in your CPD course. You have already established a working foundation, and refining the assistant's pedagogical behavior is an exciting next stage of development. 

 
 

My Moodle AI Agent

by Dr. Nellie Deutsch -

Hi Rikaz,

Thank you for sharing an excellent video presentation and such a detailed reflection on your progress in building the CPD & Ethics AI Assistant for Moodle. Your presentation was thorough and engaging, beginning with an explanation of how you combined the Moodle AgentLab agent with Gemini Guided Learning to move from planning to developing a working AI assistant on your Moodle 5.3.1 sandbox.

You identified a meaningful educational challenge in continuing professional development and medical ethics. Clinicians and learners often encounter complex clinical governance policies and need timely, constructive feedback on ethical discussions. Your decision to develop an AI assistant that simplifies dense policy content and provides formative feedback on discussion posts demonstrates how AI can make professional learning more accessible, relevant, and engaging. I particularly appreciated your creation of a three-part sample course to test the assistant in an authentic learning environment.

You provided an excellent explanation of your Moodle block architecture, including the purpose of version.php, access.php, language strings, settings.php, and the main block file. Your attention to Moodle plugin conventions, permissions, and server-side API integration shows that you are developing an understanding of how Moodle plugins function rather than simply relying on AI-generated code. It was also encouraging to see your attention to protecting the API key by keeping it on the server rather than exposing it in the browser.

You highlighted how AgentLab and Gemini Guided Learning complemented one another throughout the development process. AgentLab helped you work with Moodle's architecture and plugin requirements, while Gemini Guided Learning supported your understanding of each development stage through interactive guidance. This is exactly the kind of learning experience I hoped participants would gain from using the AI agents in the course. The goal is not simply to generate working code but to understand the process, ask meaningful questions, experiment, and develop the confidence to build and improve your own AI tools.

You also addressed several important technical challenges, including adjusting PHP's max_input_vars, correcting the Moodle block file structure, enabling the plugin settings, and resolving API parameter compatibility issues with GPT-5 nano. Your discovery that GPT-5 nano does not accept a custom temperature setting and requires a different approach to reasoning parameters was particularly valuable. These troubleshooting experiences are an essential part of learning to develop AI agents, and your willingness to investigate and resolve each issue demonstrates persistence and growing technical confidence.

I also appreciated your consideration of API costs. GPT-5 nano is an inexpensive option, but you may wish to explore the Gemini API as well. Google offers a free API tier for certain Gemini models, which could make experimentation even more affordable within the available usage limits. Comparing Gemini and GPT-5 nano in terms of response quality, speed, and operating costs would be an interesting next step, especially as you begin testing your assistant with more learners.

Your demonstration of the Simplify Course Content feature was particularly interesting because it showed how a technically complex topic can become easier to understand through AI-supported explanations. I would also be interested in seeing how your Give Ethics Feedback feature responds to different clinical scenarios. Since medical ethics often involves multiple perspectives and contextual considerations, it would be valuable to explore how the assistant encourages critical thinking and reflection rather than simply providing answers. Keeping the feedback formative and ensuring that learners understand the importance of professional judgment would strengthen its educational value.

I encourage you to continue experimenting with your CPD & Ethics AI Assistant and exploring how it can respond to individual learning needs. You have already made impressive progress in moving from an idea to a functioning Moodle block, and I look forward to seeing how you develop its educational capabilities as the course progresses.