Skip to content
Snippets Groups Projects
Verified Commit f4dd9373 authored by Luc Everse's avatar Luc Everse :passport_control:
Browse files

Also send errors to Submit

parent 70f9086e
No related branches found
No related tags found
2 merge requests!179Release 2.5.0,!177Submit integration
Pipeline #737379 passed
...@@ -262,13 +262,18 @@ public class SubmitAppController extends ControllerBase ...@@ -262,13 +262,18 @@ public class SubmitAppController extends ControllerBase
try { try {
final var url = new URL(submitMetadata.getUrl()); final var url = new URL(submitMetadata.getUrl());
if (entityContainer.hadException()) {
this.sendError(url, entityContainer, submitMetadata);
return;
}
SUBMIT_ACCESS_LEVEL_MAP.entrySet().stream().forEach(e -> { SUBMIT_ACCESS_LEVEL_MAP.entrySet().stream().forEach(e -> {
try { try {
final var report = this.reportGenerator.generateReport( final var report = this.reportGenerator.generateReport(
entityContainer, Set.of(e.getKey()) entityContainer, Set.of(e.getKey())
); );
this.sendFeedback(url, report, e.getValue(), submitMetadata, null); this.sendFeedback(url, report, e.getValue(), submitMetadata, null, true);
} catch (final IOException | TemplateException ex) { } catch (final IOException | TemplateException ex) {
logger.error("Could not template report", ex); logger.error("Could not template report", ex);
} }
...@@ -280,6 +285,30 @@ public class SubmitAppController extends ControllerBase ...@@ -280,6 +285,30 @@ public class SubmitAppController extends ControllerBase
} }
} }
/**
* Sends an internal error to Submit.
*
* @param url the URL to send the error to
* @param entityContainer the container of the entity that caused the error
* @param submitMetadata metadata to be attached to the error message
*/
private void sendError(
final URL url,
final EntityContainer entityContainer,
final SubmitAppMetadata submitMetadata
) {
// Send the first bit of feedback with a "true" success, because sending an error locks
// down the submission's feedback
this.sendFeedback(
url, "The script encountered an internal error and could not finish checking "
+ "your submission.",
"STUDENT", submitMetadata, null, true
);
this.sendFeedback(
url, entityContainer.getExceptionMessage(), "TA", submitMetadata, null, false
);
}
/** /**
* Sends a report to Submit. * Sends a report to Submit.
* *
...@@ -288,13 +317,16 @@ public class SubmitAppController extends ControllerBase ...@@ -288,13 +317,16 @@ public class SubmitAppController extends ControllerBase
* @param visibleFor for whom the report should be visible * @param visibleFor for whom the report should be visible
* @param submitMetadata metadata to be attached to the feedback * @param submitMetadata metadata to be attached to the feedback
* @param score the final score, if any * @param score the final score, if any
* @param success whether the feedback is part of a successful run (true) or a script failure
* (false)
*/ */
private void sendFeedback( private void sendFeedback(
final URL url, final URL url,
final @Nullable String report, final @Nullable String report,
final String visibleFor, final String visibleFor,
final SubmitAppMetadata submitMetadata, final SubmitAppMetadata submitMetadata,
final @Nullable Integer score final @Nullable Integer score,
final boolean success
) { ) {
try { try {
final var conn = (HttpURLConnection) url.openConnection(); final var conn = (HttpURLConnection) url.openConnection();
...@@ -312,6 +344,7 @@ public class SubmitAppController extends ControllerBase ...@@ -312,6 +344,7 @@ public class SubmitAppController extends ControllerBase
body.visibleFor = visibleFor; body.visibleFor = visibleFor;
body.textualFeedback = report; body.textualFeedback = report;
body.score = score; body.score = score;
body.success = success;
this.gson.toJson(body, writer); this.gson.toJson(body, writer);
writer.flush(); writer.flush();
} }
...@@ -352,7 +385,7 @@ public class SubmitAppController extends ControllerBase ...@@ -352,7 +385,7 @@ public class SubmitAppController extends ControllerBase
score, submitMetadata.getSubmissionId(), submitMetadata.getScriptId() score, submitMetadata.getSubmissionId(), submitMetadata.getScriptId()
); );
this.sendFeedback(url, null, "STUDENT", submitMetadata, score); this.sendFeedback(url, null, "STUDENT", submitMetadata, score, true);
} }
/** /**
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment