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

1b80087288
This commit is contained in:
Mikołaj Pich 2019-12-07 22:24:52 +01:00
parent 6df2820e96
commit d35e92f6a7
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",