Skip to content

Move the shared CodeTailor helpers to common modules - #1632

Open
aspadiyath wants to merge 1 commit into
RunestoneInteractive:mainfrom
aspadiyath:codetailor-shared-helpers
Open

aspadiyath wants to merge 1 commit into
RunestoneInteractive:mainfrom
aspadiyath:codetailor-shared-helpers

Conversation

@aspadiyath

Copy link
Copy Markdown
Contributor

First of the five PRs proposed in #1627 (Explain in Plain English questions). It moves the CodeTailor plumbing EiPE will reuse out of coach.py and evaluate_fixed_code.py into three modules in book_server_api/. No behavior change.

Module What moved in
activecode_questions.py clean_python_testcase, the activecode marker parsing, starter_code_from_question, extract_suffix_code_from_htmlsrc, data_file_candidates, fetch_data_files. Two new helpers replace code that was inline in coach.py: find_question (base course first, then a global name match) and question_test_code (question_json.suffix_code, else the tests in the textarea).
openai_token.py DEV_API_KEY, the dev-course check, and fetch_openai_token(course)
jobe.py The JOBE session, data file upload, and load_and_run_tests. That function is now split around run_python_program, which returns a run's stdout and stderr.

The helpers lose their leading underscores, because other modules now import them. The Java runner and the rest of evaluate_fixed_code.py stay where they are.

Things a reviewer might notice:

  • The "resolved via global name match" warning no longer starts with CodeTailor:, because find_question isn't specific to CodeTailor any more.
  • When a course has no base course, parsons_scaffolding now makes one global question lookup where it used to make the same lookup twice.

Tests: added test_activecode_questions.py for the moved helpers, which had no tests. It covers starter-code and test splitting, data file candidates, and how load_and_run_tests reads JOBE output. Existing CodeTailor tests pass. The book server app imports cleanly.

🤖 Generated with Claude Code

No behavior change. Explain in Plain English questions (RunestoneInteractive#1627) need the
same question, token and JOBE plumbing CodeTailor has, so move it out of
coach.py and evaluate_fixed_code.py:

- activecode_questions.py: a question's starter code, tests and data
  files, plus find_question (base course first, then a global match) and
  question_test_code (question_json.suffix_code or the textarea tests)
- openai_token.py: the course's OpenAI token and the dev-course key
- jobe.py: the JOBE session, data file upload, and load_and_run_tests,
  now split around run_python_program, which returns a run's output

Adds tests for the moved helpers, which had none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aspadiyath
aspadiyath requested a review from bnmnetp as a code owner October 26, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant