Skip to content

Commit

Permalink
include student points in API CourseSummary and round points to 2 dec…
Browse files Browse the repository at this point in the history
…imals
  • Loading branch information
sealexan committed Dec 14, 2023
1 parent c330d7f commit dc9e590
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface CourseSummary {
@get:Value("#{@courseService.getTeamMembers(target.assistants)}")
val assistants: Set<MemberOverview?>?

@get:Value("#{@courseServiceForCaching.getStudents(target.slug)}")
@get:Value("#{@courseServiceForCaching.getStudentsWithPoints(target.slug)}")
val students: List<StudentDTO?>?
val assignments: List<AssignmentSummary?>?

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/ch/uzh/ifi/access/service/CourseService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.springframework.lang.Nullable
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Service
import org.springframework.web.server.ResponseStatusException
import java.math.RoundingMode
import java.nio.charset.Charset
import java.nio.file.Files
import java.nio.file.NoSuchFileException
Expand Down Expand Up @@ -71,7 +72,7 @@ class CourseServiceForCaching(
val user = roleService.getUserByUsername(it)
if (user != null) {
val coursePoints = courseRepository.getTotalPoints(courseSlug, user.username) ?: 0.0
val studentDTO = StudentDTO(user.firstName, user.lastName, user.email, coursePoints, user.username, it)
val studentDTO = StudentDTO(user.firstName, user.lastName, user.email, coursePoints.toBigDecimal().setScale(2, RoundingMode.HALF_UP).toDouble(), user.username, it)
studentDTO
} else {
StudentDTO(registrationId = it)
Expand Down

0 comments on commit dc9e590

Please sign in to comment.