Add missing semester fetch impl via eduOne
This commit is contained in:
parent
2583e044e7
commit
1b6e840917
2 changed files with 27 additions and 1 deletions
|
@ -335,7 +335,10 @@ class Scrapper {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getSemesters(): List<Semester> = studentStart.getSemesters()
|
||||
suspend fun getSemesters(): List<Semester> = when (isEduOne) {
|
||||
true -> studentPlus.getSemesters(studentId, diaryId, unitId)
|
||||
else -> studentStart.getSemesters()
|
||||
}
|
||||
|
||||
suspend fun getCurrentStudent(): RegisterStudent? {
|
||||
return when (isEduOne) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.github.wulkanowy.sdk.scrapper.notes.Note
|
|||
import io.github.wulkanowy.sdk.scrapper.notes.NoteCategory
|
||||
import io.github.wulkanowy.sdk.scrapper.register.AuthorizePermissionPlusRequest
|
||||
import io.github.wulkanowy.sdk.scrapper.register.RegisterStudent
|
||||
import io.github.wulkanowy.sdk.scrapper.register.Semester
|
||||
import io.github.wulkanowy.sdk.scrapper.service.StudentPlusService
|
||||
import io.github.wulkanowy.sdk.scrapper.timetable.CompletedLesson
|
||||
import io.github.wulkanowy.sdk.scrapper.timetable.Lesson
|
||||
|
@ -356,4 +357,26 @@ internal class StudentPlusRepository(
|
|||
val key = getEncodedKey(studentId, diaryId, unitId)
|
||||
return api.getConferences(key)
|
||||
}
|
||||
|
||||
suspend fun getSemesters(studentId: Int, diaryId: Int, unitId: Int): List<Semester> {
|
||||
val key = getEncodedKey(studentId, diaryId, unitId)
|
||||
val context = api.getContext()
|
||||
val student = context.students.find { it.key == key }
|
||||
val level = student?.className.orEmpty().takeWhile { it.isDigit() }
|
||||
return api.getSemesters(key, diaryId).map {
|
||||
Semester(
|
||||
diaryId = diaryId,
|
||||
diaryName = student?.className.orEmpty(),
|
||||
className = student?.className?.replace(level, ""),
|
||||
schoolYear = it.dataOd.toLocalDate().year,
|
||||
semesterId = it.id,
|
||||
semesterNumber = it.numerOkresu,
|
||||
start = it.dataOd.toLocalDate(),
|
||||
end = it.dataDo.toLocalDate(),
|
||||
unitId = unitId,
|
||||
classId = 0,
|
||||
kindergartenDiaryId = 0,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue