forked from github/wulkanowy-mirror
Add option to force calc average by app (#400)
This commit is contained in:
parent
1d9a49d552
commit
83dbd9874e
@ -11,9 +11,9 @@ cache:
|
|||||||
- $HOME/.gradle/caches/
|
- $HOME/.gradle/caches/
|
||||||
- $HOME/.gradle/wrapper/
|
- $HOME/.gradle/wrapper/
|
||||||
|
|
||||||
#branches:
|
branches:
|
||||||
# only:
|
only:
|
||||||
# - develop
|
- develop
|
||||||
|
|
||||||
android:
|
android:
|
||||||
licenses:
|
licenses:
|
||||||
|
@ -20,6 +20,9 @@ class PreferencesRepository @Inject constructor(
|
|||||||
val gradeAverageMode: String
|
val gradeAverageMode: String
|
||||||
get() = sharedPref.getString(context.getString(R.string.pref_key_grade_average_mode), "only_one_semester") ?: "only_one_semester"
|
get() = sharedPref.getString(context.getString(R.string.pref_key_grade_average_mode), "only_one_semester") ?: "only_one_semester"
|
||||||
|
|
||||||
|
val gradeAverageForceCalc: Boolean
|
||||||
|
get() = sharedPref.getBoolean(context.getString(R.string.pref_key_grade_average_force_calc), false)
|
||||||
|
|
||||||
val isGradeExpandable: Boolean
|
val isGradeExpandable: Boolean
|
||||||
get() = !sharedPref.getBoolean(context.getString(R.string.pref_key_expand_grade), false)
|
get() = !sharedPref.getBoolean(context.getString(R.string.pref_key_expand_grade), false)
|
||||||
|
|
||||||
|
@ -67,6 +67,6 @@ class GradeAverageProvider @Inject constructor(
|
|||||||
if (it.any { summary -> summary.average != .0 }) {
|
if (it.any { summary -> summary.average != .0 }) {
|
||||||
Maybe.just(it.map { summary -> summary.subject to summary.average }.toMap())
|
Maybe.just(it.map { summary -> summary.subject to summary.average }.toMap())
|
||||||
} else Maybe.empty()
|
} else Maybe.empty()
|
||||||
}
|
}.filter { !preferencesRepository.gradeAverageForceCalc }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,6 +253,7 @@
|
|||||||
<string name="pref_view_header">Wygląd</string>
|
<string name="pref_view_header">Wygląd</string>
|
||||||
<string name="pref_view_list">Domyślny widok</string>
|
<string name="pref_view_list">Domyślny widok</string>
|
||||||
<string name="pref_view_grade_average_mode">Obliczanie średniej końcoworocznej</string>
|
<string name="pref_view_grade_average_mode">Obliczanie średniej końcoworocznej</string>
|
||||||
|
<string name="pref_view_grade_average_force_calc">Wymuś obliczanie średniej przez aplikację</string>
|
||||||
<string name="pref_view_present">Pokazuj obecność we frekwencji</string>
|
<string name="pref_view_present">Pokazuj obecność we frekwencji</string>
|
||||||
<string name="pref_view_app_theme">Motyw aplikacji</string>
|
<string name="pref_view_app_theme">Motyw aplikacji</string>
|
||||||
<string name="pref_view_expand_grade">Rozwiń oceny</string>
|
<string name="pref_view_expand_grade">Rozwiń oceny</string>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<string name="pref_key_grade_color_scheme">grade_color_scheme</string>
|
<string name="pref_key_grade_color_scheme">grade_color_scheme</string>
|
||||||
<string name="pref_key_expand_grade">expand_grade</string>
|
<string name="pref_key_expand_grade">expand_grade</string>
|
||||||
<string name="pref_key_grade_average_mode">grade_average_mode</string>
|
<string name="pref_key_grade_average_mode">grade_average_mode</string>
|
||||||
|
<string name="pref_key_grade_average_force_calc">grade_average_always_calc</string>
|
||||||
<string name="pref_key_services_enable">services_enable</string>
|
<string name="pref_key_services_enable">services_enable</string>
|
||||||
<string name="pref_key_services_interval">services_interval</string>
|
<string name="pref_key_services_interval">services_interval</string>
|
||||||
<string name="pref_key_services_wifi_only">services_disable_wifi_only</string>
|
<string name="pref_key_services_wifi_only">services_disable_wifi_only</string>
|
||||||
|
@ -237,6 +237,7 @@
|
|||||||
<string name="pref_view_header">Appearance</string>
|
<string name="pref_view_header">Appearance</string>
|
||||||
<string name="pref_view_list">Default view</string>
|
<string name="pref_view_list">Default view</string>
|
||||||
<string name="pref_view_grade_average_mode">Calculation of the end-of-year average</string>
|
<string name="pref_view_grade_average_mode">Calculation of the end-of-year average</string>
|
||||||
|
<string name="pref_view_grade_average_force_calc">Force average calculation by app</string>
|
||||||
<string name="pref_view_present">Show presence in attendance</string>
|
<string name="pref_view_present">Show presence in attendance</string>
|
||||||
<string name="pref_view_app_theme">Application theme</string>
|
<string name="pref_view_app_theme">Application theme</string>
|
||||||
<string name="pref_view_expand_grade">Expand grades</string>
|
<string name="pref_view_expand_grade">Expand grades</string>
|
||||||
|
@ -105,6 +105,11 @@
|
|||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/pref_view_grade_average_mode"
|
android:title="@string/pref_view_grade_average_mode"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_key_grade_average_force_calc"
|
||||||
|
android:title="@string/pref_view_grade_average_force_calc"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="@string/pref_key_fill_message_content"
|
android:key="@string/pref_key_fill_message_content"
|
||||||
|
@ -59,6 +59,7 @@ class GradeAverageProviderTest {
|
|||||||
|
|
||||||
doReturn(.33).`when`(preferencesRepository).gradeMinusModifier
|
doReturn(.33).`when`(preferencesRepository).gradeMinusModifier
|
||||||
doReturn(.33).`when`(preferencesRepository).gradePlusModifier
|
doReturn(.33).`when`(preferencesRepository).gradePlusModifier
|
||||||
|
doReturn(false).`when`(preferencesRepository).gradeAverageForceCalc
|
||||||
|
|
||||||
doReturn(Single.just(firstGrades)).`when`(gradeRepository).getGrades(student, semesters[1], true)
|
doReturn(Single.just(firstGrades)).`when`(gradeRepository).getGrades(student, semesters[1], true)
|
||||||
doReturn(Single.just(secondGrade)).`when`(gradeRepository).getGrades(student, semesters[2], true)
|
doReturn(Single.just(secondGrade)).`when`(gradeRepository).getGrades(student, semesters[2], true)
|
||||||
@ -128,6 +129,24 @@ class GradeAverageProviderTest {
|
|||||||
assertEquals(3.26, averages["Fizyka"])
|
assertEquals(3.26, averages["Fizyka"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun onlyOneSemester_averageFromSummary_forceCalc() {
|
||||||
|
doReturn(true).`when`(preferencesRepository).gradeAverageForceCalc
|
||||||
|
doReturn("all_year").`when`(preferencesRepository).gradeAverageMode
|
||||||
|
doReturn(Single.just(firstGrades)).`when`(gradeRepository).getGrades(student, semesters[1], false)
|
||||||
|
doReturn(Single.just(listOf(
|
||||||
|
getSummary(22, "Matematyka", 3.1),
|
||||||
|
getSummary(22, "Fizyka", 3.26)
|
||||||
|
))).`when`(gradeSummaryRepository).getGradesSummary(semesters[2], true)
|
||||||
|
|
||||||
|
val averages = gradeAverageProvider.getGradeAverage(student, semesters, semesters[2].semesterId, true)
|
||||||
|
.blockingGet()
|
||||||
|
|
||||||
|
assertEquals(2, averages.size)
|
||||||
|
assertEquals(3.0, averages["Matematyka"])
|
||||||
|
assertEquals(3.25, averages["Fizyka"])
|
||||||
|
}
|
||||||
|
|
||||||
private fun getGrade(semesterId: Int, subject: String, value: Int): Grade {
|
private fun getGrade(semesterId: Int, subject: String, value: Int): Grade {
|
||||||
return Grade(
|
return Grade(
|
||||||
studentId = 101,
|
studentId = 101,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user