diff --git a/app/build.gradle b/app/build.gradle index 04da2d8270..c8fdf45da2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2127 - versionName "0.21.27" + versionCode 2128 + versionName "0.21.28" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/model/RealmSubmission.kt b/app/src/main/java/org/ole/planet/myplanet/model/RealmSubmission.kt index ba34e3b34b..f36ec0262c 100644 --- a/app/src/main/java/org/ole/planet/myplanet/model/RealmSubmission.kt +++ b/app/src/main/java/org/ole/planet/myplanet/model/RealmSubmission.kt @@ -204,12 +204,25 @@ open class RealmSubmission : RealmObject() { } } + fun generateParentId(courseId: String?, examId: String?): String? { + return if (!examId.isNullOrEmpty()) { + if (!courseId.isNullOrEmpty()) { + "$examId@$courseId" + } else { + examId + } + } else { + null + } + } + @JvmStatic - fun getNoOfSubmissionByUser(id: String?, userId: String?, mRealm: Realm): String { + fun getNoOfSubmissionByUser(id: String?, courseId:String?, userId: String?, mRealm: Realm): String { if (id == null || userId == null) return "No Submissions Found" - + val submissionParentId= generateParentId(courseId, id) + if(submissionParentId.isNullOrEmpty()) return "No Submissions Found" val submissionCount = mRealm.where(RealmSubmission::class.java) - .equalTo("parentId", id) + .equalTo("parentId", submissionParentId) .equalTo("userId", userId) .equalTo("status", "complete") .count().toInt() @@ -230,15 +243,15 @@ open class RealmSubmission : RealmObject() { } @JvmStatic - fun getRecentSubmissionDate(id: String?, userId: String?, mRealm: Realm): String { + fun getRecentSubmissionDate(id: String?, courseId:String?, userId: String?, mRealm: Realm): String { if (id == null || userId == null) return "" - + val submissionParentId= generateParentId(courseId, id) + if(submissionParentId.isNullOrEmpty()) return "" val recentSubmission = mRealm.where(RealmSubmission::class.java) - .equalTo("parentId", id) + .equalTo("parentId", submissionParentId) .equalTo("userId", userId) .sort("startTime", Sort.DESCENDING) .findFirst() - return recentSubmission?.startTime?.let { TimeUtils.getFormatedDateWithTime(it) } ?: "" } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt b/app/src/main/java/org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt index e4551d0ae7..b618711e36 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt @@ -85,8 +85,8 @@ class AdapterSurvey(private val context: Context, private val mRealm: Realm, pri startSurvey.visibility = View.GONE } - tvNoSubmissions.text = getNoOfSubmissionByUser(exam.id, user?.id, mRealm) - tvDateCompleted.text = getRecentSubmissionDate(exam.id, user?.id, mRealm) + tvNoSubmissions.text = getNoOfSubmissionByUser(exam.id, exam.courseId, user?.id, mRealm) + tvDateCompleted.text = getRecentSubmissionDate(exam.id, exam.courseId, user?.id, mRealm) tvDate.text = formatDate(RealmStepExam.getSurveyCreationTime(exam.id!!, mRealm)!!, "MMM dd, yyyy") } }