| 1 | package edu.ucsb.cs.scaffold.controller; | |
| 2 | ||
| 3 | import io.swagger.v3.oas.annotations.Operation; | |
| 4 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 5 | import lombok.RequiredArgsConstructor; | |
| 6 | import org.springframework.beans.factory.annotation.Value; | |
| 7 | import org.springframework.http.HttpEntity; | |
| 8 | import org.springframework.http.HttpHeaders; | |
| 9 | import org.springframework.http.HttpMethod; | |
| 10 | import org.springframework.http.ResponseEntity; | |
| 11 | import org.springframework.web.bind.annotation.GetMapping; | |
| 12 | import org.springframework.web.bind.annotation.RestController; | |
| 13 | import org.springframework.web.client.RestTemplate; | |
| 14 | import org.springframework.web.util.UriComponentsBuilder; | |
| 15 | ||
| 16 | @Tag(name = "PrairieLearn") | |
| 17 | @RestController | |
| 18 | @RequiredArgsConstructor | |
| 19 | public class PrairieLearnController { | |
| 20 | ||
| 21 | private final RestTemplate restTemplate; | |
| 22 | ||
| 23 | @Value("${pl.api.token:}") | |
| 24 | private String plApiToken; | |
| 25 | ||
| 26 | @Value("${pl.api.base:https://us.prairielearn.com/pl/api/v1}") | |
| 27 | private String plApiBase; | |
| 28 | ||
| 29 | @Value("${pl.course.instance.id:213859}") | |
| 30 | private String plCourseInstanceId; | |
| 31 | ||
| 32 | @Operation( | |
| 33 | summary = | |
| 34 | "Proxy request to PrairieLearn API – returns assessments for the configured course instance") | |
| 35 | @GetMapping("/api/test-pl") | |
| 36 | public Object testPrairieLearn() { | |
| 37 | HttpHeaders headers = new HttpHeaders(); | |
| 38 |
1
1. testPrairieLearn : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("Private-Token", plApiToken); |
| 39 | HttpEntity<Void> entity = new HttpEntity<>(headers); | |
| 40 | String url = | |
| 41 | UriComponentsBuilder.fromUriString(plApiBase) | |
| 42 | .pathSegment("course_instances", plCourseInstanceId, "assessments") | |
| 43 | .toUriString(); | |
| 44 | ResponseEntity<Object> response = | |
| 45 | restTemplate.exchange(url, HttpMethod.GET, entity, Object.class); | |
| 46 |
1
1. testPrairieLearn : replaced return value with null for edu/ucsb/cs/scaffold/controller/PrairieLearnController::testPrairieLearn → KILLED |
return response.getBody(); |
| 47 | } | |
| 48 | } | |
Mutations | ||
| 38 |
1.1 |
|
| 46 |
1.1 |