mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-19 05:16:56 -06:00
[Mobidziennik] Fix getting grades with no category. Add support for comments.
This commit is contained in:
parent
f8a7d52b1d
commit
5b443e02a3
@ -24,7 +24,7 @@ object Regexes {
|
|||||||
"""Liczona do średniej:.*?<strong>nie<br/?></strong>""".toRegex(RegexOption.DOT_MATCHES_ALL)
|
"""Liczona do średniej:.*?<strong>nie<br/?></strong>""".toRegex(RegexOption.DOT_MATCHES_ALL)
|
||||||
}
|
}
|
||||||
val MOBIDZIENNIK_GRADES_DETAILS by lazy {
|
val MOBIDZIENNIK_GRADES_DETAILS by lazy {
|
||||||
"""<strong.*?>(.+?)</strong>.*?<sup>.+?</sup>.*?<small>\((.+?)\)</small>.*?<span>.*?Wartość oceny:.*?<strong>([0-9.]+)</strong>.*?Wpisał\(a\):.*?<strong>(.+?)</strong>""".toRegex(RegexOption.DOT_MATCHES_ALL)
|
"""<strong.*?>(.+?)</strong>.*?<sup>.+?</sup>.*?(?:<small>\((.+?)\)</small>.*?)?<span>.*?Wartość oceny:.*?<strong>([0-9.]+)</strong>.*?Wpisał\(a\):.*?<strong>(.+?)</strong>.*?(?:Komentarz:.*?<strong>(.+?)</strong>)?</span>""".toRegex(RegexOption.DOT_MATCHES_ALL)
|
||||||
}
|
}
|
||||||
|
|
||||||
val MOBIDZIENNIK_EVENT_TYPE by lazy {
|
val MOBIDZIENNIK_EVENT_TYPE by lazy {
|
||||||
|
@ -96,13 +96,17 @@ class MobidziennikWebGrades(override val data: DataMobidziennik,
|
|||||||
if (Regexes.MOBIDZIENNIK_GRADES_COUNT_TO_AVG.containsMatchIn(html)) {
|
if (Regexes.MOBIDZIENNIK_GRADES_COUNT_TO_AVG.containsMatchIn(html)) {
|
||||||
Regexes.MOBIDZIENNIK_GRADES_DETAILS.find(html)?.let { match ->
|
Regexes.MOBIDZIENNIK_GRADES_DETAILS.find(html)?.let { match ->
|
||||||
val gradeName = match[1]
|
val gradeName = match[1]
|
||||||
val gradeDescription = match[2]
|
var gradeDescription = match[2]
|
||||||
val gradeValue = match[3].toFloatOrNull() ?: 0.0f
|
val gradeValue = match[3].toFloatOrNull() ?: 0.0f
|
||||||
val teacherName = match[4].fixWhiteSpaces()
|
val teacherName = match[4].fixWhiteSpaces()
|
||||||
|
|
||||||
val teacherId = data.teacherList.singleOrNull { it.fullNameLastFirst == teacherName }?.id ?: -1
|
val teacherId = data.teacherList.singleOrNull { it.fullNameLastFirst == teacherName }?.id ?: -1
|
||||||
val subjectId = data.subjectList.singleOrNull { it.longName == subjectName }?.id ?: -1
|
val subjectId = data.subjectList.singleOrNull { it.longName == subjectName }?.id ?: -1
|
||||||
|
|
||||||
|
if (match[5].isNotEmpty()) {
|
||||||
|
gradeDescription += "\n"+match[5].replace("<br>", "\n")
|
||||||
|
}
|
||||||
|
|
||||||
val gradeObject = Grade(
|
val gradeObject = Grade(
|
||||||
profileId,
|
profileId,
|
||||||
gradeId,
|
gradeId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user