E2157. Fix issues related to deadlines and late policies
Problem Description
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing). The current implementation of this feature has issues
Issues with the Current Implementation
The current implementation of Expertiza has the following Issues:
- Issue 1 - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”.
- Issue 2 - Late policies cannot be created without raising an error.
- Issue 3 - After creating a late policy, the “back” link does not take the user back to editing the assignment.
- Issue 4 - The "+" and "-" buttons for Show/Hide Date Updater do not work.
- Issue 5 - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.
What needs to be done
We will resolve each of these issues in the following manner:
- To avoid confusion, use “late policy” exclusively.
- Ensure that all errors being raised are fixed. This will be achieved by modifying existing code and bringing new checks as and when required.
- Ensure that on click of the back button, the user is taken back to the assignment page.
- Expertiza has a way to adjust the dates on assignments. This is especially helpful when an assignment is copied from another and the dates get copied too. We need to ensure the "+" and "-" buttons update the dates accordingly.
- Add test cases for late_policy.rb and late_policies_controller.rb. This will further be discussed in the Test Plan section of the page.
Approach & Fix
Issue 1: Renaming penalty policy to late policy
- Renaming done on the UI as well as on the backend
- Varible names refactored appropritely
- Flash messages changed accordingly
Issue 2: Late policies cannot be created without raising an error
The error which is raised is due to the following validation present in the model late_policy.rb.
validates :max_penalty, numericality: {less_than: 50}
- After discussing with professor we have decided to increase the max penalty limit to 100
- Added a flash error message in the create function of late_policies_controller.rb
if params[:late_policy][:max_penalty].to_i>=100 flash[:error] = "Maximum penalty cannot be greater than or equal to 100" invalid_max_penalty = true; end
Issue 3: After creating a late policy, the “back” link does not take the user back to editing the assignment.
- Added a back link in which redirects the user to edit assignment page.
- Saved the assignment object in a session variable when the user clicks on the the edit asignment icon
- We also added a back button on index page since there was no direct way of going back to edit assignment page once a late policy was created.
- We also added padding between the edit and delete links on index page
<%= link_to 'Back', :controller=> 'assignments', :action => 'edit', :id => session[:assignment] %>
Issue 4: The "+" and "-" buttons for Show/Hide Date Updater do not work.
While testing this issue we noticed that the functionality was working perfectly fine, however, it was not user friendly.
- We decided to add a tooltip icon explaining how this functionality works
- We also inproved its UI by adding the alignment and padding.
Issue 5: Neither late_policy.rb nor late_policies_controller.rb have any tests at all. Define a test plan, and write appropriate tests for these classes.
- Added test file late_policies_controller_spec.rb with appropriate test cases
- Added test file late_policies_spec.rb with appropriate test cases
Expected Results
Each Issue is described with the predicted fix and a screenshot showing the issue fixed.
- Issue 1 - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between "late policy" and "penalty policy", as "late policy" will be used exclusively.
- Issue 2 - Once this issue is fixed, late policies can be created and saved successfully without raising the "The following error occurred while saving the penalty policy:" error.
- Issue 3 - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the General tab on the Edit Assignment page.
- Issue 4 - Once this issue is fixed, "+" and "-" buttons for Show/Hide Date Updater will work and update all the dates relative to the first date keeping the days gap between all the dates the same as before.
- Issue 5 - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.
Test Plan
Before fix
Manual Testing ()
Log in to Expertiza as an Instructor by entering the credentials: Username: instructor6, Password: password
The following route is common to testing all the issues:
Welcome page -> Manage Assignments -> Select a Course -> Select Edit option for any assignment -> Edit Assignment (General) ->
Issue 1 -
Due Dates -> No 'penalty policy' on the page.
Issue 2 -
Due Dates -> New late policy -> Enter information and Create -> Late policy is successfully created and saved.
Issue 3 -
Due Dates -> New late policy -> Enter information and Create -> Back -> Edit Assignment (General)
Issue 4 -
Due Dates -> Show/Hide Date Updater -> Enter number of days -> Hit + / -
Automated Testing Using RSpec
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to write tests for late_policy.rb and late_policies_controller.rb repesctively.
Coverage
To make sure we are covering all of our code with test cases we will use the Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually running the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.
Afterfix
To test the controller 'late_policies_controller.rb' and model 'late_policy.rb' we created 2 test files late_policy_spec.rb and late_policies_controller_spec.rb. To write test cases we used rspec functions and tested the functions on the basis of :
- What they returned
- Which page got rendered
- Which flash error got produced
- Which method got called
We also used stubbing and mocking functions to carry out our tests. After executing our tests we got an increase in the overall code coverage of over 0.5% for each file.
Here are the results of SimpleCov gem highlighting the code coverage of our tests.
Milestones
10/25 – Project Selection
10/26 – Develop Project Design Document
Project Mentors
- Tirth Patel
Team Members
- Anmol Lunavat
- Shubham Waghe
- Vishal Sharma