Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Student(
val guardians: List<Guardian> = 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -66,7 +69,8 @@ internal object StudentProfileParser
classRegistryId = classRegistryId,
guardians = guardians,
sposaVariableSymbol = sposaVariableSymbol,
sposaBankAccount = sposaBankAccount
sposaBankAccount = sposaBankAccount,
hasCertificatesLink = hasCertificatesLink,
)
}
catch (e: Exception)
Expand All @@ -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")
Expand Down