Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aqua-sc committed May 9, 2024
1 parent 59c24ca commit b672fda
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ private ResponseEntity<?> alterTests(
DockerSubmissionTestModel.installImage(finalDockerImage);
}
});
testEntity.setDockerImage(dockerImage);

testEntity.setDockerTestScript(dockerScript);
testEntity.setDockerTestTemplate(
dockerTemplate); // If present, the test is in template mode
//Update fields
if (dockerImage != null || !httpMethod.equals(HttpMethod.PATCH)) {
testEntity.setDockerImage(dockerImage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class SubmissionJson {


private DockerTestFeedbackJson dockerFeedback;
private String artifactUrl;



Expand All @@ -31,7 +32,8 @@ public SubmissionJson() {

public SubmissionJson(
long id, String projectUrl, String groupUrl, Long projectId, Long groupId, String fileUrl,
Boolean structureAccepted, OffsetDateTime submissionTime, String structureFeedbackUrl, DockerTestFeedbackJson dockerFeedback, String dockerStatus) {
Boolean structureAccepted, OffsetDateTime submissionTime, String structureFeedbackUrl, DockerTestFeedbackJson dockerFeedback, String dockerStatus,
String artifactUrl) {
this.submissionId = id;
this.projectUrl = projectUrl;
this.groupUrl = groupUrl;
Expand All @@ -43,6 +45,7 @@ public SubmissionJson(
this.dockerFeedback = dockerFeedback;
this.structureFeedback = structureFeedbackUrl;
this.dockerStatus = dockerStatus;
this.artifactUrl = artifactUrl;
}

public long getSubmissionId() {
Expand Down Expand Up @@ -134,4 +137,12 @@ public DockerTestFeedbackJson getDockerFeedback() {
public void setDockerFeedback(DockerTestFeedbackJson dockerFeedback) {
this.dockerFeedback = dockerFeedback;
}

public String getArtifactUrl() {
return artifactUrl;
}

public void setArtifactUrl(String artifactUrl) {
this.artifactUrl = artifactUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,15 @@ private static DockerSubtestResult getDockerSubtestResult(String entry) {
templateEntry.setRequired(true);
} else if (currentOption.equalsIgnoreCase(">Optional")) {
templateEntry.setRequired(false);
} else if (currentOption.substring(0, 12).equalsIgnoreCase(">Description")) {
} else if (currentOption.length() >=13 && currentOption.substring(0, 13).equalsIgnoreCase(">Description=")) {
templateEntry.setTestDescription(currentOption.split("=\"")[1].split("\"")[0]);
}
}
templateEntry.setCorrect(entry.substring(lineIterator));
String substring = entry.substring(lineIterator);
if (substring.endsWith("\n")) {
substring = substring.substring(0, substring.length() - 1);
}
templateEntry.setCorrect(substring);
return templateEntry;
}

Expand Down Expand Up @@ -309,9 +313,10 @@ public static boolean isValidTemplate(String template) {
}
if (isConfigurationLine) {
if (line.charAt(0) == '>') {
boolean isDescription = line.length() >= 13 && line.substring(0, 13).equalsIgnoreCase(">Description=");
// option lines
if (!line.equalsIgnoreCase(">Required") && !line.equalsIgnoreCase(">Optional")
&& !line.substring(0, 12).equalsIgnoreCase(">Description")) {
&& !isDescription) {
return false;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ public void setRequired(boolean required) {

@Override
public boolean isAllowed() {
return false;
return correct.equals(output);
}

@Override
public String getFeedbackAsString() {
// Display feedback as a json, only display testName and testDescription if they are not empty
String testDescription = this.testDescription.isEmpty() ? "" : "\",\"testDescription\":\"" + this.testDescription;
return "{\"testName\":\"" + testName + testDescription + "\",\"correct\":\"" + correct + "\",\"output\":\"" + output + "\"}";
//TODO add allowed to json
return "{\"testName\":\"" + testName + testDescription + "\",\"correct\":\"" + correct + "\",\"output\":\"" + output + "\", \"required\":" + required + ", \"succes\": " + isAllowed() + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DockerTemplateTestOutput(List<DockerSubtestResult> subtestResults, boolea
@Override
public String getFeedbackAsString(){
//json representation of the tests
StringBuilder feedback = new StringBuilder("{subtests: [");
StringBuilder feedback = new StringBuilder("{\"subtests\": [");
for (DockerSubtestResult subtestResult : subtestResults) {
feedback.append(subtestResult.getFeedbackAsString()).append(",");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ else if (submission.getDockerTestType().equals(DockerTestType.SIMPLE)) {
submission.getSubmissionTime(),
submission.getStructureFeedback(),
feedback,
submission.getDockerTestState().toString()
submission.getDockerTestState().toString(),
ApiRoutes.SUBMISSION_BASE_PATH + "/" + submission.getId() + "/artifacts"
);
}

Expand Down

0 comments on commit b672fda

Please sign in to comment.