diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt index ea1b4c3b..8a78e6ee 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikData.kt @@ -5,11 +5,8 @@ package pl.szczodrzynski.edziennik.api.v2.idziennik.data import pl.szczodrzynski.edziennik.R -import pl.szczodrzynski.edziennik.api.v2.idziennik.DataIdziennik -import pl.szczodrzynski.edziennik.api.v2.idziennik.ENDPOINT_IDZIENNIK_WEB_GRADES -import pl.szczodrzynski.edziennik.api.v2.idziennik.ENDPOINT_IDZIENNIK_WEB_TIMETABLE -import pl.szczodrzynski.edziennik.api.v2.idziennik.data.web.IdziennikWebGrades -import pl.szczodrzynski.edziennik.api.v2.idziennik.data.web.IdziennikWebTimetable +import pl.szczodrzynski.edziennik.api.v2.idziennik.* +import pl.szczodrzynski.edziennik.api.v2.idziennik.data.web.* import pl.szczodrzynski.edziennik.utils.Utils class IdziennikData(val data: DataIdziennik, val onSuccess: () -> Unit) { @@ -48,6 +45,26 @@ class IdziennikData(val data: DataIdziennik, val onSuccess: () -> Unit) { data.startProgress(R.string.edziennik_progress_endpoint_grades) IdziennikWebGrades(data) { onSuccess() } } + ENDPOINT_IDZIENNIK_WEB_PROPOSED_GRADES -> { + data.startProgress(R.string.edziennik_progress_endpoint_proposed_grades) + IdziennikWebProposedGrades(data) { onSuccess() } + } + ENDPOINT_IDZIENNIK_WEB_EXAMS -> { + data.startProgress(R.string.edziennik_progress_endpoint_exams) + IdziennikWebExams(data) { onSuccess() } + } + ENDPOINT_IDZIENNIK_WEB_NOTICES -> { + data.startProgress(R.string.edziennik_progress_endpoint_notices) + IdziennikWebNotices(data) { onSuccess() } + } + ENDPOINT_IDZIENNIK_WEB_ANNOUNCEMENTS -> { + data.startProgress(R.string.edziennik_progress_endpoint_announcements) + IdziennikWebAnnouncements(data) { onSuccess() } + } + ENDPOINT_IDZIENNIK_WEB_ATTENDANCE -> { + data.startProgress(R.string.edziennik_progress_endpoint_attendance) + IdziennikWebAttendance(data) { onSuccess() } + } else -> onSuccess() } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebAnnouncements.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebAnnouncements.kt new file mode 100644 index 00000000..5f700482 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebAnnouncements.kt @@ -0,0 +1,74 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2019-10-28. + */ + +package pl.szczodrzynski.edziennik.api.v2.idziennik.data.web + +import com.google.gson.JsonArray +import com.google.gson.JsonObject +import pl.szczodrzynski.edziennik.api.v2.ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA +import pl.szczodrzynski.edziennik.api.v2.IDZIENNIK_WEB_ANNOUNCEMENTS +import pl.szczodrzynski.edziennik.api.v2.idziennik.DataIdziennik +import pl.szczodrzynski.edziennik.api.v2.idziennik.ENDPOINT_IDZIENNIK_WEB_ANNOUNCEMENTS +import pl.szczodrzynski.edziennik.api.v2.idziennik.data.IdziennikWeb +import pl.szczodrzynski.edziennik.api.v2.models.ApiError +import pl.szczodrzynski.edziennik.data.db.modules.announcements.Announcement +import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS +import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata +import pl.szczodrzynski.edziennik.getJsonObject +import pl.szczodrzynski.edziennik.utils.models.Date + +class IdziennikWebAnnouncements(override val data: DataIdziennik, + val onSuccess: () -> Unit) : IdziennikWeb(data) { + companion object { + private const val TAG = "IdziennikWebAnnouncements" + } + + init { + val param = JsonObject() + param.add("parametryFiltrow", JsonArray()) + + webApiGet(TAG, IDZIENNIK_WEB_ANNOUNCEMENTS, mapOf( + "uczenId" to (data.studentId ?: ""), + "param" to param + )) { result -> + val json = result.getJsonObject("d") ?: run { + data.error(ApiError(TAG, ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA) + .withApiResponse(result)) + return@webApiGet + } + + for (jAnnouncementEl in json.getAsJsonArray("ListK")) { + val jAnnouncement = jAnnouncementEl.asJsonObject + // jAnnouncement + val announcementId = jAnnouncement.get("Id").asLong + + val rTeacher = data.getTeacherByFirstLast(jAnnouncement.get("Autor").asString) + val addedDate = java.lang.Long.parseLong(jAnnouncement.get("DataDodania").asString.replace("[^\\d]".toRegex(), "")) + val startDate = Date.fromMillis(java.lang.Long.parseLong(jAnnouncement.get("DataWydarzenia").asString.replace("[^\\d]".toRegex(), ""))) + + val announcementObject = Announcement( + profileId, + announcementId, + jAnnouncement.get("Temat").asString, + jAnnouncement.get("Tresc").asString, + startDate, + null, + rTeacher.id + ) + data.announcementList.add(announcementObject) + data.metadataList.add(Metadata( + profileId, + Metadata.TYPE_ANNOUNCEMENT, + announcementObject.id, + profile?.empty ?: false, + profile?.empty ?: false, + addedDate + )) + } + + data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_ANNOUNCEMENTS, SYNC_ALWAYS) + onSuccess() + } + } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebAttendance.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebAttendance.kt new file mode 100644 index 00000000..68823c17 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebAttendance.kt @@ -0,0 +1,143 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2019-10-28. + */ + +package pl.szczodrzynski.edziennik.api.v2.idziennik.data.web + +import pl.szczodrzynski.edziennik.api.v2.ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA +import pl.szczodrzynski.edziennik.api.v2.IDZIENNIK_WEB_ATTENDANCE +import pl.szczodrzynski.edziennik.api.v2.idziennik.DataIdziennik +import pl.szczodrzynski.edziennik.api.v2.idziennik.ENDPOINT_IDZIENNIK_WEB_ATTENDANCE +import pl.szczodrzynski.edziennik.api.v2.idziennik.data.IdziennikWeb +import pl.szczodrzynski.edziennik.api.v2.models.ApiError +import pl.szczodrzynski.edziennik.crc16 +import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS +import pl.szczodrzynski.edziennik.data.db.modules.attendance.Attendance +import pl.szczodrzynski.edziennik.data.db.modules.attendance.Attendance.* +import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata +import pl.szczodrzynski.edziennik.getJsonObject +import pl.szczodrzynski.edziennik.utils.models.Date +import pl.szczodrzynski.edziennik.utils.models.Time + +class IdziennikWebAttendance(override val data: DataIdziennik, + val onSuccess: () -> Unit) : IdziennikWeb(data) { + companion object { + private const val TAG = "IdziennikWebAttendance" + } + + init { + getAttendance() + } + + private var attendanceYear: Int = Date.getToday().year + private var attendanceMonth: Int = Date.getToday().month + private var attendancePrevMonthChecked = false + private fun getAttendance() { + webApiGet(TAG, IDZIENNIK_WEB_ATTENDANCE, mapOf( + "idPozDziennika" to data.registerId, + "mc" to attendanceMonth, + "rok" to attendanceYear, + "dataTygodnia" to "" + )) { result -> + val json = result.getJsonObject("d") ?: run { + data.error(ApiError(TAG, ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA) + .withApiResponse(result)) + return@webApiGet + } + + for (jAttendanceEl in json.getAsJsonArray("Obecnosci")) { + val jAttendance = jAttendanceEl.asJsonObject + // jAttendance + val attendanceTypeIdziennik = jAttendance.get("TypObecnosci").asInt + if (attendanceTypeIdziennik == 5 || attendanceTypeIdziennik == 7) + continue + val attendanceDate = Date.fromY_m_d(jAttendance.get("Data").asString) + val attendanceTime = Time.fromH_m(jAttendance.get("OdDoGodziny").asString) + if (attendanceDate.combineWith(attendanceTime) > System.currentTimeMillis()) + continue + + val attendanceId = jAttendance.get("IdLesson").asString.crc16().toLong() + val rSubject = data.getSubject(jAttendance.get("Przedmiot").asString, jAttendance.get("IdPrzedmiot").asLong, "") + val rTeacher = data.getTeacherByFDotSpaceLast(jAttendance.get("PrzedmiotNauczyciel").asString) + + var attendanceName = "obecność" + var attendanceType = Attendance.TYPE_CUSTOM + + when (attendanceTypeIdziennik) { + 1 /* nieobecność usprawiedliwiona */ -> { + attendanceName = "nieobecność usprawiedliwiona" + attendanceType = TYPE_ABSENT_EXCUSED + } + 2 /* spóźnienie */ -> { + attendanceName = "spóźnienie" + attendanceType = TYPE_BELATED + } + 3 /* nieobecność nieusprawiedliwiona */ -> { + attendanceName = "nieobecność nieusprawiedliwiona" + attendanceType = TYPE_ABSENT + } + 4 /* zwolnienie */, 9 /* zwolniony / obecny */ -> { + attendanceType = TYPE_RELEASED + if (attendanceTypeIdziennik == 4) + attendanceName = "zwolnienie" + if (attendanceTypeIdziennik == 9) + attendanceName = "zwolnienie / obecność" + } + 0 /* obecny */, 8 /* Wycieczka */ -> { + attendanceType = TYPE_PRESENT + if (attendanceTypeIdziennik == 8) + attendanceName = "wycieczka" + } + } + + val semester = profile?.dateToSemester(attendanceDate) ?: 1 + + val attendanceObject = Attendance( + profileId, + attendanceId, + rTeacher.id, + rSubject.id, + semester, + attendanceName, + attendanceDate, + attendanceTime, + attendanceType + ) + + data.attendanceList.add(attendanceObject) + if (attendanceObject.type != TYPE_PRESENT) { + data.metadataList.add(Metadata( + profileId, + Metadata.TYPE_ATTENDANCE, + attendanceObject.id, + profile?.empty ?: false, + profile?.empty ?: false, + System.currentTimeMillis() + )) + } + } + + val attendanceDateValue = attendanceYear * 10000 + attendanceMonth * 100 + if (profile?.empty == true && attendanceDateValue > profile?.getSemesterStart(1)?.value ?: 99999999) { + attendancePrevMonthChecked = true // do not need to check prev month later + attendanceMonth-- + if (attendanceMonth < 1) { + attendanceMonth = 12 + attendanceYear-- + } + getAttendance() + } else if (!attendancePrevMonthChecked /* get also the previous month */) { + attendanceMonth-- + if (attendanceMonth < 1) { + attendanceMonth = 12 + attendanceYear-- + } + attendancePrevMonthChecked = true + getAttendance() + } else { + data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_ATTENDANCE, SYNC_ALWAYS) + onSuccess() + } + } + } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebExams.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebExams.kt new file mode 100644 index 00000000..eb0e2c0e --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebExams.kt @@ -0,0 +1,113 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2019-10-28. + */ + +package pl.szczodrzynski.edziennik.api.v2.idziennik.data.web + +import com.google.gson.JsonObject +import pl.szczodrzynski.edziennik.api.v2.ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA +import pl.szczodrzynski.edziennik.api.v2.IDZIENNIK_WEB_EXAMS +import pl.szczodrzynski.edziennik.api.v2.idziennik.DataIdziennik +import pl.szczodrzynski.edziennik.api.v2.idziennik.ENDPOINT_IDZIENNIK_WEB_EXAMS +import pl.szczodrzynski.edziennik.api.v2.idziennik.data.IdziennikWeb +import pl.szczodrzynski.edziennik.api.v2.models.ApiError +import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS +import pl.szczodrzynski.edziennik.data.db.modules.events.Event +import pl.szczodrzynski.edziennik.data.db.modules.lessons.Lesson +import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata +import pl.szczodrzynski.edziennik.getJsonObject +import pl.szczodrzynski.edziennik.utils.models.Date + +class IdziennikWebExams(override val data: DataIdziennik, + val onSuccess: () -> Unit) : IdziennikWeb(data) { + companion object { + private const val TAG = "IdziennikWebExams" + } + + init { + getExams() + } + + private var examsYear = Date.getToday().year + private var examsMonth = Date.getToday().month + private var examsMonthsChecked = 0 + private var examsNextMonthChecked = false // TO DO temporary // no more // idk + private fun getExams() { + val param = JsonObject() + param.addProperty("strona", 1) + param.addProperty("iloscNaStrone", "99") + param.addProperty("iloscRekordow", -1) + param.addProperty("kolumnaSort", "ss.Nazwa,sp.Data_sprawdzianu") + param.addProperty("kierunekSort", 0) + param.addProperty("maxIloscZaznaczonych", 0) + param.addProperty("panelFiltrow", 0) + + webApiGet(TAG, IDZIENNIK_WEB_EXAMS, mapOf( + "idP" to data.registerId, + "rok" to examsYear, + "miesiac" to examsMonth, + "param" to param + )) { result -> + val json = result.getJsonObject("d") ?: run { + data.error(ApiError(TAG, ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA) + .withApiResponse(result)) + return@webApiGet + } + + for (jExamEl in json.getAsJsonArray("ListK")) { + val jExam = jExamEl.asJsonObject + // jExam + val eventId = jExam.get("_recordId").asLong + val rSubject = data.getSubject(jExam.get("przedmiot").asString, -1, "") + val rTeacher = data.getTeacherByLastFirst(jExam.get("wpisal").asString) + val examDate = Date.fromY_m_d(jExam.get("data").asString) + val lessonObject = Lesson.getByWeekDayAndSubject(data.lessonList, examDate.weekDay, rSubject.id) + val examTime = lessonObject?.startTime + + val eventType = if (jExam.get("rodzaj").asString == "sprawdzian/praca klasowa") Event.TYPE_EXAM else Event.TYPE_SHORT_QUIZ + val eventObject = Event( + profileId, + eventId, + examDate, + examTime, + jExam.get("zakres").asString, + -1, + eventType, + false, + rTeacher.id, + rSubject.id, + data.teamClass?.id ?: -1 + ) + + data.eventList.add(eventObject) + data.metadataList.add(Metadata( + profileId, + Metadata.TYPE_EVENT, + eventObject.id, + profile?.empty ?: false, + profile?.empty ?: false, + System.currentTimeMillis() + )) + } + + if (profile?.empty == true && examsMonthsChecked < 3 /* how many months backwards to check? */) { + examsMonthsChecked++ + examsMonth-- + if (examsMonth < 1) { + examsMonth = 12 + examsYear-- + } + getExams() + } else if (!examsNextMonthChecked /* get also one month forward */) { + val showDate = Date.getToday().stepForward(0, 1, 0) + examsYear = showDate.year + examsMonth = showDate.month + examsNextMonthChecked = true + getExams() + } else { + data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_EXAMS, SYNC_ALWAYS) + onSuccess() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebNotices.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebNotices.kt new file mode 100644 index 00000000..7cdaf3af --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebNotices.kt @@ -0,0 +1,75 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2019-10-28. + */ + +package pl.szczodrzynski.edziennik.api.v2.idziennik.data.web + +import pl.szczodrzynski.edziennik.api.v2.ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA +import pl.szczodrzynski.edziennik.api.v2.IDZIENNIK_WEB_NOTICES +import pl.szczodrzynski.edziennik.api.v2.idziennik.DataIdziennik +import pl.szczodrzynski.edziennik.api.v2.idziennik.ENDPOINT_IDZIENNIK_WEB_NOTICES +import pl.szczodrzynski.edziennik.api.v2.idziennik.data.IdziennikWeb +import pl.szczodrzynski.edziennik.api.v2.models.ApiError +import pl.szczodrzynski.edziennik.crc16 +import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS +import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata +import pl.szczodrzynski.edziennik.data.db.modules.notices.Notice +import pl.szczodrzynski.edziennik.data.db.modules.notices.Notice.* +import pl.szczodrzynski.edziennik.getJsonObject +import pl.szczodrzynski.edziennik.utils.models.Date + +class IdziennikWebNotices(override val data: DataIdziennik, + val onSuccess: () -> Unit) : IdziennikWeb(data) { + companion object { + private const val TAG = "IdziennikWebNotices" + } + + init { + webApiGet(TAG, IDZIENNIK_WEB_NOTICES, mapOf( + "idPozDziennika" to data.registerId + )) { result -> + val json = result.getJsonObject("d") ?: run { + data.error(ApiError(TAG, ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA) + .withApiResponse(result)) + return@webApiGet + } + + for (jNoticeEl in json.getAsJsonArray("SUwaga")) { + val jNotice = jNoticeEl.asJsonObject + // jNotice + val noticeId = jNotice.get("id").asString.crc16().toLong() + + val rTeacher = data.getTeacherByLastFirst(jNotice.get("Nauczyciel").asString) + val addedDate = Date.fromY_m_d(jNotice.get("Data").asString) + + var nType = TYPE_NEUTRAL + val jType = jNotice.get("Typ").asString + if (jType == "n") { + nType = TYPE_NEGATIVE + } else if (jType == "p") { + nType = TYPE_POSITIVE + } + + val noticeObject = Notice( + profileId, + noticeId, + jNotice.get("Tresc").asString, + jNotice.get("Semestr").asInt, + nType, + rTeacher.id) + data.noticeList.add(noticeObject) + data.metadataList.add(Metadata( + profileId, + Metadata.TYPE_NOTICE, + noticeObject.id, + profile?.empty ?: false, + profile?.empty ?: false, + addedDate.inMillis + )) + } + + data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_NOTICES, SYNC_ALWAYS) + onSuccess() + } + } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebProposedGrades.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebProposedGrades.kt new file mode 100644 index 00000000..376aa8cf --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebProposedGrades.kt @@ -0,0 +1,108 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2019-10-28. + */ + +package pl.szczodrzynski.edziennik.api.v2.idziennik.data.web + +import pl.szczodrzynski.edziennik.api.v2.ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA +import pl.szczodrzynski.edziennik.api.v2.IDZIENNIK_WEB_MISSING_GRADES +import pl.szczodrzynski.edziennik.api.v2.idziennik.DataIdziennik +import pl.szczodrzynski.edziennik.api.v2.idziennik.ENDPOINT_IDZIENNIK_WEB_PROPOSED_GRADES +import pl.szczodrzynski.edziennik.api.v2.idziennik.data.IdziennikWeb +import pl.szczodrzynski.edziennik.api.v2.models.ApiError +import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS +import pl.szczodrzynski.edziennik.data.db.modules.grades.Grade +import pl.szczodrzynski.edziennik.data.db.modules.grades.Grade.TYPE_SEMESTER1_PROPOSED +import pl.szczodrzynski.edziennik.data.db.modules.grades.Grade.TYPE_YEAR_PROPOSED +import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata +import pl.szczodrzynski.edziennik.getJsonObject +import pl.szczodrzynski.edziennik.utils.Utils.getWordGradeValue + +class IdziennikWebProposedGrades(override val data: DataIdziennik, + val onSuccess: () -> Unit) : IdziennikWeb(data) { + companion object { + private const val TAG = "IdziennikWebProposedGrades" + } + + init { + webApiGet(TAG, IDZIENNIK_WEB_MISSING_GRADES, mapOf( + "idPozDziennika" to data.registerId + )) { result -> + val json = result.getJsonObject("d") ?: run { + data.error(ApiError(TAG, ERROR_IDZIENNIK_WEB_REQUEST_NO_DATA) + .withApiResponse(result)) + return@webApiGet + } + + val jSubjects = json.getAsJsonArray("Przedmioty") + for (jSubjectEl in jSubjects) { + val jSubject = jSubjectEl.getAsJsonObject() + // jSubject + val rSubject = data.getSubject(jSubject.get("Przedmiot").getAsString(), -1, jSubject.get("Przedmiot").getAsString()) + val semester1Proposed = jSubject.get("OcenaSem1").getAsString() + val semester2Proposed = jSubject.get("OcenaSem2").getAsString() + val semester1Value = getWordGradeValue(semester1Proposed) + val semester2Value = getWordGradeValue(semester2Proposed) + val semester1Id = rSubject.id * -100 - 1 + val semester2Id = rSubject.id * -100 - 2 + + if (semester1Proposed != "") { + val gradeObject = Grade( + profileId, + semester1Id, + "", + -1, + "", + semester1Value.toString(), + semester1Value.toFloat(), + 0f, + 1, + -1, + rSubject.id) + + gradeObject.type = TYPE_SEMESTER1_PROPOSED + + data.gradeList.add(gradeObject) + data.metadataList.add(Metadata( + profileId, + Metadata.TYPE_GRADE, + gradeObject.id, + profile?.empty ?: false, + profile?.empty ?: false, + System.currentTimeMillis() + )) + } + + if (semester2Proposed != "") { + val gradeObject = Grade( + profileId, + semester2Id, + "", + -1, + "", + semester2Value.toString(), + semester2Value.toFloat(), + 0f, + 2, + -1, + rSubject.id) + + gradeObject.type = TYPE_YEAR_PROPOSED + + data.gradeList.add(gradeObject) + data.metadataList.add(Metadata( + profileId, + Metadata.TYPE_GRADE, + gradeObject.id, + profile?.empty ?: false, + profile?.empty ?: false, + System.currentTimeMillis() + )) + } + } + + data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_PROPOSED_GRADES, SYNC_ALWAYS) + onSuccess() + } + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 10533021..6cb98a7d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -976,4 +976,6 @@ Polski English Pobieranie planu lekcji... + Pobieranie ocen proponowanych... + Pobieranie listy sprawdzianów...