CSC/ECE 517 Fall 2015/oss E1561 WZL: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(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:

  1. Remove DueDate.assign_topic_deadline and use DeadlineHelper.create_topic_deadline method wherever possible.
  1. Create a new method for sort in due_date.rb and invoke it from places used in due_date.rb and response_controller.rb.
  1. Rename setFlag() to adhere to Rails naming conventions.
  1. Refactor DueDate.default_permission.
  1. Refactor DeadlineHelper.set_start_due_date method 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/>