[catsoop-users] CATSOOP - question about plugin infrastructure

adam j hartz hz at mit.edu
Sat May 17 22:20:22 EDT 2025


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 <question>
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


More information about the catsoop-users mailing list