Skip to content
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

ALTAPPS-1308: Shared speed up code submissions evaluation for beginners by removing linters #1125

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ extension Reply {
solution: solution,
checkProfile: checkProfile,
lines: lines,
prompt: nil
prompt: nil,
lintProfile: nil
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ class StepQuizCodeViewModel: ObservableObject {
extension StepQuizCodeViewModel: StepQuizChildQuizInputProtocol {
@objc
func createReply() -> Reply {
Reply(language: viewData.languageStringValue, code: viewData.code)
Reply.Companion.shared.code(
code: viewData.code,
language: viewData.languageStringValue,
lintProfile: nil
)
}

func update(step: Step, dataset: Dataset, reply: Reply?) {
Expand Down Expand Up @@ -148,7 +152,11 @@ extension StepQuizCodeViewModel: StepQuizCodeFullScreenOutputProtocol {

@objc
func syncReply(code: String?) {
let reply = Reply.Companion.shared.code(code: code, language: viewData.languageStringValue)
let reply = Reply.Companion.shared.code(
code: code,
language: viewData.languageStringValue,
lintProfile: nil
)
moduleOutput?.handleChildQuizSync(reply: reply)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ data class Reply(
@SerialName("lines")
val lines: List<ParsonsLine>? = null,
@SerialName("prompt")
val prompt: String? = null
val prompt: String? = null,
@SerialName("lint_profile")
val lintProfile: String? = ""
) {

companion object {
internal const val PROMPT_MANUALLY_CONFIRMED_SCORE: Float = 1F

fun code(code: String?, language: String?): Reply =
Reply(code = code, language = language)
fun code(code: String?, language: String?, lintProfile: String? = null): Reply =
Reply(code = code, language = language, lintProfile = lintProfile)

fun sql(sqlCode: String?): Reply =
Reply(solveSql = sqlCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.hyperskill
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonNull
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.buildJsonObject
Expand Down Expand Up @@ -298,4 +299,56 @@ class ReplySerializationTest {
)
assertEquals(expectedReply, decodedReply)
}

@Test
fun `Code Reply serialization with nullable lint_profile`() {
val json = NetworkModule.provideJson()
val encodedValue = json.encodeToJsonElement(
Reply.code(
code = "code",
language = "language"
)
)
val expected = buildJsonObject {
put("code", JsonPrimitive("code"))
put("language", JsonPrimitive("language"))
put("lint_profile", JsonNull)
}
assertEquals(expected, encodedValue)
}

@Test
fun `Code Reply serialization with provided lint_profile`() {
val json = NetworkModule.provideJson()
val encodedValue = json.encodeToJsonElement(
Reply.code(
code = "code",
language = "language",
lintProfile = "lint_profile"
)
)
val expected = buildJsonObject {
put("code", JsonPrimitive("code"))
put("language", JsonPrimitive("language"))
put("lint_profile", JsonPrimitive("lint_profile"))
}
assertEquals(expected, encodedValue)
}

@Test
fun `Code Reply serialization with default lint_profile`() {
val json = NetworkModule.provideJson()
val encodedValue = json.encodeToJsonElement(
Reply.code(
code = "code",
language = "language",
lintProfile = ""
)
)
val expected = buildJsonObject {
put("code", JsonPrimitive("code"))
put("language", JsonPrimitive("language"))
}
assertEquals(expected, encodedValue)
}
}
Loading