Skip to content

Commit b2fa242

Browse files
Inline homework question creation loop
1 parent eab18c0 commit b2fa242

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

api/views/homework_create.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ class HomeworkCreateInput:
1818
due_date_str: str
1919

2020

21-
def create_questions(homework, questions_data):
22-
for question_data in questions_data:
23-
create_question(homework, question_data)
24-
25-
2621
def homework_create_instructions_url(homework_data):
2722
instructions_url = homework_data.get("instructions_url")
2823
if not instructions_url:
@@ -108,7 +103,8 @@ def create_homework(course, homework_data):
108103
)
109104

110105
questions_data = homework_data.get("questions", [])
111-
create_questions(homework, questions_data)
106+
for question_data in questions_data:
107+
create_question(homework, question_data)
112108

113109
homework_record = homework_to_dict(homework)
114110
return homework_record, None

docs/refactoring-plan.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4684,6 +4684,20 @@ Steps:
46844684
`wide_tuple_unpacking=0`, `wide_positional_calls=0`,
46854685
`wide_function_args=0`, `nested_wide_for_unpacking=0`,
46864686
`range_len_loops=0`), and `git diff --check`.
4687+
- [x] 2026-07-02: Removed the single-use homework creation question-loop helper.
4688+
`create_homework` now iterates over submitted question payloads directly
4689+
after creating the homework, while `create_question` remains the named
4690+
boundary for question payload construction. Verification:
4691+
`uv run ruff check api/views/homework_create.py docs/refactoring-plan.md`,
4692+
`python -m py_compile api/views/homework_create.py`,
4693+
`uv run python manage.py test api.tests.test_homeworks api.tests.test_homework_mutations api.tests.test_homework_upserts`,
4694+
removed-helper reference scan, touched-function line-threshold scan,
4695+
`uvx pyrefly check`, repository AST cleanup scan excluding migrations
4696+
(`forbidden_comprehensions=0`, `threshold_violations=0`,
4697+
`append_constructed=0`, `wide_tuple_unpacking=0`,
4698+
`wide_positional_calls=0`, `wide_function_args=0`,
4699+
`nested_wide_for_unpacking=0`, `range_len_loops=0`), and
4700+
`git diff --check`.
46874701
- [x] 2026-07-02: Named the E2E repository root and string path before adding
46884702
it to `sys.path`, removing the last non-allowed nested-call site from the
46894703
nested-call scan while leaving allowed `enumerate(zip(...))` test loops

0 commit comments

Comments
 (0)