Creating Custom Interactive Multiple Choice Question Cells in JupyterLab

I’m currently working on a project where I want to create custom cells in JupyterLab, allowing instructors to input multiple-choice questions and have these questions rendered as interactive elements in the notebook.

I’m aware that one way to achieve this is by pasting HTML code into either code or markdown cells, but it feels more natural to have this as a separate cell type instead.

I came across an older thread that discussed the creation of custom cells in JupyterLab. You can find the link to the old thread here: Old Thread.

If anyone has insights, suggestions, or information on how to build a custom cell renderer instead pasting it as html.

As a note: it is unlikely such a thing would be added as a new cell_type. Natural for your specific users or not, these are basically the underpinning of interoperability between all .ipynb-aware tools.

There have been some discussions of changing cell_type to be more like the MIME bundle of outputs, but even this would likely not occur for… years.

In the near term, some options might include:

  • making a custom Jupyter Widget or output type
  • making a plugin for an extensible markdown renderer, such as jupyterlab-markup
    • for now, the marked renderer is not extensible
  • making a lab extension which can render a sidebar panel which can react based on dedicated cell metadata
  • making a fully-custom Notebook-compatible editor
    • probably don’t consider this