Defense: keep assignment text for admins, hide it only from students
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user