CSC/ECE 517 Spring 2013/FINAL PROJECT E736 UNDO DELIVERABLE: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "= E736. Undo Functionality for Expertiza = *Contacts: Ed Gehringer (efg@ncsu.edu) and Andrew Kofink (ajkofink@ncsu.edu) *Begin implementing SQL transactions (ActiveRecord:Transac...")
 
 
(40 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= E736. Undo Functionality for Expertiza =
= E736. Undo Functionality for Expertiza =
*Contacts: Ed Gehringer (efg@ncsu.edu) and Andrew Kofink (ajkofink@ncsu.edu)
*Contacts: Ed Gehringer (efg@ncsu.edu) and Andrew Kofink (ajkofink@ncsu.edu)
*Begin implementing SQL transactions (ActiveRecord:Transactions). This should let the user "roll back" any creation or update of a SQL table (assignments, rubrics, etc.)  Several issues arise, that you should discuss with me.  
*[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2013/FINAL_PROJECT_E736_UNDO Design Document]
**Should students be able to roll back, e.g., submissions or reviews?
**Suppose an instructor is trying to roll back and a TA is editing the same assignment?  How can conflicts be presented?
**Do rollbacks affect only what's in the db, or do they also affect submitted files?
*[https://docs.google.com/a/ncsu.edu/document/d/11YTjxFXFR13vJ769yFBbqn9qOueK2Ktz0Pd-gyS2W5U/ Project Description Doc]
*[https://docs.google.com/a/ncsu.edu/document/d/11YTjxFXFR13vJ769yFBbqn9qOueK2Ktz0Pd-gyS2W5U/ Project Description Doc]
== Team Members ==
== Team Members ==
Line 12: Line 9:
*Travis Folsom (twfolsom@ncsu.edu)
*Travis Folsom (twfolsom@ncsu.edu)


== Design Document ==
== Project Deliverables ==
 
=== Screencast Video Overview ===
A video overview of the project was created via [http://www.screencast-o-matic.com/ Screencast-O-Matic] and can be found [http://www.youtube.com/watch?v=1DYS5InjBOk here]. 


=== Overview of Undo Functionality ===
=== Overview of Undo Functionality ===
*Undo should cover any edit functionalities and any submissions of linksFile submissions do not need to be included for the scope of this project.  
*Undo allows the user to undo and redo their most recent actions for any items that offer the undo functionality.   
*User should be able to undo any changes to an item (such as course or assignment) as long as no other user has edited that same item within the user's current session. 
*The undo of file submissions was not required; it is not implemented in this project.
*If undo is attempted on an item already modified by another user, display a message stating why undo cannot be done.   
*If an undo is attempted on an item already modified by another user, a message is displayed stating why undo cannot be performed.  Otherwise, the user is able to undo any changes to an item with the undo functionality.   
*When multiple actions are performed in one step, the undo functionality groups all of the changes together for the purposes of restoring all items affected by the action previously performed.


=== List of Items to be Supported by Undo Functionality ===
=== List of Items Now Supported by Undo Functionality ===  
*Add Signup Sheet
**Delete Topic
**Edit Topic
**New Topic
*Assignments
*Assignments
**Add/Remove Participants
**Inherit Participants from Course
**Copy Participants to Course
**Copy
**Create
**Delete
**Edit
**Add/Remove/Modify questionnaires and their weight and notification limit
*Courses
*Courses
*More items may be covered if time allows.
**Add Participants
**Copy
**Create
**Delete
**Edit
**Toggle Private/Public
*Import
**Import Participants
**Import Teams
**Import Users
*Student Actions
**Create Team
**Edit Team Name
**Leave Team
**Submit Hyperlink
*Questions
**Copy
**Create
**Delete
**Edit
*Questionnaires
**Copy
**Create
**Delete
**Edit
*Teams
**Add
**Create (Manual)
**Create (Random)
**Delete
**Delete All Teams
**Edit
 
=== Redo Functionality ===
In addition to the Undo functionality being added, the ability to Redo an undone action is also implemented. Whenever an Undo is performed, the user is given an option to Redo the action that was undone.  Whenever a Redo is performed, the user is given an option to Undo the action again. 


=== Design Patterns and Designs ===
=== Design Patterns and Designs ===
*DRY
*DRY
**"Don't Repeat Yourself" practice will be followed.  
**"Don't Repeat Yourself" practice was followed.  
*Memento
**The app/controllers/application_controller.rb file contains all of the Undo functionality code for Expertiza. All other controllers are able to call the necessary undo-related methods to enable the Undo functionality.
**The memento pattern is a software design pattern that provides the ability to restore an object to its previous state (undo via rollback). The memento pattern is implemented with two objects: the originator and a caretaker. The originator is some object that has an internal state. The caretaker is going to do something to the originator, but wants to be able to undo the change. The caretaker first asks the originator for a memento object. Then it does whatever operation (or sequence of operations) it was going to do. To roll back to the state before the operations, it returns the memento object to the originator. The memento object itself is an opaque object (one which the caretaker cannot, or should not, change). When using this pattern, care should be taken if the originator may change other objects or resources - the memento pattern operates on a single object. Classic examples of the memento pattern include the seed of a pseudorandom number generator (it will always produce the same sequence thereafter when initialized with the seed state) and the state in a finite state machine.
**The Memento pattern will be followed through open-source Ruby gems leveraged by the project.


=== Frameworks to Leverage ===
=== Framework Leveraged & Enhanced ===
*Paper Trail(https://github.com/airblade/paper_trail)
*Paper Trail(https://github.com/airblade/paper_trail)
**PaperTrail allows for tracking changes to model data.  
**Paper Trail allows for tracking changes to model data.  
***Good for auditing or versioning.  
***Good for auditing or versioning.  
**Offers many functionalities including:
**Offers many functionalities including:
Line 42: Line 87:
**There is a [http://railscasts.com/episodes/255-undo-with-paper-trail Railscast] showing how to implement the undo feature with Paper Trail.  
**There is a [http://railscasts.com/episodes/255-undo-with-paper-trail Railscast] showing how to implement the undo feature with Paper Trail.  
**Ranked as the most popular framework for Active Record versioning feature in [https://www.ruby-toolbox.com/categories/Active_Record_Versioning here]
**Ranked as the most popular framework for Active Record versioning feature in [https://www.ruby-toolbox.com/categories/Active_Record_Versioning here]
**Alternative Frameworks are listed [https://www.ruby-toolbox.com/categories/Active_Record_Versioning here].
*Enhancement
**Paper Trail only supported undo of the most recent action and did not restore associations. 
**Paper Trail customized to add support for restoring associations within the Expertiza system. 
***Database transactions paired with timestamps and user ids to group them together.
 
=== Classes Modified ===
*apps/
**controllers/
***application_controller.rb
***assignment_controller.rb
***course_controller.rb
***import_file_controller.rb
***participants_controller.rb
***sign_up_sheet_controller.rb
***student_team_controller.rb
***team_controller.rb
***teams_users_controller.rb
***versions_controller.rb
**models/
***assignment_participant.rb
***assignment.rb
***questionnaire.rb
***course.rb
***participant.rb
***sign_up_topic.rb
***ta_mapping.rb
***team_node.rb
***teams_user.rb
*db/
**migrate/
***000_create_versions.rb
***20130418214537_update_site_controllers_for_versions.rb
***20130418215246_update_controller_actions_for_versions_revert.rb
 
=== Unit & Functional Tests ===
The implementation of the Undo functionality did not afford any testing opportunities applicable to unit or functional tests.
 
=== Bug Fixes & Other Improvements ===
The following bugs were found within Expertiza and fixed:
*ApplicationController enhanced to rescue from ActiveRecord::RecordNotFound errors and redirect to tree display. 
*Copy of Assignment opened Edit page for the original Assignment and now correctly opens the Edit page for the copy of the assignment. 
 
The following general improvements were made:
*Explicitly declared the has_one association between each object and its tree node to eliminate the manual deletion of a related tree node with the object. 
*Edited the Copy of Course flash message to be more clear that the copy had already been created and to resolve a misspelling.
 
=== Problem Areas with Expertiza ===
There were some areas of functionality within Expertiza that did not work.  There were some cases in which the undo functionality could not be added due to the inherent problems.  These problem areas were:
*Assigning surveys in an assignment.
*Dates in assignments do not show up when the assignment is edited. 
*Unable to assign random reviewers.
*Unable to edit advice for questions in questionnaire.
*Unable to remove participants from a course.
*Unable to inherit team from a course


=== Expected Classes to be Modified ===
=== Future Recommendations ===
*Assignment-related Classes
*Add integration tests.
*Course-related Classes
*Add undo functionality to other areas of Expertiza (especially student actions such as review responses)
*More classes may be covered as time allows.
*Determine appropriate methodology for cleaning up Versions table.


=== Unit Testing Plans ===
=== Template to Implement Undo Functionality ===
*Every class method modified will be tested via unit test.  
* Install paper_trail gem. Please follow the steps listed on its [https://github.com/airblade/paper_trail official webpage ].  
*Every new method added will be tested via at least one unit test.  
* Add ''has_paper_trail'' to the model you want to have undo functionality
*All test methods shall be named with an appropriately descriptive name that is not too long.
class Foo < ActiveRecord::Base
    has_paper_trail
    ...
end


=== Functional Testing Plans ===
* Call ''undo_link'' method in the corresponding controller. The argument is a string, which you want to show along with the undo link in flash[:note]. The following is code snippet shows how the undo functionality is implemented for the delete method of FoosController
*The following functional test plans will be followed for all items enhanced with the Undo functionality:
class FoosController < ApplicationController
**Test that an item may be changed, then undo performed successfully.
    def delete
**Test that a sequence of changes may be performed by one user, then undo performed successfully for each action from the sequence.  
        @foo = Foo.find(params[:id])
**Test that an item may be changed by one user, changed again by another user, then undo performed by the original user will display a failure message with description.
        @foo.destroy
        undo_link("Foo \"#{@foo.name}\" has been deleted successfully. ")
        redirect_to :back
    end
end

Latest revision as of 00:24, 24 April 2013

E736. Undo Functionality for Expertiza

Team Members

  • Chun Sing Tsui (ctsui@ncsu.edu)
  • Kenny Yarboro (kbyarbor@ncsu.edu)
  • Meng Cao (mcao2@ncsu.edu)
  • Travis Folsom (twfolsom@ncsu.edu)

Project Deliverables

Screencast Video Overview

A video overview of the project was created via Screencast-O-Matic and can be found here.

Overview of Undo Functionality

  • Undo allows the user to undo and redo their most recent actions for any items that offer the undo functionality.
  • The undo of file submissions was not required; it is not implemented in this project.
  • If an undo is attempted on an item already modified by another user, a message is displayed stating why undo cannot be performed. Otherwise, the user is able to undo any changes to an item with the undo functionality.
  • When multiple actions are performed in one step, the undo functionality groups all of the changes together for the purposes of restoring all items affected by the action previously performed.

List of Items Now Supported by Undo Functionality

  • Add Signup Sheet
    • Delete Topic
    • Edit Topic
    • New Topic
  • Assignments
    • Add/Remove Participants
    • Inherit Participants from Course
    • Copy Participants to Course
    • Copy
    • Create
    • Delete
    • Edit
    • Add/Remove/Modify questionnaires and their weight and notification limit
  • Courses
    • Add Participants
    • Copy
    • Create
    • Delete
    • Edit
    • Toggle Private/Public
  • Import
    • Import Participants
    • Import Teams
    • Import Users
  • Student Actions
    • Create Team
    • Edit Team Name
    • Leave Team
    • Submit Hyperlink
  • Questions
    • Copy
    • Create
    • Delete
    • Edit
  • Questionnaires
    • Copy
    • Create
    • Delete
    • Edit
  • Teams
    • Add
    • Create (Manual)
    • Create (Random)
    • Delete
    • Delete All Teams
    • Edit

Redo Functionality

In addition to the Undo functionality being added, the ability to Redo an undone action is also implemented. Whenever an Undo is performed, the user is given an option to Redo the action that was undone. Whenever a Redo is performed, the user is given an option to Undo the action again.

Design Patterns and Designs

  • DRY
    • "Don't Repeat Yourself" practice was followed.
    • The app/controllers/application_controller.rb file contains all of the Undo functionality code for Expertiza. All other controllers are able to call the necessary undo-related methods to enable the Undo functionality.

Framework Leveraged & Enhanced

  • Paper Trail(https://github.com/airblade/paper_trail)
    • Paper Trail allows for tracking changes to model data.
      • Good for auditing or versioning.
    • Offers many functionalities including:
        • Viewing a model at any stage in its lifecycle.
        • Reverting a model to any version.
        • Undeleting items after they have been destroyed.
    • Compatible with Rails-2.3.15, which is the version Expertiza uses.
    • There is a Railscast showing how to implement the undo feature with Paper Trail.
    • Ranked as the most popular framework for Active Record versioning feature in here
  • Enhancement
    • Paper Trail only supported undo of the most recent action and did not restore associations.
    • Paper Trail customized to add support for restoring associations within the Expertiza system.
      • Database transactions paired with timestamps and user ids to group them together.

Classes Modified

  • apps/
    • controllers/
      • application_controller.rb
      • assignment_controller.rb
      • course_controller.rb
      • import_file_controller.rb
      • participants_controller.rb
      • sign_up_sheet_controller.rb
      • student_team_controller.rb
      • team_controller.rb
      • teams_users_controller.rb
      • versions_controller.rb
    • models/
      • assignment_participant.rb
      • assignment.rb
      • questionnaire.rb
      • course.rb
      • participant.rb
      • sign_up_topic.rb
      • ta_mapping.rb
      • team_node.rb
      • teams_user.rb
  • db/
    • migrate/
      • 000_create_versions.rb
      • 20130418214537_update_site_controllers_for_versions.rb
      • 20130418215246_update_controller_actions_for_versions_revert.rb

Unit & Functional Tests

The implementation of the Undo functionality did not afford any testing opportunities applicable to unit or functional tests.

Bug Fixes & Other Improvements

The following bugs were found within Expertiza and fixed:

  • ApplicationController enhanced to rescue from ActiveRecord::RecordNotFound errors and redirect to tree display.
  • Copy of Assignment opened Edit page for the original Assignment and now correctly opens the Edit page for the copy of the assignment.

The following general improvements were made:

  • Explicitly declared the has_one association between each object and its tree node to eliminate the manual deletion of a related tree node with the object.
  • Edited the Copy of Course flash message to be more clear that the copy had already been created and to resolve a misspelling.

Problem Areas with Expertiza

There were some areas of functionality within Expertiza that did not work. There were some cases in which the undo functionality could not be added due to the inherent problems. These problem areas were:

  • Assigning surveys in an assignment.
  • Dates in assignments do not show up when the assignment is edited.
  • Unable to assign random reviewers.
  • Unable to edit advice for questions in questionnaire.
  • Unable to remove participants from a course.
  • Unable to inherit team from a course

Future Recommendations

  • Add integration tests.
  • Add undo functionality to other areas of Expertiza (especially student actions such as review responses)
  • Determine appropriate methodology for cleaning up Versions table.

Template to Implement Undo Functionality

  • Install paper_trail gem. Please follow the steps listed on its official webpage .
  • Add has_paper_trail to the model you want to have undo functionality
class Foo < ActiveRecord::Base
    has_paper_trail
    ...
end
  • Call undo_link method in the corresponding controller. The argument is a string, which you want to show along with the undo link in flash[:note]. The following is code snippet shows how the undo functionality is implemented for the delete method of FoosController
class FoosController < ApplicationController
    def delete
        @foo = Foo.find(params[:id])
        @foo.destroy
        undo_link("Foo \"#{@foo.name}\" has been deleted successfully. ")
        redirect_to :back
    end
end