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
E1959.Intelligent copying of assignments without topics (Issue #1341) #1524
Conversation
Generated by expertiza-bot |
Hey @subhasekhar, |
app/models/assignment_form.rb
Outdated
questionnaire_weight: aq.questionnaire_weight, | ||
used_in_round: aq.used_in_round, | ||
dropdown: aq.dropdown | ||
assignment_id: new_assign.id, |
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.
Indent the first parameter one step more than the start of the previous line.
app/models/assignment_form.rb
Outdated
) | ||
end | ||
end | ||
end | ||
|
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.
1 trailing blank lines detected.
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.
Removed.
app/models/assignment_form.rb
Outdated
if copytopics == 'Y' | ||
topics = SignUpTopic.where(assignment_id: old_assign.id) | ||
topics.each do |topic| | ||
SignUpTopic.create(topic_name: topic.topic_name, assignment_id: new_assign_id, max_choosers: topic.max_choosers, category: topic.category, topic_identifier: topic.topic_identifier, micropayment: topic.micropayment) |
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.
Line is too long. [224/160]
@assignment_id = params[:id] | ||
end | ||
|
||
def copy#Issue #1341 - Might require to modify below code |
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.
Missing space after #
.
@assignment_id = params[:id] | ||
end | ||
|
||
def copy#Issue #1341 - Might require to modify below code |
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.
Put a space before an end-of-line comment.
@@ -380,4 +385,4 @@ def update_feedback_assignment_form_attributes | |||
def assignment_form_params | |||
params.require(:assignment_form).permit! | |||
end | |||
end | |||
end |
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.
Final newline missing.
@assignment_id = params[:id] | ||
end | ||
|
||
def copy#Issue #1341 - Might require to modify below code |
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.
Do not place comments on the same line as the def
keyword.
Code Climate has analyzed commit f6c084e and detected 2 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 22.2% (50% is the threshold). This pull request will bring the total coverage in the repository to 29.9% (-22.0% change). View more on Code Climate. |
…assignment_form.rb
@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay) | |||
end | |||
|
|||
# Copies the inputted assignment into new one and returns the new assignment id | |||
def self.copy(assignment_id, user) | |||
def self.copy(assignment_id, copyoption, user) |
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.
Method copy
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay) | |||
end | |||
|
|||
# Copies the inputted assignment into new one and returns the new assignment id | |||
def self.copy(assignment_id, user) | |||
def self.copy(assignment_id, copyoption, user) |
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.
Method copy
has 33 lines of code (exceeds 25 allowed). Consider refactoring.
app/models/assignment_form.rb
Outdated
dropdown: aq.dropdown | ||
) | ||
AssignmentQuestionnaire.create( | ||
assignment_id: new_assign.id, |
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.
Indent the first parameter one step more than the start of the previous line.
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.
Solved.
app/models/assignment_form.rb
Outdated
used_in_round: aq.used_in_round, | ||
dropdown: aq.dropdown | ||
) | ||
AssignmentQuestionnaire.create( |
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.
Use 2 (not 4) spaces for indentation.
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.
Solved.
app/models/assignment_form.rb
Outdated
if copyoption != 'copyWithoutTopics' | ||
topics = SignUpTopic.where(assignment_id: old_assign.id) | ||
topics.each do |topic| | ||
newSignUpTopic = SignUpTopic.create(topic_name: topic.topic_name, assignment_id: new_assign_id, max_choosers: topic.max_choosers, category: topic.category, topic_identifier: topic.topic_identifier, micropayment: topic.micropayment) |
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.
Line is too long. [241/160]
spec/models/assignment_form_spec.rb
Outdated
expect(AssignmentForm.copy(1, 'copyWithTopicsTeams', build(:instructor))).to eq(2) | ||
end | ||
|
||
|
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.
Tab detected.
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.
Solved.
spec/models/assignment_form_spec.rb
Outdated
allow_any_instance_of(AssignmentForm).to receive(:update_attribute).with(any_args).and_return('OK!') | ||
expect(AssignmentForm.copy(1, 'copyWithTopicsTeams', build(:instructor))).to eq(2) | ||
end | ||
|
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.
Trailing whitespace detected.
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.
Solved.
spec/models/assignment_form_spec.rb
Outdated
expect(AssignmentForm.copy(1, 'copyWithTopicsTeams', build(:instructor))).to eq(2) | ||
end | ||
|
||
|
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.
Trailing whitespace detected.
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.
Solved.
allow(assignment).to receive(:dup).and_return(new_assignment) | ||
allow(new_assignment).to receive(:save).and_return(false) | ||
|
||
context 'when new assignment is not able to be copied' do |
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.
Inconsistent indentation detected.
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.
Solved.
context 'when new assignment is not able to be copied' do | ||
it 'should show an error and redirect to assignments#tree display page' do | ||
allow(AssignmentForm).to receive(:copy).with("1", nil, instructor).and_return(false) | ||
allow(Assignment).to receive(:find).with(2).and_return(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.
Inconsistent indentation detected.
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.
Solved.
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.
Please correct the code climate issues.
@@ -398,7 +398,7 @@ GEM | |||
rake (>= 0.8.7) | |||
thor (>= 0.18.1, < 2.0) | |||
rainbow (3.0.0) | |||
rake (12.3.2) | |||
rake (13.0.0) |
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.
Most of the Gems versions are changed, it might affect the other parts of the system. Could to try keeping the same version?
(assignment.instructor_id == current_user.try(:id)) || | ||
TaMapping.exists?(ta_id: current_user.try(:id), course_id: assignment.course_id) || | ||
(assignment.course_id && Course.find(assignment.course_id).instructor_id == current_user.try(:id)) | ||
(assignment.instructor_id == current_user.try(:id)) || |
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.
white spaces.
<%= label_tag(:copyoption_topics, "copy with topics") %><br> | ||
<%= radio_button_tag(:copyoption, "copyWithTopicsTeams") %> | ||
<%= label_tag(:copyoption_topics_teams, "copy with topics and teams") %><br> | ||
<%= submit_tag("Create") %> |
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.
Shouldn't the submit button name be "Copy"
React.createElement(TabSystem), | ||
document.getElementById("tree_display") | ||
) | ||
} | ||
|
||
}) |
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.
Seems like you did not intend to change this file but introduced many whitespaces and newlines unknowingly. Please correct it. (remove this file from commit if it does not have any changes relevant to your project or correct its code climate )
@@ -143,7 +144,7 @@ | |||
end | |||
end | |||
|
|||
resources :institution, except: [:destroy] do | |||
resources :institution, except: [:destroy] do |
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.
white space
allow(assignment).to receive(:dup).and_return(new_assignment) | ||
allow(new_assignment).to receive(:save).and_return(false) | ||
|
||
context 'when new assignment is not able to be copied' do |
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.
white spaces
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.
Solved.
Do you have any other pull request for expertiza beta? We would like these changes on beta. |
@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay) | |||
end | |||
|
|||
# Copies the inputted assignment into new one and returns the new assignment id | |||
def self.copy(assignment_id, user) | |||
def self.copy(assignment_id, copyoption, user) |
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.
Method copy
has 40 lines of code (exceeds 25 allowed). Consider refactoring.
@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay) | |||
end | |||
|
|||
# Copies the inputted assignment into new one and returns the new assignment id | |||
def self.copy(assignment_id, user) | |||
def self.copy(assignment_id, copyoption, user) |
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.
Method copy
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
we identified the code to make the changes and identified the pattern used.