fix: края архива, истории, пагинации и лимита попыток

This commit is contained in:
2026-10-29 21:05:44 +03:00
parent 82394cc688
commit a42bc64193
6 changed files with 14 additions and 9 deletions

View File

@@ -290,7 +290,7 @@ class GroupService(
MembershipHistoryRow(
id = event.id.toString(),
studentId = event.studentId.toString(),
studentName = studentsById[event.studentId]?.fullName.orEmpty(),
studentName = studentsById[event.studentId]?.fullName?.takeIf { it.isNotBlank() } ?: event.studentId.toString(),
fromGroupId = event.fromGroupId?.toString(),
fromGroupName = event.fromGroupId?.let { groupsById[it]?.name },
toGroupId = event.toGroupId?.toString(),
@@ -306,8 +306,8 @@ class GroupService(
@Transactional
fun restoreGroup(groupId: UUID): GroupDetail {
val group = groups.findById(groupId).orElseThrow { NotFoundException("Группа не найдена") }
if (group.status == GroupStatus.ACTIVE) {
throw BadRequestException("Группа ${group.name} уже активна")
if (group.status != GroupStatus.ARCHIVED) {
throw BadRequestException("Группа ${group.name} не находится в архиве")
}
group.status = GroupStatus.ACTIVE
groups.save(group)

View File

@@ -60,7 +60,7 @@ class StudentProfileService(
submissionLimit: Int = DEFAULT_SUBMISSION_LIMIT,
): StudentCourseProfile {
val role = normalizeRole(callerRole)
val effectiveLimit = submissionLimit.coerceIn(1, MAX_SUBMISSION_LIMIT)
val effectiveLimit = if (submissionLimit <= 0) Int.MAX_VALUE else submissionLimit.coerceIn(1, MAX_SUBMISSION_LIMIT)
val course = academic.getCourse(courseId.toString(), token)
val context = identity.getStudentContext(studentId.toString())
requireProfileAccess(course, context, studentId, callerId, role)

View File

@@ -288,6 +288,10 @@ class StudentProfileIntegrationTest {
assertThat(lab.submissionsTotal).isEqualTo(3)
assertThat(lab.attemptsCount).isEqualTo(3)
assertThat(lab.submissions.map { it.seq }).containsExactly(3)
val unlimited = profiles.profile(courseId, studentId, UUID.randomUUID(), "ADMIN", TEACHER_TOKEN, submissionLimit = 0)
val unlimitedLab = unlimited.labs.single()
assertThat(unlimitedLab.submissions.map { it.seq }).containsExactly(3, 2, 1)
}
private fun stubCourse(