E2157. Fix issues related to deadlines and late policies

From Expertiza_Wiki
Revision as of 18:53, 30 November 2021 by Swaghe (talk | contribs)
Jump to navigation Jump to search

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 team found some issues in the current implementation which either cause errors are completely not functional. The goal of this project is to eliminate these issues by making necessary changes and adding new test cases which cover all scenarios.

Issues with the Current Implementation

The following issues have been raised in the current implementation:

  • 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.

Issues Fixed

All the above mentioned issues has been fixed, check out below video which shows how all the issues are being addressed :

  1. Working Demo

Refactoring and Design Patterns

Since our goal is to fix existing functionalities we will not be updating the existing design patterns being employed in the code. Yet, we would like to discuss what makes these refactoring important. Refactoring is a systematic process of improving code without creating new functionality. Thus, a key to the success of our project is ensuring everything that was working before our changes work even after our changes have been added. To ensure this, we will continue to test the system after each issue has been fixed. This will allow us to ensure two things:

  • We are only changing what we set out to change when fixing a particular issue.
  • We are not breaking what was working before we deployed our fix.

We believe at the end our changes will increase the quality of Expertiza and improve the experience for users an developers alike.

Project Scope


All the issues raised mainly exist in the "Due Dates" tab on the "Edit Assignment" page.

  • Issue 1 - Change "penalty policy" to "late policy" on all the relevant UI screens (app/views/late_policies).
  • Issue 2 - Analyze and fix required function and write appropriate test cases (late_policies_controller.rb).
  • Issue 3 - Analyze and fix required function and write appropriate test cases (late_policies_controller.rb).
  • Issue 4 - Analyze and fix required function and write appropriate test cases (late_policies_controller.rb).
  • Issue 5 - Write new test cases for late_policies_controller.rb and late_policy.rb.

Problem description, Approach & Fix

Issue 1: Renaming penalty policy to late policy

Problem Description: Usage of different terms for the same thing causes ambiguity and can lead to unfortunate errors. In this instance having two different terms for "late policy" will cause confusion when instructors are creating assignments.

Fix: To avoid confusion, use “late policy” exclusively.

Issue 2: Issue 2: Late policies cannot be created without raising an error

Problem Description: The current implementation throws errors whenever late policies are created. Most of these errors are from the end of the system and not users. This is not desirable from our system as it should be able to handle internal errors and throw error messages only when they are absolutely required.

Fix:

  • Ensure that all errors being raised are fixed. This will be achieved by modifying existing code and bringing new checks as and when required.0
  • Added a flash error message in the create function of late_policies_controller.rb

Issue 3: After creating a late policy, the “back” link does not take the user back to editing the assignment.

Problem Description: The "back" button functionality is broken. In an extensive system like ours, such issues can make our users irritable and do not provide them with the best user experience. These navigation buttons are an important part of the system and should take the users to correct pages.

Fix: Ensure that on click of the back button, the user is taken back to the assignment page.

Issue 4: The "+" and "-" buttons for Show/Hide Date Updater do not work.

Problem Description: If I create an assignment by copying an old assignment, the due dates are copied too. It is likely that I want the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.). To avoid the need to edit all the deadlines manually, Expertiza has a date updater. Currently, the broken "+" and "-" button make it hard for our users to take full advantage of this functionality.

Fix: Editing the code linked to these button should allow us to ensure that users can increment and decrement between dates as per requirements.

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.

Problem Description: The purpose of a test case is to determine if different features within a system are performing as expected and to confirm that the system satisfies all related standards, guidelines, and customer requirements. The process of writing a test case can also help reveal errors or defects within the system.

Fix:

  • Add test file for late_policies_controller_spec.rb with appropriate test cases
  • Add test file for late_policies_spec.rb with appropriate test cases

Expected Results

We expect the new code changes should not break existing functionality and the following results upon completion:

  • 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 increase once tests for late_policy.rb and late_policies_controller.rb are written.





Test Plan


Before fix

Manual Testing ()

  1. Working Demo Video

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 + / - 

After fix

Automated Testing Using RSpec

We created two new test files, late_policy_spec.rb and late_policies_controller_spec.rb which cover test scenarios for late_policy.rb and late_policies_controller.rb repesctively.

late_policy_spec.rb

This test suite covers the two functions available in the model. Our test ensures that the model functions as expected. Most of the corner cases are being covered by controller test and thus the key to this test suite is ensuring all functionalities function as expected.

The first function in the model is for checking if for a particular instructor, the policy name already exists. For this scenario, there are two possible outcomes :

  • Policy name already exists under an instructor.
  • Policy name does not exists under an instructor.

Our test cases cover both of these scenarios.

The second method in this controller checks if penalty points are being updated correctly or not. One key aspect to testing this function was the mocking of the helper method. Our model depends on a helper file to update penalty points based on certain factors. Since the functionality of the model should be independent of helper behavior, we have mocked that call. The calculation of penalty is based on the type of the deadline which can have 4 possible values :

  • nil
  • 1
  • 2
  • 5

Based on each none or one of the penalty points from submission, review or meta_review gets updated. Our test suite goes through each and ensures the correct one is being updated.

late_policies_controller_spec.rb Our controller test ensures that the controller works as expected. We have covered the test cases for each method present in the controller, Moreover, we tried to cover most of the corner cases. We have total of 14 controller test case and detailed test cases can be checked out in our pull request (#Pull Request).

Following are few test cases :


1.) This test case covers the scenario where the penalty per unit exceeds the max penalty for an assignment.


2.) Trying to create/update policy which already exists.



3.) Delete the policy.

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.

Test coverage has been increased by 0.6 percentage :

Milestones

10/25 – Project Selection

11/03 – Develop Project Design Document

11/06 – Update Project Design Document based on feedback from Round 1

Project Mentors

  • Tirth Patel

Team Members

  • Anmol Lunavat
  • Shubham Waghe
  • Vishal Sharma

Useful Links

E2157

  1. GitHub forked repository
  2. Pull Request

Expertiza

  1. Expertiza on GitHub
  2. Live Expertiza website