-
Notifications
You must be signed in to change notification settings - Fork 3
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
Quiz selection functionality #57
Conversation
# Conflicts: # testomania/src/main/java/com/earth/testomania/technical/presentation/TechnicalTestsScreen.kt # testomania/src/main/java/com/earth/testomania/technical/presentation/ui_parts/QuizUI.kt
testomania/src/main/java/com/earth/testomania/technical/domain/model/SelectedAnswer.kt
Show resolved
Hide resolved
testomania/src/main/java/com/earth/testomania/technical/presentation/QuizViewModel.kt
Outdated
Show resolved
Hide resolved
fun isCorrectAnswer( | ||
techQuizWrapper: TechQuizWrapper, | ||
possibleAnswerKey: String | ||
) = techQuizWrapper.quiz.correctAnswers[possibleAnswerKey] ?: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this method in TechQuiz class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well TechQuiz
is just a model and should stay that way, but is selected answer correct or not is business logic, so it should be in ViewModel, logic of is correct or not can be changed in the future, like if answers will be differentiated with numbers and not letters, just for example, so yea I think fun isCorrectAnswer
should remain in ViewModel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not agree with you. As I know TechQuiz is an object which has question, possible answers and correct answer, so adding one method for checking correctnes of answers, is more modular and convinient. I'm not asking to add it in dto model, but there should be no problem for adding it in presentation model. I hope that logic for determaining if answer is correct or not is same, there this model is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you mean domain/model/TechQuiz.kt and not presentation layer. am I right? @kdiakonidze
If we do that then we need an interface with a defined method isCorrectAnswer
and I think that is a generalization of TechQuiz.kt
which I agree with, but we need more conversation on that, meanwhile I think we can leave it in ViewModel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, domain model. If you use isCorrectAnswer method only one place, than ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for now it is only defined in this viewmodel and is used in only one compose function
testomania/src/main/java/com/earth/testomania/technical/presentation/QuizViewModel.kt
Outdated
Show resolved
Hide resolved
techQuizWrapper.multiSelectionWasDone.value = true | ||
} | ||
|
||
private fun saveMultiSelectQuizPoint(techQuizWrapper: TechQuizWrapper) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method also can be moved to TechQuiz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can say same as in case of isCorrectAnswer
function above.
TechQuiz
is Model and saveMultiSelectQuizPoint
is buisness logic, which can vary in case of different tests
# Conflicts: # testomania/src/main/java/com/earth/testomania/technical/presentation/TechnicalTestsScreen.kt # testomania/src/main/java/com/earth/testomania/technical/presentation/ui_parts/QuizAnswerUI.kt # testomania/src/main/java/com/earth/testomania/technical/presentation/ui_parts/QuizUI.kt
No description provided.