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
|
- instrumented
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
only: master
|
ignore: /.*/
|
||||||
tags:
|
tags:
|
||||||
only: /.*/
|
only: /^\d+\.\d+\.\d+$/
|
||||||
|
@ -94,14 +94,18 @@ public class Timetable {
|
|||||||
moveWarningToLessonNode(e);
|
moveWarningToLessonNode(e);
|
||||||
|
|
||||||
switch (e.size()) {
|
switch (e.size()) {
|
||||||
|
case 1:
|
||||||
|
addLessonInfoFromElement(lesson, e.first());
|
||||||
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Element span = e.last().select("span").first();
|
Element span = e.last().select("span").first();
|
||||||
if (span.hasClass(LessonTypes.CLASS_MOVED_OR_CANCELED)) {
|
if (span.hasClass(LessonTypes.CLASS_MOVED_OR_CANCELED)) {
|
||||||
lesson.setNewMovedInOrChanged(true);
|
lesson.setNewMovedInOrChanged(true);
|
||||||
lesson.setDescription("poprzednio: " + getLessonAndGroupInfoFromSpan(span)[0]);
|
lesson.setDescription("poprzednio: " + getLessonAndGroupInfoFromSpan(span)[0]);
|
||||||
|
addLessonInfoFromElement(lesson, e.first());
|
||||||
|
} else {
|
||||||
|
addLessonInfoFromElement(lesson, e.last());
|
||||||
}
|
}
|
||||||
case 1:
|
|
||||||
addLessonInfoFromElement(lesson, e.first());
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
addLessonInfoFromElement(lesson, e.get(1));
|
addLessonInfoFromElement(lesson, e.get(1));
|
||||||
@ -167,7 +171,8 @@ public class Timetable {
|
|||||||
lesson.setRoom(spans.get(5).text());
|
lesson.setRoom(spans.get(5).text());
|
||||||
lesson.setMovedOrCanceled(false);
|
lesson.setMovedOrCanceled(false);
|
||||||
lesson.setNewMovedInOrChanged(true);
|
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() + ")");
|
+ " (poprzednio: " + spans.get(0).text() + ")");
|
||||||
} else if (9 == spans.size()) {
|
} else if (9 == spans.size()) {
|
||||||
String[] subjectAndGroupInfo = getLessonAndGroupInfoFromSpan(spans.get(4));
|
String[] subjectAndGroupInfo = getLessonAndGroupInfoFromSpan(spans.get(4));
|
||||||
@ -178,13 +183,15 @@ public class Timetable {
|
|||||||
lesson.setMovedOrCanceled(false);
|
lesson.setMovedOrCanceled(false);
|
||||||
lesson.setNewMovedInOrChanged(true);
|
lesson.setNewMovedInOrChanged(true);
|
||||||
lesson.setDivisionIntoGroups(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] + ")");
|
+ " (poprzednio: " + getLessonAndGroupInfoFromSpan(spans.get(0))[0] + ")");
|
||||||
} else if (4 <= spans.size()) {
|
} else if (4 <= spans.size()) {
|
||||||
lesson.setSubject(spans.get(0).text());
|
lesson.setSubject(spans.get(0).text());
|
||||||
lesson.setTeacher(spans.get(1).text());
|
lesson.setTeacher(spans.get(1).text());
|
||||||
lesson.setRoom(spans.get(2).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[]{
|
return new String[]{
|
||||||
span.text().replace(" " + groupName, ""),
|
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("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(0).getDescription());
|
||||||
Assert.assertEquals("", full.getWeekTable().getDay(4).getLesson(1).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("poprzednio: Wychowanie fizyczne", full.getWeekTable().getDay(4).getLesson(2).getDescription());
|
||||||
Assert.assertEquals("egzamin", full.getWeekTable().getDay(3).getLesson(0).getDescription());
|
Assert.assertEquals("egzamin", full.getWeekTable().getDay(3).getLesson(0).getDescription());
|
||||||
Assert.assertEquals("", full.getWeekTable().getDay(4).getLesson(1).getDescription());
|
Assert.assertEquals("", full.getWeekTable().getDay(4).getLesson(1).getDescription());
|
||||||
|
@ -3,6 +3,40 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Witryna ucznia i rodzica – Plan lekcji</title>
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="mainContainer">
|
<main class="mainContainer">
|
||||||
@ -238,7 +272,17 @@
|
|||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</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>
|
||||||
<tr>
|
<tr>
|
||||||
<td>4</td>
|
<td>4</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user