Defense: keep assignment text for admins, hide it only from students
This commit is contained in:
@@ -22,15 +22,17 @@ class DefenseMyController(
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
fun my(
|
fun my(
|
||||||
@AuthenticationPrincipal jwt: Jwt,
|
@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}")
|
@GetMapping("/{labId}")
|
||||||
fun one(
|
fun one(
|
||||||
@PathVariable labId: UUID,
|
@PathVariable labId: UUID,
|
||||||
@AuthenticationPrincipal jwt: Jwt,
|
@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")
|
@PostMapping("/start")
|
||||||
fun start(
|
fun start(
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class DefenseService(
|
|||||||
labId = s.labId.toString(),
|
labId = s.labId.toString(),
|
||||||
status = s.status,
|
status = s.status,
|
||||||
code = s.code,
|
code = s.code,
|
||||||
assignmentMd = if (s.status == DefenseStatus.waiting.name) "" else s.assignmentMd,
|
assignmentMd = s.assignmentMd,
|
||||||
startedAt = s.startedAt?.toString(),
|
startedAt = s.startedAt?.toString(),
|
||||||
readyAt = s.readyAt?.toString(),
|
readyAt = s.readyAt?.toString(),
|
||||||
readyReason = s.readyReason,
|
readyReason = s.readyReason,
|
||||||
|
|||||||
Reference in New Issue
Block a user