blob: f5f8a44dcb544379e9c930d13fcf83d33c57df0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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.*;
@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;
public TestResultsController(TestResultsService testResultsService) {
this.testResultsService = testResultsService;
}
// TODO - update to consume text/xml+markr, consider return value
@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);
}
}
|