-
Notifications
You must be signed in to change notification settings - Fork 38
feat: [FC-0047] Course progress and collapsing sections #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
eb64023
ff0bfd1
78628f5
3d5ff50
9f75619
4989c52
2ca4f5f
0bd69bd
d04c020
442496d
23dcabf
654bcf0
d0feb18
b72fc59
203aee6
84dfdba
8eb71c7
b820e45
6df86fc
1d3203b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.openedx.core.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import org.openedx.core.data.model.room.AssignmentProgressDb | ||
|
||
data class AssignmentProgress( | ||
@SerializedName("assignment_type") | ||
val assignmentType: String?, | ||
@SerializedName("num_points_earned") | ||
val numPointsEarned: Float?, | ||
@SerializedName("num_points_possible") | ||
val numPointsPossible: Float?, | ||
) { | ||
fun mapToDomain() = org.openedx.core.domain.model.AssignmentProgress( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move it to the imports section |
||
assignmentType = assignmentType ?: "", | ||
numPointsEarned = numPointsEarned ?: 0f, | ||
numPointsPossible = numPointsPossible ?: 0f | ||
) | ||
|
||
fun mapToRoomEntity() = AssignmentProgressDb( | ||
assignmentType = assignmentType, | ||
numPointsEarned = numPointsEarned, | ||
numPointsPossible = numPointsPossible | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package org.openedx.core.data.model | |
import com.google.gson.annotations.SerializedName | ||
import org.openedx.core.BlockType | ||
import org.openedx.core.domain.model.Block | ||
import org.openedx.core.utils.TimeUtils | ||
|
||
data class Block( | ||
@SerializedName("id") | ||
|
@@ -33,6 +34,10 @@ data class Block( | |
val completion: Double?, | ||
@SerializedName("contains_gated_content") | ||
val containsGatedContent: Boolean?, | ||
@SerializedName("assignment_progress") | ||
val assignmentProgress: AssignmentProgress?, | ||
@SerializedName("due") | ||
val due: String? | ||
) { | ||
fun mapToDomain(blockData: Map<String, org.openedx.core.data.model.Block>): Block { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move it to the imports section |
||
val blockType = BlockType.getBlockType(type ?: "") | ||
|
@@ -61,7 +66,9 @@ data class Block( | |
studentViewMultiDevice = studentViewMultiDevice ?: false, | ||
blockCounts = blockCounts?.mapToDomain()!!, | ||
completion = completion ?: 0.0, | ||
containsGatedContent = containsGatedContent ?: false | ||
containsGatedContent = containsGatedContent ?: false, | ||
assignmentProgress = assignmentProgress?.mapToDomain(), | ||
due = TimeUtils.iso8601ToDate(due ?: ""), | ||
) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,12 @@ package org.openedx.core.data.model.room | |
import androidx.room.ColumnInfo | ||
import androidx.room.Embedded | ||
import org.openedx.core.BlockType | ||
import org.openedx.core.domain.model.* | ||
import org.openedx.core.domain.model.Block | ||
import org.openedx.core.domain.model.BlockCounts | ||
import org.openedx.core.domain.model.EncodedVideos | ||
import org.openedx.core.domain.model.StudentViewData | ||
import org.openedx.core.domain.model.VideoInfo | ||
import org.openedx.core.utils.TimeUtils | ||
|
||
data class BlockDb( | ||
@ColumnInfo("id") | ||
|
@@ -33,7 +38,11 @@ data class BlockDb( | |
@ColumnInfo("completion") | ||
val completion: Double, | ||
@ColumnInfo("contains_gated_content") | ||
val containsGatedContent: Boolean | ||
val containsGatedContent: Boolean, | ||
@Embedded | ||
val assignmentProgress: AssignmentProgressDb?, | ||
@ColumnInfo("due") | ||
val due: String? | ||
) { | ||
fun mapToDomain(blocks: List<BlockDb>): Block { | ||
val blockType = BlockType.getBlockType(type) | ||
|
@@ -62,7 +71,9 @@ data class BlockDb( | |
descendants = descendants, | ||
descendantsType = descendantsType, | ||
completion = completion, | ||
containsGatedContent = containsGatedContent | ||
containsGatedContent = containsGatedContent, | ||
assignmentProgress = assignmentProgress?.mapToDomain(), | ||
due = TimeUtils.iso8601ToDate(due ?: ""), | ||
) | ||
} | ||
|
||
|
@@ -86,7 +97,9 @@ data class BlockDb( | |
studentViewMultiDevice = studentViewMultiDevice ?: false, | ||
blockCounts = BlockCountsDb.createFrom(blockCounts), | ||
completion = completion ?: 0.0, | ||
containsGatedContent = containsGatedContent ?: false | ||
containsGatedContent = containsGatedContent ?: false, | ||
assignmentProgress = assignmentProgress?.mapToRoomEntity(), | ||
due = due | ||
) | ||
} | ||
} | ||
|
@@ -201,3 +214,18 @@ data class BlockCountsDb( | |
} | ||
} | ||
} | ||
|
||
data class AssignmentProgressDb( | ||
@ColumnInfo("assignment_type") | ||
val assignmentType: String?, | ||
@ColumnInfo("num_points_earned") | ||
val numPointsEarned: Float?, | ||
@ColumnInfo("num_points_possible") | ||
val numPointsPossible: Float?, | ||
) { | ||
fun mapToDomain() = org.openedx.core.domain.model.AssignmentProgress( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move it to the imports section |
||
assignmentType = assignmentType ?: "", | ||
numPointsEarned = numPointsEarned ?: 0f, | ||
numPointsPossible = numPointsPossible ?: 0f | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.openedx.core.domain.model | ||
|
||
data class AssignmentProgress( | ||
val assignmentType: String, | ||
val numPointsEarned: Float, | ||
val numPointsPossible: Float | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,13 @@ data class Progress( | |
val assignmentsCompleted: Int, | ||
val totalAssignmentsCount: Int, | ||
) : Parcelable { | ||
|
||
fun getProgress(): Float = try { | ||
assignmentsCompleted.toFloat() / totalAssignmentsCount.toFloat() | ||
} catch (_: ArithmeticException) { | ||
0f | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about replacing it with a computed property, let's say |
||
|
||
companion object { | ||
val DEFAULT_PROGRESS = Progress(0, 0) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,12 @@ | |
<string name="core_date_format_tomorrow" tools:ignore="MissingTranslation">Tomorrow</string> | ||
<string name="core_date_format_yesterday" tools:ignore="MissingTranslation">Yesterday</string> | ||
<string name="core_date_format_days_ago" tools:ignore="MissingTranslation">%1$s days ago</string> | ||
<string name="core_date_format_past_due_assignment" tools:ignore="MissingTranslation">Past due assignment</string> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused resource |
||
<string name="core_date_format_assignment_due_today" tools:ignore="MissingTranslation">Due Today</string> | ||
<string name="core_date_format_assignment_due_tomorrow" tools:ignore="MissingTranslation">Due Tomorrow</string> | ||
<string name="core_date_format_assignment_due_yesterday" tools:ignore="MissingTranslation">Due Yesterday</string> | ||
<string name="core_date_format_assignment_due_in" tools:ignore="MissingTranslation">Due in %1$s days</string> | ||
<string name="core_date_format_assignment_due_days_ago" tools:ignore="MissingTranslation">Due %1$s days ago</string> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use plurals here for correct translation into other languages |
||
<plurals name="core_date_items_hidden" tools:ignore="MissingTranslation"> | ||
<item quantity="one">%d Item Hidden</item> | ||
<item quantity="other">%d Items Hidden</item> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enables an alternative visual representation for the course structure.
->Enables an alternative navigation through units.