Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class DevDataBootstrap(
) {
val pupilUserId = requireNotNull(pupil.id) { "Pupil seed user must have an id" }
val classroomId = classroom.id
val existingProgress = pupilGameProgressRepository.findByPupilIdAndClassroom_Id(pupilUserId, classroomId)
val existingProgress = pupilGameProgressRepository.findByPupilIdAndClassroomId(pupilUserId, classroomId)
if (existingProgress != null) {
existingProgress.updateProgress(
totalScore = totalScore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class PupilGameProgress(
@Embeddable
data class PupilGameProgressId(
@Column(name = "pupil_user_id")
val pupilUserId: Long = 0,
var pupilUserId: Long = 0,
@Column(name = "classroom_id")
val classroomId: Long = 0,
var classroomId: Long = 0,
) : Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface PupilGameProgressRepository : JpaRepository<PupilGameProgress, PupilGa
* @param classroomId the classroom ID
* @return the matching progress record, or null if no record exists
*/
fun findByPupilIdAndClassroom_Id(pupilUserId: Long, classroomId: Long): PupilGameProgress?
fun findByPupilIdAndClassroomId(pupilUserId: Long, classroomId: Long): PupilGameProgress?

/**
* Finds all progress records for a classroom.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.ntnu.idi.idatt.backend.game.mapstops.application

import edu.ntnu.idi.idatt.backend.game.application.GameAccessContext
import edu.ntnu.idi.idatt.backend.game.application.GameAccessContextResolver
import edu.ntnu.idi.idatt.backend.game.application.GameReadMode
import edu.ntnu.idi.idatt.backend.game.mapstops.domain.MapStop
Expand Down Expand Up @@ -61,7 +60,7 @@ class MapStopService(
val accessContext = gameAccessContextResolver.resolveReadContext(currentUser, classroomId, readMode)
val stops = mapStopsRepository.findAllByIsActiveTrueOrderByDisplayOrderAsc()
if (accessContext.allStopsOpen || accessContext.pupilUserId == null) {
return stops.mapNotNull { stop -> stop.toOpenOverviewEntry() }
return stops.map { stop -> stop.toOpenOverviewEntry() }
}
val progressByStopId = pupilStopProgressRepository
.findAllByIdPupilUserIdAndIdClassroomId(accessContext.pupilUserId, classroomId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PupilProgressSeedingEventListener(
*/
@EventListener
fun onPupilJoined(event: PupilJoinedClassroomEvent) {
val pupilId = requireNotNull(event.pupil.id) { "Pupil is missing an id" }
requireNotNull(event.pupil.id) { "Pupil is missing an id" }
pupilProgressSeedingService.seedIfAbsent(
pupil = event.pupil,
classroom = event.classroom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,4 @@ class MapStop (
var isFinalBoss: Boolean? = false,
@Column(name = "is_active")
var isActive: Boolean? = false,
) {

}
)
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ enum class StopProgressStatus {
@Embeddable
data class PupilStopProgressId(
@Column(name = "pupil_user_id")
val pupilUserId: Long?,
var pupilUserId: Long?,
@Column(name = "classroom_id")
val classroomId: Long,
var classroomId: Long,
@Column(name = "stop_id")
val stopId: Long,
var stopId: Long,
) : Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.springframework.http.ResponseCookie
import org.springframework.http.ResponseEntity
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.security.web.csrf.CsrfTokenRepository
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package edu.ntnu.idi.idatt.backend.iam.domain
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import jakarta.persistence.FetchType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
Expand Down