Add pupil description with school name or class code

This commit is contained in:
Mikołaj Pich 2018-12-12 17:47:42 +01:00
parent b70257fbee
commit da80d5ece0
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
4 changed files with 19 additions and 4 deletions

View file

@ -42,7 +42,10 @@ data class Diary(
val year: Int,
@SerializedName("Okresy")
val semesters: List<Semester> = emptyList()
val semesters: List<Semester> = emptyList(),
@SerializedName("UczenPelnaNazwa")
val fullName: String
) {
data class Semester(

View file

@ -8,6 +8,8 @@ data class Pupil(
val studentId: Int,
val studentName: String,
val schoolSymbol: String,
@Deprecated("use description val")
val schoolName: String,
val description: String,
val loginType: Api.LoginType
)

View file

@ -22,6 +22,8 @@ class StudentAndParentResponse {
@Selector("option")
lateinit var name: String
lateinit var description: String
}
class Diary {

View file

@ -47,7 +47,8 @@ class RegisterRepository(
studentId = pupil.id,
studentName = pupil.name,
schoolSymbol = getExtractedSchoolSymbolFromUrl(schoolUrl),
schoolName = "?",
description = pupil.description,
schoolName = pupil.description,
loginType = loginType
)
}
@ -60,13 +61,20 @@ class RegisterRepository(
private fun getStudents(symbol: String, schoolUrl: String): Single<List<StudentAndParentResponse.Pupil>> {
url.schoolId = getExtractedSchoolSymbolFromUrl(schoolUrl)
url.symbol = symbol
return if (!useNewStudent) snp.getSchoolInfo(schoolUrl).map { it.students }
else student.getSchoolInfo(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "UczenDziennik.mvc/Get").map { diary -> diary.data?.distinctBy { it.studentId } }
return if (!useNewStudent) snp.getSchoolInfo(schoolUrl).map { res ->
res.students.map { pupil ->
pupil.apply {
description = res.schoolName
}
}
} else student.getSchoolInfo(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "UczenDziennik.mvc/Get")
.map { diary -> diary.data?.distinctBy { it.studentId } }
.map { diaries ->
diaries.map {
StudentAndParentResponse.Pupil().apply {
id = it.studentId
name = "${it.studentName} ${it.studentSurname}"
description = it.symbol + " " + (it.year - it.level + 1)
}
}
}