autograder.cli.courses.assignments.submissions.common

 1import typing
 2
 3import edq.util.time
 4
 5import autograder.assignment
 6
 7def display_grading_result(
 8        api_response: typing.Dict[str, typing.Any],
 9        grading_result: typing.Union[autograder.assignment.GradedAssignment, None],
10        include_found_user: bool = False,
11        include_found_submission: bool = False,
12        ) -> int:
13    """
14    Display the result of a grading endpoint, e.g., a grading report.
15    Return the recommended exit status.
16    """
17
18    message = api_response.get('message', '')
19    if ((message is not None) and (message != '')):
20        # Replace any timestamps in the message.
21        message = edq.util.time.Timestamp.convert_embedded(message, pretty = True)
22
23        print("--- Message from Autograder ---")
24        print(message)
25        print("-------------------------------")
26
27    if (include_found_user and (not api_response['found-user'])):
28        print("Proxy user not found.")
29        return 10
30
31    if (include_found_submission and (not api_response['found-submission'])):
32        print("Target submission not found.")
33        return 11
34
35    if (api_response['rejected']):
36        print("Submission was rejected by the autograder.")
37        return 12
38
39    if (not api_response['grading-success']):
40        print("Grading failed.")
41        return 13
42
43    if (grading_result is not None):
44        print(grading_result.report())
45
46    return 0
def display_grading_result( api_response: Dict[str, Any], grading_result: Optional[autograder.assignment.GradedAssignment], include_found_user: bool = False, include_found_submission: bool = False) -> int:
 8def display_grading_result(
 9        api_response: typing.Dict[str, typing.Any],
10        grading_result: typing.Union[autograder.assignment.GradedAssignment, None],
11        include_found_user: bool = False,
12        include_found_submission: bool = False,
13        ) -> int:
14    """
15    Display the result of a grading endpoint, e.g., a grading report.
16    Return the recommended exit status.
17    """
18
19    message = api_response.get('message', '')
20    if ((message is not None) and (message != '')):
21        # Replace any timestamps in the message.
22        message = edq.util.time.Timestamp.convert_embedded(message, pretty = True)
23
24        print("--- Message from Autograder ---")
25        print(message)
26        print("-------------------------------")
27
28    if (include_found_user and (not api_response['found-user'])):
29        print("Proxy user not found.")
30        return 10
31
32    if (include_found_submission and (not api_response['found-submission'])):
33        print("Target submission not found.")
34        return 11
35
36    if (api_response['rejected']):
37        print("Submission was rejected by the autograder.")
38        return 12
39
40    if (not api_response['grading-success']):
41        print("Grading failed.")
42        return 13
43
44    if (grading_result is not None):
45        print(grading_result.report())
46
47    return 0

Display the result of a grading endpoint, e.g., a grading report. Return the recommended exit status.