Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to request a removal of a specified submission to the CLI #7

Merged
merged 8 commits into from
Dec 18, 2023
25 changes: 25 additions & 0 deletions autograder/api/submission/remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import autograder.api.common
import autograder.api.config

API_ENDPOINT = 'submission/remove'
API_PARAMS = [
autograder.api.config.PARAM_COURSE_ID,
autograder.api.config.PARAM_USER_EMAIL,
autograder.api.config.PARAM_USER_PASS,
autograder.api.config.PARAM_ASSIGNMENT_ID,

autograder.api.config.PARAM_TARGET_EMAIL_OR_SELF,
autograder.api.config.PARAM_TARGET_SUBMISSION_OR_RECENT,
]

DESCRIPTION = 'Remove a specified submission. Defaults to the most recent submission.'

def send(arguments, **kwargs):
return autograder.api.common.handle_api_request(arguments, API_PARAMS, API_ENDPOINT, **kwargs)

def _get_parser():
parser = autograder.api.config.get_argument_parser(
description = DESCRIPTION,
params = API_PARAMS)

return parser
27 changes: 27 additions & 0 deletions autograder/cli/submission/remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sys

import autograder.api.submission.remove

def run(arguments):
result = autograder.api.submission.remove.send(arguments, exit_on_error = True)

if (not result['found-user']):
print("No matching user found.")
return 1

if (not result['found-submission']):
print("No matching submission found.")
return 2

print("Submission removed.")
return 0

def main():
return run(_get_parser().parse_args())

def _get_parser():
parser = autograder.api.submission.remove._get_parser()
return parser

if (__name__ == '__main__'):
sys.exit(main())
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"endpoint": "submission/remove",
"arguments": {
"target-email": "ZZZ"
},
"output": {
"found-user": false,
"found-submission": false
}
}
10 changes: 10 additions & 0 deletions tests/api/data/test_submission_remove_submission_other_recent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"endpoint": "submission/remove",
"arguments": {
"target-email": "[email protected]"
},
"output": {
"found-user": true,
"found-submission": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"endpoint": "submission/remove",
"arguments": {
"target-email": "[email protected]",
"target-submission": "1697406265"
},
"output": {
"found-user": true,
"found-submission": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"endpoint": "submission/remove",
"arguments": {},
"output": {
"found-user": true,
"found-submission": false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"endpoint": "submission/remove/submission",
OliverLok marked this conversation as resolved.
Show resolved Hide resolved
"arguments": {},
"output": {
"found-user": true,
"found-submission": false
}
}
Loading