Skip to content

Commit

Permalink
Merge pull request #1182 from hyperskill/release/1.72
Browse files Browse the repository at this point in the history
Release 1.72
  • Loading branch information
ivan-magda authored Sep 23, 2024
2 parents 5543441 + 9b4ef2e commit 2946f15
Show file tree
Hide file tree
Showing 83 changed files with 1,600 additions and 402 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@ class StepQuizFeedbackBlocksDelegate(
private const val NON_LATEX_HINT_TEMPLATE = """<pre><span style="font-family: 'Roboto';">%s</span></pre>"""
}

private val viewStateDelegate = ViewStateDelegate<StepQuizFeedbackState>()
private val viewStateDelegate = ViewStateDelegate<StepQuizFeedbackState>().apply {
addState<StepQuizFeedbackState.Idle>()
addState<StepQuizFeedbackState.UnsupportedStep>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackUnsupported
)
addState<StepQuizFeedbackState.Evaluation>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackEvaluation,
layoutStepQuizFeedbackBlockBinding.stepQuizCodeExecutionHint
)
addState<StepQuizFeedbackState.Correct>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackCorrect,
layoutStepQuizFeedbackBlockBinding.stepQuizSubmissionHint,
layoutStepQuizFeedbackBlockBinding.stepQuizCodeExecutionHint
)
addState<StepQuizFeedbackState.Wrong>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackWrong,
layoutStepQuizFeedbackBlockBinding.stepQuizSubmissionHint
)
addState<StepQuizFeedbackState.ValidationFailed>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackValidation
)
addState<StepQuizFeedbackState.RejectedSubmission>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackValidation
)
}

init {
with(viewStateDelegate) {
addState<StepQuizFeedbackState.Idle>()
addState<StepQuizFeedbackState.UnsupportedStep>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackUnsupported
)
addState<StepQuizFeedbackState.Evaluation>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackEvaluation
)
addState<StepQuizFeedbackState.Correct>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackCorrect,
layoutStepQuizFeedbackBlockBinding.stepQuizFeedback
)
addState<StepQuizFeedbackState.Wrong>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackWrong,
layoutStepQuizFeedbackBlockBinding.stepQuizFeedback
)
addState<StepQuizFeedbackState.ValidationFailed>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackValidation
)
addState<StepQuizFeedbackState.RejectedSubmission>(
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackValidation
)
}

