From ADITI.YADAV at ucalgary.ca Sat May 17 17:41:58 2025 From: ADITI.YADAV at ucalgary.ca (ADITI YADAV) Date: Sat, 17 May 2025 21:41:58 +0000 Subject: [catsoop-users] CATSOOP - question about plugin infrastructure Message-ID: Hi CAT-SOOP Team, I hope you're doing well! I'm currently working on a local setup of CAT-SOOP (installed via pip) for a research project. I'm trying to implement a custom hint structure that would allow students to view progressive hints during quizzes, and eventually track which students view which hints. Since CAT-SOOP doesn?t currently have an inbuilt hint system, I?ve been attempting to implement this as a plugin. Here's what I've tried so far: I created a plugin named hints inside courses/sample_course/__PLUGINS__/hints/. I started with post_load.py, and confirmed via available_plugins(context, course) and terminal output that the plugin is being detected. In post_load.py, I attempted to inject HTML into context["cs_content"], and then into context["csq_content"], and finally context["csq_prompt"], but the hint button never appears on the rendered quiz page. I also tried using a pre_render.py file instead, but none of the print() debug statements in that file ever appear in the terminal, suggesting that pre_render hooks may not be executed at all. I'm running CAT-SOOP locally using catsoop start, with course content authored via blocks in .catsoop files. I'd appreciate any guidance on the following: * Which plugin hook(s) are guaranteed to run before the question box is rendered (e.g., so I can inject hints inline with the prompt)? * Is there a reliable way to modify or append content to questions created using the pythonliteral qtype from within a plugin? * Are there limitations on where csq_content, csq_prompt, or cs_content_addons are used depending on the question type? * Does pre_render.py work in the current pip-installable version, or is it only supported when running CAT-SOOP from source? Is there any working example of a plugin that successfully injects HTML into question content? I?ve tried to exhaust all avenues of documentation and debugging (including reading loader.py), but I feel a bit stuck. Thanks so much for your time. Best, Aditi Yadav Undergraduate Researcher University of Calgary -------------- next part -------------- An HTML attachment was scrubbed... URL: From hz at mit.edu Sat May 17 22:20:22 2025 From: hz at mit.edu (adam j hartz) Date: Sat, 17 May 2025 22:20:22 -0400 Subject: [catsoop-users] CATSOOP - question about plugin infrastructure In-Reply-To: References: Message-ID: Hi Aditi, Thanks for reaching out! I think the short answer is that the right hook to use for modifying questions is probably the pre_handle hook (since questions get rendered during the handler stage). By that time, though, cs_content will already have been parsed down into a different format, which is a list consisting of strings (representing raw HTML content) and tuples (representing questions), called cs_problem_spec. So you could make a very minimal plugin that modifies every question's prompt by putting the following in pre_handle.py: for part in cs_problem_spec: if isinstance(part, tuple): part[1]['csq_prompt'] += 'hello' In that example, part[0] contains the functions from the question type itself, and part[1] contains all of the variables set in your tag (or inherited from the default values specified in the question type). So you could use the contents of part[1] in that example to determine the question's name, type, etc, and from there do whatever computation you need to do in order to figure out what kind of hint to display (and you can include Markdown and/or HTML in what you add to the prompt). If you want the prompt to update after a submission is made, you'll also want to set csq_rerender = True for those questions (which you can either do directly in the questions themselves, or in the plugin by setting part[1]['csq_rerender'] = True after adding your hints). Hope this helps to get you started! I'd be happy to continue the conversation if that would be helpful. Thanks, -Adam