Skip to content

Commit

Permalink
Added new fields for test case descriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
james-perretta committed Aug 6, 2024
1 parent 46b78e6 commit 063215b
Show file tree
Hide file tree
Showing 14 changed files with 464 additions and 51 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.10 python3.10-distutils python3.10-venv
curl https://bootstrap.pypa.io/get-pip.py | sudo python3.10
python3.10 -m pip install pip==24.0
python3.10 -m venv venv
source venv/bin/activate
Expand Down
26 changes: 26 additions & 0 deletions autograder/core/migrations/0107_auto_20240806_1626.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.2 on 2024-08-06 16:26

import autograder.core.fields
import autograder.core.models.ag_test.ag_test_case
import autograder.core.models.ag_test.ag_test_suite
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0106_test_descriptions'),
]

operations = [
migrations.AlterField(
model_name='agtestcase',
name='past_limit_submission_fdbk_config',
field=autograder.core.fields.ValidatedJSONField(default=autograder.core.models.ag_test.ag_test_case._past_limit_fdbk, serializable_class=autograder.core.models.ag_test.ag_test_case.AGTestCaseFeedbackConfig),
),
migrations.AlterField(
model_name='agtestsuite',
name='past_limit_submission_fdbk_config',
field=autograder.core.fields.ValidatedJSONField(default=autograder.core.models.ag_test.ag_test_suite._past_limit_fdbk, serializable_class=autograder.core.models.ag_test.ag_test_suite.AGTestSuiteFeedbackConfig),
),
]
8 changes: 8 additions & 0 deletions autograder/core/models/ag_test/ag_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,17 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]:
'pk',
'name',
'last_modified',

'staff_description',
'student_description',

'ag_test_suite',
'ag_test_commands',
'normal_fdbk_config',
'ultimate_submission_fdbk_config',
'past_limit_submission_fdbk_config',
'staff_viewer_fdbk_config',

)

SERIALIZE_RELATED = ('ag_test_commands',)
Expand All @@ -161,6 +166,9 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]:
'name',
'ag_test_suite',

'staff_description',
'student_description',

'normal_fdbk_config',
'ultimate_submission_fdbk_config',
'past_limit_submission_fdbk_config',
Expand Down
8 changes: 8 additions & 0 deletions autograder/core/models/ag_test/ag_test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]:
'last_modified',
'cmd',

'staff_description',
'student_description',
'student_on_fail_description',

'stdin_source',
'stdin_text',
'stdin_instructor_file',
Expand Down Expand Up @@ -468,6 +472,10 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]:

'cmd',

'staff_description',
'student_description',
'student_on_fail_description',

'stdin_source',
'stdin_text',
'stdin_instructor_file',
Expand Down
8 changes: 7 additions & 1 deletion autograder/core/models/ag_test/ag_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]:
'project',
'last_modified',

'staff_description',
'student_description',

'instructor_files_needed',
'read_only_instructor_files',
'student_files_needed',
Expand Down Expand Up @@ -287,6 +290,9 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]:
EDITABLE_FIELDS = (
'name',

'staff_description',
'student_description',

'instructor_files_needed',
'read_only_instructor_files',
'student_files_needed',
Expand All @@ -302,5 +308,5 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]:
'normal_fdbk_config',
'ultimate_submission_fdbk_config',
'past_limit_submission_fdbk_config',
'staff_viewer_fdbk_config'
'staff_viewer_fdbk_config',
)
40 changes: 40 additions & 0 deletions autograder/core/submission_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,13 @@ def ag_test_suite_order(self) -> int:
def fdbk_settings(self) -> Dict[str, object]:
return self._fdbk.to_dict()

@property
def student_description(self) -> str | None:
return (
self._ag_test_suite.student_description
if self.fdbk_conf.show_student_description else None
)

@property
def setup_name(self) -> Optional[str]:
if not self._show_setup_name:
Expand Down Expand Up @@ -721,6 +728,7 @@ def _visible_ag_test_case_results(self) -> List[AGTestCaseResultFeedback]:
'ag_test_suite_name',
'ag_test_suite_pk',
'fdbk_settings',
'student_description',
'total_points',
'total_points_possible',
'setup_name',
Expand Down Expand Up @@ -799,6 +807,13 @@ def denormalized_ag_test_case_result(self) -> DenormalizedAGTestCaseResult:
def fdbk_settings(self) -> Dict[str, object]:
return self._fdbk.to_dict()

@property
def student_description(self) -> str | None:
return (
self._ag_test_case.student_description
if self.fdbk_conf.show_student_description else None
)

@property
def total_points(self) -> int:
points = sum((cmd_res.total_points for cmd_res in self._visible_cmd_results))
Expand Down Expand Up @@ -837,6 +852,7 @@ def _visible_cmd_results(self) -> Iterable[AGTestCommandResultFeedback]:
'ag_test_case_name',
'ag_test_case_pk',
'fdbk_settings',
'student_description',
'total_points',
'total_points_possible',

Expand Down Expand Up @@ -919,6 +935,28 @@ def fdbk_conf(self) -> AGTestCommandFeedbackConfig:
def fdbk_settings(self) -> Dict[str, object]:
return self.fdbk_conf.to_dict()

@property
def student_description(self) -> str | None:
return (
self._cmd.student_description if self.fdbk_conf.show_student_description else None
)

