catsoop docs for website and pythonic-multiline #111

Open
ichuang wants to merge 14 commits from ichuang/catsoop:pythonic-multiline into main
First-time contributor

Summary

This PR expands the pythonic question type with explicit multi-line input
and multi-prompt grading, adds focused unit coverage for the new behavior, and
substantially expands CAT-SOOP's course-authoring documentation.

The implementation work is intentionally limited to pythonic. The remaining
changes are documentation, examples, navigation, a screenshot used by the
pythoncode guide, and changelog entries.

pythonic changes

Explicit renderers and solution formatting

  • Adds csq_renderer with explicit support for:
    • "smallbox" (the default)
    • "bigbox"
    • "ace"
    • "textarea"
  • Reuses the existing pythoncode ACE and textarea rendering paths while
    retaining pythonic's expression-only parsing and grading behavior.
  • Restores previously submitted multi-line expressions and honors csq_rows
    for editor height.
  • Keeps renderer selection explicit: setting csq_rows alone does not switch
    a question away from smallbox.
  • Adds csq_output_mode:
    • "default" uses repr for raw-mode solutions.
    • "formatted" uses str.
  • Reports an escaped, visible error for an unknown renderer.

Multi-prompt questions

  • Adds csq_prompts, a non-empty list of labels that renders several
    single-line fields as one pythonic question.
  • Combines the submitted fields into a dictionary with string keys ("0",
    "1", and so on) before applying the existing sandbox and check-function
    pipeline.
  • Requires every field to be present and nonempty.
  • Adds csq_solns for optional per-field solution display while retaining
    csq_soln as the value used for grading.
  • Validates prompt and solution configuration up front.
  • Processes prompt labels as CAT-SOOP content, restores exact prior field
    values, escapes rendered values and attributes, and adds associated labels
    and ARIA metadata.

Safer failure logging

Invalid pythonic submissions now log the question name and exception type
without logging the raw student response or exception details. Student-facing
behavior still uses the existing invalid-expression message or a configured
csq_msg_function.

Documentation

This branch adds authoring documentation for:

  • course/page directory structure, page source types, preload.py, roles, and
    release/due dates;
  • page structure, includes, page Python, questions, and processing order;
  • the rendering model, mixed Markdown/HTML, and cs_form;
  • images, downloads, __STATIC__, and the CURRENT, COURSE, and BASE
    prefixes;
  • dynamic Python pages, cs_handler, raw responses, content types, redirects,
    request-driven endpoints, and staff-only actions;
  • inline and external JavaScript, cs_scripts, modules, and avoiding conflicts
    with CAT-SOOP's bundled JavaScript;
  • __USERS__ files and common user fields;
  • filesystem and API access to CAT-SOOP logs, including problemactions,
    problemstate, _question_info, and _checker;
  • the checkoff question type and its queue prerequisites;
  • the pythonic question type, including multi-line and multi-prompt usage;
  • custom pythonic check functions, partial credit, rich HTML/image feedback,
    and the native csm_check checker library;
  • the pythoncode question type, its execution model, tests, attempt limits,
    source validation, and targeted hints through check functions and
    csq_hint;
  • the custom-qtype lifecycle, hooks, inheritance, assets, security, and
    testing; and
  • self_partner and sympy_check as contrasting case studies of stateful and
    computation-oriented course-local qtypes.

The pythoncode guide includes a student-view screenshot. The two custom-qtype
case studies document course-local examples; this PR does not add
self_partner or sympy_check as built-in CAT-SOOP question types.

Navigation under “Running a Course” and “Customizing, Extending, and Modifying
CAT-SOOP” has been updated to expose the new pages.

Compatibility and migration

  • Existing pythonic questions continue to use the smallbox renderer and
    the existing grading contract by default.
  • Existing "bigbox" questions remain supported.
  • Existing checker return forms—scalar score, (score, message), and
    {"score": ..., "msg": ...}—are unchanged.
  • Multi-prompt fields use derived names such as __question_name_0000, so
    authors should keep csq_name stable.
  • csq_solns controls only per-field solution display; csq_soln remains the
    grading solution.
  • No database, configuration, or log migration is required.

Testing

Targeted pythonic and Markdown tests:

python3.9 -m pytest -q \
    catsoop/test/test_markdown.py \
    catsoop/test/test_qtype_pythonic.py

23 passed

All 16 new documentation pages were also loaded and rendered through
CAT-SOOP's page loader, with checks for malformed question parsing.

The complete local suite was run with:

python3.9 -m pytest -q catsoop/test

It produced 43 passes and 9 environment-specific failures on macOS:

  • Six unchanged cslog stress tests define multiprocessing targets locally
    and cannot be pickled by macOS's default spawn start method.
  • Three unchanged pythoncode sandbox tests fail while applying process
    limits in preexec_fn in this local environment.

The branch-specific pythonic tests pass, and the files involved in those nine
failures are unchanged by this PR.

git diff --check also passes.

Changelog

The unreleased changelog now records the new pythonic renderers,
multi-prompt support, safer failure logging, and the new pythonic and
pythoncode authoring guides.

