CSC/ECE 517 Spring 2016/Refactor review mapping controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 9: Line 9:
==='''About Review mapping controller'''===
==='''About Review mapping controller'''===


Review mapping controller contains methods related to peer reviewing strategies. It contains methods to add a reviewer, delete a reviewer, selecting a reviewer. Depending on the number of students and number of submissions, the topics to be reviewed are assigned to the students automatically. If a user wants to look for the submission team , it returns the team by comparing the submission id's with the team id's. Also, it assigns quizzes dynamically. Generation of review report, feedback report and teammate review is done.
Review mapping controller contains methods related to peer reviewing strategies. It contains methods to add a reviewer, delete a reviewer, selecting a reviewer. Depending on the number of students and number of submissions, the topics to be reviewed are assigned to the students automatically. If a user wants to look for the team for a submission , it returns the team by comparing the submission id's with the team id's. Also, it assigns quizzes dynamically. Generation of review report, feedback report and teammate review is done.


==='''Code Improvements'''===
==='''Code Improvements'''===

Revision as of 02:29, 24 March 2016

E1615. Refactoring the Review Mapping Controller

This page provides details about the OSS project which was based on refactoring one of controllers related to peer reviewing strategies used in Expertiza.



About Review mapping controller

Review mapping controller contains methods related to peer reviewing strategies. It contains methods to add a reviewer, delete a reviewer, selecting a reviewer. Depending on the number of students and number of submissions, the topics to be reviewed are assigned to the students automatically. If a user wants to look for the team for a submission , it returns the team by comparing the submission id's with the team id's. Also, it assigns quizzes dynamically. Generation of review report, feedback report and teammate review is done.

Code Improvements

1. Unused variables and arguments: There are unused variables in the methods. If there are unused variables in the methods, it uses stack unnecessarily. So, it is better to remove the unused variables.

When both keys and values are not used, but given as arguments, then the used variables can be added "_" or replaced with "_" to represent it as unused variable but allowed in the arguments.

At line 533 and line 539
Previous Code: teams_hash = unsorted_teams_hash.sort_by{|k, v| v}.to_h
After Changing the code: teams_hash = unsorted_teams_hash.sort_by{|_, v| v}.to_h

2. Use sample instead of shuffle When sample is used, the elements are chosen by using random and unique indices in the array so that the elements doesn't repeat in the array. This cannot be guaranteed in shuffle.


Previous Code:
assignment_team = assignment_teams.to_a.shuffle[0] rescue nil

topic = assignment.candidate_topics_to_review(reviewer).to_a.shuffle[0] rescue nil
After Changing the code:

assignment_team = assignment_teams.to_a.sample rescue nil

topic = assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil


References

  1. Expertiza on GitHub
  2. Forked repository for the project
  3. Expertiza Main Page