-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
E1770. [TFD] refactor_assignment_participant.rb #1049
Conversation
app/models/assignment_participant.rb
Outdated
@@ -1,6 +1,6 @@ | |||
require 'uri' | |||
require 'yaml' | |||
|
|||
require 'TFD1770_refactor' |
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.
According to this configuration, maybe you do not need to require lib file.
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.
app/models/assignment_participant.rb
Outdated
end | ||
|
||
# methods extracted from scores method:assignment_questionnaires, merge_scores, topic_total_scores, caculate_scores | ||
def assignment_questionnaires(questions, scores) |
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.
It will be better the method name is a verb or an action, instead of a noun.
app/models/assignment_participant.rb
Outdated
caculate_scores(scores) | ||
end | ||
|
||
# methods extracted from scores method:assignment_questionnaires, merge_scores, topic_total_scores, caculate_scores |
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.
Good comment! You could move this comment before the definition of scores
method.
attributes = ImportFileHelper.define_attributes(row) | ||
user = ImportFileHelper.create_new_user(attributes, session) | ||
end | ||
user = AssignmentParticipant.check_info_and_create(row, _row_header = nil, session) |
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.
Good refactoring!
lib/TFD1770_refactor.rb
Outdated
@@ -0,0 +1,28 @@ | |||
module Instance_method |
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.
- It will be better if you rename this file to a reasonable name, instead of
TFD1770_refactor.rb
. - Also, you may need to put these two modules into two lib files since they are quite different.
- Also rename the module names to reasonable names, instead of
Instance_method
andClass_method
.
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 will fix them ASAP, Thank you!
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 have finished all the modifications except deleting "require", because if I delete it, the test will not be passed. Can you explain this why I cannot delete it?
Hi team,
Thanks, |
first try