@property
def student_on_fail_description(self) -> str | None:
if not self.fdbk_conf.show_student_description:
return None

if self.return_code_correct is not None and not self.return_code_correct:
return self._cmd.student_on_fail_description

if self.stdout_correct is not None and not self.stdout_correct:
return self._cmd.student_on_fail_description

if self.stderr_correct is not None and not self.stderr_correct:
return self._cmd.student_on_fail_description

return None

@property
def timed_out(self) -> Optional[bool]:
if self._fdbk.show_whether_timed_out:
Expand Down Expand Up @@ -1172,6 +1210,8 @@ def total_points_possible(self) -> int:
'ag_test_command_pk',
'ag_test_command_name',
'fdbk_settings',
'student_description',
'student_on_fail_description',

'timed_out',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def test_serialize(self):
'pk',
'name',
'last_modified',
'staff_description',
'student_description',
'ag_test_suite',
'ag_test_commands',
'normal_fdbk_config',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_ultimate_fdbk_default(self):
self.assertFalse(ag_cmd.ultimate_submission_fdbk_config.show_actual_stdout)
self.assertFalse(ag_cmd.ultimate_submission_fdbk_config.show_actual_stderr)
self.assertTrue(ag_cmd.ultimate_submission_fdbk_config.show_whether_timed_out)
self.assertTrue(ag_cmd.normal_fdbk_config.show_student_description)
self.assertTrue(ag_cmd.ultimate_submission_fdbk_config.show_student_description)

def test_past_limit_fdbk_default(self):
ag_cmd = ag_models.AGTestCommand.objects.validate_and_create(
Expand All @@ -127,7 +127,7 @@ def test_past_limit_fdbk_default(self):
self.assertFalse(ag_cmd.past_limit_submission_fdbk_config.show_actual_stdout)
self.assertFalse(ag_cmd.past_limit_submission_fdbk_config.show_actual_stderr)
self.assertFalse(ag_cmd.past_limit_submission_fdbk_config.show_whether_timed_out)
self.assertFalse(ag_cmd.normal_fdbk_config.show_student_description)
self.assertFalse(ag_cmd.past_limit_submission_fdbk_config.show_student_description)

def test_staff_viewer_fdbk_default(self):
ag_cmd = ag_models.AGTestCommand.objects.validate_and_create(
Expand All @@ -145,7 +145,7 @@ def test_staff_viewer_fdbk_default(self):
self.assertTrue(ag_cmd.staff_viewer_fdbk_config.show_actual_stdout)
self.assertTrue(ag_cmd.staff_viewer_fdbk_config.show_actual_stderr)
self.assertTrue(ag_cmd.staff_viewer_fdbk_config.show_whether_timed_out)
self.assertTrue(ag_cmd.normal_fdbk_config.show_student_description)
self.assertTrue(ag_cmd.staff_viewer_fdbk_config.show_student_description)

def test_some_valid_non_defaults(self):
points_for_correct_return_code = 1
Expand Down Expand Up @@ -505,6 +505,10 @@ def test_serialize(self):
'last_modified',
'cmd',

'staff_description',
'student_description',
'student_on_fail_description',

'stdin_source',
'stdin_text',
'stdin_instructor_file',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def test_valid_create_with_defaults(self):
suite.past_limit_submission_fdbk_config.show_setup_return_code)
self.assertTrue(suite.past_limit_submission_fdbk_config.show_setup_timed_out)
self.assertTrue(suite.past_limit_submission_fdbk_config.show_setup_stdout)
self.assertFalse(suite.past_limit_submission_fdbk_config.show_setup_stderr)
self.assertTrue(suite.past_limit_submission_fdbk_config.show_setup_stderr)
self.assertFalse(suite.past_limit_submission_fdbk_config.show_student_description)

self.assertTrue(suite.staff_viewer_fdbk_config.visible)
self.assertTrue(suite.staff_viewer_fdbk_config.show_individual_tests)
Expand Down Expand Up @@ -210,6 +211,9 @@ def test_serialization(self):
'project',
'last_modified',

'staff_description',
'student_description',

'instructor_files_needed',
'read_only_instructor_files',
'student_files_needed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,28 @@ def test_some_commands_not_visible(self):
self.ag_test_case_result,
ag_models.FeedbackCategory.ultimate_submission).total_points_possible)

def test_student_description_visible(self) -> None:
description = 'al;skdfja;slkfj description'
self.ag_test_case.validate_and_update(
student_description=description,
normal_fdbk_config={
'show_student_description': True,
}
)
fdbk = get_case_fdbk(self.ag_test_case_result, ag_models.FeedbackCategory.normal)
self.assertEqual(description, fdbk.student_description)

def test_student_description_hidden(self) -> None:
description = 'al;skdfja;slkfj description'
self.ag_test_case.validate_and_update(
student_description=description,
normal_fdbk_config={
'show_student_description': False,
}
)
fdbk = get_case_fdbk(self.ag_test_case_result, ag_models.FeedbackCategory.normal)
self.assertIsNone(fdbk.student_description)

def test_fdbk_to_dict(self):
self.maxDiff = None

Expand All @@ -242,6 +264,7 @@ def test_fdbk_to_dict(self):
'ag_test_case_name',
'ag_test_case_pk',
'fdbk_settings',
'student_description',
'total_points',
'total_points_possible',
'ag_test_command_results',
Expand Down
Loading

0 comments on commit 063215b

Please sign in to comment.