Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions core/src/main/java/in/testpress/database/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import `in`.testpress.database.roommigration.RoomMigration20To21.MIGRATION_20_21
import `in`.testpress.database.roommigration.RoomMigration21To22.MIGRATION_21_22
import `in`.testpress.database.roommigration.RoomMigration22To23.MIGRATION_22_23
import `in`.testpress.database.roommigration.RoomMigration23To24.MIGRATION_23_24
import `in`.testpress.database.roommigration.RoomMigration24To25.MIGRATION_24_25

@Database(version = 24,
@Database(version = 25,
entities = [
ContentEntity::class,
OfflineVideo::class,
Expand Down Expand Up @@ -59,7 +60,8 @@ import `in`.testpress.database.roommigration.RoomMigration23To24.MIGRATION_23_24
OfflineExam::class,
OfflineCourseAttempt::class,
OfflineAttempt::class,
OfflineAttemptSection::class
OfflineAttemptSection::class,
OfflineAttemptItem::class
], exportSchema = true)
@TypeConverters(Converters::class)
abstract class TestpressDatabase : RoomDatabase() {
Expand All @@ -84,6 +86,7 @@ abstract class TestpressDatabase : RoomDatabase() {
abstract fun offlineCourseAttemptDao():OfflineCourseAttemptDao
abstract fun offlineAttemptDao():OfflineAttemptDao
abstract fun offlineAttemptSectionDao():OfflineAttemptSectionDao
abstract fun offlineAttemptItemDoa(): OfflineAttemptItemDao

companion object {
private lateinit var INSTANCE: TestpressDatabase
Expand All @@ -92,7 +95,8 @@ abstract class TestpressDatabase : RoomDatabase() {
MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13, MIGRATION_13_14,
MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17, MIGRATION_17_18, MIGRATION_18_19,
MIGRATION_19_20, MIGRATION_20_21, MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24
MIGRATION_19_20, MIGRATION_20_21, MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24,
MIGRATION_24_25
)

operator fun invoke(context: Context): TestpressDatabase {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package `in`.testpress.database.dao

import `in`.testpress.database.BaseDao
import `in`.testpress.database.entities.OfflineAttemptItem
import androidx.room.Dao

@Dao
interface OfflineAttemptItemDao : BaseDao<OfflineAttemptItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package `in`.testpress.database.entities

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity
data class OfflineAttemptItem(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var question: Question,
var selectedAnswers: List<Int> = arrayListOf(),
var review: Boolean? = null,
var savedAnswers: List<Int> = arrayListOf(),
var order: Int,
var shortText: String? = null,
var currentShortText: String? = null,
var attemptSection: OfflineAttemptSection? = null,
var essayText: String? = null,
var localEssayText: String? = null,
var files: ArrayList<OfflineUserUploadedFile> = arrayListOf(),
var unSyncedFiles: List<String> = arrayListOf(),
var attemptId: Long
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package `in`.testpress.database.entities

data class OfflineUserUploadedFile(
val id: Long? = null,
val url: String? = null,
val path: String? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package `in`.testpress.database.roommigration

import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase

object RoomMigration24To25 {
val MIGRATION_24_25: Migration = object : Migration(24, 25) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("CREATE TABLE IF NOT EXISTS `OfflineAttemptItem` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `question` TEXT NOT NULL, `selectedAnswers` TEXT NOT NULL, `review` INTEGER, `savedAnswers` TEXT NOT NULL, `order` INTEGER NOT NULL, `shortText` TEXT, `currentShortText` TEXT, `attemptSection` TEXT, `essayText` TEXT, `localEssayText` TEXT, `files` TEXT NOT NULL, `unSyncedFiles` TEXT NOT NULL, `attemptId` INTEGER NOT NULL)")
}
}
}