Skip to main content

A JupyterLab extension.

Project description

Student frontend JupyterLab Extension

A JupyterLab extension that serves as an alternative frontend.

Illustrative screenshots

  1. Student programming environment.

  1. Consent the use of the system.

  1. (Optional) View description of the three hint types.

  1. Click one of the type buttons to request hint. Reflect on the problem.

  1. Retrieve AI-generated hints based on the buggy code and reflection

  1. Optional to escalate the request to instructors if the hint is rated as unhelpful.

  1. Retrieve instructor feedback if escalated.

Requirements

  • JupyterLab >= 4.0.0

Development

Note: You will need NodeJS to build the extension package.

# Clone the repo to your local environment
# Change directory to the frontend_student_jx directory
# Install package in development mode
source .venv/bin/activate
pip install -e "."
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Server extension must be manually installed in develop mode
jupyter server extension enable hintbot
# Rebuild extension Typescript source after making changes
jlpm build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# In one terminal:
jlpm run watch          # rebuilds on source changes
# In another terminal:
jupyter lab             # run Jupyterlab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

Packaging the extension

See RELEASE

Publish to PyPI

This project is already configured for Python packaging with Hatch and the JupyterLab builder (prebuilt extension for JupyterLab 4). To rebuild and publish a release on PyPI:

  1. Clean everything jlpm clean:all

  2. Rebuild the labextension (production) jlpm build:prod

  3. Build wheel hatch build

  4. Sanity check the build

  • Test-install in a clean virtualenv: pip install dist/*.whl, start JupyterLab, and confirm the extension is active.
  1. Upload to PyPI
  • Create a PyPI account and an API token (Settings → API tokens).
  • Install twine: pip install twine.
  • Upload: TWINE_USERNAME=__token__ TWINE_PASSWORD=<pypi-token> twine upload dist/*.
  1. Install as a user
  • Users can then install with: pip install jx-loop-hint.
  • Because this is a prebuilt extension, no jupyter lab build step is required for JupyterLab 4.

Notes on Student ID for budget tracking

The extension uses the environment variable VOC_USERID to identify the student when making requests to the backend for hint budget tracking. If this environment variable is not set, it falls back to a default, fixed identifier.

Notes on the student program for a question is extracted from a notebook

The extension extracts a student's program for a particular question by scanning notebook cells starting from the question's markdown cell and concatenating subsequent code cells until it reaches a configured end-marker cell. This extracted program is sent along with other context (e.g., notebook JSON) to the backend when creating an AI hint request.

Key rules implemented by the extension (behavior mirrors src/requestHint.ts):

  • Question start detection

    • If a questions.json configuration is present under user_customizable_configs/notebook_questions/, the extension treats any markdown cell whose nbgrader.grade_id equals a question_start_grade_id in that config as the start of a question.
  • Program extraction (end marker)

    • The matching question entry in questions.json should provide a question_end_grade_id. The extractor will stop concatenating code cells when it encounters a cell whose nbgrader.grade_id equals that question_end_grade_id.
  • What is concatenated

    • Only code cells are appended, in document order, starting from the cell immediately after the question-start markdown cell up to (but not including) the end-marker cell.
    • Cell boundaries are preserved by inserting a single newline between appended cells so the backend can reason about cell separation.
  • Robust reading across JupyterLab versions

    • The extractor tries multiple ways to read a cell's text to be resilient across JupyterLab versions and widget/model shapes:
      1. cell.value.text (common for ICellModel)
      2. cell.model.value.text (widget wrappers)
      3. sharedModel.getSource() (some collaborative/shared models)
      4. cell.input.model.value.text (widget-level input model)

Example config entry (user_customizable_configs/notebook_questions/questions.json):

[
	{
		"question_id": "q1",
		"question_start_grade_id": "cell-abc123",
		"question_end_grade_id": "cell-abc123_assert"
	}
]

This will cause the extractor to use q1 as the problem_id sent to the backend and to stop assembling the program when a cell with grade id cell-abc123_assert is encountered.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jx_loop_hint-0.0.1.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jx_loop_hint-0.0.1-py3-none-any.whl (63.2 kB view details)

Uploaded Python 3

File details

Details for the file jx_loop_hint-0.0.1.tar.gz.

File metadata

  • Download URL: jx_loop_hint-0.0.1.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for jx_loop_hint-0.0.1.tar.gz
Algorithm Hash digest
SHA256 961a040217f121bc9f21d2f415e8e0289c1f1ce02c95b47820c5fed644d30e5e
MD5 77a75b162bd1f262ae16f952b6312621
BLAKE2b-256 f0046bfca1b63592da3bac7a0846dc3dc5ec578fbe4abfd7213d266272d554d5

See more details on using hashes here.

File details

Details for the file jx_loop_hint-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: jx_loop_hint-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 63.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for jx_loop_hint-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe2ce3c7a8b170be4986387d9a05cca4f9562a7f82fc74db07a10be390eef38e
MD5 68c76918c7eaa101389d3c45e807c3fd
BLAKE2b-256 98ae30c48359f7a795d7c0897b8c038454cb1186a4c848a33cbe936beea605cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page