getEvaluationDrawable(context).let { evaluationDrawable ->
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackEvaluation
.setCompoundDrawablesWithIntrinsicBounds(evaluationDrawable, null, null, null)
Expand All @@ -73,8 +73,11 @@ class StepQuizFeedbackBlocksDelegate(
viewStateDelegate.switchState(state)
layoutStepQuizFeedbackBlockBinding.root.isVisible = state !is StepQuizFeedbackState.Idle
when (state) {
is StepQuizFeedbackState.Evaluation -> {
setHint(state.hint, layoutStepQuizFeedbackBlockBinding)
}
is StepQuizFeedbackState.Correct -> {
setHint(layoutStepQuizFeedbackBlockBinding, state.hint, state.useLatex)
setHint(state.hint, layoutStepQuizFeedbackBlockBinding)
}
is StepQuizFeedbackState.Wrong -> {
with(layoutStepQuizFeedbackBlockBinding) {
Expand Down Expand Up @@ -103,7 +106,7 @@ class StepQuizFeedbackBlocksDelegate(
} else null
)

setHint(layoutStepQuizFeedbackBlockBinding, state.feedbackHint, state.useFeedbackHintLatex)
setHint(state.hint, layoutStepQuizFeedbackBlockBinding)
}
}
is StepQuizFeedbackState.ValidationFailed -> {
Expand All @@ -119,21 +122,61 @@ class StepQuizFeedbackBlocksDelegate(
}

private fun setHint(
layoutStepQuizFeedbackBlockBinding: LayoutStepQuizFeedbackBlockBinding,
hint: String?,
useLatex: Boolean
hint: StepQuizFeedbackState.Hint?,
layoutStepQuizFeedbackBlockBinding: LayoutStepQuizFeedbackBlockBinding
) {
val resultHint = hint?.let {
if (useLatex) {
hint
} else {
String.format(NON_LATEX_HINT_TEMPLATE, hint)
layoutStepQuizFeedbackBlockBinding.stepQuizSubmissionHint.isVisible =
hint is StepQuizFeedbackState.Hint.FromSubmission
layoutStepQuizFeedbackBlockBinding.stepQuizCodeExecutionHint.isVisible =
hint is StepQuizFeedbackState.Hint.FromRunCodeExecution
when (hint) {
is StepQuizFeedbackState.Hint.FromSubmission ->
setRemoteHint(hint, layoutStepQuizFeedbackBlockBinding)
is StepQuizFeedbackState.Hint.FromRunCodeExecution ->
setCodeExecutionHint(hint, layoutStepQuizFeedbackBlockBinding)
null -> {
// no op
}
}
layoutStepQuizFeedbackBlockBinding.stepQuizFeedback.isVisible = resultHint != null
}

private fun setRemoteHint(
hint: StepQuizFeedbackState.Hint.FromSubmission,
layoutStepQuizFeedbackBlockBinding: LayoutStepQuizFeedbackBlockBinding
) {
val resultHint = if (hint.useLatex) {
hint.text
} else {
String.format(NON_LATEX_HINT_TEMPLATE, hint.text)
}
layoutStepQuizFeedbackBlockBinding.stepQuizFeedbackBody.setText(resultHint)
}

private fun setCodeExecutionHint(
hint: StepQuizFeedbackState.Hint.FromRunCodeExecution,
layoutStepQuizFeedbackBlockBinding: LayoutStepQuizFeedbackBlockBinding
) {
with(layoutStepQuizFeedbackBlockBinding) {
val isInputVisible =
hint is StepQuizFeedbackState.Hint.FromRunCodeExecution.Result && hint.input != null
stepQuizCodeExecutionInputTitleTextView.isVisible = isInputVisible
stepQuizCodeExecutionInputValueTextView.isVisible = isInputVisible
if (isInputVisible) {
stepQuizCodeExecutionInputValueTextView.text =
(hint as? StepQuizFeedbackState.Hint.FromRunCodeExecution.Result)?.input
}

val isOutputVisible =
hint is StepQuizFeedbackState.Hint.FromRunCodeExecution.Result
stepQuizCodeExecutionOutputTitleTextView.isVisible = isOutputVisible
stepQuizCodeExecutionOutputValueTextView.isVisible = isOutputVisible
if (isOutputVisible) {
stepQuizCodeExecutionOutputValueTextView.text =
(hint as? StepQuizFeedbackState.Hint.FromRunCodeExecution.Result)?.output
}
}
}

private fun getEvaluationDrawable(context: Context): AnimationDrawable =
AnimationDrawable().apply {
addFrame(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class CommonCodeQuizConfig(private val step: Step) : CodeStepQuizConfig {
?.mapIndexed { i, sample ->
CodeDetail.Sample(
i + 1,
sample.first().trim('\n'),
sample.last().trim('\n')
sample.input.trim('\n'),
sample.output.trim('\n')
)
} ?: emptyList()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
tools:viewBindingIgnore="true">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/stepQuizFeedback"
android:id="@+id/stepQuizSubmissionHint"
style="@style/StepQuizFeedback.Wrong"
android:text="Current quiz type is not supported in mobile app yet"
android:layout_margin="16dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
android:text="@string/step_quiz_status_correct_text" />

<com.google.android.material.card.MaterialCardView
android:id="@+id/stepQuizFeedback"
android:id="@+id/stepQuizSubmissionHint"
android:layout_height="wrap_content"
style="@style/StepQuizFeedback.Feedback"
android:background="@color/color_background"
Expand Down Expand Up @@ -123,4 +123,61 @@

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:id="@+id/stepQuizCodeExecutionHint"
android:layout_height="wrap_content"
style="@style/StepQuizFeedback.Feedback"
android:background="@color/color_background"
android:maxWidth="@dimen/auth_button_max_width"
android:layout_marginTop="20dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">

<TextView
android:id="@+id/stepQuizCodeExecutionTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Body1"
android:text="@string/step_quiz_code_execution_title"
android:layout_marginBottom="7dp"/>

<TextView
android:id="@+id/stepQuizCodeExecutionInputTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Body1"
android:text="@string/step_quiz_code_execution_input"
android:layout_marginBottom="7dp"/>

<TextView
android:id="@+id/stepQuizCodeExecutionInputValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Body1"
tools:text="5"
android:layout_marginBottom="7dp"/>

<TextView
android:id="@+id/stepQuizCodeExecutionOutputTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Body1"
android:text="@string/step_quiz_code_execution_output"
android:layout_marginBottom="7dp"/>

<TextView
android:id="@+id/stepQuizCodeExecutionOutputValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Body1"
tools:text="120" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>

</androidx.appcompat.widget.LinearLayoutCompat>
5 changes: 3 additions & 2 deletions config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
<ID>CyclomaticComplexMethod:LeaderboardWidgetReducer.kt$LeaderboardWidgetReducer$override fun reduce(state: State, message: Message): LeaderboardWidgetReducerResult</ID>
<ID>CyclomaticComplexMethod:LoadingView.kt$LoadingView$override fun onDraw(canvas: Canvas)</ID>
<ID>CyclomaticComplexMethod:ProfileReducer.kt$ProfileReducer$override fun reduce(state: State, message: Message): ReducerResult</ID>
<ID>CyclomaticComplexMethod:StepQuizActionDispatcher.kt$StepQuizActionDispatcher$override suspend fun doSuspendableAction(action: Action)</ID>
<ID>CyclomaticComplexMethod:StepQuizCodeBlanksReducer.kt$StepQuizCodeBlanksReducer$private fun handleDeleteButtonClicked( state: State ): StepQuizCodeBlanksReducerResult?</ID>
<ID>CyclomaticComplexMethod:StepQuizCodeBlanksReducer.kt$StepQuizCodeBlanksReducer$private fun handleSuggestionClicked( state: State, message: Message.SuggestionClicked ): StepQuizCodeBlanksReducerResult?</ID>
<ID>CyclomaticComplexMethod:StepQuizCodeBlanksViewStateMapper.kt$StepQuizCodeBlanksViewStateMapper$private fun mapContentState( state: StepQuizCodeBlanksFeature.State.Content ): StepQuizCodeBlanksViewState.Content</ID>
<ID>CyclomaticComplexMethod:StepQuizHintsReducer.kt$StepQuizHintsReducer$override fun reduce(state: State, message: Message): StepQuizHintsReducerResult</ID>
<ID>CyclomaticComplexMethod:StepQuizReducer.kt$StepQuizReducer$override fun reduce(state: State, message: Message): StepQuizReducerResult</ID>
Expand Down Expand Up @@ -73,6 +71,7 @@
<ID>LongMethod:StepQuizCodeBlanksReducer.kt$StepQuizCodeBlanksReducer$private fun handleSuggestionClicked( state: State, message: Message.SuggestionClicked ): StepQuizCodeBlanksReducerResult?</ID>
<ID>LongMethod:StepQuizCodeBlanksViewStateMapper.kt$StepQuizCodeBlanksViewStateMapper$private fun mapContentState( state: StepQuizCodeBlanksFeature.State.Content ): StepQuizCodeBlanksViewState.Content</ID>
<ID>LongMethod:StreakFreezeDialogFragment.kt$StreakFreezeDialogFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID>
<ID>LongMethod:StudyPlanWidgetReducer.kt$StudyPlanWidgetReducer$private fun handleLearningActivitiesWithSectionsFetchSuccess( state: State, message: StudyPlanWidgetFeature.LearningActivitiesWithSectionsFetchResult.Success ): StudyPlanWidgetReducerResult</ID>
<ID>LongMethod:TrackProgressContent.kt$@Composable fun TrackProgressContent( viewState: ProgressScreenViewState.TrackProgressViewState.Content, onNewMessage: (ProgressScreenFeature.Message) -&gt; Unit, modifier: Modifier = Modifier )</ID>
<ID>LongParameterList:AppInteractor.kt$AppInteractor$( private val appRepository: AppRepository, private val authInteractor: AuthInteractor, private val currentProfileStateRepository: CurrentProfileStateRepository, private val userStorageInteractor: UserStorageInteractor, private val analyticInteractor: AnalyticInteractor, private val progressesRepository: ProgressesRepository, private val trackRepository: TrackRepository, private val providersRepository: ProvidersRepository, private val projectsRepository: ProjectsRepository, private val shareStreakRepository: ShareStreakRepository, private val pushNotificationsInteractor: PushNotificationsInteractor )</ID>
<ID>LongParameterList:AuthRemoteDataSourceImpl.kt$AuthRemoteDataSourceImpl$( private val authCacheMutex: Mutex, private val deauthorizationFlow: Flow&lt;UserDeauthorized&gt;, private val authSocialHttpClient: HttpClient, private val authCredentialsHttpClient: HttpClient, private val networkEndpointConfigInfo: NetworkEndpointConfigInfo, private val json: Json, private val settings: Settings )</ID>
Expand Down Expand Up @@ -261,12 +260,14 @@
<ID>ReturnCount:TopicsRepetitionsActionDispatcher.kt$TopicsRepetitionsActionDispatcher$override suspend fun doSuspendableAction(action: Action)</ID>
<ID>SpreadOperator:StepQuizViewStateDelegateFactory.kt$StepQuizViewStateDelegateFactory$( *listOfNotNull( fragmentStepQuizBinding.stepQuizFeedbackBlocks.root, descriptionBinding?.stepQuizDescription, fragmentStepQuizBinding.stepQuizButtons.stepQuizSubmitButton, *quizViews ).toTypedArray() )</ID>
<ID>SpreadOperator:StepQuizViewStateDelegateFactory.kt$StepQuizViewStateDelegateFactory$( *listOfNotNull( skeletonView, descriptionBinding?.stepQuizDescriptionSkeleton ).toTypedArray() )</ID>
<ID>SwallowedException:Block.kt$e: Exception</ID>
<ID>SwallowedException:NotificationExtensions.kt$e: ActivityNotFoundException</ID>
<ID>SwallowedException:ProfileSettingsDialogFragment.kt$ProfileSettingsDialogFragment$e: ActivityNotFoundException</ID>
<ID>SwallowedException:PushNotificationData.kt$PushNotificationData$e: Exception</ID>
<ID>SwallowedException:TimeIntervalPickerDialogFragment.kt$TimeIntervalPickerDialogFragment$exception: Exception</ID>
<ID>ThrowsCount:FillBlanksResolver.kt$FillBlanksResolver$@Throws(InvalidFillBlanksConfigException::class) fun resolve(dataset: Dataset): FillBlanksMode</ID>
<ID>TooGenericExceptionCaught:BaseStateRepository.kt$BaseStateRepository$e: Exception</ID>
<ID>TooGenericExceptionCaught:Block.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:LatexWebView.kt$LatexWebView$e: Exception</ID>
<ID>TooGenericExceptionCaught:PushNotificationData.kt$PushNotificationData$e: Exception</ID>
<ID>TooGenericExceptionCaught:PushNotificationsInteractor.kt$PushNotificationsInteractor$e: Exception</ID>
Expand Down
4 changes: 2 additions & 2 deletions gradle/app.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
minSdk = '24'
targetSdk = '34'
compileSdk = '34'
versionName = '1.71'
versionCode = '547'
versionName = '1.72'
versionCode = '560'
4 changes: 2 additions & 2 deletions iosHyperskillApp/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleVersion</key>
<string>576</string>
<string>589</string>
<key>CFBundleShortVersionString</key>
<string>1.71</string>
<string>1.72</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleExecutable</key>
Expand Down
Loading

0 comments on commit 2946f15

Please sign in to comment.