mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2024-11-26 04:14:37 -06:00
Display separate annual average and semester average if available (#2524)
* Add displaying year average on grade details screen * Add displaying year average on grade summary screen * Add displaying year average on grade summary header * Fix tests * Hide semester average if it is not available in grade summary item * Add full names of summary averages labels
This commit is contained in:
parent
b5cc32d59f
commit
82210c37e3
@ -195,7 +195,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'io.github.wulkanowy:sdk:2.5.6'
|
implementation 'io.github.wulkanowy:sdk:2.5.7-SNAPSHOT'
|
||||||
|
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
||||||
|
|
||||||
|
2559
app/schemas/io.github.wulkanowy.data.db.AppDatabase/64.json
Normal file
2559
app/schemas/io.github.wulkanowy.data.db.AppDatabase/64.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -177,6 +177,7 @@ import javax.inject.Singleton
|
|||||||
AutoMigration(from = 60, to = 61),
|
AutoMigration(from = 60, to = 61),
|
||||||
AutoMigration(from = 61, to = 62),
|
AutoMigration(from = 61, to = 62),
|
||||||
AutoMigration(from = 62, to = 63, spec = Migration63::class),
|
AutoMigration(from = 62, to = 63, spec = Migration63::class),
|
||||||
|
AutoMigration(from = 63, to = 64),
|
||||||
],
|
],
|
||||||
version = AppDatabase.VERSION_SCHEMA,
|
version = AppDatabase.VERSION_SCHEMA,
|
||||||
exportSchema = true
|
exportSchema = true
|
||||||
@ -185,7 +186,7 @@ import javax.inject.Singleton
|
|||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION_SCHEMA = 63
|
const val VERSION_SCHEMA = 64
|
||||||
|
|
||||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
|
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
|
||||||
Migration2(),
|
Migration2(),
|
||||||
|
@ -33,7 +33,13 @@ data class GradeSummary(
|
|||||||
@ColumnInfo(name = "points_sum")
|
@ColumnInfo(name = "points_sum")
|
||||||
val pointsSum: String,
|
val pointsSum: String,
|
||||||
|
|
||||||
val average: Double
|
@ColumnInfo(name = "points_sum_all_year")
|
||||||
|
val pointsSumAllYear: String?,
|
||||||
|
|
||||||
|
val average: Double,
|
||||||
|
|
||||||
|
@ColumnInfo(name = "average_all_year")
|
||||||
|
val averageAllYear: Double? = null,
|
||||||
) {
|
) {
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
var id: Long = 0
|
var id: Long = 0
|
||||||
|
@ -37,9 +37,11 @@ fun List<SdkGradeSummary>.mapToEntities(semester: Semester) = map {
|
|||||||
predictedGrade = it.predicted,
|
predictedGrade = it.predicted,
|
||||||
finalGrade = it.final,
|
finalGrade = it.final,
|
||||||
pointsSum = it.pointsSum,
|
pointsSum = it.pointsSum,
|
||||||
|
pointsSumAllYear = it.pointsSumAllYear,
|
||||||
proposedPoints = it.proposedPoints,
|
proposedPoints = it.proposedPoints,
|
||||||
finalPoints = it.finalPoints,
|
finalPoints = it.finalPoints,
|
||||||
average = it.average
|
average = it.average,
|
||||||
|
averageAllYear = it.averageAllYear,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,5 +26,7 @@ private fun generateSummary(subject: String, predicted: String, final: String) =
|
|||||||
proposedPoints = "",
|
proposedPoints = "",
|
||||||
finalPoints = "",
|
finalPoints = "",
|
||||||
pointsSum = "",
|
pointsSum = "",
|
||||||
average = .0
|
average = .0,
|
||||||
|
pointsSumAllYear = null,
|
||||||
|
averageAllYear = null,
|
||||||
)
|
)
|
||||||
|
@ -266,7 +266,9 @@ class GradeAverageProvider @Inject constructor(
|
|||||||
proposedPoints = "",
|
proposedPoints = "",
|
||||||
finalPoints = "",
|
finalPoints = "",
|
||||||
pointsSum = "",
|
pointsSum = "",
|
||||||
average = .0
|
pointsSumAllYear = null,
|
||||||
|
average = .0,
|
||||||
|
averageAllYear = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,13 +296,15 @@ class GradeAverageProvider @Inject constructor(
|
|||||||
proposedPoints = "",
|
proposedPoints = "",
|
||||||
finalPoints = "",
|
finalPoints = "",
|
||||||
pointsSum = "",
|
pointsSum = "",
|
||||||
|
pointsSumAllYear = null,
|
||||||
average = when {
|
average = when {
|
||||||
calcAverage -> details
|
calcAverage -> details
|
||||||
.updateModifiers(student, params)
|
.updateModifiers(student, params)
|
||||||
.calcAverage(isOptionalArithmeticAverage = params.isOptionalArithmeticAverage)
|
.calcAverage(isOptionalArithmeticAverage = params.isOptionalArithmeticAverage)
|
||||||
|
|
||||||
else -> .0
|
else -> .0
|
||||||
}
|
},
|
||||||
|
averageAllYear = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,11 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
|||||||
ViewType.HEADER.id -> HeaderViewHolder(
|
ViewType.HEADER.id -> HeaderViewHolder(
|
||||||
HeaderGradeDetailsBinding.inflate(inflater, parent, false)
|
HeaderGradeDetailsBinding.inflate(inflater, parent, false)
|
||||||
)
|
)
|
||||||
|
|
||||||
ViewType.ITEM.id -> ItemViewHolder(
|
ViewType.ITEM.id -> ItemViewHolder(
|
||||||
ItemGradeDetailsBinding.inflate(inflater, parent, false)
|
ItemGradeDetailsBinding.inflate(inflater, parent, false)
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,6 +112,7 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
|||||||
header = items[position].value as GradeDetailsHeader,
|
header = items[position].value as GradeDetailsHeader,
|
||||||
position = position
|
position = position
|
||||||
)
|
)
|
||||||
|
|
||||||
is ItemViewHolder -> bindItemViewHolder(
|
is ItemViewHolder -> bindItemViewHolder(
|
||||||
holder = holder,
|
holder = holder,
|
||||||
grade = items[position].value as Grade
|
grade = items[position].value as Grade
|
||||||
@ -133,6 +136,10 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
|||||||
maxLines = if (expandedPositions[headerPosition]) 2 else 1
|
maxLines = if (expandedPositions[headerPosition]) 2 else 1
|
||||||
}
|
}
|
||||||
gradeHeaderAverage.text = formatAverage(header.average, root.context.resources)
|
gradeHeaderAverage.text = formatAverage(header.average, root.context.resources)
|
||||||
|
with(gradeHeaderAverageAllYear) {
|
||||||
|
isVisible = header.averageAllYear != null && header.averageAllYear != .0
|
||||||
|
text = formatAverageAllYear(header.averageAllYear, root.context.resources)
|
||||||
|
}
|
||||||
gradeHeaderPointsSum.text =
|
gradeHeaderPointsSum.text =
|
||||||
context.getString(R.string.grade_points_sum, header.pointsSum)
|
context.getString(R.string.grade_points_sum, header.pointsSum)
|
||||||
gradeHeaderPointsSum.isVisible = !header.pointsSum.isNullOrEmpty()
|
gradeHeaderPointsSum.isVisible = !header.pointsSum.isNullOrEmpty()
|
||||||
@ -233,6 +240,13 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
|||||||
resources.getString(R.string.grade_average, average)
|
resources.getString(R.string.grade_average, average)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun formatAverageAllYear(average: Double?, resources: Resources) =
|
||||||
|
if (average == null || average == .0) {
|
||||||
|
resources.getString(R.string.grade_no_average)
|
||||||
|
} else {
|
||||||
|
resources.getString(R.string.grade_average_year, average)
|
||||||
|
}
|
||||||
|
|
||||||
private class HeaderViewHolder(val binding: HeaderGradeDetailsBinding) :
|
private class HeaderViewHolder(val binding: HeaderGradeDetailsBinding) :
|
||||||
RecyclerView.ViewHolder(binding.root)
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ data class GradeDetailsItem(
|
|||||||
data class GradeDetailsHeader(
|
data class GradeDetailsHeader(
|
||||||
val subject: String,
|
val subject: String,
|
||||||
val average: Double?,
|
val average: Double?,
|
||||||
|
val averageAllYear: Double?,
|
||||||
val pointsSum: String?,
|
val pointsSum: String?,
|
||||||
val grades: List<GradeDetailsItem>
|
val grades: List<GradeDetailsItem>
|
||||||
) {
|
) {
|
||||||
|
@ -226,8 +226,9 @@ class GradeDetailsPresenter @Inject constructor(
|
|||||||
GradeDetailsHeader(
|
GradeDetailsHeader(
|
||||||
subject = gradeSubject.subject,
|
subject = gradeSubject.subject,
|
||||||
average = gradeSubject.average,
|
average = gradeSubject.average,
|
||||||
|
averageAllYear = gradeSubject.summary.averageAllYear,
|
||||||
pointsSum = gradeSubject.points,
|
pointsSum = gradeSubject.points,
|
||||||
grades = subItems
|
grades = subItems,
|
||||||
).apply {
|
).apply {
|
||||||
newGrades = gradeSubject.grades.filter { grade -> !grade.isRead }.size
|
newGrades = gradeSubject.grades.filter { grade -> !grade.isRead }.size
|
||||||
}, ViewType.HEADER
|
}, ViewType.HEADER
|
||||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.modules.grade.summary
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
@ -65,37 +66,55 @@ class GradeSummaryAdapter @Inject constructor(
|
|||||||
val gradeSummaries = items
|
val gradeSummaries = items
|
||||||
.filter { it.gradeDescriptive == null }
|
.filter { it.gradeDescriptive == null }
|
||||||
.map { it.gradeSummary }
|
.map { it.gradeSummary }
|
||||||
|
val isSecondSemester = items.any { item ->
|
||||||
|
item.gradeSummary.let { it.averageAllYear != null && it.averageAllYear != .0 }
|
||||||
|
}
|
||||||
|
|
||||||
val context = binding.root.context
|
val context = binding.root.context
|
||||||
val finalItemsCount = gradeSummaries.count { isGradeValid(it.finalGrade) }
|
val finalItemsCount = gradeSummaries.count { isGradeValid(it.finalGrade) }
|
||||||
val calculatedItemsCount = gradeSummaries.count { value -> value.average != 0.0 }
|
val calculatedSemesterItemsCount = gradeSummaries.count { value -> value.average != 0.0 }
|
||||||
|
val calculatedAnnualItemsCount =
|
||||||
|
gradeSummaries.count { value -> value.averageAllYear != 0.0 }
|
||||||
val allItemsCount = gradeSummaries.count { !it.subject.equals("zachowanie", true) }
|
val allItemsCount = gradeSummaries.count { !it.subject.equals("zachowanie", true) }
|
||||||
val finalAverage = gradeSummaries.calcFinalAverage(
|
val finalAverage = gradeSummaries.calcFinalAverage(
|
||||||
preferencesRepository.gradePlusModifier,
|
plusModifier = preferencesRepository.gradePlusModifier,
|
||||||
preferencesRepository.gradeMinusModifier
|
minusModifier = preferencesRepository.gradeMinusModifier,
|
||||||
)
|
)
|
||||||
val calculatedAverage = gradeSummaries.filter { value -> value.average != 0.0 }
|
val calculatedSemesterAverage = gradeSummaries.filter { value -> value.average != 0.0 }
|
||||||
.map { values -> values.average }
|
.map { values -> values.average }
|
||||||
.reversed() // fix average precision
|
.reversed() // fix average precision
|
||||||
.average()
|
.average()
|
||||||
.let { if (it.isNaN()) 0.0 else it }
|
.let { if (it.isNaN()) 0.0 else it }
|
||||||
|
val calculatedAnnualAverage = gradeSummaries.filter { value -> value.averageAllYear != 0.0 }
|
||||||
|
.mapNotNull { values -> values.averageAllYear }
|
||||||
|
.reversed() // fix average precision
|
||||||
|
.average()
|
||||||
|
.let { if (it.isNaN()) 0.0 else it }
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
|
gradeSummaryScrollableHeaderCalculated.text = formatAverage(calculatedSemesterAverage)
|
||||||
|
gradeSummaryScrollableHeaderCalculatedAnnual.text =
|
||||||
|
formatAverage(calculatedAnnualAverage)
|
||||||
gradeSummaryScrollableHeaderFinal.text = formatAverage(finalAverage)
|
gradeSummaryScrollableHeaderFinal.text = formatAverage(finalAverage)
|
||||||
gradeSummaryScrollableHeaderCalculated.text = formatAverage(calculatedAverage)
|
gradeSummaryScrollableHeaderFinalSubjectCount.text = context.getString(
|
||||||
gradeSummaryScrollableHeaderFinalSubjectCount.text =
|
|
||||||
context.getString(
|
|
||||||
R.string.grade_summary_from_subjects,
|
|
||||||
finalItemsCount,
|
|
||||||
allItemsCount
|
|
||||||
)
|
|
||||||
gradeSummaryScrollableHeaderCalculatedSubjectCount.text = context.getString(
|
|
||||||
R.string.grade_summary_from_subjects,
|
R.string.grade_summary_from_subjects,
|
||||||
calculatedItemsCount,
|
finalItemsCount,
|
||||||
allItemsCount
|
allItemsCount
|
||||||
)
|
)
|
||||||
|
gradeSummaryScrollableHeaderCalculatedSubjectCount.text = context.getString(
|
||||||
|
R.string.grade_summary_from_subjects,
|
||||||
|
calculatedSemesterItemsCount,
|
||||||
|
allItemsCount
|
||||||
|
)
|
||||||
|
gradeSummaryScrollableHeaderCalculatedSubjectCountAnnual.text = context.getString(
|
||||||
|
R.string.grade_summary_from_subjects,
|
||||||
|
calculatedAnnualItemsCount,
|
||||||
|
allItemsCount
|
||||||
|
)
|
||||||
|
gradeSummaryScrollableHeaderCalculatedAnnualContainer.isVisible = isSecondSemester
|
||||||
|
|
||||||
gradeSummaryCalculatedAverageHelp.setOnClickListener { onCalculatedHelpClickListener() }
|
gradeSummaryCalculatedAverageHelp.setOnClickListener { onCalculatedHelpClickListener() }
|
||||||
|
gradeSummaryCalculatedAverageHelpAnnual.setOnClickListener { onCalculatedHelpClickListener() }
|
||||||
gradeSummaryFinalAverageHelp.setOnClickListener { onFinalHelpClickListener() }
|
gradeSummaryFinalAverageHelp.setOnClickListener { onFinalHelpClickListener() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +126,12 @@ class GradeSummaryAdapter @Inject constructor(
|
|||||||
with(binding) {
|
with(binding) {
|
||||||
gradeSummaryItemTitle.text = gradeSummary.subject
|
gradeSummaryItemTitle.text = gradeSummary.subject
|
||||||
gradeSummaryItemPoints.text = gradeSummary.pointsSum
|
gradeSummaryItemPoints.text = gradeSummary.pointsSum
|
||||||
|
|
||||||
gradeSummaryItemAverage.text = formatAverage(gradeSummary.average, "")
|
gradeSummaryItemAverage.text = formatAverage(gradeSummary.average, "")
|
||||||
|
gradeSummaryItemAverageAllYear.text = gradeSummary.averageAllYear?.let {
|
||||||
|
formatAverage(it, "")
|
||||||
|
}
|
||||||
|
|
||||||
gradeSummaryItemPredicted.text =
|
gradeSummaryItemPredicted.text =
|
||||||
"${gradeSummary.predictedGrade} ${gradeSummary.proposedPoints}".trim()
|
"${gradeSummary.predictedGrade} ${gradeSummary.proposedPoints}".trim()
|
||||||
gradeSummaryItemFinal.text =
|
gradeSummaryItemFinal.text =
|
||||||
@ -116,6 +140,12 @@ class GradeSummaryAdapter @Inject constructor(
|
|||||||
root.context.getString(R.string.all_no_data)
|
root.context.getString(R.string.all_no_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gradeSummaryItemAverageContainer.isVisible = gradeSummary.average != .0
|
||||||
|
gradeSummaryItemAverageDivider.isVisible = gradeSummaryItemAverageContainer.isVisible
|
||||||
|
gradeSummaryItemAverageAllYearContainer.isGone =
|
||||||
|
gradeSummary.averageAllYear == null || gradeSummary.averageAllYear == .0
|
||||||
|
gradeSummaryItemAverageAllYearDivider.isGone =
|
||||||
|
gradeSummaryItemAverageAllYearContainer.isGone
|
||||||
gradeSummaryItemFinalDivider.isVisible = gradeDescriptive == null
|
gradeSummaryItemFinalDivider.isVisible = gradeDescriptive == null
|
||||||
gradeSummaryItemPredictedDivider.isVisible = gradeDescriptive == null
|
gradeSummaryItemPredictedDivider.isVisible = gradeDescriptive == null
|
||||||
gradeSummaryItemPointsDivider.isVisible = gradeDescriptive == null
|
gradeSummaryItemPointsDivider.isVisible = gradeDescriptive == null
|
||||||
@ -123,6 +153,7 @@ class GradeSummaryAdapter @Inject constructor(
|
|||||||
gradeSummaryItemFinalContainer.isVisible = gradeDescriptive == null
|
gradeSummaryItemFinalContainer.isVisible = gradeDescriptive == null
|
||||||
gradeSummaryItemDescriptiveContainer.isVisible = gradeDescriptive != null
|
gradeSummaryItemDescriptiveContainer.isVisible = gradeDescriptive != null
|
||||||
gradeSummaryItemPointsContainer.isVisible = gradeSummary.pointsSum.isNotBlank()
|
gradeSummaryItemPointsContainer.isVisible = gradeSummary.pointsSum.isNotBlank()
|
||||||
|
gradeSummaryItemPointsDivider.isVisible = gradeSummaryItemPointsContainer.isVisible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +45,30 @@
|
|||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/gradeHeaderPointsSum"
|
app:layout_constraintEnd_toStartOf="@id/gradeHeaderAverageAllYear"
|
||||||
app:layout_constraintHorizontal_bias="0"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
app:layout_constraintHorizontal_chainStyle="packed"
|
app:layout_constraintHorizontal_chainStyle="packed"
|
||||||
app:layout_constraintStart_toStartOf="@id/gradeHeaderSubject"
|
app:layout_constraintStart_toStartOf="@id/gradeHeaderSubject"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/gradeHeaderSubject"
|
app:layout_constraintTop_toBottomOf="@+id/gradeHeaderSubject"
|
||||||
tools:text="Average: 6,00" />
|
tools:text="Average: 6,00" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gradeHeaderAverageAllYear"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:layout_constrainedWidth="true"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/gradeHeaderPointsSum"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/gradeHeaderAverage"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/gradeHeaderSubject"
|
||||||
|
tools:text="Roczna: 5,00"
|
||||||
|
tools:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/gradeHeaderPointsSum"
|
android:id="@+id/gradeHeaderPointsSum"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -64,7 +81,7 @@
|
|||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
app:layout_constrainedWidth="true"
|
app:layout_constrainedWidth="true"
|
||||||
app:layout_constraintEnd_toStartOf="@id/gradeHeaderNumber"
|
app:layout_constraintEnd_toStartOf="@id/gradeHeaderNumber"
|
||||||
app:layout_constraintStart_toEndOf="@+id/gradeHeaderAverage"
|
app:layout_constraintStart_toEndOf="@+id/gradeHeaderAverageAllYear"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/gradeHeaderSubject"
|
app:layout_constraintTop_toBottomOf="@+id/gradeHeaderSubject"
|
||||||
tools:text="Points: 123/200 (61,5%)" />
|
tools:text="Points: 123/200 (61,5%)" />
|
||||||
|
|
||||||
|
@ -20,20 +20,80 @@
|
|||||||
android:id="@+id/gradeSummaryItemTitle"
|
android:id="@+id/gradeSummaryItemTitle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="40dp"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="17sp"
|
android:textSize="17sp"
|
||||||
tools:text="@tools:sample/lorem" />
|
tools:text="@tools:sample/lorem" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/gradeSummaryItemAverageContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="35dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/grade_summary_average_semester"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/gradeSummaryItemAverage"
|
android:id="@+id/gradeSummaryItemAverage"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="25dp"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
tools:text="4.74" />
|
tools:text="2,50" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/gradeSummaryItemAverageDivider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@drawable/ic_all_divider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/gradeSummaryItemAverageAllYearContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="35dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/grade_summary_average_year"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gradeSummaryItemAverageAllYear"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="25dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:textSize="12sp"
|
||||||
|
tools:text="4,50" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/gradeSummaryItemAverageAllYearDivider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@drawable/ic_all_divider" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/gradeSummaryItemPointsContainer"
|
android:id="@+id/gradeSummaryItemPointsContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -63,9 +123,9 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
android:id="@+id/gradeSummaryItemPointsDivider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:id="@+id/gradeSummaryItemPointsDivider"
|
|
||||||
android:background="@drawable/ic_all_divider" />
|
android:background="@drawable/ic_all_divider" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -97,8 +157,8 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:id="@+id/gradeSummaryItemPredictedDivider"
|
android:id="@+id/gradeSummaryItemPredictedDivider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="@drawable/ic_all_divider" />
|
android:background="@drawable/ic_all_divider" />
|
||||||
|
|
||||||
@ -131,9 +191,9 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
android:id="@+id/gradeSummaryItemFinalDivider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:id="@+id/gradeSummaryItemFinalDivider"
|
|
||||||
android:background="@drawable/ic_all_divider" />
|
android:background="@drawable/ic_all_divider" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
tools:context=".ui.modules.grade.summary.GradeSummaryAdapter">
|
tools:context=".ui.modules.grade.summary.GradeSummaryAdapter">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="150dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:layout_marginEnd="15dp"
|
android:layout_marginEnd="15dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -21,9 +22,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:minLines="2"
|
android:minLines="2"
|
||||||
android:textStyle="bold"
|
|
||||||
android:text="@string/grade_summary_calculated_average"
|
android:text="@string/grade_summary_calculated_average"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -61,9 +62,64 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="150dp"
|
android:id="@+id/gradeSummaryScrollableHeaderCalculatedAnnualContainer"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:minLines="2"
|
||||||
|
android:text="@string/grade_summary_calculated_average_annual"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gradeSummaryScrollableHeaderCalculatedAnnual"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="21sp"
|
||||||
|
tools:text="6,00" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/gradeSummaryCalculatedAverageHelpAnnual"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="@+string/grade_summary_calculated_average_help_dialog_title"
|
||||||
|
app:srcCompat="@drawable/ic_help"
|
||||||
|
app:tint="?colorOnBackground" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gradeSummaryScrollableHeaderCalculatedSubjectCountAnnual"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textSize="13sp"
|
||||||
|
tools:text="from 8 subjects" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -71,9 +127,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:minLines="2"
|
android:minLines="2"
|
||||||
android:textStyle="bold"
|
|
||||||
android:text="@string/grade_summary_final_average"
|
android:text="@string/grade_summary_final_average"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -103,8 +159,8 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/gradeSummaryScrollableHeaderFinalSubjectCount"
|
android:id="@+id/gradeSummaryScrollableHeaderFinalSubjectCount"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textSize="13sp"
|
android:textSize="13sp"
|
||||||
tools:text="from 5 subjects" />
|
tools:text="from 5 subjects" />
|
||||||
|
@ -126,13 +126,17 @@
|
|||||||
<string name="grade_comment">Comment</string>
|
<string name="grade_comment">Comment</string>
|
||||||
<string name="grade_number_new_items">Number of new ratings: %1$d</string>
|
<string name="grade_number_new_items">Number of new ratings: %1$d</string>
|
||||||
<string name="grade_average">Average: %1$.2f</string>
|
<string name="grade_average">Average: %1$.2f</string>
|
||||||
|
<string name="grade_average_year">Year: %1$.2f</string>
|
||||||
<string name="grade_points_sum">Points: %s</string>
|
<string name="grade_points_sum">Points: %s</string>
|
||||||
<string name="grade_no_average">No average</string>
|
<string name="grade_no_average">No average</string>
|
||||||
|
<string name="grade_summary_average_semester">Semester average</string>
|
||||||
|
<string name="grade_summary_average_year">Annual average</string>
|
||||||
<string name="grade_summary_points">Total points</string>
|
<string name="grade_summary_points">Total points</string>
|
||||||
<string name="grade_summary_final_grade">Final grade</string>
|
<string name="grade_summary_final_grade">Final grade</string>
|
||||||
<string name="grade_summary_predicted_grade">Predicted grade</string>
|
<string name="grade_summary_predicted_grade">Predicted grade</string>
|
||||||
<string name="grade_summary_descriptive">Descriptive grade</string>
|
<string name="grade_summary_descriptive">Descriptive grade</string>
|
||||||
<string name="grade_summary_calculated_average">Calculated average</string>
|
<string name="grade_summary_calculated_average">Calculated semester average</string>
|
||||||
|
<string name="grade_summary_calculated_average_annual">Calculated annual average</string>
|
||||||
<string name="grade_summary_calculated_average_help_dialog_title">How does Calculated Average work?</string>
|
<string name="grade_summary_calculated_average_help_dialog_title">How does Calculated Average work?</string>
|
||||||
<string name="grade_summary_calculated_average_help_dialog_message">The Calculated Average is the arithmetic average calculated from the subjects averages. It allows you to know the approximate final average. It is calculated in a way selected by the user in the application settings. It is recommended that you choose the appropriate option. This is because the calculation of school averages differs. Additionally, if your school reports the average of the subjects on the Vulcan page, the application downloads them and does not calculate these averages. This can be changed by forcing the calculation of the average in the application settings.\n\n<b>Average of grades only from selected semester</b>:\n1. Calculating the weighted average for each subject in a given semester\n2.Adding calculated averages\n3. Calculation of the arithmetic average of the summed averages\n\n<b>Average of averages from both semesters</b>:\n1.Calculating the weighted average for each subject in semester 1 and 2\n2. Calculating the arithmetic average of the calculated averages for semesters 1 and 2 for each subject.\n3. Adding calculated averages\n4. Calculation of the arithmetic average of the summed averages\n\n<b>Average of grades from the whole year:</b>\n1. Calculating weighted average over the year for each subject. The final average in the 1st semester is irrelevant.\n2. Adding calculated averages\n3. Calculating the arithmetic average of summed averages</string>
|
<string name="grade_summary_calculated_average_help_dialog_message">The Calculated Average is the arithmetic average calculated from the subjects averages. It allows you to know the approximate final average. It is calculated in a way selected by the user in the application settings. It is recommended that you choose the appropriate option. This is because the calculation of school averages differs. Additionally, if your school reports the average of the subjects on the Vulcan page, the application downloads them and does not calculate these averages. This can be changed by forcing the calculation of the average in the application settings.\n\n<b>Average of grades only from selected semester</b>:\n1. Calculating the weighted average for each subject in a given semester\n2.Adding calculated averages\n3. Calculation of the arithmetic average of the summed averages\n\n<b>Average of averages from both semesters</b>:\n1.Calculating the weighted average for each subject in semester 1 and 2\n2. Calculating the arithmetic average of the calculated averages for semesters 1 and 2 for each subject.\n3. Adding calculated averages\n4. Calculation of the arithmetic average of the summed averages\n\n<b>Average of grades from the whole year:</b>\n1. Calculating weighted average over the year for each subject. The final average in the 1st semester is irrelevant.\n2. Adding calculated averages\n3. Calculating the arithmetic average of summed averages</string>
|
||||||
<string name="grade_summary_final_average_help_dialog_title">How does the Final Average work?</string>
|
<string name="grade_summary_final_average_help_dialog_title">How does the Final Average work?</string>
|
||||||
|
@ -1679,7 +1679,9 @@ class GradeAverageProviderTest {
|
|||||||
finalPoints = "",
|
finalPoints = "",
|
||||||
finalGrade = "",
|
finalGrade = "",
|
||||||
predictedGrade = "",
|
predictedGrade = "",
|
||||||
position = 0
|
position = 0,
|
||||||
|
pointsSumAllYear = null,
|
||||||
|
averageAllYear = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,15 @@ class GradeExtensionTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun calcWeightedAverage() {
|
fun calcWeightedAverage() {
|
||||||
assertEquals(3.47, listOf(
|
assertEquals(
|
||||||
createGrade(5.0, 6.0, 0.33),
|
3.47, listOf(
|
||||||
createGrade(5.0, 5.0, -0.33),
|
createGrade(5.0, 6.0, 0.33),
|
||||||
createGrade(4.0, 1.0, 0.0),
|
createGrade(5.0, 5.0, -0.33),
|
||||||
createGrade(1.0, 9.0, 0.5),
|
createGrade(4.0, 1.0, 0.0),
|
||||||
createGrade(0.0, .0, 0.0)
|
createGrade(1.0, 9.0, 0.5),
|
||||||
).calcAverage(false), 0.005)
|
createGrade(0.0, .0, 0.0)
|
||||||
|
).calcAverage(false), 0.005
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -86,7 +88,11 @@ class GradeExtensionTest {
|
|||||||
assertEquals(-.25, createGrade(5.0, .0, -.33).changeModifier(.0, .25).modifier, .0)
|
assertEquals(-.25, createGrade(5.0, .0, -.33).changeModifier(.0, .25).modifier, .0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createGrade(value: Double, weightValue: Double = .0, modifier: Double = 0.25): Grade {
|
private fun createGrade(
|
||||||
|
value: Double,
|
||||||
|
weightValue: Double = .0,
|
||||||
|
modifier: Double = 0.25
|
||||||
|
): Grade {
|
||||||
return Grade(
|
return Grade(
|
||||||
semesterId = 1,
|
semesterId = 1,
|
||||||
studentId = 1,
|
studentId = 1,
|
||||||
@ -116,7 +122,9 @@ class GradeExtensionTest {
|
|||||||
proposedPoints = "",
|
proposedPoints = "",
|
||||||
finalPoints = "",
|
finalPoints = "",
|
||||||
pointsSum = "",
|
pointsSum = "",
|
||||||
average = .0
|
average = .0,
|
||||||
|
pointsSumAllYear = null,
|
||||||
|
averageAllYear = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user