CSC/ECE 517 Fall 2015/oss E1561 WZL: Difference between revisions
(Created page with "'''E1561. Refactoring due_date.rb and deadline_helper.rb''' This page provides a description of the Expertiza based OSS project. This project aimed at refactoring due_date.rb an...") |
No edit summary |
||
| Line 69: | Line 69: | ||
end | end | ||
</pre> | </pre> | ||
|} | |||
Remove <code>DueDate.assign_topic_deadline</code> and use <code>DeadlineHelper.create_topic_deadline</code> method in <code>sign_up_sheet.rb</code>. | Remove <code>DueDate.assign_topic_deadline</code> and use <code>DeadlineHelper.create_topic_deadline</code> method in <code>sign_up_sheet.rb</code>. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 85: | Line 86: | ||
DeadlineHelper.create_topic_deadline(due_date, 0, topic.id) | DeadlineHelper.create_topic_deadline(due_date, 0, topic.id) | ||
</pre> | </pre> | ||
|} | |||
=Results Screenshot= | =Results Screenshot= | ||
= References= | = References= | ||
<references/> | <references/> | ||
Revision as of 17:55, 30 October 2015
E1561. Refactoring due_date.rb and deadline_helper.rb
This page provides a description of the Expertiza based OSS project. This project aimed at refactoring due_date.rb and deadline_helper.rb.
Introduction to Expertiza
Expertiza is a Open Source Rails application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. This Open Source application can be cloned from Github, the latest active branch is "Rails 4".
Project Desicription<ref>https://docs.google.com/document/d/1J0WUBtYV_MDhpEQ-50z8gXE-OrvVkpEaZxvn_9RCAsM/edit#</ref>
Files involved:
due_date.rb response_controller.rb deadline-helper.rb sign_up_sheet.rb
What it does: Manages the deadlines of an assignment, setting due dates for an assignment, copying due dates from one assignment to a new assignment etc.
What's wrong with it:
- It has methods making unnecessary DB calls.
- It contains duplicated methods.
What needs to be done: There are 5 major goals for this project:
- Remove
DueDate.assign_topic_deadlineand useDeadlineHelper.create_topic_deadlinemethod wherever possible.
- Create a new method for sort in
due_date.rband invoke it from places used indue_date.rbandresponse_controller.rb.
- Rename
setFlag()to adhere to Rails naming conventions.
- Refactor
DueDate.default_permission.
- Refactor
DeadlineHelper.set_start_due_datemethod to smaller methods.
Modification
Case 1: Remove DueDate.assign_topic_deadline and use DeadlineHelper.create_topic_deadline
DueDate.assign_topic_deadline method which is same as DeadlineHelper.create_topic_deadline method.
| DueDate.assign_topic_deadline Method | DeadlineHelper.create_topic_deadline Method |
|---|---|
def self.assign_topic_deadline(due_date,offset,topic_id)
topic_deadline = TopicDeadline.new
topic_deadline.topic_id = topic_id
topic_deadline.due_at = DateTime.parse(due_date.due_at.to_s) + offset.to_i
topic_deadline.deadline_type_id = due_date.deadline_type_id
topic_deadline.late_policy_id = nil
topic_deadline.submission_allowed_id = due_date.submission_allowed_id
topic_deadline.review_allowed_id = due_date.review_allowed_id
topic_deadline.review_of_review_allowed_id = due_date.review_of_review_allowed_id
topic_deadline.round = due_date.round
topic_deadline.save
end
|
def self.create_topic_deadline(due_date,offset,topic_id)
topic_deadline = TopicDeadline.new
topic_deadline.topic_id = topic_id
topic_deadline.due_at = DateTime.parse(due_date.due_at.to_s) + offset.to_i
topic_deadline.deadline_type_id = due_date.deadline_type_id
topic_deadline.late_policy_id = nil
topic_deadline.submission_allowed_id = due_date.submission_allowed_id
topic_deadline.review_allowed_id = due_date.review_allowed_id
topic_deadline.review_of_review_allowed_id = due_date.review_of_review_allowed_id
topic_deadline.round = due_date.round
topic_deadline.save
end
|
Remove DueDate.assign_topic_deadline and use DeadlineHelper.create_topic_deadline method in sign_up_sheet.rb.
| Before Change | After Change |
|---|---|
set_of_due_dates = DueDate.where(assignment_id: assignment_id)
set_of_due_dates.each { |due_date|
DueDate.assign_topic_deadline(due_date, 0, topic.id)
|
set_of_due_dates = DueDate.where(assignment_id: assignment_id)
set_of_due_dates.each { |due_date|
DeadlineHelper.create_topic_deadline(due_date, 0, topic.id)
|
Results Screenshot
References
<references/>