summaryrefslogtreecommitdiff
path: root/src/main/java/com/stileeducation/markr/controller/TestResultsController.java
diff options
context:
space:
mode:
authorSzymon Szukalski <szymon@skas.io>2024-07-23 16:30:53 +1000
committerSzymon Szukalski <szymon@skas.io>2024-07-23 16:30:53 +1000
commit6f62cf9d52e1d5353be33f1fbf3429b0be456dc7 (patch)
tree682bb46d22e7d041ab7fa14041b1ff745bfc8e85 /src/main/java/com/stileeducation/markr/controller/TestResultsController.java
parentaec0dff5477cafce865410381a722fedbac04ac1 (diff)
Implement simple /results/:id/aggregate endpoint and test
Diffstat (limited to 'src/main/java/com/stileeducation/markr/controller/TestResultsController.java')
-rw-r--r--src/main/java/com/stileeducation/markr/controller/TestResultsController.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/com/stileeducation/markr/controller/TestResultsController.java b/src/main/java/com/stileeducation/markr/controller/TestResultsController.java
index b1a5e63..f5f8a44 100644
--- a/src/main/java/com/stileeducation/markr/controller/TestResultsController.java
+++ b/src/main/java/com/stileeducation/markr/controller/TestResultsController.java
@@ -1,19 +1,18 @@
package com.stileeducation.markr.controller;
+import com.stileeducation.markr.dto.AggregatedTestResultsDTO;
import com.stileeducation.markr.dto.MCQTestResultsDTO;
import com.stileeducation.markr.service.TestResultsService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/")
public class TestResultsController {
public static final String IMPORT_ENDPOINT = "/import";
+ public static final String AGGREGATE_ENDPOINT = "/results/{test-id}/aggregate";
private final TestResultsService testResultsService;
@@ -25,8 +24,12 @@ public class TestResultsController {
@PostMapping(value = IMPORT_ENDPOINT, consumes = "application/xml", produces = "application/json")
public ResponseEntity<Void> handleXmlRequest(@RequestBody MCQTestResultsDTO testResults) {
testResultsService.importTestResults(testResults);
-
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
+ @GetMapping(value = AGGREGATE_ENDPOINT, produces = "application/json")
+ public AggregatedTestResultsDTO getAggregatedResults(@PathVariable("test-id") String testId) {
+ return testResultsService.aggregateTestResults(testId);
+ }
+
}