Skip to content
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

E2003, Refactor Assessment 360 Controller #1691

Closed
wants to merge 20 commits into from

Conversation

ramyananth
Copy link
Contributor

@ramyananth ramyananth commented Mar 19, 2020

Fixed the Course student grade summary page.
Added a function for eliminating the divide by zero error
Added a function for reviewing each student's info based on meta_review and teammate_review
Both functions that need to be refactored check if there are any course participants for the specific course. So this functionality is merged for both the functions.

Teammates: @ramyananth (rananth2) @ushvarma (suppala)

@expertiza-bot
Copy link
Contributor

expertiza-bot commented Mar 19, 2020

1 Message
💬 Thanks for the pull request, and welcome! 🎉 The Expertiza team is excited to review your changes, and you should hear from us soon.

This repository is being automatically checked for code-quality issues using Code Climate.
You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a pull request is considered ready to review.

Also, please spend some time looking at the instructions at the top of your course project writeup.
If you have any questions, please send email to expertiza-support@lists.ncsu.edu.

3 Warnings
⚠️ Your pull request is more than 500 LoC.
Please make sure you did not commit unnecessary changes, such as schema.rb, node_modules, change logs.
⚠️ There are code changes, but no corresponding tests.
Please include tests if this PR introduces any modifications in behavior.
⚠️ You should commit changes to the DB schema (db/schema.rb) only if you have created new DB migrations.
Please double check your code. If you did not aim to change the DB, please revert the DB schema changes.
1 Error
💥 You changed .gitignore; please double-check whether this is necessary.

Generated by expertiza-bot

@coveralls
Copy link

coveralls commented Mar 19, 2020

Coverage Status

Coverage decreased (-0.6%) to 36.925% when pulling 192a957 on ramyananth:master into 4532e88 on expertiza:master.

@expertiza-travisci-bot
Copy link

expertiza-travisci-bot commented Mar 19, 2020

Hey @ramyananth,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

app/controllers/assessment360_controller.rb Outdated Show resolved Hide resolved
# hashes for view
@meta_review = {}
@teammate_review = {}
@teamed_count = {}
# for course
# eg. @overall_teammate_review_grades = {assgt_id1: 100, assgt_id2: 178, ...}
# @overall_teammate_review_count = {assgt_id1: 1, assgt_id2: 2, ...}
%w[teammate meta].each do |type|
%w[teammate meta].each do |type|
Copy link
Member

Choose a reason for hiding this comment

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

This is a whitespace change, which should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Professor, what about the Code climate "Trailing white space" issue that comes up?

app/controllers/assessment360_controller.rb Outdated Show resolved Hide resolved
app/controllers/assessment360_controller.rb Outdated Show resolved Hide resolved
avoid_divide_by_zero_error(@assignments,@overall_teammate_review_count,@overall_meta_review_count)
end

def avoid_divide_by_zero_error (assignments,overall_teammate_review_count,overall_meta_review_count)
Copy link
Member

Choose a reason for hiding this comment

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

This is not a good name for this method. I cannot understand what it is actually doing. Probably would be better to break it up into a method that could operate on either teammate_review_count or meta_review_count, and would be called once for each.
Even better: instead of teammate_review_count (or overall_teammate_review_count), have a teammate_reviews object and use teammate_reviews.count to return the count. But that may be too much to ask, since there's only one day left.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The hash value for a student is calculated based on overall_teammate_review_count. Having just one function that can be called with teammate or meta variables might want us to do an extra check if the value passed is a teammate variable or a meta variable

app/controllers/assessment360_controller.rb Outdated Show resolved Hide resolved
app/controllers/assessment360_controller.rb Show resolved Hide resolved
app/controllers/assessment360_controller.rb Outdated Show resolved Hide resolved
app/controllers/assessment360_controller.rb Outdated Show resolved Hide resolved
overall_review_count(@assignments, @overall_teammate_review_count, @overall_meta_review_count)
end

def overall_review_count(assignments, overall_teammate_review_count, overall_meta_review_count)
Copy link

Choose a reason for hiding this comment

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

Method overall_review_count has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

def overall_review_count(assignments, overall_teammate_review_count, overall_meta_review_count)
assignments.each do |assignment|
temp_count = overall_teammate_review_count[assignment.id]
overall_review_count_hash = 1 if temp_count.nil? or temp_count.zero?
Copy link

Choose a reason for hiding this comment

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

Useless assignment to variable - overall_review_count_hash.

unless @assignment_grades[cp.id][assignment_id].nil?
@final_grades[cp.id] += @assignment_grades[cp.id][assignment_id]
end
def assignment_grade_summary(cp, assignment_id, user_id)
Copy link

Choose a reason for hiding this comment

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

Assignment Branch Condition size for assignment_grade_summary is too high. [19/15]

@codeclimate
Copy link

codeclimate bot commented Mar 23, 2020

Code Climate has analyzed commit 1df1e0e and detected 4 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Style 2

The test coverage on the diff in this pull request is 0.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 29.0% (-22.5% change).

View more on Code Climate.

app/controllers/assessment360_controller.rb Outdated Show resolved Hide resolved
unless @assignment_grades[cp.id][assignment_id].nil?
@final_grades[cp.id] += @assignment_grades[cp.id][assignment_id]
end
def assignment_grade_summary(cp, assignment_id)
Copy link

Choose a reason for hiding this comment

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

Assignment Branch Condition size for assignment_grade_summary is too high. [20.27/15]

@ramyananth ramyananth closed this Mar 31, 2020
@ramyananth ramyananth reopened this Mar 31, 2020
@ramyananth ramyananth closed this Mar 31, 2020
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.

None yet

6 participants