Skip to content

Commit

Permalink
Changed the submission response so that the reject reason is now a ge…
Browse files Browse the repository at this point in the history
…neral message.
  • Loading branch information
eriq-augustine committed Dec 30, 2023
1 parent 6c444c4 commit fde7b07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/submission/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type SubmitRequest struct {

type SubmitResponse struct {
Rejected bool `json:"rejected"`
RejectReason string `json:"reject-reason"`
Message string `json:"message"`

GradingSucess bool `json:"grading-success"`
GradingInfo *model.GradingInfo `json:"result"`
Expand All @@ -44,7 +44,7 @@ func HandleSubmit(request *SubmitRequest) (*SubmitResponse, *core.APIError) {

if (reject != nil) {
response.Rejected = true;
response.RejectReason = reject.String();
response.Message = reject.String();
return &response, nil;
}

Expand Down
8 changes: 4 additions & 4 deletions api/submission/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestSubmit(test *testing.T) {
continue;
}

if (responseContent.RejectReason != "") {
if (responseContent.Message != "") {
test.Errorf("Case %d: Response has a reject reason when it should not: '%v'.", i, responseContent);
continue;
}
Expand Down Expand Up @@ -100,13 +100,13 @@ func TestRejectSubmissionMaxAttempts(test *testing.T) {
test.Fatalf("Response is not rejected when it should be: '%v'.", responseContent);
}

if (responseContent.RejectReason == "") {
if (responseContent.Message == "") {
test.Fatalf("Response does not have a reject reason when it should: '%v'.", responseContent);
}

expected := (&grader.RejectMaxAttempts{0}).String();
if (expected != responseContent.RejectReason) {
if (expected != responseContent.Message) {
test.Fatalf("Did not get the expected rejection reason. Expected: '%s', Actual: '%s'.",
expected, responseContent.RejectReason);
expected, responseContent.Message);
}
}

0 comments on commit fde7b07

Please sign in to comment.