Defense: keep assignment text for admins, hide it only from students

This commit is contained in:
2026-09-28 17:30:11 +03:00
parent 4e1e0d1488
commit 74c09aae53
2 changed files with 6 additions and 4 deletions

View File

@@ -22,15 +22,17 @@ class DefenseMyController(
@GetMapping
fun my(
@AuthenticationPrincipal jwt: Jwt,
): List<DefenseDto> = service.mySessions(UUID.fromString(jwt.subject)).map { hideCode(it) }
): List<DefenseDto> = service.mySessions(UUID.fromString(jwt.subject)).map { hideForStudent(it) }
@GetMapping("/{labId}")
fun one(
@PathVariable labId: UUID,
@AuthenticationPrincipal jwt: Jwt,
): DefenseDto? = service.mySession(UUID.fromString(jwt.subject), labId)?.let { hideCode(it) }
): DefenseDto? = service.mySession(UUID.fromString(jwt.subject), labId)?.let { hideForStudent(it) }
private fun hideCode(d: DefenseDto): DefenseDto = if (d.status == DefenseStatus.waiting.name) d.copy(code = null) else d
/** Студент не должен видеть ни код, ни текст задания до ввода кода. */
private fun hideForStudent(d: DefenseDto): DefenseDto =
if (d.status == DefenseStatus.waiting.name) d.copy(code = null, assignmentMd = "") else d
@PostMapping("/start")
fun start(

View File

@@ -204,7 +204,7 @@ class DefenseService(
labId = s.labId.toString(),
status = s.status,
code = s.code,
assignmentMd = if (s.status == DefenseStatus.waiting.name) "" else s.assignmentMd,
assignmentMd = s.assignmentMd,
startedAt = s.startedAt?.toString(),
readyAt = s.readyAt?.toString(),
readyReason = s.readyReason,