Skip to content

added a countdown timer for passing the test#20

Open
amsak1983 wants to merge 1 commit intomainfrom
lesson18_countdown_timer
Open

added a countdown timer for passing the test#20
amsak1983 wants to merge 1 commit intomainfrom
lesson18_countdown_timer

Conversation

@amsak1983
Copy link
Owner

No description provided.

@amsak1983 amsak1983 force-pushed the lesson18_countdown_timer branch from 7941b32 to b797636 Compare April 22, 2025 13:57
def accept!(answer_ids)
self.correct_questions += 1 if correct_answer?(answer_ids)

set_first_or_next_question

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этого и след метода не должно быть в этом методе. метод accept только подсчет правильности ведет. не надо в него подмешить другую лоигку. нарушаешь принцип единоотвественности и преврашаешь метод в ниндзя метод, который помимо очевидной вещи из названия под капотом делает еще какую-то магию


def percentage_completion
(self.correct_questions / questions_count.to_f * 100).round
self.score = (self.correct_questions / questions_count.to_f * 100).round

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем это в переменную сохранять? как ты это используешь потом?

@@ -0,0 +1,5 @@
class AddStateToTestPassage < ActiveRecord::Migration[7.0]
def change
add_column :test_passages, :state, :integer, default: 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как будто усложняешь. тесты либо пройден, либо нет. зачем тебе знать по времени не пройден или по другой какой-то еще причине?

@@ -0,0 +1,5 @@
class AddDurationToTests < ActiveRecord::Migration[7.0]
def change
add_column :tests, :duration, :integer, default: 900 # Default duration is 15 minutes (in seconds)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обычно дефолтное значинем ставим 0, когда тест можно бесконечно проходить

<td><%= test.category.title %></td>
<td><%= t("tests.levels.#{test.level}") %></td>
<td data-inline-edit-target="duration">
<%= test.duration / 60 %> минут <!-- Display duration in minutes -->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test.duration / 60 на этой вьюхе вызывает несколько раз. можно сохранить в переменную.
если что на вьюхах тоже можно переменные задавать, не только в контроллере

@amsak1983 amsak1983 force-pushed the lesson18_countdown_timer branch from b797636 to 1e5f8a6 Compare April 23, 2025 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants