autograder.cli.courses.assignments.submissions.fetch.user.attempt

Get a submission along with all grading information.

usage: python3 -m autograder.cli.courses.assignments.submissions.fetch.user.attempt
       [-h] [--version] [--server SERVER] [--user USER] [--pass PASS]
       [--course COURSE] [--assignment ASSIGNMENT]
       [--target-email TARGET_EMAIL] [--target-submission TARGET_SUBMISSION]
       [--out-dir OUT_DIR] [--testing-mode]

Get a submission along with all grading information.

options:
    -h, --help          show this help message and exit
    --version           show program's version number and exit

command-specific options:
    --server SERVER     The URL of the autograder server to communicate with.
    --user USER         The email of the user making this request.
    --pass PASS         The password of the user making this request.
    --course COURSE     The ID of the course to make this request to.
    --assignment ASSIGNMENT
                        The ID of the assignment to make this request to.
    --target-email TARGET_EMAIL
                        The email of the user that is the target of this
                        request (defaults to you). (default: None)
    --target-submission TARGET_SUBMISSION
                        The ID of the submission (default to the most recent
                        submission). (default: None)
    --out-dir OUT_DIR   A directory to write output in. (default: .)

testing options:
    --testing-mode      Run as if a test is being run (default: False).
 1"""
 2Get a submission along with all grading information.
 3"""
 4
 5import argparse
 6import sys
 7
 8import autograder.api.courses.assignments.submissions.fetch.user.attempt
 9import autograder.cli.common
10import autograder.cli.parser
11import autograder.util.grading
12
13def run_cli(args: argparse.Namespace) -> int:
14    """ Run the CLI. """
15
16    config = args._config_info.application_config
17
18    found_user, found_submission, result = autograder.api.courses.assignments.submissions.fetch.user.attempt.send(config, exit_on_error = True)
19
20    if (not found_user):
21        autograder.cli.common.print_no_match('user', config.target_email)
22        return 1
23
24    if (not found_submission):
25        autograder.cli.common.print_no_match('submission', config.target_submission)
26        return 2
27
28    if (result is None):
29        raise ValueError("Existing submission was not provided by API.")
30
31    out_path = autograder.util.grading.output_grading_result(result, base_dir = config.out_dir)
32    print(f"Submission wrote to '{out_path}'.")
33
34    return 0
35
36def main() -> int:
37    """ Get a parser, parse the args, and call run. """
38
39    return run_cli(_get_parser().parse_args())
40
41def _get_parser() -> argparse.ArgumentParser:
42    """ Get a parser for this operation. """
43
44    parser = autograder.cli.parser.get_parser(
45        __doc__.strip(),
46        autograder.api.courses.assignments.submissions.fetch.user.attempt.API_PARAMS)
47
48    return parser
49
50if (__name__ == '__main__'):
51    sys.exit(main())
def run_cli(args: argparse.Namespace) -> int:
14def run_cli(args: argparse.Namespace) -> int:
15    """ Run the CLI. """
16
17    config = args._config_info.application_config
18
19    found_user, found_submission, result = autograder.api.courses.assignments.submissions.fetch.user.attempt.send(config, exit_on_error = True)
20
21    if (not found_user):
22        autograder.cli.common.print_no_match('user', config.target_email)
23        return 1
24
25    if (not found_submission):
26        autograder.cli.common.print_no_match('submission', config.target_submission)
27        return 2
28
29    if (result is None):
30        raise ValueError("Existing submission was not provided by API.")
31
32    out_path = autograder.util.grading.output_grading_result(result, base_dir = config.out_dir)
33    print(f"Submission wrote to '{out_path}'.")
34
35    return 0

Run the CLI.

def main() -> int:
37def main() -> int:
38    """ Get a parser, parse the args, and call run. """
39
40    return run_cli(_get_parser().parse_args())

Get a parser, parse the args, and call run.