CSC/ECE 517 Spring 2022 - E2236: Fix issues related to deadlines and late policies: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(38 intermediate revisions by 2 users not shown)
Line 6: Line 6:
====Issues with the Current Implementation====
====Issues with the Current Implementation====
The following issues have been raised in 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 1''' - When creating a late policy, the “back” link does not take the user back to editing the assignment.
[[File:Issue 1.jpg|1200px]]




[[File:Qissue1.png|650px]]


* '''Issue 2''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.
[[File:Issue 2.jpg|1200px]]


* '''Issue 2''' - Late policies cannot be created without raising an error.




[[File:Qissue2.png|650px]]


* '''Issue 3''' - After checking the "Apply penalty policy" box and clicking the 'save' or 'create' button on the Due dates tab, the box is unchecked on page refresh.
[[File:Issue 3.png|1200px]]


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




[[File:Qissue31.png|650px]]




[[File:Qissue32.png|650px]]




* '''Issue 4''' - The "+" and "-" buttons for Show/Hide Date Updater do not work.
* '''Issue 4''' - There is also no indication of this penalty policy for students, and no proof it actually works
[[File:Issue 4.png|1200px]]




[[File:Issue41.png|650px]]




[[File:Issue42.png|650px]]




* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.
* '''Issue 5''' - No Botton navigating to the list of all late policies
[[File:Issue 5.jpg|1200px]]
 
 
 
 
* '''Issue 6''' - When creating/editing an assignment, you can’t see the detail of each late policy
[[File:Issue 6.png|1200px]]


====Refactoring and Design Patterns====
====Refactoring and Design Patterns====
Line 47: Line 52:


==Project Scope==
==Project Scope==
[[File:Rsz late policy.png|600px]]
[[File:517_Final_flow_chart.drawio.png|600px]]
<br>
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==
 
<h4> Issue 1: Renaming penalty policy to late policy</h4>
'''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.
 
'''Code Snippet : '''
 
[[File:Issue1A.png]]
 
 
<h4> Issue 2: Issue 2: Late policies cannot be created without raising an error </h4>
'''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:'''
<ul>
<li>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</li>
<li>Added a flash error message in the create function of late_policies_controller.rb</li>
</ul>
'''Code Snippet : '''
 
[[File:Issue2A.png]]
 
 
<h4> Issue 3: After creating a late policy, the “back” link does not take the user back to editing the assignment.</h4>
'''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. To achieve this, we have added the assignment reference in the current session.
 
'''Code Snippet : '''
 
[[File:issue3A.png]]
 
 
<h4>Issue 4: The "+" and "-" buttons for Show/Hide Date Updater do not work.</h4>
'''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.We found out that this functionality is already working, however we added an information icon so that it is well understood by the user how to use this.
 
'''Code Snippet : '''
 
[[File:issue4A.png]]
 
<h4>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.</h4>
'''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:'''
<ul>
<li>Added test file for late_policies_controller_spec.rb with appropriate test cases</li>
<li>Added test file for late_policies_spec.rb with appropriate test cases
</ul>
 
 
===Test Plan===
----
'''''Before fix'''''
<br>
<br>
'''Manual Testing ()'''
 
#[https://drive.google.com/file/d/1gpW2Y6mw-ctg5EZE4JZoSLS5mjJuIg1S/view?usp=sharing 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''' - <pre> Due Dates -> No 'penalty policy' on the page. </pre>
 
'''Issue 2''' - <pre> Due Dates -> New late policy -> Enter information and Create -> Late policy is successfully created and saved. </pre>
 
'''Issue 3''' - <pre> Due Dates -> New late policy -> Enter information and Create -> Back -> Edit Assignment (General) </pre>
 
'''Issue 4''' - <pre> Due Dates -> Show/Hide Date Updater -> Enter number of days -> Hit + / - </pre>
 
'''''After fix'''''
 
The new code changes does not break existing functionality. Please check out below video which shows how all the five issues are being addressed :
#[https://drive.google.com/file/d/1gpW2Y6mw-ctg5EZE4JZoSLS5mjJuIg1S/view?usp=sharing Working Demo]
 
