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..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,6 +20,7 @@ class Student( val guardians: List = emptyList(), val sposaVariableSymbol: String? = null, val sposaBankAccount: String? = null, + 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 c5673746..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 @@ -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 hasCertificatesLink = hasCertificatesLink(document) + return Student( fullName = fullName, username = username, @@ -66,7 +69,8 @@ internal object StudentProfileParser classRegistryId = classRegistryId, guardians = guardians, sposaVariableSymbol = sposaVariableSymbol, - sposaBankAccount = sposaBankAccount + sposaBankAccount = sposaBankAccount, + hasCertificatesLink = hasCertificatesLink, ) } catch (e: Exception) @@ -75,6 +79,14 @@ internal object StudentProfileParser } } + private fun hasCertificatesLink(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")