From c76b71bb76931096a0d3d6c7c405fdd008e25ba9 Mon Sep 17 00:00:00 2001 From: jzitnik-dev Date: Fri, 20 Mar 2026 15:26:08 +0100 Subject: [PATCH 1/2] feat: New `hasCertificates` property on student --- .../tomhula/jecnaapi/data/student/Student.kt | 1 + .../parser/parsers/StudentProfileParser.kt | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt index 23e04eba..c3de9b9e 100644 --- a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt +++ b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt @@ -20,6 +20,7 @@ class Student( val guardians: List = emptyList(), val sposaVariableSymbol: String? = null, val sposaBankAccount: String? = null, + val hasCertificates: Boolean = false, ) : SchoolAttendee(fullName, username, schoolMail, privateMail, phoneNumbers, profilePicturePath) { override fun equals(other: Any?): Boolean diff --git a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt index c5673746..af3eaf2f 100644 --- a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt +++ b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt @@ -4,6 +4,7 @@ import io.github.tomhula.jecnaapi.data.student.Guardian import io.github.tomhula.jecnaapi.data.student.Student import io.github.tomhula.jecnaapi.parser.ParseException import com.fleeksoft.ksoup.Ksoup +import com.fleeksoft.ksoup.nodes.Document import com.fleeksoft.ksoup.nodes.Element import kotlinx.datetime.LocalDate @@ -50,6 +51,8 @@ internal object StudentProfileParser val sposaVariableSymbol = sposaTable?.let { getTableValue(it, "Variabilní symbol žáka") } val sposaBankAccount = sposaTable?.let { getTableValue(it, "Bankovní účet") } + val hasCertificates = hasCertificate(document) + return Student( fullName = fullName, username = username, @@ -66,7 +69,8 @@ internal object StudentProfileParser classRegistryId = classRegistryId, guardians = guardians, sposaVariableSymbol = sposaVariableSymbol, - sposaBankAccount = sposaBankAccount + sposaBankAccount = sposaBankAccount, + hasCertificates = hasCertificates, ) } catch (e: Exception) @@ -75,6 +79,14 @@ internal object StudentProfileParser } } + private fun hasCertificate(document: Document): Boolean + { + val menuTile = document.selectFirstOrThrow("ul.menuTile") + val certificateLink = menuTile.selectFirst("a.link[href=\"/certification/student\"]") + + return certificateLink != null + } + private fun getTableValue(table: Element, key: String): String? { val rows = table.select("tr") From 1d9d0b96521acd62460daf8f2019ebdd2892d1d0 Mon Sep 17 00:00:00 2001 From: jzitnik-dev Date: Fri, 20 Mar 2026 15:48:13 +0100 Subject: [PATCH 2/2] refactor: `hasCertificates` -> `hasCertificatesLink` --- .../io/github/tomhula/jecnaapi/data/student/Student.kt | 2 +- .../tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt index c3de9b9e..ce5a3ed6 100644 --- a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt +++ b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/data/student/Student.kt @@ -20,7 +20,7 @@ class Student( val guardians: List = emptyList(), val sposaVariableSymbol: String? = null, val sposaBankAccount: String? = null, - val hasCertificates: Boolean = false, + val hasCertificatesLink: Boolean = false, ) : SchoolAttendee(fullName, username, schoolMail, privateMail, phoneNumbers, profilePicturePath) { override fun equals(other: Any?): Boolean diff --git a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt index af3eaf2f..71d36b4e 100644 --- a/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt +++ b/src/commonMain/kotlin/io/github/tomhula/jecnaapi/parser/parsers/StudentProfileParser.kt @@ -51,7 +51,7 @@ internal object StudentProfileParser val sposaVariableSymbol = sposaTable?.let { getTableValue(it, "Variabilní symbol žáka") } val sposaBankAccount = sposaTable?.let { getTableValue(it, "Bankovní účet") } - val hasCertificates = hasCertificate(document) + val hasCertificatesLink = hasCertificatesLink(document) return Student( fullName = fullName, @@ -70,7 +70,7 @@ internal object StudentProfileParser guardians = guardians, sposaVariableSymbol = sposaVariableSymbol, sposaBankAccount = sposaBankAccount, - hasCertificates = hasCertificates, + hasCertificatesLink = hasCertificatesLink, ) } catch (e: Exception) @@ -79,7 +79,7 @@ internal object StudentProfileParser } } - private fun hasCertificate(document: Document): Boolean + private fun hasCertificatesLink(document: Document): Boolean { val menuTile = document.selectFirstOrThrow("ul.menuTile") val certificateLink = menuTile.selectFirst("a.link[href=\"/certification/student\"]")