diff --git a/build.gradle b/build.gradle index 20ec0bdf..7764a251 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { moshi = "1.13.0" } -version = "2.5.6" +version = "2.5.7-SNAPSHOT" group = "io.github.wulkanowy" nexusPublishing { diff --git a/sdk-scrapper/api/sdk-scrapper.api b/sdk-scrapper/api/sdk-scrapper.api index 427458bc..ef8b49d8 100644 --- a/sdk-scrapper/api/sdk-scrapper.api +++ b/sdk-scrapper/api/sdk-scrapper.api @@ -621,21 +621,23 @@ public final class io/github/wulkanowy/sdk/scrapper/grades/GradeStatisticsPartia public final class io/github/wulkanowy/sdk/scrapper/grades/GradeSummary { public fun ()V - public fun (ILjava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V - public synthetic fun (ILjava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (ILjava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V + public synthetic fun (ILjava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()I + public final fun component10 ()Z public final fun component2 ()Ljava/lang/String; public final fun component3 ()D - public final fun component4 ()Ljava/lang/String; + public final fun component4 ()Ljava/lang/Double; public final fun component5 ()Ljava/lang/String; public final fun component6 ()Ljava/lang/String; public final fun component7 ()Ljava/lang/String; public final fun component8 ()Ljava/lang/String; - public final fun component9 ()Z - public final fun copy (ILjava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Lio/github/wulkanowy/sdk/scrapper/grades/GradeSummary; - public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/scrapper/grades/GradeSummary;ILjava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Lio/github/wulkanowy/sdk/scrapper/grades/GradeSummary; + public final fun component9 ()Ljava/lang/String; + public final fun copy (ILjava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Lio/github/wulkanowy/sdk/scrapper/grades/GradeSummary; + public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/scrapper/grades/GradeSummary;ILjava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Lio/github/wulkanowy/sdk/scrapper/grades/GradeSummary; public fun equals (Ljava/lang/Object;)Z public final fun getAverage ()D + public final fun getAverageAllYear ()Ljava/lang/Double; public final fun getFinal ()Ljava/lang/String; public final fun getFinalPoints ()Ljava/lang/String; public final fun getName ()Ljava/lang/String; diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradeSummary.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradeSummary.kt index 51987228..10b6858d 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradeSummary.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradeSummary.kt @@ -4,6 +4,7 @@ data class GradeSummary( val order: Int = 0, val name: String = "", val average: Double = .0, + val averageAllYear: Double? = null, val predicted: String = "", val final: String = "", val pointsSum: String = "", diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesMapper.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesMapper.kt index 7759222c..324bc679 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesMapper.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesMapper.kt @@ -51,6 +51,7 @@ internal fun GradesResponse.mapGradesSummary() = gradesWithSubjects.map { subjec order = subject.order, name = subject.name.trim(), average = subject.average, + averageAllYear = subject.averageAllYear, predicted = getGradeShortValue(subject.proposed), final = getGradeShortValue(subject.annual), pointsSum = subject.pointsSum.takeIf { it != "-" }.orEmpty().trim(), diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesResponse.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesResponse.kt index c59928ad..05b6c246 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesResponse.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesResponse.kt @@ -64,6 +64,10 @@ internal data class GradeSubject( @JsonNames("srednia") val average: Double = .0, + @SerialName("SredniaWszystkieSemestry") + @JsonNames("sredniaWszystkieSemestry") + val averageAllYear: Double? = null, + @SerialName("ProponowanaOcenaRoczna") @JsonNames("proponowanaOcenaOkresowa") val proposed: String? = "", diff --git a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesSummaryPlus.kt b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesSummaryPlus.kt new file mode 100644 index 00000000..f289954f --- /dev/null +++ b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesSummaryPlus.kt @@ -0,0 +1,44 @@ +package io.github.wulkanowy.sdk.scrapper.grades + +import io.github.wulkanowy.sdk.scrapper.BaseLocalTest +import kotlinx.coroutines.runBlocking +import org.junit.Assert.assertEquals +import org.junit.Test + +class GradesSummaryPlus : BaseLocalTest() { + + private val grades by lazy { + runBlocking { + getStudentPlusRepo(GradesTest::class.java, "OcenyPlus.json") + .getGrades(0, 1, 2, 3) + .summary + } + } + + @Test + fun getAll() { + assertEquals(3, grades.size) + } + + @Test + fun `get summary with empty average`() { + with(grades[0]) { + assertEquals("Zachowanie", name) + assertEquals(.0, average, .0) + assertEquals(null, averageAllYear) + assertEquals("", predicted) + assertEquals("", final) + } + } + + @Test + fun `get summary with numeric average`() { + with(grades[1]) { + assertEquals("Zajęcia artystyczne", name) + assertEquals(1.0, average, .0) + assertEquals(2.0, averageAllYear) + assertEquals("", predicted) + assertEquals("", final) + } + } +} diff --git a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesGradeSummaryTest.kt b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesSummaryTest.kt similarity index 79% rename from sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesGradeSummaryTest.kt rename to sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesSummaryTest.kt index d01f0327..f6d83414 100644 --- a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesGradeSummaryTest.kt +++ b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/grades/GradesSummaryTest.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Test -class GradesGradeSummaryTest : BaseLocalTest() { +class GradesSummaryTest : BaseLocalTest() { private val grades by lazy { runBlocking { getStudentRepo(GradesTest::class.java, "Oceny.json").getGrades(0).summary } @@ -19,6 +19,8 @@ class GradesGradeSummaryTest : BaseLocalTest() { fun getSummaryAverage_empty() { with(grades[0]) { assertEquals("Edukacja dla bezpieczeństwa", name) + assertEquals(4.0, average, .0) + assertEquals(3.0, averageAllYear) assertEquals("", predicted) assertEquals("", final) } @@ -28,6 +30,8 @@ class GradesGradeSummaryTest : BaseLocalTest() { fun getSummaryAverage_longFinal() { with(grades[1]) { assertEquals("Fizyka", name) + assertEquals(.0, average, .0) + assertEquals(null, averageAllYear) assertEquals("3", predicted) assertEquals("4", final) } @@ -37,6 +41,8 @@ class GradesGradeSummaryTest : BaseLocalTest() { fun getSummaryAverage_longPredictedAndFinal() { with(grades[2]) { assertEquals("Język angielski", name) + assertEquals(.0, average, .0) + assertEquals(null, averageAllYear) assertEquals("5", predicted) assertEquals("6", final) } @@ -46,6 +52,8 @@ class GradesGradeSummaryTest : BaseLocalTest() { fun getSummaryAverage_shortPredictedAndLongFinal() { with(grades[3]) { assertEquals("Język polski", name) + assertEquals(.0, average, .0) + assertEquals(null, averageAllYear) assertEquals("4/5", predicted) assertEquals("5", final) } @@ -55,6 +63,8 @@ class GradesGradeSummaryTest : BaseLocalTest() { fun getSummaryAverage_shortNegativePredictedAndFinal() { with(grades[4]) { assertEquals("Wychowanie fizyczne", name) + assertEquals(.0, average, .0) + assertEquals(null, averageAllYear) assertEquals("4-", predicted) assertEquals("5-", final) } diff --git a/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/Oceny.json b/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/Oceny.json index 90b2c543..dbe7366e 100644 --- a/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/Oceny.json +++ b/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/Oceny.json @@ -30,8 +30,10 @@ "OcenaRoczna": " ", "ProponowanaOcenaRocznaPunkty": null, "OcenaRocznaPunkty": null, - "Srednia": 0, + "Srednia": 4, + "SredniaWszystkieSemestry": 3, "SumaPunktow": null, + "SumaPunktowWszystkieSemestry": null, "WidocznyPrzedmiot": false }, { diff --git a/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/OcenyPlus.json b/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/OcenyPlus.json index 9d59f88b..fcf6ff62 100644 --- a/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/OcenyPlus.json +++ b/sdk-scrapper/src/test/resources/io/github/wulkanowy/sdk/scrapper/grades/OcenyPlus.json @@ -10,7 +10,9 @@ "egzaminOcenaProponowana": null, "egzaminOcenaLaczna": null, "sumaPunktow": null, + "sumaPunktowWszystkieSemestry": null, "srednia": 0.0, + "sredniaWszystkieSemestry": null, "proponowanaOcenaOkresowa": " ", "proponowanaOcenaOkresowaPunkty": null, "ocenaOkresowa": " ", @@ -50,7 +52,9 @@ "egzaminOcenaProponowana": null, "egzaminOcenaLaczna": null, "sumaPunktow": "", - "srednia": 0.0, + "sumaPunktowWszystkieSemestry": null, + "srednia": 1.0, + "sredniaWszystkieSemestry": 2.0, "proponowanaOcenaOkresowa": null, "proponowanaOcenaOkresowaPunkty": null, "ocenaOkresowa": null, diff --git a/sdk/api/sdk.api b/sdk/api/sdk.api index bdc75148..9fa08f03 100644 --- a/sdk/api/sdk.api +++ b/sdk/api/sdk.api @@ -510,19 +510,21 @@ public final class io/github/wulkanowy/sdk/pojo/GradeStatisticsSubject { } public final class io/github/wulkanowy/sdk/pojo/GradeSummary { - public fun (Ljava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()D - public final fun component3 ()Ljava/lang/String; + public final fun component3 ()Ljava/lang/Double; public final fun component4 ()Ljava/lang/String; public final fun component5 ()Ljava/lang/String; public final fun component6 ()Ljava/lang/String; public final fun component7 ()Ljava/lang/String; - public final fun copy (Ljava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/github/wulkanowy/sdk/pojo/GradeSummary; - public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/pojo/GradeSummary;Ljava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/wulkanowy/sdk/pojo/GradeSummary; + public final fun component8 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/github/wulkanowy/sdk/pojo/GradeSummary; + public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/pojo/GradeSummary;Ljava/lang/String;DLjava/lang/Double;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/wulkanowy/sdk/pojo/GradeSummary; public fun equals (Ljava/lang/Object;)Z public final fun getAverage ()D + public final fun getAverageAllYear ()Ljava/lang/Double; public final fun getFinal ()Ljava/lang/String; public final fun getFinalPoints ()Ljava/lang/String; public final fun getName ()Ljava/lang/String; diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt index 2ae0bd4a..1c30116b 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt @@ -38,6 +38,7 @@ internal fun List.mapGradesSummary() = map { proposedPoints = it.proposedPoints, pointsSum = it.pointsSum, average = it.average, + averageAllYear = it.averageAllYear, final = it.final, predicted = it.predicted, ) diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/pojo/Grades.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/pojo/Grades.kt index a2188080..eb3f491b 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/pojo/Grades.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/pojo/Grades.kt @@ -34,6 +34,7 @@ data class Grade( data class GradeSummary( val name: String, val average: Double = .0, + val averageAllYear: Double? = null, val predicted: String, val final: String, val pointsSum: String,