Add new averageAllYear field to grade summaries

This commit is contained in:
Mikołaj Pich 2024-04-22 15:09:02 +02:00
parent d32f1b75ed
commit 3331b6b65f
No known key found for this signature in database
12 changed files with 87 additions and 15 deletions

View file

@ -18,7 +18,7 @@ ext {
moshi = "1.13.0"
}
version = "2.5.6"
version = "2.5.7-SNAPSHOT"
group = "io.github.wulkanowy"
nexusPublishing {

View file

@ -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 <init> ()V
public fun <init> (ILjava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V
public synthetic fun <init> (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 <init> (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 <init> (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;

View file

@ -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 = "",

View file

@ -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(),

View file

@ -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? = "",

View file

@ -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)
}
}
}

View file

@ -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)
}

View file

@ -30,8 +30,10 @@
"OcenaRoczna": " ",
"ProponowanaOcenaRocznaPunkty": null,
"OcenaRocznaPunkty": null,
"Srednia": 0,
"Srednia": 4,
"SredniaWszystkieSemestry": 3,
"SumaPunktow": null,
"SumaPunktowWszystkieSemestry": null,
"WidocznyPrzedmiot": false
},
{

View file

@ -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,

View file

@ -510,19 +510,21 @@ public final class io/github/wulkanowy/sdk/pojo/GradeStatisticsSubject {
}
public final class io/github/wulkanowy/sdk/pojo/GradeSummary {
public fun <init> (Ljava/lang/String;DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public synthetic fun <init> (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 <init> (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 <init> (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;

View file

@ -38,6 +38,7 @@ internal fun List<ScrapperGradeSummary>.mapGradesSummary() = map {
proposedPoints = it.proposedPoints,
pointsSum = it.pointsSum,
average = it.average,
averageAllYear = it.averageAllYear,
final = it.final,
predicted = it.predicted,
)

View file

@ -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,