Skip to content

Commit 034d8d5

Browse files
fix: changes according demo feedback
1 parent 38977a2 commit 034d8d5

File tree

5 files changed

+64
-23
lines changed

5 files changed

+64
-23
lines changed

core/src/main/java/org/openedx/core/data/api/CourseApi.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ interface CourseApi {
108108
@Path("username") username: String
109109
): List<DownloadCoursePreview>
110110

111-
112111
@GET("/api/course_home/progress/{course_id}")
113112
suspend fun getCourseProgress(
114113
@Path("course_id") courseId: String,

core/src/main/java/org/openedx/core/data/model/CourseProgressResponse.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ data class CourseProgressResponse(
9494
@SerializedName("status_date") val statusDate: String?
9595
)
9696

97+
@Suppress("LongMethod")
9798
fun mapToDomain(): CourseProgress {
9899
return CourseProgress(
99100
verifiedMode = verifiedMode ?: "",
@@ -172,6 +173,7 @@ data class CourseProgressResponse(
172173
)
173174
}
174175

176+
@Suppress("LongMethod, CyclomaticComplexMethod")
175177
fun mapToRoomEntity(courseId: String): CourseProgressEntity {
176178
return CourseProgressEntity(
177179
courseId = courseId,

core/src/main/java/org/openedx/core/data/model/room/CourseProgressEntity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ data class CourseProgressEntity(
4848
@ColumnInfo("assignment_colors")
4949
val assignmentColors: List<String>?
5050
) {
51+
@Suppress("LongMethod")
5152
fun mapToDomain(): CourseProgress {
5253
return CourseProgress(
5354
verifiedMode = verifiedMode,

course/src/main/java/org/openedx/course/presentation/progress/CourseProgressScreen.kt

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Arrangement
77
import androidx.compose.foundation.layout.Box
88
import androidx.compose.foundation.layout.Column
99
import androidx.compose.foundation.layout.IntrinsicSize
10+
import androidx.compose.foundation.layout.PaddingValues
1011
import androidx.compose.foundation.layout.Row
1112
import androidx.compose.foundation.layout.Spacer
1213
import androidx.compose.foundation.layout.fillMaxHeight
@@ -28,6 +29,8 @@ import androidx.compose.material.MaterialTheme
2829
import androidx.compose.material.Scaffold
2930
import androidx.compose.material.Surface
3031
import androidx.compose.material.Text
32+
import androidx.compose.material.icons.Icons
33+
import androidx.compose.material.icons.automirrored.outlined.InsertDriveFile
3134
import androidx.compose.material.rememberScaffoldState
3235
import androidx.compose.runtime.Composable
3336
import androidx.compose.runtime.collectAsState
@@ -44,6 +47,7 @@ import androidx.compose.ui.res.stringResource
4447
import androidx.compose.ui.text.SpanStyle
4548
import androidx.compose.ui.text.buildAnnotatedString
4649
import androidx.compose.ui.text.font.FontWeight
50+
import androidx.compose.ui.text.style.TextAlign
4751
import androidx.compose.ui.text.withStyle
4852
import androidx.compose.ui.unit.Dp
4953
import androidx.compose.ui.unit.dp
@@ -61,6 +65,8 @@ import org.openedx.foundation.presentation.UIMessage
6165
import org.openedx.foundation.presentation.WindowSize
6266
import org.openedx.foundation.presentation.windowSizeValue
6367

68+
const val EMPTY_STATE_VIEW_HEIGHT = 0.4f
69+
6470
@Composable
6571
fun CourseProgressScreen(
6672
windowSize: WindowSize,
@@ -103,30 +109,27 @@ private fun CourseProgressContent(
103109
)
104110
}
105111

106-
HandleUIMessage(uiMessage = uiMessage, scaffoldState = scaffoldState)
107-
108112
Box(
109-
modifier = Modifier
113+
modifier = screenWidth
110114
.fillMaxSize()
115+
.background(MaterialTheme.appColors.background)
111116
.padding(it)
112117
.displayCutoutForLandscape(),
113118
contentAlignment = Alignment.TopCenter
114119
) {
115-
Surface(
116-
modifier = screenWidth,
117-
color = MaterialTheme.appColors.background
120+
LazyColumn(
121+
modifier = Modifier
122+
.fillMaxSize()
123+
.padding(horizontal = 16.dp),
124+
verticalArrangement = Arrangement.spacedBy(16.dp),
125+
contentPadding = PaddingValues(vertical = 16.dp)
118126
) {
119-
LazyColumn(
120-
modifier = Modifier
121-
.fillMaxSize()
122-
.padding(16.dp),
123-
verticalArrangement = Arrangement.spacedBy(16.dp)
124-
) {
125-
item {
126-
CourseCompletionView(
127-
progress = uiState.progress
128-
)
129-
}
127+
item {
128+
CourseCompletionView(
129+
progress = uiState.progress
130+
)
131+
}
132+
if (uiState.progress.gradingPolicy.assignmentPolicies.isNotEmpty()) {
130133
item {
131134
OverallGradeView(
132135
progress = uiState.progress,
@@ -156,12 +159,45 @@ private fun CourseProgressContent(
156159
progress = uiState.progress
157160
)
158161
}
162+
} else {
163+
item {
164+
Box(
165+
modifier = Modifier
166+
.fillParentMaxHeight(EMPTY_STATE_VIEW_HEIGHT)
167+
.fillMaxWidth(),
168+
contentAlignment = Alignment.Center
169+
) {
170+
NoGradesView()
171+
}
172+
}
159173
}
160174
}
161175
}
176+
177+
HandleUIMessage(uiMessage = uiMessage, scaffoldState = scaffoldState)
162178
}
163179
}
164180

181+
@Composable
182+
private fun NoGradesView() {
183+
Column(
184+
horizontalAlignment = Alignment.CenterHorizontally
185+
) {
186+
Icon(
187+
modifier = Modifier.size(60.dp),
188+
imageVector = Icons.AutoMirrored.Outlined.InsertDriveFile,
189+
contentDescription = null,
190+
tint = MaterialTheme.appColors.divider
191+
)
192+
Spacer(modifier = Modifier.height(12.dp))
193+
Text(
194+
text = stringResource(R.string.course_progress_no_assignments),
195+
style = MaterialTheme.appTypography.titleMedium,
196+
color = MaterialTheme.appColors.textDark,
197+
textAlign = TextAlign.Center
198+
)
199+
}
200+
}
165201

166202
@Composable
167203
private fun GradeDetailsHeaderView() {
@@ -263,9 +299,11 @@ private fun OverallGradeView(
263299
progress.gradingPolicy.assignmentPolicies.forEach { assignmentPolicy ->
264300
val assignmentColors = progress.assignmentColors
265301
val color = if (assignmentColors.isNotEmpty()) {
266-
assignmentColors[progress.gradingPolicy.assignmentPolicies.indexOf(
267-
assignmentPolicy
268-
) % assignmentColors.size]
302+
assignmentColors[
303+
progress.gradingPolicy.assignmentPolicies.indexOf(
304+
assignmentPolicy
305+
) % assignmentColors.size
306+
]
269307
} else {
270308
MaterialTheme.appColors.primary
271309
}
@@ -440,8 +478,8 @@ private fun AssignmentTypeRow(
440478
Text(
441479
text = stringResource(
442480
R.string.progress_earned_possible_assignment_problems,
443-
earned,
444-
possible
481+
earned.toInt(),
482+
possible.toInt()
445483
),
446484
style = MaterialTheme.appTypography.bodySmall,
447485
color = MaterialTheme.appColors.textDark,

course/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@
8080
<string name="progress_earned_possible_assignment_problems">%1$s / %2$s Complete</string>
8181
<string name="progress_of_grade">of Grade</string>
8282
<string name="progress_current_and_max_weighted_graded_percent">%1$s / %2$s%%</string>
83+
<string name="course_progress_no_assignments">This course does not contain graded assignments.</string>
8384
</resources>

0 commit comments

Comments
 (0)