Put comment in grade entry (<5 chars) if entry is empty

This commit is contained in:
Mikołaj Pich 2019-11-27 14:56:19 +01:00
parent 767978d3d1
commit 1b80087288
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
3 changed files with 29 additions and 1 deletions

View file

@ -10,6 +10,7 @@ fun GradesResponse.mapGradesList(): List<Grade> {
val values = getGradeValueWithModifier(grade.entry)
grade.apply {
subject = gradesSubject.name
entry = entry.removeSurrounding("(", ")")
comment = entry.substringBefore(" (").run {
if (length > 4) entry
else entry.substringBeforeLast(")").substringAfter(" (")

View file

@ -21,7 +21,7 @@ class GradesTest : BaseLocalTest() {
@Test
fun getAllTest() {
assertEquals(10, snp.size) // 2 items are skipped
assertEquals(10, student.size)
assertEquals(11, student.size)
assertEquals(3, studentPoints.size)
}
@ -225,6 +225,24 @@ class GradesTest : BaseLocalTest() {
}
}
@Test
fun getGrade_onlyCommentEntry() {
with(student[10]) {
assertEquals("Fizyka", subject)
assertEquals("BK,3", entry)
assertEquals(0, value)
assertEquals(.0, modifier, .0)
assertEquals("", comment)
assertEquals("000000", color)
assertEquals("d1", symbol)
assertEquals("Sprawozdanie - wyznaczanie przyspieczenia.", description)
assertEquals("3,00", weight)
assertEquals(0.0, weightValue, .0)
assertEquals(getDate(2017, 11, 23), date)
assertEquals("Anonimus Max", teacher)
}
}
@Test
fun getGrade_pointsEntry() {
with(studentPoints[0]) {

View file

@ -37,6 +37,15 @@
"KodKolumny": "O",
"DataOceny": "05.12.2018",
"KolorOceny": 7261447
},
{
"Nauczyciel": "Anonimus Max",
"Wpis": "(BK,3)",
"Waga": 3,
"NazwaKolumny": "Sprawozdanie - wyznaczanie przyspieczenia.",
"KodKolumny": "d1",
"DataOceny": "23.11.2017",
"KolorOceny": 0
}
],
"ProponowanaOcenaRoczna": "3",