diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiGrades.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiGrades.kt index 17ae0d68..5cbc67e5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiGrades.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiGrades.kt @@ -32,19 +32,16 @@ class LibrusApiGrades(override val data: DataLibrus, val subjectId = grade.getJsonObject("Subject")?.getLong("Id") ?: -1 val addedDate = Date.fromIso(grade.getString("AddDate")) - val category = data.gradeCategories.singleOrNull { it.categoryId == categoryId } - val categoryName = category?.text ?: "" - val color = category?.color ?: -1 - var weight = category?.weight ?: 0f - val value = Utils.getGradeValue(name) - - - if (name == "-" || name == "+" - || name.equals("np", ignoreCase = true) - || name.equals("bz", ignoreCase = true)) { - weight = 0f + val category = data.gradeCategories.singleOrNull { + it.categoryId == categoryId && it.type == GradeCategory.TYPE_NORMAL } + val value = Utils.getGradeValue(name) + val weight = if (name == "-" || name == "+" + || name.equals("np", ignoreCase = true) + || name.equals("bz", ignoreCase = true)) 0f + else category?.weight ?: 0f + val description = grade.getJsonArray("Comments")?.asJsonObjectList()?.let { comments -> if (comments.isNotEmpty()) { data.gradeCategories.singleOrNull { @@ -57,8 +54,8 @@ class LibrusApiGrades(override val data: DataLibrus, val gradeObject = Grade( profileId, id, - categoryName, - color, + category?.text ?: "", + category?.color ?: -1, description, name, value, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTextGrades.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTextGrades.kt index 0281722f..ff4e1c82 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTextGrades.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTextGrades.kt @@ -30,7 +30,12 @@ class LibrusApiTextGrades(override val data: DataLibrus, val teacherId = grade.getJsonObject("AddedBy")?.getLong("Id") ?: return@forEach val semester = grade.getInt("Semester") ?: return@forEach val subjectId = grade.getJsonObject("Subject")?.getLong("Id") ?: return@forEach - val description = grade.getString("RealGradeValue") ?: grade.getString("Map") ?: "" + + val map = grade.getString("Map") + val realValue = grade.getString("RealGradeValue") + + val name = map ?: realValue ?: return@forEach + val description = if (map != null && map != realValue) realValue ?: "" else "" val categoryId = grade.getJsonObject("Skill")?.getLong("Id") ?: return@forEach @@ -45,8 +50,8 @@ class LibrusApiTextGrades(override val data: DataLibrus, id, category?.text ?: "", category?.color ?: -1, - "", description, + name, 0f, 0f, semester,