Skip to content

Commit

Permalink
Fix assignment summary in Otter Assign so that manual questions are i…
Browse files Browse the repository at this point in the history
…nclude (#911)

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* free disk space in CI runs using docker to prevent image build failures

* add comment about source

* reorg workflow, add support for docker gha cache in CI

* undo gha caching changes since it's already done in conftest.py

* debugging failed builds

* debugging failed builds

* remove alternate_file

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* debugging failed builds

* include manual questions in assignment summary
  • Loading branch information
chrispyles authored Jan 24, 2025
1 parent 733bf06 commit b005c67
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**v6.1.0 (unreleased):**

* Update Otter Assign to handle notebooks with an invalid kernelspec by assuming the language is Python per [#895](https://github.com/ucbds-infra/otter-grader/issues/895)
* Fixed assignment summary in Otter Assign so that manual questions are included per [#886](https://github.com/ucbds-infra/otter-grader/issues/886)

**v6.0.5:**

Expand Down
1 change: 1 addition & 0 deletions otter/assign/notebook_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def _get_transformed_cells(self, cells: list[nbf.NotebookNode]) -> list[nbf.Note
)

question = QuestionConfig(question_config)
self.tests_mgr.add_question(question)
if question.manual or question.export:
need_begin_export = True

Expand Down
1 change: 0 additions & 1 deletion otter/assign/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pathlib
import shutil
import tempfile
import warnings

from .assignment import Assignment
from .notebook_transformer import NotebookTransformer, TransformedNotebookContainer
Expand Down
30 changes: 21 additions & 9 deletions otter/assign/tests_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,8 @@ def _add_test_case(self, question: QuestionConfig, test_case: TestCase):
question (``otter.assign.question_config.QuestionConfig``): the question config
test_case (``TestCase``): the test case to track
"""
question_name = question["name"]
self._questions[question_name] = question

if question_name not in self._tests_by_question:
self._tests_by_question[question_name] = []

self._tests_by_question[question_name].append(test_case)
self.add_question(question)
self._tests_by_question[question.name].append(test_case)

def _parse_test_config(self, source: list[str]) -> tuple[dict[str, Any], Union[int, None]]:
"""
Expand All @@ -114,6 +109,17 @@ def _parse_test_config(self, source: list[str]) -> tuple[dict[str, Any], Union[i

return config, i

def add_question(self, question: QuestionConfig):
"""
Add a question for tracking and inclusion in the assignment summary
Args:
question (``otter.assign.question_config.QuestionConfig``): the question config
"""
self._questions[question.name] = question
if question.name not in self._tests_by_question:
self._tests_by_question[question.name] = []

def read_test(self, cell: nbf.NotebookNode, question: QuestionConfig):
"""
Parse and track a test case from the provided cell for the specified question.
Expand Down Expand Up @@ -184,7 +190,7 @@ def has_tests(self, question: QuestionConfig) -> bool:
Returns:
``bool``: whether the question has any test cases
"""
return question.name in self._tests_by_question
return len(self._tests_by_question.get(question.name, [])) > 0

@staticmethod
def _resolve_test_file_points(
Expand Down Expand Up @@ -356,6 +362,9 @@ def write_tests(

test_ext = ".py" if self.assignment.is_python else ".R"
for test_name in self._tests_by_question.keys():
if not self._tests_by_question[test_name]:
continue

test_info = self._create_test_file_info(test_name)
test_path = os.path.join(test_dir, test_name + test_ext)

Expand Down Expand Up @@ -397,6 +406,9 @@ def determine_question_point_value(self, question: QuestionConfig) -> Union[int,
Returns:
``int | float``: the point value of the question
"""
if question.manual:
return question.points or 0

test_cases = self._tests_by_question.get(question.name, [])

points = question.points
Expand Down Expand Up @@ -430,7 +442,7 @@ def generate_assignment_summary(self) -> str:
for question_name in sorted(self._tests_by_question.keys()):
config = self._questions[question_name]
points = self.determine_question_point_value(config)
rows.append({"name": question_name, "points": points})
rows.append({"name": question_name, "points": points, "manual": config.manual})
total += points
if config.manual:
manual += points
Expand Down

0 comments on commit b005c67

Please sign in to comment.