Skip to content

Commit

Permalink
Merged #36 by Lucas.
Browse files Browse the repository at this point in the history
  • Loading branch information
eriq-augustine committed Jan 5, 2025
1 parent 8aee932 commit cc7701a
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 1 deletion.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ This is a shortcut for [`autograder.cli.courses.assignments.submissions.submit`]
python3 -m autograder.run.submit my_file.py
```

To submit an assignment late, use the following command.
For more information and examples, see the [late submission section](#submitting-an-assignment-late) of this document.

```sh
python3 -m autograder.run.submit --allow-late my_file.py
```

### `autograder.run.history`

This command gets a summary of all your past submissions for an assignment.
Expand Down Expand Up @@ -223,6 +230,31 @@ The autograder failed to grade your assignment.
Message from the autograder: Request could not be authenticated. Ensure that your username, password, and course are properly set.
```

##### Submitting an Assignment Late

If you are submitting an assignment late, the autograder requires confirmation in order to grade your submission.
This helps users avoid situations where they accidentally submit an assignment late or submit to the wrong assignment.
Users must add the `--allow-late` flag to the normal submission command when they want to submit an assignment past the due date.

For example, your output when submitting a late assignment may look like:
```
--- Message from Autograder ---
Attempting to submit assignment (HO0) late without the 'allow late' option.
It was due on 2024-12-13 16:00 (which was 48h34m57.178s ago).
Use the 'allow late' option to submit an assignment late.
See your interface's documentation for more information.
-------------------------------
Submission was rejected by the autograder.
```

When you see this message, be sure to double check the assignment name and due date.
If those details look correct and you want to submit that assignment late, then run the following command:
```sh
python3 -m autograder.run.submit --allow-late my_file.py
```

Now, the server will grade your late submission like normal!

#### Checking Your Last Submission

You can ask the autograder to show you the grade report for your last submission using the
Expand Down
7 changes: 6 additions & 1 deletion autograder/api/courses/assignments/submissions/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

autograder.api.config.APIParam('message',
'An optional message to attatch to the submission.',
required = False)
required = False),

autograder.api.config.APIParam('allow-late',
'Allow this submission to be graded, even if it is late (default: %(default)s).',
required = False,
parser_options = {'action': 'store_true', 'default': False})
]

DESCRIPTION = 'Submit an assignment submission to the autograder.'
Expand Down
8 changes: 8 additions & 0 deletions tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
TIMESTAMP_PATTERN = r'\b\d{10,13}\b'
TIMESTAMP_REPLACEMENT = '1234567890123'

TIME_DELTA_PATTERN = r'(\d+h)?(\d+m)?(\d+\.)?(\d+[mun]?s)'
TIME_DELTA_REPLACEMENT = '<time-delta:1234567890123>'

TIME_MESSAGE_PATTERN = r'<timestamp:(-?\d+|nil)>'
TIME_MESSAGE_REPLACEMENT = '<timestamp:1234567890123>'