## Summary This PR expands the `pythonic` question type with explicit multi-line input and multi-prompt grading, adds focused unit coverage for the new behavior, and substantially expands CAT-SOOP's course-authoring documentation. The implementation work is intentionally limited to `pythonic`. The remaining changes are documentation, examples, navigation, a screenshot used by the `pythoncode` guide, and changelog entries. ## `pythonic` changes ### Explicit renderers and solution formatting - Adds `csq_renderer` with explicit support for: - `"smallbox"` (the default) - `"bigbox"` - `"ace"` - `"textarea"` - Reuses the existing `pythoncode` ACE and textarea rendering paths while retaining `pythonic`'s expression-only parsing and grading behavior. - Restores previously submitted multi-line expressions and honors `csq_rows` for editor height. - Keeps renderer selection explicit: setting `csq_rows` alone does not switch a question away from `smallbox`. - Adds `csq_output_mode`: - `"default"` uses `repr` for raw-mode solutions. - `"formatted"` uses `str`. - Reports an escaped, visible error for an unknown renderer. ### Multi-prompt questions - Adds `csq_prompts`, a non-empty list of labels that renders several single-line fields as one `pythonic` question. - Combines the submitted fields into a dictionary with string keys (`"0"`, `"1"`, and so on) before applying the existing sandbox and check-function pipeline. - Requires every field to be present and nonempty. - Adds `csq_solns` for optional per-field solution display while retaining `csq_soln` as the value used for grading. - Validates prompt and solution configuration up front. - Processes prompt labels as CAT-SOOP content, restores exact prior field values, escapes rendered values and attributes, and adds associated labels and ARIA metadata. ### Safer failure logging Invalid `pythonic` submissions now log the question name and exception type without logging the raw student response or exception details. Student-facing behavior still uses the existing invalid-expression message or a configured `csq_msg_function`. ## Documentation This branch adds authoring documentation for: - course/page directory structure, page source types, `preload.py`, roles, and release/due dates; - page structure, includes, page Python, questions, and processing order; - the rendering model, mixed Markdown/HTML, and `cs_form`; - images, downloads, `__STATIC__`, and the `CURRENT`, `COURSE`, and `BASE` prefixes; - dynamic Python pages, `cs_handler`, raw responses, content types, redirects, request-driven endpoints, and staff-only actions; - inline and external JavaScript, `cs_scripts`, modules, and avoiding conflicts with CAT-SOOP's bundled JavaScript; - `__USERS__` files and common user fields; - filesystem and API access to CAT-SOOP logs, including `problemactions`, `problemstate`, `_question_info`, and `_checker`; - the `checkoff` question type and its queue prerequisites; - the `pythonic` question type, including multi-line and multi-prompt usage; - custom `pythonic` check functions, partial credit, rich HTML/image feedback, and the native `csm_check` checker library; - the `pythoncode` question type, its execution model, tests, attempt limits, source validation, and targeted hints through check functions and `csq_hint`; - the custom-qtype lifecycle, hooks, inheritance, assets, security, and testing; and - `self_partner` and `sympy_check` as contrasting case studies of stateful and computation-oriented course-local qtypes. The `pythoncode` guide includes a student-view screenshot. The two custom-qtype case studies document course-local examples; this PR does not add `self_partner` or `sympy_check` as built-in CAT-SOOP question types. Navigation under “Running a Course” and “Customizing, Extending, and Modifying CAT-SOOP” has been updated to expose the new pages. ## Compatibility and migration - Existing `pythonic` questions continue to use the `smallbox` renderer and the existing grading contract by default. - Existing `"bigbox"` questions remain supported. - Existing checker return forms—scalar score, `(score, message)`, and `{"score": ..., "msg": ...}`—are unchanged. - Multi-prompt fields use derived names such as `__question_name_0000`, so authors should keep `csq_name` stable. - `csq_solns` controls only per-field solution display; `csq_soln` remains the grading solution. - No database, configuration, or log migration is required. ## Testing Targeted `pythonic` and Markdown tests: ```text python3.9 -m pytest -q \ catsoop/test/test_markdown.py \ catsoop/test/test_qtype_pythonic.py 23 passed ``` All 16 new documentation pages were also loaded and rendered through CAT-SOOP's page loader, with checks for malformed question parsing. The complete local suite was run with: ```text python3.9 -m pytest -q catsoop/test ``` It produced 43 passes and 9 environment-specific failures on macOS: - Six unchanged `cslog` stress tests define multiprocessing targets locally and cannot be pickled by macOS's default `spawn` start method. - Three unchanged `pythoncode` sandbox tests fail while applying process limits in `preexec_fn` in this local environment. The branch-specific `pythonic` tests pass, and the files involved in those nine failures are unchanged by this PR. `git diff --check` also passes. ## Changelog The unreleased changelog now records the new `pythonic` renderers, multi-prompt support, safer failure logging, and the new `pythonic` and `pythoncode` authoring guides.
Owner

Sorry for the long delay, @ichuang ! Thanks for putting in the work here, but, as a general rule, I'm not accepting pull requests that were generated by LLMs. If it's easy to separate out the parts that were written by a human, I'd be happy to merge, especially since the changes to pythonic do seem quite nice. If not, no worries; I can rewrite those pieces if need be.

Sorry for the long delay, @ichuang ! Thanks for putting in the work here, but, as a general rule, I'm not accepting pull requests that were generated by LLMs. If it's easy to separate out the parts that were written by a human, I'd be happy to merge, especially since the changes to `pythonic` do seem quite nice. If not, no worries; I can rewrite those pieces if need be.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pythonic-multiline:ichuang-pythonic-multiline'
git switch 'ichuang-pythonic-multiline'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'ichuang-pythonic-multiline'
git switch 'ichuang-pythonic-multiline'
git rebase 'main'
git switch 'main'
git merge --ff-only 'ichuang-pythonic-multiline'
git switch 'ichuang-pythonic-multiline'
git rebase 'main'
git switch 'main'
git merge --no-ff 'ichuang-pythonic-multiline'
git switch 'main'
git merge --squash 'ichuang-pythonic-multiline'
git switch 'main'
git merge --ff-only 'ichuang-pythonic-multiline'
git switch 'main'
git merge 'ichuang-pythonic-multiline'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
catsoop/catsoop!111
No description provided.