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

Not display success user code run status #890

Merged
merged 1 commit into from
Feb 4, 2021
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 @@ -69,11 +69,6 @@ final class CodeQuizFullscreenRunCodePresenter: CodeQuizFullscreenRunCodePresent
}
}()

let isTestOutputMatchesSampleOutput = samples
.first(where: { $0.input == userCodeRun.stdin })?
.output.trimmingCharacters(in: .whitespacesAndNewlines)
== testOutput?.trimmingCharacters(in: .whitespacesAndNewlines)

let shouldShowTestOutput = userCodeRun.status == .failure || userCodeRun.status == .success

let isSamplesButtonEnabled = userCodeRun.status != .evaluation && !samples.isEmpty
Expand All @@ -87,7 +82,6 @@ final class CodeQuizFullscreenRunCodePresenter: CodeQuizFullscreenRunCodePresent
testInput: userCodeRun.stdin,
testOutput: testOutput,
userCodeRunStatus: userCodeRun.status,
isTestOutputMatchesSampleOutput: isTestOutputMatchesSampleOutput,
shouldShowTestInput: userCodeRun.language != .sql,
shouldShowTestOutput: shouldShowTestOutput,
isSamplesButtonEnabled: isSamplesButtonEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ final class CodeQuizFullscreenRunCodeView: UIView {
self.samplesButton.isEnabled = viewModel.isSamplesButtonEnabled
self.isRunCodeButtonEnabled = viewModel.isRunCodeButtonEnabled

self.updateTestOutputCard(
userCodeRunStatus: viewModel.userCodeRunStatus,
isTestOutputMatchesSampleOutput: viewModel.isTestOutputMatchesSampleOutput
)
self.updateTestOutputCard(userCodeRunStatus: viewModel.userCodeRunStatus)

self.testInputTextView.isEditable = viewModel.userCodeRunStatus == .evaluation ? false : true
self.evaluationView.isHidden = viewModel.userCodeRunStatus == .evaluation ? false : true
Expand Down Expand Up @@ -220,20 +217,14 @@ final class CodeQuizFullscreenRunCodeView: UIView {
return view
}

private func updateTestOutputCard(userCodeRunStatus: UserCodeRun.Status?, isTestOutputMatchesSampleOutput: Bool) {
private func updateTestOutputCard(userCodeRunStatus: UserCodeRun.Status?) {
let (image, tintColor, backgroundColor): (UIImage?, UIColor, UIColor) = {
if userCodeRunStatus == .failure {
return (
UIImage(named: "quiz-mark-wrong"),
UIColor.stepikLightRedFixed,
UIColor.quizElementWrongBackground
)
} else if userCodeRunStatus == .success && isTestOutputMatchesSampleOutput {
return (
UIImage(named: "quiz-feedback-correct"),
UIColor.stepikCallToActionText,
UIColor.quizElementCorrectBackground
)
} else {
return (
UIImage(named: "console"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ struct CodeQuizFullscreenRunCodeViewModel {
let testInput: String?
let testOutput: String?
let userCodeRunStatus: UserCodeRun.Status?
let isTestOutputMatchesSampleOutput: Bool
let shouldShowTestInput: Bool
let shouldShowTestOutput: Bool
let isSamplesButtonEnabled: Bool
Expand Down