'''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.
 
[[File:Test_1.png|600px]]  


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 :
=== Files to be refactored ===
* Policy name already exists under an instructor.
* Policy name does not exists under an instructor.


Our test cases cover both of these scenarios.  
* '''Issue 1'''
Check how to store assignment information into session and fix it.<br>
1. app/views/late_policies/new.html.erb  <br>
2. app/views/assignments/edit/_due_dates.html.erb  <br>
3. app/controllers/assignments_controller.rb  <br>


[[File:Test_2.png|600px]]
* '''Issue 2'''
[[File:Test_3.png|600px]]
Store assignment information in session through the creation of late policies.<br>
1. app/views/late_policies/new.html.erb  <br>
2. app/views/assignments/edit/_due_dates.html.erb  <br>
3. app/controllers/assignments_controller.rb  <br>


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 :
* '''Issue 3'''
* nil
Save late policy information of this assignment into database.<br>
* 1
1. app/views/assignments/edit/_due_dates.html.erb<br>
* 2
2. app/controllers/assignments_controller.rb<br>
* 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.  
* '''Issue 4'''
Show late policy of current assignment on student view page.<br>
1. app/views/student_task/view.html.erb <br>
2. app/controllers/student_task_controller.rb <br>


'''late_policies_controller_spec.rb'''
* '''Issue 5'''  
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 (#[https://github.com/expertiza/expertiza/pull/2127 Pull Request]).
Create buttons link to all late policies on both main page and assigment view page.<br>
1. app/views/assignments/edit/_late_policy.html.erb<br>
2. app/controllers/assignments_controller.rb<br>


Following are few test cases :
* '''Issue 6'''
A button link to all late policies on assignment/new page to show all policies.<br>
1. app/views/assignments/edit/_late_policy.html.erb<br>
2. app/controllers/assignments_controller.rb<br>


1.) This test case covers the scenario where the penalty per unit exceeds the max penalty for an assignment.
== Testing ==
=== Testing Goals and Test Objects ===


[[File:MaxPenaltyLess.png]]
#When logging in as a student:
##You can see the late policy details of your assignments
##The late policy works correctly if you submit your assignment late
#When logging in as an instructor:
##There is a button to navigate you to the page showing all the late policies
##You can see the details of the late policy when creating or editing an assignment
##The "back" button will lead to a correct webpage when creating or editing an assignment
##The "Apply penalty policy" box is saved after submitting the form when creating or editing an assignment


=== RSpec Unit Tests ===
'''''Test cases provided here, will add RSpec code blocks for the final submission'''''
*Issue1
<pre>
Scenario: The instructor wants to go back as he is creating a new late policy
Given: Logged in as an instructor
When: Clicks “Manage…” -> “Assignments” -> “Create new assignment” -> “Due dates” -> “Createlate policy”
And: Clicks “Back”
Then: Redirect to the previous create assignment page.
</pre>
*Issue2
<pre>
Scenario: The instructor have created a new late policy and tries to go back to previous page
Given: Logged in as an instructor
When: An instructor successfully creates a new late policy, being redirected to the “/late_policies” webpage with all information of late policies.
And: The instructor clicks “Back” button
Then: The instructor is redirected to the previous create/edit assignment page.
</pre>
*Issue3: After checking the "Apply penalty policy" box and clicking the 'save' or 'create' button on the Due dates tab, the box is unchecked on page refresh.
<pre>
Scenario: The instructor create a new assignment with a late policy applied
Given: Logged in as an instructor
When: The instructor clicks “Manage…” -> “Assignments” -> “Create new assignment”, enter informations for the new assignment
And: Click “Save” and refresh/redirect to the assignment edit page
Then: The checkbox for the late policy should be in the state of checked.
</pre>
<pre>
Scenario: The instructor apply a late policy to an assignment with no late policy applied yet
Given: Logged in as an instructor
When: The instructor clicks “Manage…” -> “Assignments” and goes to an assignment’s edit page
And: The assignment should not has late policy applied before
Then: As the instructor applies late policy to the assignment and refresh/redirect to the assignment edit page, the checkbox for the late policy should be in the state of checked.
</pre>
*Issue4: Show indication and proof about late policies at student’s side
<pre>
Scenario: A student wants to know late policies related to his assignments
Given: Logged in as a student
When: The student clicks “Assignments” from navbar
And: Select an assignment and redirect to the assignment’s detail page (“student_task/view”)
Then: There should be a section parallel with sections like “Signup sheet” and “Your score”, with the name of “Late policy”. As the student clicks on it, the website redirects to the assignment’s late policy detail page.
</pre>
*Issue5: Add “Late policies” inside the “Mange…” section from instructors’ navbar
<pre>
Scenario: An instructor tries to view the list of all the late policies without creating a new assignment
Given: Logged in as an Instructor
When: The instructor hovers his mouse on the “Manage…” section for navbar
And: From the list below, there should be a section called “Late policies”
Then: As the instructor clicks the “Late policies” section, he gets redirected to the /late_policies with all late policies’ details.
</pre>
*Issue6: Add “show all late policies” button inside the “new assignment” -> “Due dates” page
<pre>
Scenario: An instructor tries to create a new assignment and apply a late policy to it
Given: Logged in as an Instructor
When: The instructor clicks “Manage…” -> “Assignments” -> “Create new assignment” -> “Due dates”
And: Besides the “New late policy” button, there should be a “Show all late policies” button.
Then: As the instructor clicks the “Show all late policies” button, he gets redirected to the /late_policies with all late policies’ details.
</pre>


2.) Trying to create/update policy which already exists.
=== Manual Testing ===
'''Student's View in Assignment'''


