forked from github/wulkanowy-mirror
[API] Get rid of NULL in timetable lesson descriptions (#106)
This commit is contained in:
parent
23183c9d7a
commit
2cf262130e
@ -228,6 +228,6 @@ workflows:
|
||||
- instrumented
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
ignore: /.*/
|
||||
tags:
|
||||
only: /.*/
|
||||
only: /^\d+\.\d+\.\d+$/
|
||||
|
@ -94,14 +94,18 @@ public class Timetable {
|
||||
moveWarningToLessonNode(e);
|
||||
|
||||
switch (e.size()) {
|
||||
case 1:
|
||||
addLessonInfoFromElement(lesson, e.first());
|
||||
break;
|
||||
case 2:
|
||||
Element span = e.last().select("span").first();
|
||||
if (span.hasClass(LessonTypes.CLASS_MOVED_OR_CANCELED)) {
|
||||
lesson.setNewMovedInOrChanged(true);
|
||||
lesson.setDescription("poprzednio: " + getLessonAndGroupInfoFromSpan(span)[0]);
|
||||
addLessonInfoFromElement(lesson, e.first());
|
||||
} else {
|
||||
addLessonInfoFromElement(lesson, e.last());
|
||||
}
|
||||
case 1:
|
||||
addLessonInfoFromElement(lesson, e.first());
|
||||
break;
|
||||
case 3:
|
||||
addLessonInfoFromElement(lesson, e.get(1));
|
||||
@ -167,7 +171,8 @@ public class Timetable {
|
||||
lesson.setRoom(spans.get(5).text());
|
||||
lesson.setMovedOrCanceled(false);
|
||||
lesson.setNewMovedInOrChanged(true);
|
||||
lesson.setDescription(StringUtils.substringBetween(spans.last().text(), "(", ")")
|
||||
lesson.setDescription(StringUtils.defaultString(StringUtils.substringBetween(
|
||||
spans.last().text(), "(", ")"), spans.last().text())
|
||||
+ " (poprzednio: " + spans.get(0).text() + ")");
|
||||
} else if (9 == spans.size()) {
|
||||
String[] subjectAndGroupInfo = getLessonAndGroupInfoFromSpan(spans.get(4));
|
||||
@ -178,13 +183,15 @@ public class Timetable {
|
||||
lesson.setMovedOrCanceled(false);
|
||||
lesson.setNewMovedInOrChanged(true);
|
||||
lesson.setDivisionIntoGroups(true);
|
||||
lesson.setDescription(StringUtils.substringBetween(spans.last().text(), "(", ")")
|
||||
lesson.setDescription(StringUtils.defaultString(StringUtils.substringBetween(
|
||||
spans.last().text(), "(", ")"), spans.last().text())
|
||||
+ " (poprzednio: " + getLessonAndGroupInfoFromSpan(spans.get(0))[0] + ")");
|
||||
} else if (4 <= spans.size()) {
|
||||
lesson.setSubject(spans.get(0).text());
|
||||
lesson.setTeacher(spans.get(1).text());
|
||||
lesson.setRoom(spans.get(2).text());
|
||||
lesson.setDescription(StringUtils.substringBetween(spans.last().text(), "(", ")"));
|
||||
lesson.setDescription(StringUtils.defaultString(StringUtils.substringBetween(
|
||||
spans.last().text(), "(", ")"), spans.last().text()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +219,8 @@ public class Timetable {
|
||||
|
||||
return new String[]{
|
||||
span.text().replace(" " + groupName, ""),
|
||||
StringUtils.substringBetween(groupName, "[", "]")
|
||||
StringUtils.defaultString(StringUtils.substringBetween(
|
||||
groupName, "[", "]"), groupName)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +151,7 @@ public class TimetableTest extends StudentAndParentTestCase {
|
||||
Assert.assertEquals("zastępstwo (poprzednio: Wychowanie fizyczne)", full.getWeekTable().getDay(3).getLesson(1).getDescription());
|
||||
Assert.assertEquals("", full.getWeekTable().getDay(4).getLesson(0).getDescription());
|
||||
Assert.assertEquals("", full.getWeekTable().getDay(4).getLesson(1).getDescription());
|
||||
Assert.assertEquals("bez nawiasów (poprzednio: Religia)", full.getWeekTable().getDay(4).getLesson(3).getDescription());
|
||||
Assert.assertEquals("poprzednio: Wychowanie fizyczne", full.getWeekTable().getDay(4).getLesson(2).getDescription());
|
||||
Assert.assertEquals("egzamin", full.getWeekTable().getDay(3).getLesson(0).getDescription());
|
||||
Assert.assertEquals("", full.getWeekTable().getDay(4).getLesson(1).getDescription());
|
||||
|
@ -3,6 +3,40 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Witryna ucznia i rodzica – Plan lekcji</title>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table td > div:not(:last-child) {
|
||||
border-bottom: 5px solid silver;
|
||||
padding-bottom: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
table td div span:nth-child(1) {
|
||||
display: block;
|
||||
}
|
||||
table span {
|
||||
font-size: smaller;
|
||||
}
|
||||
.x-treelabel-ppl {
|
||||
background: #99f;
|
||||
font-style: italic;
|
||||
}
|
||||
.x-treelabel-rlz {
|
||||
background: #f3a;
|
||||
}
|
||||
.x-treelabel-inv {
|
||||
background: #f00;
|
||||
}
|
||||
.x-treelabel-zas {
|
||||
background: #0f0;
|
||||
}
|
||||
table span:not([class]),
|
||||
table span[class=""] {
|
||||
background: #999;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="mainContainer">
|
||||
@ -238,7 +272,17 @@
|
||||
<span></span>
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<div>
|
||||
<span class="x-treelabel-inv">Religia</span>
|
||||
<span class="x-treelabel-inv">Cyranka Krystian</span>
|
||||
<span class="x-treelabel-inv">3</span>
|
||||
<span class="x-treelabel-ppl x-treelabel-zas">Wychowanie do życia w rodzinie</span>
|
||||
<span class="x-treelabel-ppl x-treelabel-zas">Nowak Jadwiga</span>
|
||||
<span class="x-treelabel-ppl x-treelabel-zas">3</span>
|
||||
<span class="x-treelabel-rlz">bez nawiasów</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user