[API/Librus] Show map value in descriptive grades.

This commit is contained in:
Kacper Ziubryniewicz 2020-01-04 13:43:49 +01:00
parent 45d31d2358
commit 95a150f7d8
2 changed files with 17 additions and 15 deletions

View File

@ -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,

View File

@ -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,