Add GradePointsSummary
This commit is contained in:
parent
080acd76ab
commit
f51ee645a8
7 changed files with 25 additions and 20 deletions
|
@ -0,0 +1,17 @@
|
|||
package io.github.wulkanowy.api.grades
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class GradePointsSummary(
|
||||
|
||||
val semesterId: Int = 0,
|
||||
|
||||
@SerializedName("Subject")
|
||||
val subject: String,
|
||||
|
||||
@SerializedName("Value1")
|
||||
val others: Double,
|
||||
|
||||
@SerializedName("Value2")
|
||||
val student: Double
|
||||
)
|
|
@ -70,13 +70,8 @@ fun List<GradesStatisticsResponse.Partial>.mapGradesStatisticsPartial(semesterId
|
|||
}.flatten()
|
||||
}
|
||||
|
||||
fun List<GradesStatisticsResponse.Points>.mapGradesStatisticsPoints(semesterId: Int): List<GradeStatistics> {
|
||||
fun List<GradePointsSummary>.mapGradesStatisticsPoints(semesterId: Int): List<GradePointsSummary> {
|
||||
return map {
|
||||
// TODO: use different class
|
||||
GradeStatistics().apply {
|
||||
this.semesterId = semesterId
|
||||
grade = it.percentage
|
||||
subject = it.subject
|
||||
}
|
||||
it.copy(semesterId = semesterId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,15 +23,6 @@ class GradesStatisticsResponse {
|
|||
val items: List<GradeStatistics>?
|
||||
)
|
||||
|
||||
data class Points(
|
||||
|
||||
@SerializedName("Subject")
|
||||
val subject: String,
|
||||
|
||||
@SerializedName("Label1")
|
||||
val percentage: String
|
||||
)
|
||||
|
||||
data class Partial(
|
||||
|
||||
@SerializedName("Subject")
|
||||
|
|
|
@ -17,6 +17,7 @@ import io.github.wulkanowy.api.exams.mapExamsList
|
|||
import io.github.wulkanowy.api.getSchoolYear
|
||||
import io.github.wulkanowy.api.getScriptParam
|
||||
import io.github.wulkanowy.api.grades.Grade
|
||||
import io.github.wulkanowy.api.grades.GradePointsSummary
|
||||
import io.github.wulkanowy.api.grades.GradeRequest
|
||||
import io.github.wulkanowy.api.grades.GradeStatistics
|
||||
import io.github.wulkanowy.api.grades.GradeSummary
|
||||
|
@ -137,7 +138,7 @@ class StudentRepository(private val api: StudentService) {
|
|||
.map { it.mapGradesStatisticsPartial(semesterId) }
|
||||
}
|
||||
|
||||
fun getGradesPointsStatistics(semesterId: Int): Single<List<GradeStatistics>> {
|
||||
fun getGradesPointsStatistics(semesterId: Int): Single<List<GradePointsSummary>> {
|
||||
return api.getGradesPointsStatistics(GradesStatisticsRequest(semesterId))
|
||||
.compose(ErrorHandlerTransformer()).map { it.data }
|
||||
.map { it.mapGradesStatisticsPoints(semesterId) }
|
||||
|
|
|
@ -9,6 +9,7 @@ import io.github.wulkanowy.api.attendance.AttendanceSummaryResponse
|
|||
import io.github.wulkanowy.api.attendance.Subject
|
||||
import io.github.wulkanowy.api.exams.ExamRequest
|
||||
import io.github.wulkanowy.api.exams.ExamResponse
|
||||
import io.github.wulkanowy.api.grades.GradePointsSummary
|
||||
import io.github.wulkanowy.api.grades.GradeRequest
|
||||
import io.github.wulkanowy.api.grades.GradesResponse
|
||||
import io.github.wulkanowy.api.grades.GradesStatisticsRequest
|
||||
|
@ -56,7 +57,7 @@ interface StudentService {
|
|||
fun getGradesPartialStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single<ApiResponse<List<GradesStatisticsResponse.Partial>>>
|
||||
|
||||
@POST("Statystyki.mvc/GetPunkty")
|
||||
fun getGradesPointsStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single<ApiResponse<List<GradesStatisticsResponse.Points>>>
|
||||
fun getGradesPointsStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single<ApiResponse<List<GradePointsSummary>>>
|
||||
|
||||
@POST("Statystyki.mvc/GetOcenyRoczne")
|
||||
fun getGradesAnnualStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single<ApiResponse<List<GradesStatisticsResponse.Annual>>>
|
||||
|
|
|
@ -75,7 +75,8 @@ class GradesStatisticsTest : BaseLocalTest() {
|
|||
fun getGradeStatisticsPoints() {
|
||||
with(points[0]) {
|
||||
assertEquals("Edukacja dla bezpieczeństwa", subject)
|
||||
assertEquals("78,18", grade)
|
||||
assertEquals(80.0, student, .0)
|
||||
assertEquals(78.18, others, .0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ class TeachersTest : BaseLocalTest() {
|
|||
assertEquals(3, student.size)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun getTeacher_std() {
|
||||
listOf(snp[2], student[2]).map {
|
||||
|
|
Loading…
Reference in a new issue