Add triple change support in different configuration

This commit is contained in:
Mikołaj Pich 2020-02-09 00:43:31 +01:00
parent 7e89883696
commit 68d5092683
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
4 changed files with 85 additions and 22 deletions

View file

@ -63,22 +63,39 @@ class TimetableParser {
}
}
divs.size == 2 -> getLessonInfo(lesson, divs[0])
divs.size == 3 -> {
if (divs[0]?.selectFirst("span")?.hasClass(CLASS_CHANGES) == true &&
divs[1]?.selectFirst("span")?.hasClass(CLASS_MOVED_OR_CANCELED) == true &&
divs[2]?.selectFirst("span")?.hasClass(CLASS_MOVED_OR_CANCELED) == true) {
getLessonInfo(lesson, divs[0]).run {
val old = getLessonInfo(lesson, divs[1])
copy(
changes = true,
canceled = false,
subjectOld = old.subject,
teacherOld = old.teacher,
roomOld = old.room
)
divs.size == 3 -> { // TODO: refactor this
when {
divs[0]?.selectFirst("span")?.hasClass(CLASS_CHANGES) == true &&
divs[1]?.selectFirst("span")?.hasClass(CLASS_MOVED_OR_CANCELED) == true &&
divs[2]?.selectFirst("span")?.hasClass(CLASS_MOVED_OR_CANCELED) == true -> {
getLessonInfo(lesson, divs[0]).run {
val old = getLessonInfo(lesson, divs[1])
copy(
changes = true,
canceled = false,
subjectOld = old.subject,
teacherOld = old.teacher,
roomOld = old.room
)
}
}
divs[0]?.selectFirst("span")?.hasClass(CLASS_MOVED_OR_CANCELED) == true &&
divs[1]?.selectFirst("span")?.hasClass(CLASS_MOVED_OR_CANCELED) == true &&
divs[2]?.selectFirst("span")?.hasClass(CLASS_CHANGES) == true -> {
getLessonInfo(lesson, divs[2]).run {
val old = getLessonInfo(lesson, divs[0])
copy(
changes = true,
canceled = false,
subjectOld = old.subject,
teacherOld = old.teacher,
roomOld = old.room
)
}
}
else -> {
getLessonInfo(lesson, divs[1])
}
} else {
getLessonInfo(lesson, divs[1])
}
}
else -> null

View file

@ -21,8 +21,8 @@ class TimetableTest : BaseLocalTest() {
@Test
fun getTimetableTest() {
assertEquals(18, snp.size)
assertEquals(18, student.size)
assertEquals(19, snp.size)
assertEquals(19, student.size)
assertEquals(18, studentBefore1911.size)
}
@ -124,7 +124,7 @@ class TimetableTest : BaseLocalTest() {
@Test
fun getGroupLesson() {
listOf(snp[15], student[15]).map {
listOf(snp[16], student[16]).map {
it.run {
// piątek, 0
assertEquals(0, number)
@ -242,7 +242,7 @@ class TimetableTest : BaseLocalTest() {
@Test
fun getLesson_emptyOriginal() {
listOf(snp[16], student[16]).map {
listOf(snp[17], student[17]).map {
it.run {
// piątek, 1
assertEquals(1, number)
@ -357,7 +357,7 @@ class TimetableTest : BaseLocalTest() {
@Test
fun getSimpleLesson_canceledWithoutReason() {
listOf(snp[17], student[17]).map {
listOf(snp[18], student[18]).map {
it.run {
// piątek, 2
assertEquals(2, number)
@ -449,4 +449,28 @@ class TimetableTest : BaseLocalTest() {
}
}
}
@Test
fun getLesson_tripleChange2() {
listOf(snp[15], student[15]).map {
it.run {
// czwartek, 3
assertEquals(3, number)
assertEquals(getDate(2018, 9, 27, 9, 45, 0), start)
assertEquals(getDate(2018, 9, 27, 10, 40, 0), end)
assertEquals("systemy operacyjne", subject)
assertEquals("t.infor.", group)
assertEquals("", teacher)
assertEquals("29", room)
assertEquals("przeniesiona z lekcji 1, 10.02.2020", info)
assertEquals("Wiedza o społeczeństwie", subjectOld)
assertEquals("Jan Kowalski", teacherOld)
assertEquals("50", roomOld)
assertEquals(false, canceled)
assertEquals(true, changes)
}
}
}
}

View file

@ -333,7 +333,29 @@
<span class='x-treelabel-rlz'>(Podział na grupy)</span>
</div>
</td>
<td></td>
<td>
<!-- @see TimetableTest#getLesson_tripleChange2() -->
<div>
<span class='x-treelabel-ppl x-treelabel-inv'>Wiedza o społeczeństwie [t.infor.]</span>
<span class='x-treelabel-ppl x-treelabel-inv'></span>
<span class='x-treelabel-ppl x-treelabel-inv'>Jan Kowalski</span>
<span class='x-treelabel-ppl x-treelabel-inv'>50</span>
<span class='x-treelabel-rlz'>(okienko dla uczniów)</span>
</div>
<div>
<span class='x-treelabel-ppl x-treelabel-inv'>Wiedza o społeczeństwie</span>
<span class='x-treelabel-ppl x-treelabel-inv'></span>
<span class='x-treelabel-ppl x-treelabel-inv'>50</span>
<span class='x-treelabel-rlz'>(Podział na grupy)</span>
</div>
<div>
<span class='x-treelabel-ppl x-treelabel-zas'>systemy operacyjne [t.infor.]</span>
<span class='x-treelabel-ppl x-treelabel-zas'></span>
<span class='x-treelabel-ppl x-treelabel-zas'></span>
<span class='x-treelabel-ppl x-treelabel-zas'>29</span>
<span class='x-treelabel-rlz'>(przeniesiona z lekcji 1, 10.02.2020)</span>
</div>
</td>
<td></td>
</tr>
</tbody>

View file

@ -69,7 +69,7 @@
"<div><span class='x-treelabel-ppl x-treelabel-inv'>Podstawy przedsiębiorczości</span><span class='x-treelabel-ppl x-treelabel-inv'>C Urszula</span><span class='x-treelabel-ppl x-treelabel-inv'>4</span><span class='x-treelabel-rlz'>(przeniesiona)</span></div><div><span class='x-treelabel-ppl x-treelabel-zas'>Historia</span><span class='x-treelabel-ppl x-treelabel-zas'></span><span class='x-treelabel-ppl x-treelabel-zas'>6</span><span class='x-treelabel-rlz'>(przeniesiona z lekcji 7, 30.04.2019)</span></div>",
"<div><span class=''>Administracja i eksploatacja systemów komputerowych, urządzeń peryferyjnych i lokalnych sieci komputerowych</span><span class=''></span><span class=''></span></div><div><span class='x-treelabel-ppl x-treelabel-inv'>Podstawy informatyki [2/2]</span><span class='x-treelabel-ppl x-treelabel-inv'></span><span class='x-treelabel-ppl x-treelabel-inv'>(Imię i nazwisko nauczyciela, który miał mieć z nami zajęcia)</span><span class='x-treelabel-ppl x-treelabel-inv'> 125</span></div><button type='button' class='uwaga-btn'>Uwaga</button><div class='uwaga-panel' style='display: block;'> z grupą - p. (Nazwisko nauczyciela, który ma zajęcia z drugą grupą)</div>",
"<div><span class='x-treelabel-ppl x-treelabel-zas'>Eksploatacja urządzeń techniki komputerowej [t.infor.]</span><span class='x-treelabel-ppl x-treelabel-zas'> </span> <span class='x-treelabel-ppl x-treelabel-zas'> </span><span class='x-treelabel-ppl x-treelabel-zas'> 216</span><span class='x-treelabel-rlz'>(przeniesiona z lekcji 6, 06.12.2019)</span></div><div><span class='x-treelabel-ppl x-treelabel-inv'>Wiedza o kulturze [t.infor.]</span><span class='x-treelabel-ppl x-treelabel-inv'> </span> <span class='x-treelabel-ppl x-treelabel-inv'>[nauczyciel od WOK]</span><span class='x-treelabel-ppl x-treelabel-inv'> 010</span><span class='x-treelabel-rlz'>(okienko dla uczniów)</span></div><div><span class='x-treelabel-ppl x-treelabel-inv'>Wiedza o kulturze</span><span class='x-treelabel-ppl x-treelabel-inv'> </span> <span class='x-treelabel-ppl x-treelabel-inv'>010</span><span class='x-treelabel-rlz'>(Podział na grupy)</span></div>",
"",
"<div><span class='x-treelabel-ppl x-treelabel-inv'>Wiedza o społeczeństwie [t.infor.]</span><span class='x-treelabel-ppl x-treelabel-inv'></span><span class='x-treelabel-ppl x-treelabel-inv'>Jan Kowalski</span><span class='x-treelabel-ppl x-treelabel-inv'>50</span><span class='x-treelabel-rlz'>(okienko dla uczniów)</span></div><div><span class='x-treelabel-ppl x-treelabel-inv'>Wiedza o społeczeństwie</span><span class='x-treelabel-ppl x-treelabel-inv'></span><span class='x-treelabel-ppl x-treelabel-inv'>50</span><span class='x-treelabel-rlz'>(Podział na grupy)</span></div><div><span class='x-treelabel-ppl x-treelabel-zas'>systemy operacyjne [t.infor.]</span><span class='x-treelabel-ppl x-treelabel-zas'></span><span class='x-treelabel-ppl x-treelabel-zas'></span><span class='x-treelabel-ppl x-treelabel-zas'>29</span><span class='x-treelabel-rlz'>(przeniesiona z lekcji 1, 10.02.2020)</span></div>",
""
]
],