mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[API/Librus] Use added by teacher id instead of lesson teacher in attendance.
This commit is contained in:
parent
62f53930da
commit
7d8caa8df7
@ -9,10 +9,9 @@ import pl.szczodrzynski.edziennik.*
|
|||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_ATTENDANCES
|
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_ATTENDANCES
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Attendance
|
import pl.szczodrzynski.edziennik.data.db.entity.Attendance
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
import pl.szczodrzynski.edziennik.utils.Utils
|
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
|
||||||
class LibrusApiAttendances(override val data: DataLibrus,
|
class LibrusApiAttendances(override val data: DataLibrus,
|
||||||
@ -33,11 +32,12 @@ class LibrusApiAttendances(override val data: DataLibrus,
|
|||||||
val attendances = json.getJsonArray("Attendances")?.asJsonObjectList()
|
val attendances = json.getJsonArray("Attendances")?.asJsonObjectList()
|
||||||
|
|
||||||
attendances?.forEach { attendance ->
|
attendances?.forEach { attendance ->
|
||||||
val id = Utils.strToInt((attendance.getString("Id") ?: return@forEach)
|
val id = ((attendance.getString("Id") ?: return@forEach)
|
||||||
.replace("[^\\d.]".toRegex(), "")).toLong()
|
.replace("[^\\d.]".toRegex(), "")).toLong()
|
||||||
val lessonId = attendance.getJsonObject("Lesson")?.getLong("Id") ?: -1
|
val lessonId = attendance.getJsonObject("Lesson")?.getLong("Id") ?: -1
|
||||||
val lessonNo = attendance.getInt("LessonNo") ?: return@forEach
|
val lessonNo = attendance.getInt("LessonNo") ?: return@forEach
|
||||||
val lessonDate = Date.fromY_m_d(attendance.getString("Date"))
|
val lessonDate = Date.fromY_m_d(attendance.getString("Date"))
|
||||||
|
val teacherId = attendance.getJsonObject("AddedBy")?.getLong("Id")
|
||||||
val semester = attendance.getInt("Semester") ?: return@forEach
|
val semester = attendance.getInt("Semester") ?: return@forEach
|
||||||
val type = attendance.getJsonObject("Type")?.getLong("Id") ?: return@forEach
|
val type = attendance.getJsonObject("Type")?.getLong("Id") ?: return@forEach
|
||||||
val typeObject = data.attendanceTypes.get(type)
|
val typeObject = data.attendanceTypes.get(type)
|
||||||
@ -52,7 +52,7 @@ class LibrusApiAttendances(override val data: DataLibrus,
|
|||||||
val attendanceObject = Attendance(
|
val attendanceObject = Attendance(
|
||||||
profileId,
|
profileId,
|
||||||
id,
|
id,
|
||||||
lesson?.teacherId ?: -1,
|
teacherId ?: lesson?.teacherId ?: -1,
|
||||||
lesson?.subjectId ?: -1,
|
lesson?.subjectId ?: -1,
|
||||||
semester,
|
semester,
|
||||||
topic,
|
topic,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user