class APITest(tests.server.base.ServerBaseTest):
"""
Test API calls by mocking a server.
Expand Down Expand Up @@ -110,6 +116,8 @@ def clean_output_timestamps(output):
# Convert the output to JSON so we can do a simple find/replace for all timestamps-like things.
text_output = json.dumps(output)
text_output = re.sub(TIMESTAMP_PATTERN, TIMESTAMP_REPLACEMENT, text_output)
text_output = re.sub(TIME_DELTA_PATTERN, TIME_DELTA_REPLACEMENT, text_output)
text_output = re.sub(TIME_MESSAGE_PATTERN, TIME_MESSAGE_REPLACEMENT, text_output)

return json.loads(text_output)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"module": "autograder.api.courses.assignments.submissions.submit",
"arguments": {
"allow-late": false
},
"files": [
"__DATA_DIR__(hw0_solution.py)"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"module": "autograder.api.courses.assignments.submissions.submit",
"arguments": {
"course": "course-languages",
"assignment": "bash",
"allow-late": true
},
"files": [
"__DATA_DIR__(assignment.sh)"
],
"output-modifier": "clean_output_timestamps",
"output": {
"rejected": false,
"message": "",
"grading-success": true,
"result": {
"id": "course-languages::bash::[email protected]::1234567890123",
"short-id": "1234567890123",
"course-id": "course-languages",
"assignment-id": "bash",
"user": "[email protected]",
"message": "",
"max_points": 10,
"score": 10,
"name": "bash",
"questions": [
{
"name": "Task 1: add()",
"max_points": 10,
"score": 10,
"message": "",
"grading_start_time": 1234567890123,
"grading_end_time": 1234567890123
}
],
"grading_start_time": 1234567890123,
"grading_end_time": 1234567890123,
"additional-info": null
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"module": "autograder.api.courses.assignments.submissions.submit",
"arguments": {
"course": "course-languages",
"assignment": "bash",
"allow-late": false
},
"files": [
"__DATA_DIR__(assignment.sh)"
],
"output-modifier": "clean_output_timestamps",
"output": {
"rejected": true,
"message": "Attempting to submit assignment (A Simple Bash Assignment) late without the 'allow late' option. It was due on <timestamp:1234567890123> (which was <time-delta:1234567890123> ago). Use the 'allow late' option to submit an assignment late. See your interface's documentation for more information.",
"grading-success": false,
"result": null
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"module": "autograder.api.courses.assignments.submissions.submit",
"arguments": {
"allow-late": false
},
"files": [
"__DATA_DIR__(hw0_no_compile.py)"
Expand Down
12 changes: 12 additions & 0 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
TIME_REGEX = r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}'
TIME_REPLACEMENT = '<TIME>'

TIME_DELTA_PATTERN = r'(\d+h)?(\d+m)?(\d+\.)?(\d+s)'
TIME_DELTA_REPLACEMENT = '<time-delta:12h34m56.789s>'

TIME_MESSAGE_PATTERN = r'<timestamp:(-?\d+|nil)>'
TIME_MESSAGE_REPLACEMENT = '<timestamp:1234567890123>'

class CLITest(tests.server.base.ServerBaseTest):
"""
Test CLI tools.
Expand Down Expand Up @@ -199,6 +205,12 @@ def content_equals_ignore_time(test_case, expected, actual, **kwargs):
expected = re.sub(TIME_REGEX, TIME_REPLACEMENT, expected)
actual = re.sub(TIME_REGEX, TIME_REPLACEMENT, actual)

expected = re.sub(TIME_DELTA_PATTERN, TIME_DELTA_REPLACEMENT, expected)
actual = re.sub(TIME_DELTA_PATTERN, TIME_DELTA_REPLACEMENT, actual)

expected = re.sub(TIME_MESSAGE_PATTERN, TIME_MESSAGE_REPLACEMENT, expected)
actual = re.sub(TIME_MESSAGE_PATTERN, TIME_MESSAGE_REPLACEMENT, actual)

content_equals(test_case, expected, actual)

def json_logs_equal(test_case, expected, actual, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"cli": "autograder.cli.courses.assignments.submissions.submit",
"output-check": "content_equals_ignore_time",
"arguments": [
"--course", "course-languages",
"--assignment", "bash",
"--allow-late",
"__DATA_DIR__(assignment.sh)"
]
}
---
Autograder transcript for assignment: bash.
Grading started at <TIME> and ended at <TIME>.
Task 1: add(): 10 / 10

Total: 10 / 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"cli": "autograder.cli.courses.assignments.submissions.submit",
"output-check": "content_equals_ignore_time",
"arguments": [
"--course", "course-languages",
"--assignment", "bash",
"__DATA_DIR__(assignment.sh)"
],
"exit-status": 1
}
---
--- Message from Autograder ---
Attempting to submit assignment (A Simple Bash Assignment) late without the 'allow late' option. It was due on <TIME> (which was <time-delta:1234567890123> ago). Use the 'allow late' option to submit an assignment late. See your interface's documentation for more information.
-------------------------------
Submission was rejected by the autograder.
5 changes: 5 additions & 0 deletions tests/data/assignment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function add() {
local a=$1
local b=$2
echo $((a + b))
}

0 comments on commit cc7701a

Please sign in to comment.