[[File:SamePolicy.png]]  
[[File:Student View.png|1200px]]


'''Admin's View When Creating new Assignment'''


[[File:createSamePolicy.png]]
[[File:Admin View.png|1200px]]
 
 
3.) Delete the policy.
 
[[File:DestroyPolicy.png]]
 
'''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 :
 
[[File:Coverage.png]]
 
==Milestones==
 


==Project Mentors==
==Project Mentors==
*
* Nicholas Himes


==Team Members==
==Team Members==
Line 213: Line 180:


==Useful Links==
==Useful Links==
===E2157===
===E2236===
#[https://github.com/wshubham/expertiza/tree/beta GitHub forked repository]
#[https://github.com/517-E2236/expertiza/tree/beta GitHub Repository]
#[https://github.com/expertiza/expertiza/pull/2127 Pull Request]


===Expertiza===
===Expertiza===
#[https://github.com/expertiza/expertiza Expertiza on GitHub]
#[https://github.com/expertiza/expertiza Expertiza on GitHub]
#[http://expertiza.ncsu.edu/ Live Expertiza website]
#[http://expertiza.ncsu.edu/ Live Expertiza website]
===Demo Vedio===
#[https://drive.google.com/file/d/1o91z8bYT0cTnydLSqCaHpV0tCIOTFiyD/view?usp=sharing/ Demo Vedio Link]

Latest revision as of 20:24, 26 April 2022

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 - When creating a late policy, the “back” link does not take the user back to editing the assignment.


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



  • Issue 3 - After checking the "Apply penalty policy" box and clicking the 'save' or 'create' button on the Due dates tab, the box is unchecked on page refresh.




  • Issue 4 - There is also no indication of this penalty policy for students, and no proof it actually works




  • Issue 5 - No Botton navigating to the list of all late policies



  • Issue 6 - When creating/editing an assignment, you can’t see the detail of each late policy

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

Files to be refactored

  • Issue 1

Check how to store assignment information into session and fix it.
1. app/views/late_policies/new.html.erb
2. app/views/assignments/edit/_due_dates.html.erb
3. app/controllers/assignments_controller.rb

  • Issue 2

Store assignment information in session through the creation of late policies.
1. app/views/late_policies/new.html.erb
2. app/views/assignments/edit/_due_dates.html.erb
3. app/controllers/assignments_controller.rb

  • Issue 3

Save late policy information of this assignment into database.
1. app/views/assignments/edit/_due_dates.html.erb
2. app/controllers/assignments_controller.rb

  • Issue 4

Show late policy of current assignment on student view page.
1. app/views/student_task/view.html.erb
2. app/controllers/student_task_controller.rb

  • Issue 5

Create buttons link to all late policies on both main page and assigment view page.
1. app/views/assignments/edit/_late_policy.html.erb
2. app/controllers/assignments_controller.rb

  • Issue 6

A button link to all late policies on assignment/new page to show all policies.
1. app/views/assignments/edit/_late_policy.html.erb
2. app/controllers/assignments_controller.rb

Testing

Testing Goals and Test Objects

  1. When logging in as a student:
    1. You can see the late policy details of your assignments
    2. The late policy works correctly if you submit your assignment late
  2. When logging in as an instructor:
    1. There is a button to navigate you to the page showing all the late policies
    2. You can see the details of the late policy when creating or editing an assignment
    3. The "back" button will lead to a correct webpage when creating or editing an assignment
    4. The "Apply penalty policy" box is saved after submitting the form when creating or editing an assignment

RSpec Unit Tests

Test cases provided here, will add RSpec code blocks for the final submission

  • Issue1
Scenario: The instructor wants to go back as he is creating a new late policy
Given: Logged in as an instructor
When: Clicks “Manage…” -> “Assignments” -> “Create new assignment” -> “Due dates” -> “Createlate policy”
And: Clicks “Back”
Then: Redirect to the previous create assignment page.
  • Issue2
Scenario: The instructor have created a new late policy and tries to go back to previous page
Given: Logged in as an instructor
When: An instructor successfully creates a new late policy, being redirected to the “/late_policies” webpage with all information of late policies.
And: The instructor clicks “Back” button
Then: The instructor is redirected to the previous create/edit assignment page.
  • Issue3: After checking the "Apply penalty policy" box and clicking the 'save' or 'create' button on the Due dates tab, the box is unchecked on page refresh.
Scenario: The instructor create a new assignment with a late policy applied
Given: Logged in as an instructor
When: The instructor clicks “Manage…” -> “Assignments” -> “Create new assignment”, enter informations for the new assignment
And: Click “Save” and refresh/redirect to the assignment edit page
Then: The checkbox for the late policy should be in the state of checked.
Scenario: The instructor apply a late policy to an assignment with no late policy applied yet
Given: Logged in as an instructor
When: The instructor clicks “Manage…” -> “Assignments” and goes to an assignment’s edit page
And: The assignment should not has late policy applied before
Then: As the instructor applies late policy to the assignment and refresh/redirect to the assignment edit page, the checkbox for the late policy should be in the state of checked.
  • Issue4: Show indication and proof about late policies at student’s side
Scenario: A student wants to know late policies related to his assignments
Given: Logged in as a student
When: The student clicks “Assignments” from navbar
And: Select an assignment and redirect to the assignment’s detail page (“student_task/view”)
Then: There should be a section parallel with sections like “Signup sheet” and “Your score”, with the name of “Late policy”. As the student clicks on it, the website redirects to the assignment’s late policy detail page.
  • Issue5: Add “Late policies” inside the “Mange…” section from instructors’ navbar
Scenario: An instructor tries to view the list of all the late policies without creating a new assignment
Given: Logged in as an Instructor
When: The instructor hovers his mouse on the “Manage…” section for navbar
And: From the list below, there should be a section called “Late policies”
Then: As the instructor clicks the “Late policies” section, he gets redirected to the /late_policies with all late policies’ details.
  • Issue6: Add “show all late policies” button inside the “new assignment” -> “Due dates” page
Scenario: An instructor tries to create a new assignment and apply a late policy to it
Given: Logged in as an Instructor
When: The instructor clicks “Manage…” -> “Assignments” -> “Create new assignment” -> “Due dates” 
And: Besides the “New late policy” button, there should be a “Show all late policies” button.
Then: As the instructor clicks the “Show all late policies” button, he gets redirected to the /late_policies with all late policies’ details.

Manual Testing

Student's View in Assignment

Admin's View When Creating new Assignment

Project Mentors

  • Nicholas Himes

Team Members

  • Zhiyuan Ma
  • Gaolin Zhang
  • Zhijin Yang
  • Yuyang Jiang

Useful Links

E2236

  1. GitHub Repository

Expertiza

  1. Expertiza on GitHub
  2. Live Expertiza website

Demo Vedio

  1. Demo Vedio Link