From 90f8d42ce230e3445518baf994c25e5ccd5f263e Mon Sep 17 00:00:00 2001 From: James Perretta Date: Thu, 22 Aug 2024 15:26:20 -0400 Subject: [PATCH] Added field for admin test notes to be shown only when editing. --- .../migrations/0108_internal_admin_notes.py | 28 +++++++++++ .../core/models/ag_test/ag_test_case.py | 7 +++ .../core/models/ag_test/ag_test_command.py | 7 +++ .../core/models/ag_test/ag_test_suite.py | 7 +++ .../test_ag_test/test_ag_test_case.py | 5 ++ .../test_ag_test/test_ag_test_command.py | 6 +++ .../test_ag_test/test_ag_test_suite.py | 11 +++++ autograder/rest_api/schema/schema.yml | 48 +++++++++++++++++++ 8 files changed, 119 insertions(+) create mode 100644 autograder/core/migrations/0108_internal_admin_notes.py diff --git a/autograder/core/migrations/0108_internal_admin_notes.py b/autograder/core/migrations/0108_internal_admin_notes.py new file mode 100644 index 00000000..588dc09f --- /dev/null +++ b/autograder/core/migrations/0108_internal_admin_notes.py @@ -0,0 +1,28 @@ +# Generated by Django 3.2.2 on 2024-08-22 19:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0107_auto_20240806_1626'), + ] + + operations = [ + migrations.AddField( + model_name='agtestcase', + name='internal_admin_notes', + field=models.TextField(blank=True, help_text='Additional information for admins. Shown only when editing the test case.'), + ), + migrations.AddField( + model_name='agtestcommand', + name='internal_admin_notes', + field=models.TextField(blank=True, help_text='Additional information for admins. Shown only when editing the command.'), + ), + migrations.AddField( + model_name='agtestsuite', + name='internal_admin_notes', + field=models.TextField(blank=True, help_text='Additional information for admins. Shown only when editing the test suite.'), + ), + ] diff --git a/autograder/core/models/ag_test/ag_test_case.py b/autograder/core/models/ag_test/ag_test_case.py index 05710d55..16211b8f 100644 --- a/autograder/core/models/ag_test/ag_test_case.py +++ b/autograder/core/models/ag_test/ag_test_case.py @@ -56,6 +56,11 @@ class Meta: help_text='''The suite this autograder test belongs to. This field is REQUIRED.''') + internal_admin_notes = models.TextField( + blank=True, + help_text='Additional information for admins. Shown only when editing the test case.' + ) + staff_description = models.TextField( blank=True, help_text='Text description shown only to staff. Rendered as markdown.' @@ -148,6 +153,7 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]: 'name', 'last_modified', + 'internal_admin_notes', 'staff_description', 'student_description', @@ -166,6 +172,7 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]: 'name', 'ag_test_suite', + 'internal_admin_notes', 'staff_description', 'student_description', diff --git a/autograder/core/models/ag_test/ag_test_command.py b/autograder/core/models/ag_test/ag_test_command.py index 5d353d53..c083d80c 100644 --- a/autograder/core/models/ag_test/ag_test_command.py +++ b/autograder/core/models/ag_test/ag_test_command.py @@ -156,6 +156,11 @@ class Meta: on_delete=models.CASCADE, help_text="""The AGTestCase that this command belongs to.""") + internal_admin_notes = models.TextField( + blank=True, + help_text='Additional information for admins. Shown only when editing the command.' + ) + staff_description = models.TextField( blank=True, help_text='Text description shown only to staff. Rendered as markdown.' @@ -425,6 +430,7 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]: 'last_modified', 'cmd', + 'internal_admin_notes', 'staff_description', 'student_description', 'student_on_fail_description', @@ -473,6 +479,7 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]: 'cmd', + 'internal_admin_notes', 'staff_description', 'student_description', 'student_on_fail_description', diff --git a/autograder/core/models/ag_test/ag_test_suite.py b/autograder/core/models/ag_test/ag_test_suite.py index 1606c091..64ef83e9 100644 --- a/autograder/core/models/ag_test/ag_test_suite.py +++ b/autograder/core/models/ag_test/ag_test_suite.py @@ -157,6 +157,11 @@ def set_order(project: Project, order: List[int]) -> None: have yet to be graded do not prevent members of a group from submitting again.''') + internal_admin_notes = models.TextField( + blank=True, + help_text='Additional information for admins. Shown only when editing the test suite.' + ) + staff_description = models.TextField( blank=True, help_text='Text description shown only to staff. Rendered as markdown.' @@ -251,6 +256,7 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]: 'project', 'last_modified', + 'internal_admin_notes', 'staff_description', 'student_description', @@ -286,6 +292,7 @@ def delete(self, *args: Any, **kwargs: Any) -> Tuple[int, Dict[str, int]]: EDITABLE_FIELDS = ( 'name', + 'internal_admin_notes', 'staff_description', 'student_description', diff --git a/autograder/core/tests/test_models/test_ag_test/test_ag_test_case.py b/autograder/core/tests/test_models/test_ag_test/test_ag_test_case.py index 4fd9f7a6..4038e732 100644 --- a/autograder/core/tests/test_models/test_ag_test/test_ag_test_case.py +++ b/autograder/core/tests/test_models/test_ag_test/test_ag_test_case.py @@ -25,6 +25,10 @@ def test_valid_create(self): self.assertEqual(name, ag_test.name) self.assertEqual(self.ag_suite, ag_test.ag_test_suite) + self.assertEqual('', ag_test.internal_admin_notes) + self.assertEqual('', ag_test.staff_description) + self.assertEqual('', ag_test.student_description) + self.assertTrue(ag_test.normal_fdbk_config.visible) self.assertTrue(ag_test.normal_fdbk_config.show_individual_commands) self.assertTrue(ag_test.normal_fdbk_config.show_student_description) @@ -180,6 +184,7 @@ def test_serialize(self): 'pk', 'name', 'last_modified', + 'internal_admin_notes', 'staff_description', 'student_description', 'ag_test_suite', diff --git a/autograder/core/tests/test_models/test_ag_test/test_ag_test_command.py b/autograder/core/tests/test_models/test_ag_test/test_ag_test_command.py index ec1c787b..e2ad8705 100644 --- a/autograder/core/tests/test_models/test_ag_test/test_ag_test_command.py +++ b/autograder/core/tests/test_models/test_ag_test/test_ag_test_command.py @@ -40,6 +40,11 @@ def test_default_vals(self): ag_cmd: ag_models.AGTestCommand = ag_models.AGTestCommand.objects.validate_and_create( name=self.name, ag_test_case=self.ag_test, cmd=self.cmd) + self.assertEqual('', ag_cmd.internal_admin_notes) + self.assertEqual('', ag_cmd.staff_description) + self.assertEqual('', ag_cmd.student_description) + self.assertEqual('', ag_cmd.student_on_fail_description) + self.assertEqual(ag_models.StdinSource.none, ag_cmd.stdin_source) self.assertEqual('', ag_cmd.stdin_text) self.assertIsNone(ag_cmd.stdin_instructor_file) @@ -505,6 +510,7 @@ def test_serialize(self): 'last_modified', 'cmd', + 'internal_admin_notes', 'staff_description', 'student_description', 'student_on_fail_description', diff --git a/autograder/core/tests/test_models/test_ag_test/test_ag_test_suite.py b/autograder/core/tests/test_models/test_ag_test/test_ag_test_suite.py index c7d25693..e5704dfc 100644 --- a/autograder/core/tests/test_models/test_ag_test/test_ag_test_suite.py +++ b/autograder/core/tests/test_models/test_ag_test/test_ag_test_suite.py @@ -23,6 +23,10 @@ def test_valid_create_with_defaults(self): self.assertEqual(suite_name, suite.name) self.assertEqual(self.project, suite.project) + self.assertEqual('', suite.internal_admin_notes) + self.assertEqual('', suite.staff_description) + self.assertEqual('', suite.student_description) + self.assertCountEqual([], suite.instructor_files_needed.all()) self.assertTrue(suite.read_only_instructor_files) self.assertCountEqual([], suite.student_files_needed.all()) @@ -92,6 +96,9 @@ def test_valid_create_non_defaults(self): suite = ag_models.AGTestSuite.objects.validate_and_create( name=name, project=project, + internal_admin_notes='some very internal admin notes', + staff_description='an description for staff', + student_description='info for students', instructor_files_needed=instructor_files_needed, read_only_instructor_files=False, student_files_needed=student_files_needed, @@ -114,6 +121,9 @@ def test_valid_create_non_defaults(self): suite.refresh_from_db() self.assertEqual(name, suite.name) self.assertEqual(project, suite.project) + self.assertEqual('some very internal admin notes', suite.internal_admin_notes) + self.assertEqual('an description for staff', suite.staff_description) + self.assertEqual('info for students', suite.student_description) self.assertCountEqual(instructor_files_needed, suite.instructor_files_needed.all()) self.assertFalse(suite.read_only_instructor_files) self.assertCountEqual(student_files_needed, suite.student_files_needed.all()) @@ -211,6 +221,7 @@ def test_serialization(self): 'project', 'last_modified', + 'internal_admin_notes', 'staff_description', 'student_description', diff --git a/autograder/rest_api/schema/schema.yml b/autograder/rest_api/schema/schema.yml index 4dd9c96f..4b8832b8 100644 --- a/autograder/rest_api/schema/schema.yml +++ b/autograder/rest_api/schema/schema.yml @@ -6039,6 +6039,11 @@ components: nullable: false type: string format: date-time + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the test suite. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -6135,6 +6140,7 @@ components: - name - project - last_modified + - internal_admin_notes - staff_description - student_description - instructor_files_needed @@ -6161,6 +6167,11 @@ components: \ This field is REQUIRED." nullable: false type: string + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the test suite. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -6258,6 +6269,11 @@ components: \ This field is REQUIRED." nullable: false type: string + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the test suite. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -6393,6 +6409,11 @@ components: nullable: false type: string format: date-time + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the test case. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -6436,6 +6457,7 @@ components: - pk - name - last_modified + - internal_admin_notes - staff_description - student_description - ag_test_suite @@ -6459,6 +6481,11 @@ components: \ This field is REQUIRED." nullable: false type: integer + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the test case. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -6504,6 +6531,11 @@ components: \ This field is REQUIRED." nullable: false type: integer + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the test case. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -6578,6 +6610,11 @@ components: \ default-creatable." nullable: false type: string + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the command. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -6788,6 +6825,7 @@ components: - ag_test_case - last_modified - cmd + - internal_admin_notes - staff_description - student_description - student_on_fail_description @@ -6839,6 +6877,11 @@ components: \ default-creatable." nullable: false type: string + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the command. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false @@ -7065,6 +7108,11 @@ components: \ default-creatable." nullable: false type: string + internal_admin_notes: + description: Additional information for admins. Shown only when editing + the command. + nullable: false + type: string staff_description: description: Text description shown only to staff. Rendered as markdown. nullable: false