Add grade statistics
This commit is contained in:
parent
1a70b9c242
commit
20f0256c27
9 changed files with 318 additions and 0 deletions
|
@ -72,6 +72,8 @@ class Api {
|
|||
|
||||
fun getGradesSummary(semesterId: Int? = null) = snp.getGradesSummary(semesterId)
|
||||
|
||||
fun getGradesStatistics(semesterId: Int? = null, annual: Boolean = false) = snp.getGradesStatistics(semesterId, annual)
|
||||
|
||||
fun getHomework(date: Date? = null) = snp.getHomework(date)
|
||||
|
||||
fun getNotes() = snp.getNotes()
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package io.github.wulkanowy.api.grades
|
||||
|
||||
import pl.droidsonroids.jspoon.annotation.Selector
|
||||
|
||||
class GradeStatistics {
|
||||
|
||||
var semesterId: Int = 0
|
||||
|
||||
@Selector("td", index = 0)
|
||||
lateinit var subject: String
|
||||
|
||||
@Selector("td", index = 1, regex = "^([^,]+)")
|
||||
lateinit var grade: String
|
||||
|
||||
var gradeValue: Int = 0
|
||||
|
||||
@Selector("td:last-of-type", regex = "Klasa ocen: ([^,]+)")
|
||||
var amount: Int = 0
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.github.wulkanowy.api.grades
|
||||
|
||||
import pl.droidsonroids.jspoon.annotation.Selector
|
||||
|
||||
class GradesStatisticsResponse {
|
||||
|
||||
@Selector("#okresyKlasyfikacyjneDropDownList option[selected]", attr = "value")
|
||||
var semesterId: Int = 0
|
||||
|
||||
@Selector(".mainContainer > div table tbody tr")
|
||||
var items: List<GradeStatistics> = emptyList()
|
||||
}
|
|
@ -4,6 +4,7 @@ import io.github.wulkanowy.api.attendance.Attendance
|
|||
import io.github.wulkanowy.api.attendance.AttendanceSummary
|
||||
import io.github.wulkanowy.api.exams.Exam
|
||||
import io.github.wulkanowy.api.grades.Grade
|
||||
import io.github.wulkanowy.api.grades.GradeStatistics
|
||||
import io.github.wulkanowy.api.grades.GradeSummary
|
||||
import io.github.wulkanowy.api.homework.Homework
|
||||
import io.github.wulkanowy.api.mobile.Device
|
||||
|
@ -101,6 +102,17 @@ class StudentAndParentRepository(private val api: StudentAndParentService) {
|
|||
}
|
||||
}
|
||||
|
||||
fun getGradesStatistics(semesterId: Int?, annual: Boolean): Single<List<GradeStatistics>> {
|
||||
return api.getGradesStatistics(if (!annual) 1 else 2, semesterId).map { res ->
|
||||
res.items.map {
|
||||
it.apply {
|
||||
this.gradeValue = getGradeShortValue(this.grade).toIntOrNull() ?: 0
|
||||
this.semesterId = res.semesterId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getHomework(date: Date?): Single<List<Homework>> {
|
||||
return api.getHomework(date.toTick()).map { res ->
|
||||
res.items.asSequence().map { item ->
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.github.wulkanowy.api.attendance.AttendanceResponse
|
|||
import io.github.wulkanowy.api.attendance.AttendanceSummaryResponse
|
||||
import io.github.wulkanowy.api.exams.ExamResponse
|
||||
import io.github.wulkanowy.api.grades.GradesResponse
|
||||
import io.github.wulkanowy.api.grades.GradesStatisticsResponse
|
||||
import io.github.wulkanowy.api.grades.GradesSummaryResponse
|
||||
import io.github.wulkanowy.api.homework.HomeworkResponse
|
||||
import io.github.wulkanowy.api.mobile.RegisteredDevicesResponse
|
||||
|
@ -46,6 +47,9 @@ interface StudentAndParentService {
|
|||
@GET("Oceny/Wszystkie?details=1")
|
||||
fun getGradesSummary(@Query("okres") semester: Int?): Single<GradesSummaryResponse>
|
||||
|
||||
@GET("Statystyki.mvc/Uczen")
|
||||
fun getGradesStatistics(@Query("rodzajWidoku") type: Int?, @Query("semestr") semesterId: Int?): Single<GradesStatisticsResponse>
|
||||
|
||||
@GET("ZadaniaDomowe.mvc?rodzajWidoku=Dzien")
|
||||
fun getHomework(@Query("data") date: String): Single<HomeworkResponse>
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.github.wulkanowy.api.attendance.Attendance
|
|||
import io.github.wulkanowy.api.attendance.AttendanceSummary
|
||||
import io.github.wulkanowy.api.exams.Exam
|
||||
import io.github.wulkanowy.api.grades.Grade
|
||||
import io.github.wulkanowy.api.grades.GradeStatistics
|
||||
import io.github.wulkanowy.api.grades.GradeSummary
|
||||
import io.github.wulkanowy.api.homework.Homework
|
||||
import io.github.wulkanowy.api.messages.Message
|
||||
|
@ -250,6 +251,26 @@ class ApiTest : BaseTest() {
|
|||
assertEquals("", values[8].final)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun gradesStatisticsTest() {
|
||||
val stats = api.getGradesStatistics(321, false)
|
||||
val statsObserver = TestObserver<List<GradeStatistics>>()
|
||||
stats.subscribe(statsObserver)
|
||||
|
||||
val values = statsObserver.values()[0]
|
||||
|
||||
assertEquals("Język polski", values[0].subject)
|
||||
assertEquals("Matematyka", values[7].subject)
|
||||
|
||||
val annual = api.getGradesStatistics(123, true)
|
||||
val annualObserver = TestObserver<List<GradeStatistics>>()
|
||||
annual.subscribe(annualObserver)
|
||||
|
||||
val values2 = annualObserver.values()[0]
|
||||
|
||||
assertEquals("Język angielski", values2[0].subject)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun teachersTest() {
|
||||
val teachers = api.getTeachers()
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package io.github.wulkanowy.api.grades
|
||||
|
||||
import io.github.wulkanowy.api.BaseTest
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class GradesStatisticsTest : BaseTest() {
|
||||
|
||||
private val partial by lazy {
|
||||
getSnpRepo(GradesStatisticsTest::class.java, "Statystyki-czastkowe.html").getGradesStatistics(123, false).blockingGet()
|
||||
}
|
||||
|
||||
private val annual by lazy {
|
||||
getSnpRepo(GradesStatisticsTest::class.java, "Statystyki-roczne.html").getGradesStatistics(321, true).blockingGet()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getGradesStatistics() {
|
||||
assertEquals(12, partial.size)
|
||||
assertEquals(6, annual.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getGradesStatistics_empty() {
|
||||
partial[0].run {
|
||||
assertEquals("Język polski", subject)
|
||||
assertEquals("6", grade)
|
||||
assertEquals(6, gradeValue)
|
||||
assertEquals(0, amount)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getGradesStatistics_filled() {
|
||||
partial[3].run {
|
||||
assertEquals("Język polski", subject)
|
||||
assertEquals("3", grade)
|
||||
assertEquals(3, gradeValue)
|
||||
assertEquals(63, amount)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getGradeStatistics_shortValue() {
|
||||
annual[1].run {
|
||||
assertEquals("Język angielski", subject)
|
||||
assertEquals("bardzo dobry", grade)
|
||||
assertEquals(5, gradeValue)
|
||||
assertEquals(4, amount)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Witryna ucznia i rodzica – Statystyki ucznia</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main class="mainContainer">
|
||||
<h1>Uczeń na tle klasy</h1>
|
||||
|
||||
<form>
|
||||
<fieldset class="pseudoForm">
|
||||
<div class="float-left">
|
||||
<label for="okresyKlasyfikacyjneDropDownList">Okres klasyfikacyjny:</label>
|
||||
<select id="okresyKlasyfikacyjneDropDownList" name="okresyKlasyfikacyjneDropDownList">
|
||||
<option selected="selected" value="122">1</option>
|
||||
<option value="123">2</option>
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<h2>Rozkład ocen cząstkowych</h2>
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Przedmiot</th>
|
||||
<th>Oceny</th>
|
||||
<th>Uczeń</th>
|
||||
<th>Klasa</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td>Język polski</td>
|
||||
<td>6, 6-, 6+</td>
|
||||
<td>Uczeń ocen: 0</td>
|
||||
<td>Klasa ocen: 0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język polski</td>
|
||||
<td>5, 5-, 5+</td>
|
||||
<td>Uczeń ocen: 0</td>
|
||||
<td>Klasa ocen: 24, 9% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język polski</td>
|
||||
<td>4, 4-, 4+</td>
|
||||
<td>Uczeń ocen: 0</td>
|
||||
<td>Klasa ocen: 42, 17% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język polski</td>
|
||||
<td>3, 3-, 3+</td>
|
||||
<td>Uczeń ocen: 2, 22% wszystkich</td>
|
||||
<td>Klasa ocen: 63, 25% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język polski</td>
|
||||
<td>2, 2-, 2+</td>
|
||||
<td>Uczeń ocen: 4, 44% wszystkich</td>
|
||||
<td>Klasa ocen: 65, 26% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język polski</td>
|
||||
<td>1, 1-, 1+</td>
|
||||
<td>Uczeń ocen: 3, 33% wszystkich</td>
|
||||
<td>Klasa ocen: 60, 24% wszystkich</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Matematyka</td>
|
||||
<td>6, 6-, 6+</td>
|
||||
<td>Uczeń ocen: 0</td>
|
||||
<td>Klasa ocen: 2, 1% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Matematyka</td>
|
||||
<td>5, 5-, 5+</td>
|
||||
<td>Uczeń ocen: 1, 17% wszystkich</td>
|
||||
<td>Klasa ocen: 40, 20% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Matematyka</td>
|
||||
<td>4, 4-, 4+</td>
|
||||
<td>Uczeń ocen: 1, 17% wszystkich</td>
|
||||
<td>Klasa ocen: 26, 13% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Matematyka</td>
|
||||
<td>3, 3-, 3+</td>
|
||||
<td>Uczeń ocen: 1, 17% wszystkich</td>
|
||||
<td>Klasa ocen: 35, 18% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Matematyka</td>
|
||||
<td>2, 2-, 2+</td>
|
||||
<td>Uczeń ocen: 0</td>
|
||||
<td>Klasa ocen: 55, 28% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Matematyka</td>
|
||||
<td>1, 1-, 1+</td>
|
||||
<td>Uczeń ocen: 3, 50% wszystkich</td>
|
||||
<td>Klasa ocen: 40, 20% wszystkich</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</main>
|
||||
<footer>wersja: 18.04.0003.29139</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Witryna ucznia i rodzica – Statystyki ucznia</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main class="mainContainer">
|
||||
<h1>Uczeń na tle klasy</h1>
|
||||
|
||||
<form>
|
||||
<fieldset class="pseudoForm">
|
||||
<div class="float-left">
|
||||
<label for="okresyKlasyfikacyjneDropDownList">Okres klasyfikacyjny:</label>
|
||||
<select id="okresyKlasyfikacyjneDropDownList" name="okresyKlasyfikacyjneDropDownList">
|
||||
<option selected="selected" value="124">1</option>
|
||||
<option value="125">2</option>
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<h2>Rozkład ocen rocznych i śródrocznych</h2>
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Przedmiot</th>
|
||||
<th>Oceny</th>
|
||||
<th>Klasa</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td>Język angielski</td>
|
||||
<td>celujący</td>
|
||||
<td>Klasa ocen: 0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język angielski</td>
|
||||
<td>bardzo dobry</td>
|
||||
<td>Klasa ocen: 4, 13% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język angielski</td>
|
||||
<td>dobry</td>
|
||||
<td>Klasa ocen: 8, 26% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język angielski</td>
|
||||
<td>dostateczny</td>
|
||||
<td>Klasa ocen: 9, 29% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język angielski</td>
|
||||
<td>dopuszczający</td>
|
||||
<td>Klasa ocen: 7, 23% wszystkich</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Język angielski</td>
|
||||
<td>niedostateczny</td>
|
||||
<td>Klasa ocen: 3, 10% wszystkich</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
<footer>wersja: 18.04.0003.29139</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue