From 8bbd818247f61560a43899b092130eaba1d637de Mon Sep 17 00:00:00 2001 From: miiiinju1 Date: Thu, 2 Nov 2023 15:55:08 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:sparkles:=20[FEAT]=20=EC=8B=9C=ED=97=98=20?= =?UTF-8?q?=EB=8B=A4=EC=8B=9C=20=ED=92=80=EA=B8=B0=20=EC=8B=9C=EC=9E=91=20?= =?UTF-8?q?API=20#562?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../morandi/config/swagger/SwaggerConfig.java | 13 +++ .../service/BaekjoonSubmitService.java | 1 + .../domain/testDuring/dto/TempCodeDto.java | 16 +++- .../dto/factory/TempCodeFactory.java | 12 +++ .../testInfo/entity/AttemptProblem.java | 5 ++ .../testInfo/repository/TestRepository.java | 5 ++ .../repository/AttemptProblemRepository.java | 2 - .../controller/TestRetryController.java | 29 +++++++ .../testRetry/request/RetryTestRequest.java | 9 ++ .../response/RetryAttemptProblemResponse.java | 31 +++++++ .../testRetry/response/TestRetryResponse.java | 20 +++++ .../testRetry/service/TestRetryService.java | 82 +++++++++++++++++++ .../redis/utils/RedisKeyGenerator.java | 4 + 13 files changed, 226 insertions(+), 3 deletions(-) create mode 100644 src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java create mode 100644 src/main/java/swm_nm/morandi/domain/testRetry/request/RetryTestRequest.java create mode 100644 src/main/java/swm_nm/morandi/domain/testRetry/response/RetryAttemptProblemResponse.java create mode 100644 src/main/java/swm_nm/morandi/domain/testRetry/response/TestRetryResponse.java create mode 100644 src/main/java/swm_nm/morandi/domain/testRetry/service/TestRetryService.java diff --git a/src/main/java/swm_nm/morandi/config/swagger/SwaggerConfig.java b/src/main/java/swm_nm/morandi/config/swagger/SwaggerConfig.java index 9817e183..993020e5 100644 --- a/src/main/java/swm_nm/morandi/config/swagger/SwaggerConfig.java +++ b/src/main/java/swm_nm/morandi/config/swagger/SwaggerConfig.java @@ -116,6 +116,19 @@ public Docket practiceProblemApi() { .build() .apiInfo(apiInfo()); } + + @Bean + public Docket testRetryApi() { + return new Docket(DocumentationType.OAS_30) + .servers(serverLocal, testServer) + .groupName("test-retry-api") + .useDefaultResponseMessages(false) + .select() + .apis(RequestHandlerSelectors.basePackage("swm_nm.morandi.domain.testRetry.controller")) + .paths(PathSelectors.any()) + .build() + .apiInfo(apiInfo()); + } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("Practice Swagger") diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java index c0486e8e..26aa4e56 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java @@ -253,6 +253,7 @@ private void saveSubmitCodeToDatabase(Long testId, SubmitCodeDto submitCodeDto) .orElseThrow(() -> new MorandiException(SubmitErrorCode.TEST_NOT_EXIST)); attemptProblem.setSubmitCode(submitCodeDto.getSourceCode()); + attemptProblem.setSubmitLanguage(submitCodeDto.getLanguage()); //TODO //attemptProblem에 마지막으로 제출한 language의 정보가 빠져있음 -> 이거 나중에 추가하던지 해야함 attemptProblemRepository.save(attemptProblem); diff --git a/src/main/java/swm_nm/morandi/domain/testDuring/dto/TempCodeDto.java b/src/main/java/swm_nm/morandi/domain/testDuring/dto/TempCodeDto.java index c216ed83..595dbfe1 100644 --- a/src/main/java/swm_nm/morandi/domain/testDuring/dto/TempCodeDto.java +++ b/src/main/java/swm_nm/morandi/domain/testDuring/dto/TempCodeDto.java @@ -26,9 +26,23 @@ public void writeCode(String code, Language language) { case Cpp -> this.cppCode = code; case Java -> this.javaCode = code; } - log.error("writeCode"+code); + this.lastAccessCode = language; } + public String getCode(String code, Language language) { + switch (language) { + case Python -> { + return this.pythonCode; + } + case Cpp -> { + return this.cppCode; + } + case Java -> { + return this.javaCode; + } + } + return null; + } } diff --git a/src/main/java/swm_nm/morandi/domain/testDuring/dto/factory/TempCodeFactory.java b/src/main/java/swm_nm/morandi/domain/testDuring/dto/factory/TempCodeFactory.java index 1104c96e..3c632158 100644 --- a/src/main/java/swm_nm/morandi/domain/testDuring/dto/factory/TempCodeFactory.java +++ b/src/main/java/swm_nm/morandi/domain/testDuring/dto/factory/TempCodeFactory.java @@ -5,6 +5,7 @@ import swm_nm.morandi.config.configuration.InitialCodeConfig; import swm_nm.morandi.domain.common.Language; import swm_nm.morandi.domain.testDuring.dto.TempCodeDto; +import swm_nm.morandi.domain.testRetry.response.RetryAttemptProblemResponse; import java.util.HashMap; @@ -23,4 +24,15 @@ public TempCodeDto getTempCodeDto() { .lastAccessCode(Language.Cpp) .build(); } + + public RetryAttemptProblemResponse getRetryAttemptProblemResponse() { + HashMap initialCode = initialCodeConfig.getInitialCode(); + + return RetryAttemptProblemResponse.builder() + .pythonCode(initialCode.get(Language.Python)) + .cppCode(initialCode.get(Language.Cpp)) + .javaCode(initialCode.get(Language.Java)) + .lastAccessCode(Language.Cpp) + .build(); + } } diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/entity/AttemptProblem.java b/src/main/java/swm_nm/morandi/domain/testInfo/entity/AttemptProblem.java index 21336151..0e749229 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/entity/AttemptProblem.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/entity/AttemptProblem.java @@ -2,6 +2,7 @@ import lombok.*; import swm_nm.morandi.domain.common.BaseEntity; +import swm_nm.morandi.domain.common.Language; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.problem.entity.Problem; @@ -24,6 +25,10 @@ public class AttemptProblem extends BaseEntity { private Long executionTime; + @Builder.Default + @Enumerated(EnumType.STRING) + private Language submitLanguage = Language.Cpp; + @Column(columnDefinition = "TEXT") private String submitCode; diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/repository/TestRepository.java b/src/main/java/swm_nm/morandi/domain/testInfo/repository/TestRepository.java index aba823e4..20228dc9 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/repository/TestRepository.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/repository/TestRepository.java @@ -1,16 +1,21 @@ package swm_nm.morandi.domain.testInfo.repository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; import swm_nm.morandi.domain.testDuring.dto.TestStatus; import swm_nm.morandi.domain.testInfo.entity.Tests; import java.time.LocalDateTime; import java.util.List; +import java.util.Optional; + public interface TestRepository extends JpaRepository{ //Paging하여 테스트 기록을 가져옴 Page findAllTestsByMember_MemberIdAndTestStatus(Long memberId, TestStatus testStatus, Pageable pageable); //1년동안의 테스트 기록을 가져와서 레이팅 반환에 사용함 List findAllTestsByMember_MemberIdAndTestStatusAndTestDateAfterOrderByTestDateAsc(Long memberId, TestStatus testStatus, LocalDateTime oneYearAgo); Long countByMember_MemberIdAndTestStatus(Long memberId, TestStatus testStatus); + + Optional findTestByTestIdAndMember_MemberId(Long testId, Long memberId); } diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/repository/AttemptProblemRepository.java b/src/main/java/swm_nm/morandi/domain/testRecord/repository/AttemptProblemRepository.java index fdefe157..c1533ff5 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/repository/AttemptProblemRepository.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/repository/AttemptProblemRepository.java @@ -15,8 +15,6 @@ public interface AttemptProblemRepository extends JpaRepository { List findAllByMember_MemberId(Long memberId); List findAllByTest_TestId(Long testId); - List findAllByTestOrderByAttemptProblemIdAsc(Tests test); - @EntityGraph(attributePaths = {"test", "problem"}) Optional findByTest_TestIdAndProblem_BojProblemId(Long testId, Long bojProblemId); diff --git a/src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java b/src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java new file mode 100644 index 00000000..397a8e64 --- /dev/null +++ b/src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java @@ -0,0 +1,29 @@ +package swm_nm.morandi.domain.testRetry.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; +import swm_nm.morandi.domain.testInfo.dto.TestDto; +import swm_nm.morandi.domain.testRetry.request.RetryTestRequest; +import swm_nm.morandi.domain.testRetry.response.TestRetryResponse; +import swm_nm.morandi.domain.testRetry.service.TestRetryService; + +@RestController +@RequestMapping("/tests") +@RequiredArgsConstructor +@Tag(name = "TestRetryController", description = "테스트 다시 풀기와 관련된 컨트롤러") +public class TestRetryController { + + private final TestRetryService testRetryService; + + @PostMapping("/retry") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "테스트 다시 풀기", description = "테스트 다시 풀기") + public TestRetryResponse retryTest(@RequestBody RetryTestRequest retryTestRequest) { + return testRetryService.retryTest(retryTestRequest); + } + + +} diff --git a/src/main/java/swm_nm/morandi/domain/testRetry/request/RetryTestRequest.java b/src/main/java/swm_nm/morandi/domain/testRetry/request/RetryTestRequest.java new file mode 100644 index 00000000..6c3f9eef --- /dev/null +++ b/src/main/java/swm_nm/morandi/domain/testRetry/request/RetryTestRequest.java @@ -0,0 +1,9 @@ +package swm_nm.morandi.domain.testRetry.request; + +import lombok.Getter; +import lombok.Setter; + +@Getter @Setter +public class RetryTestRequest { + private Long testId; +} diff --git a/src/main/java/swm_nm/morandi/domain/testRetry/response/RetryAttemptProblemResponse.java b/src/main/java/swm_nm/morandi/domain/testRetry/response/RetryAttemptProblemResponse.java new file mode 100644 index 00000000..45c3c1a7 --- /dev/null +++ b/src/main/java/swm_nm/morandi/domain/testRetry/response/RetryAttemptProblemResponse.java @@ -0,0 +1,31 @@ +package swm_nm.morandi.domain.testRetry.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import swm_nm.morandi.domain.common.Language; + +@Builder +@Getter +@Slf4j +@AllArgsConstructor +@NoArgsConstructor +public class RetryAttemptProblemResponse { + private Long bojProblemId; + private String pythonCode; + private String javaCode; + private String cppCode; + private Language lastAccessCode; + + public void initialRetryAttemptProblemResponse(String code, Language language, Long bojProblemId) { + switch (language) { + case Python -> this.pythonCode = code; + case Cpp -> this.cppCode = code; + case Java -> this.javaCode = code; + } + this.bojProblemId = bojProblemId; + this.lastAccessCode = language; + } +} \ No newline at end of file diff --git a/src/main/java/swm_nm/morandi/domain/testRetry/response/TestRetryResponse.java b/src/main/java/swm_nm/morandi/domain/testRetry/response/TestRetryResponse.java new file mode 100644 index 00000000..0f9250ab --- /dev/null +++ b/src/main/java/swm_nm/morandi/domain/testRetry/response/TestRetryResponse.java @@ -0,0 +1,20 @@ +package swm_nm.morandi.domain.testRetry.response; + +import lombok.*; +import swm_nm.morandi.domain.common.Language; +import swm_nm.morandi.domain.testDuring.dto.TempCodeDto; +import swm_nm.morandi.domain.testStart.dto.BojProblemDto; +import swm_nm.morandi.domain.testStart.dto.TestCodeDto; + +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class TestRetryResponse { + private Long testId; + private List retryAttemptProblems; + +} \ No newline at end of file diff --git a/src/main/java/swm_nm/morandi/domain/testRetry/service/TestRetryService.java b/src/main/java/swm_nm/morandi/domain/testRetry/service/TestRetryService.java new file mode 100644 index 00000000..e22a7cf6 --- /dev/null +++ b/src/main/java/swm_nm/morandi/domain/testRetry/service/TestRetryService.java @@ -0,0 +1,82 @@ +package swm_nm.morandi.domain.testRetry.service; + + +import lombok.RequiredArgsConstructor; +import org.springframework.cache.annotation.CachePut; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import swm_nm.morandi.domain.testDuring.dto.TempCodeDto; +import swm_nm.morandi.domain.testDuring.dto.factory.TempCodeFactory; +import swm_nm.morandi.domain.testInfo.entity.AttemptProblem; +import swm_nm.morandi.domain.testInfo.entity.Tests; +import swm_nm.morandi.domain.testInfo.repository.TestRepository; +import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository; +import swm_nm.morandi.domain.testRetry.request.RetryTestRequest; +import swm_nm.morandi.domain.testRetry.response.RetryAttemptProblemResponse; +import swm_nm.morandi.domain.testRetry.response.TestRetryResponse; +import swm_nm.morandi.global.exception.MorandiException; +import swm_nm.morandi.global.exception.errorcode.TestErrorCode; +import swm_nm.morandi.global.utils.SecurityUtils; +import swm_nm.morandi.redis.utils.RedisKeyGenerator; + +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +@Service +@RequiredArgsConstructor +public class TestRetryService { + + private final TestRepository testRepository; + + private final RedisKeyGenerator redisKeyGenerator; + + private final RedisTemplate redisTemplate; + + private final TempCodeFactory tempCodeFactory; + private final Long expireTime = 60000L; + + public TestRetryResponse retryTest(RetryTestRequest retryTestRequest) { + Tests test = testRepository.findTestByTestIdAndMember_MemberId(retryTestRequest.getTestId(), SecurityUtils.getCurrentMemberId()) + .orElseThrow(() -> new MorandiException(TestErrorCode.TEST_NOT_FOUND)); + + + List attemptProblemResponses = + test.getAttemptProblems().stream() + .map(attemptProblem -> { + RetryAttemptProblemResponse attemptProblemResponse = tempCodeFactory.getRetryAttemptProblemResponse(); + attemptProblemResponse.initialRetryAttemptProblemResponse(attemptProblem.getSubmitCode(), + attemptProblem.getSubmitLanguage(), + attemptProblem.getProblem().getBojProblemId()); + return attemptProblemResponse; + }).toList(); + + + + saveCodeToRedis(retryTestRequest.getTestId(), attemptProblemResponses); + + return TestRetryResponse.builder() + .testId(retryTestRequest.getTestId()) + .retryAttemptProblems(attemptProblemResponses) + .build(); + + } + + private void saveCodeToRedis(Long testId, List attemptProblemResponses) { + String retryTestTempCodeKey = redisKeyGenerator.generateRetryTestTempCodeKey(testId); + + HashOperations hashOps = redisTemplate.opsForHash(); + int problemCount = attemptProblemResponses.size(); + IntStream.rangeClosed(1, problemCount).forEach(problemNumber -> + hashOps.put(retryTestTempCodeKey, + String.valueOf(problemNumber), + attemptProblemResponses.get(problemNumber-1)) + ); + redisTemplate.expire(retryTestTempCodeKey, expireTime, TimeUnit.MINUTES); + } + + + +} diff --git a/src/main/java/swm_nm/morandi/redis/utils/RedisKeyGenerator.java b/src/main/java/swm_nm/morandi/redis/utils/RedisKeyGenerator.java index 744bc3b7..c566ac8c 100644 --- a/src/main/java/swm_nm/morandi/redis/utils/RedisKeyGenerator.java +++ b/src/main/java/swm_nm/morandi/redis/utils/RedisKeyGenerator.java @@ -19,4 +19,8 @@ public String generatePracticeProblemTempCodeKey(Long practiceProblemId) { return String.format("practiceProblemId:%s", practiceProblemId); } + public String generateRetryTestTempCodeKey(Long testId) { + return String.format("retryTestId:%s", testId); + } + } From 6ba8a638434716cec639bf0777e11ee4efebd52b Mon Sep 17 00:00:00 2001 From: miiiinju1 Date: Thu, 2 Nov 2023 16:35:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:recycle:=20[REFACTOR]=20=EB=B0=B1=EC=A4=80?= =?UTF-8?q?=20=EC=A0=9C=EC=B6=9C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20Dto=20->=20String=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20#566?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #566 --- .../domain/codeSubmit/dto/SubmitCodeDto.java | 10 ++++++++++ .../domain/codeSubmit/dto/SubmitDto.java | 11 +++++++++++ .../service/BaekjoonSubmitService.java | 19 +++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitDto.java diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeDto.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeDto.java index 1e7ef721..5cafdc9d 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeDto.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeDto.java @@ -33,4 +33,14 @@ public String getLanguageId() { throw new MorandiException(SubmitErrorCode.LANGUAGE_CODE_NOT_FOUND); } } + + public static String getLanguageId(Language language) { + try { + return SubmitConstants.valueOf(language.getLanguage()).getLanguageId(); + } catch (IllegalArgumentException e) { + throw new MorandiException(SubmitErrorCode.LANGUAGE_CODE_NOT_FOUND); + } + } + + } diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitDto.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitDto.java new file mode 100644 index 00000000..7aac3835 --- /dev/null +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitDto.java @@ -0,0 +1,11 @@ +package swm_nm.morandi.domain.codeSubmit.dto; + +public interface SubmitDto { + + String getBojProblemId(); + String getLanguageId(); + + String getSourceCode(); + + +} diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java index 26aa4e56..80ba1043 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java @@ -17,6 +17,7 @@ import swm_nm.morandi.domain.codeSubmit.constants.CodeVisuabilityConstants; import swm_nm.morandi.domain.codeSubmit.dto.BaekjoonUserDto; import swm_nm.morandi.domain.codeSubmit.dto.SolutionIdDto; +import swm_nm.morandi.domain.common.Language; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; import swm_nm.morandi.domain.testDuring.dto.TestInfo; @@ -108,13 +109,15 @@ public ResponseEntity submit(SubmitCodeDto submitCodeDto) { String cookie = getCookieFromRedis(generateKey(memberId)); String CSRFKey = getCSRFKey(cookie, submitCodeDto.getBojProblemId()); - SolutionIdDto solutionId= sendSubmitRequest(cookie, CSRFKey, submitCodeDto); + SolutionIdDto solutionId = sendSubmitRequest(cookie, CSRFKey, submitCodeDto.getBojProblemId(), submitCodeDto.getLanguage(), submitCodeDto.getSourceCode()); //제출한 코드 정보를 저장 saveSubmitTempCode(submitCodeDto); return ResponseEntity.status(HttpStatus.OK).body(solutionId); } + + private void validateBojProblemId(String bojProblemId) { try { int problemId = Integer.parseInt(bojProblemId); @@ -159,10 +162,10 @@ private HttpHeaders createHeaders(String cookie) { return headers; } - private SolutionIdDto sendSubmitRequest(String cookie, String CSRFKey, SubmitCodeDto submitCodeDto) { - String acmicpcUrl = String.format("https://www.acmicpc.net/submit/%s", submitCodeDto.getBojProblemId()); + private SolutionIdDto sendSubmitRequest(String cookie, String CSRFKey, String bojProblemId, Language language, String sourceCode) { + String acmicpcUrl = String.format("https://www.acmicpc.net/submit/%s", bojProblemId); HttpHeaders headers = createHeaders(cookie); - MultiValueMap parameters = createParameters(submitCodeDto, CSRFKey); + MultiValueMap parameters = createParameters(bojProblemId, language,sourceCode, CSRFKey); HttpEntity> request = new HttpEntity<>(parameters, headers); try { @@ -203,12 +206,12 @@ private SolutionIdDto sendSubmitRequest(String cookie, String CSRFKey, SubmitCod throw new MorandiException(SubmitErrorCode.BAEKJOON_UNKNOWN_ERROR); } //POST로 보낼 때 필요한 파라미터들을 생성 - private MultiValueMap createParameters(SubmitCodeDto submitCodeDto, String CSRFKey) { + private MultiValueMap createParameters(String bojProblemId, Language language, String sourceCode, String CSRFKey) { MultiValueMap parameters = new LinkedMultiValueMap<>(); - parameters.add("problem_id", submitCodeDto.getBojProblemId()); - parameters.add("language", submitCodeDto.getLanguageId()); + parameters.add("problem_id", bojProblemId); + parameters.add("language", SubmitCodeDto.getLanguageId(language)); parameters.add("code_open", CodeVisuabilityConstants.CLOSE.getCodeVisuability()); - parameters.add("source", submitCodeDto.getSourceCode()); + parameters.add("source", sourceCode); parameters.add("csrf_key", CSRFKey); return parameters; }