CSC/ECE 517 Spring 2024 - E2411 : Fix "Back" link on “New Late Policy” page: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 132: Line 132:
* '''Navigating Back After Creating Late Policy:''' Checked that after creating a new late policy, clicking the "Back" link on the list of late policies page correctly redirects the user to the "Due Date" tab of the assignment being edited.
* '''Navigating Back After Creating Late Policy:''' Checked that after creating a new late policy, clicking the "Back" link on the list of late policies page correctly redirects the user to the "Due Date" tab of the assignment being edited.


== Program 4 ==
== Program 4 (Final Project) ==
=== Further Changes ===
=== Further Changes ===
We plan to add tests (Phase 1 did not have comprehensive tests), solve the codeclimate issues, and attempt to solve the additional issue in this phase.
We plan to add tests (Phase 1 did not have comprehensive tests), solve the codeclimate issues, and attempt to solve the additional issue in this phase.
Line 138: Line 138:
- Additional Issue: If a user directly visits the “New Late Policy” page, without going through the “edit assignment” workflow, there isn’t a “assignment” which they should be editing. In this case, the “Back” link on both “new late policy” and “all late policies” page should go to the Assignments tab on the home screen.
- Additional Issue: If a user directly visits the “New Late Policy” page, without going through the “edit assignment” workflow, there isn’t a “assignment” which they should be editing. In this case, the “Back” link on both “new late policy” and “all late policies” page should go to the Assignments tab on the home screen.


==== Test Plan ====
=== Test Plan ===


<pre>
<pre>
Line 204: Line 204:
</pre>
</pre>


=== Design ===
== Design ==
The objective of this project was to address multiple issues related to the creation and navigation of late policies for assignments in the Expertiza system. Our primary focus was on improving reliability, maintainability, and adherence to established design principles.  
* The objective of this project was to address multiple issues related to the creation and navigation of late policies for assignments in the Expertiza system. Our primary focus was on improving reliability, maintainability, and adherence to established design principles.  


Refactoring, as a systematic process, entails enhancing the codebase without altering its external behavior. As such we aimed to maintain consistency in the codebase by not altering existing design patterns unnecessarily. This approach ensured compatibility with the existing system and minimized the risk of introducing new bugs. Our refactoring efforts were primarily focused on improving the reliability of the Experiza system. By renaming ambiguous variables and ensuring that the refactored code aligned with established standards of object-oriented design, we optimized the codebase and minimized potential points of failure. Before deploying our fixes, we conducted thorough testing to ensure that existing features continued to work as expected. This validation process involved testing all relevant functionalities to verify that our changes did not introduce bugs.  
* Refactoring, as a systematic process, entails enhancing the codebase without altering its external behavior. As such we aimed to maintain consistency in the codebase by not altering existing design patterns unnecessarily. This approach ensured compatibility with the existing system and minimized the risk of introducing new bugs. Our refactoring efforts were primarily focused on improving the reliability of the Experitza system. By renaming ambiguous variables and ensuring that the refactored code aligned with established standards of object-oriented design, we optimized the codebase and minimized potential points of failure. Before deploying our fixes, we conducted thorough testing to ensure that existing features continued to work as expected. This validation process involved testing all relevant functionalities to verify that our changes did not introduce bugs.  


By following this approach to refactoring and adhering to established design principles, we successfully addressed the identified issues in the Experiza system. Our efforts have led to a more reliable and maintainable codebase, consistent with the standards of object-oriented design.
* By following this approach to refactoring and adhering to established design principles, we successfully addressed the identified issues in the Expertiza system. Our efforts have led to a more reliable and maintainable codebase, consistent with the standards of object-oriented design.


== UML Diagram ==
== UML Diagram ==

Latest revision as of 23:55, 25 April 2024


Introduction

The Expertiza project, a Ruby on Rails-based application, facilitates peer review and learning among students by allowing instructors to create and manage assignments and courses. One of the features of Expertiza is the ability for instructors to set up late policies for assignment submissions, specifying penalties for late submissions in terms of points per unit time and maximum penalties. However, several issues were identified in the implementation of the late policy feature, including error messages when creating new late policies and incorrect redirections when navigating back from the late policy pages.

Problem Statement

"This project aims to solve three issues, all related to the "New Late Policy" and "Due Dates" page while creating/editing an assignment"

Issues

Issue 1: Error Message on New Late Policy Page

When an instructor attempts to create a new late policy for an assignment, an error message "Failed to save the assignment: #" is displayed, even though the late policy creation process does not directly involve saving the assignment itself. This error message is misleading and does not provide useful information about the actual cause of the error.

Issue 2: Incorrect Redirection on New Late Policy Page

After clicking the "Back" link on the "New Late Policy" page, the user is redirected to an error page instead of the "Due Date" tab of the assignment edit page. This issue disrupts the workflow of the instructor who may want to return to the assignment details after creating or attempting to create a new late policy.



Issue 3: Incorrect Redirection After Creating Late Policy

Similarly, after creating a new late policy and being presented with the list of all late policies, clicking the "Back" link results in an error page rather than redirecting the user back to the "Due Date" tab of the assignment being edited. This issue further hinders the usability of the late policy feature.



Proposed Solution

  • To address the issues outlined above, the following solutions were proposed:

Fixing Error Message

  • The error handling mechanism in the `AssignmentForm` model was updated to provide more informative and relevant error messages. Instead of displaying a generic error message, the system now identifies and communicates specific errors that occur during the late policy creation process.

Correcting Redirections

  • The redirection issues were resolved by properly managing the `session[:assignment_id]` variable in the relevant controller actions. By ensuring that the assignment ID is correctly set and maintained in the session, the "Back" links on the late policy pages now correctly redirect the user to the "Due Date" tab of the assignment edit page.

Implementation Details

The implementation involved changes to several files in the Expertiza codebase:

1. In `assignments_controller.rb`, the `session[:assignment_id]` variable is now correctly set in the `edit`, `show`, and other relevant actions to ensure proper navigation.

2. In the `assignment_form.rb` model, the error handling logic was updated to use `@assignment.errors.full_messages` instead of `@assignment.errors.to_s`, providing more descriptive error messages.

3. In the `edit.html.erb` and `new.html.erb` views for late policies, the "Back" link URLs were updated to use `session[:assignment_id]` to ensure correct redirection to the assignment edit page.

Snippets

Fig.A : The first snippet is from the assignments_controller.rb file. Three improvements were made to the existing code to fix issue 1.

  • [Lines 51-52] Firstly, the variable aid has an ambiguous named that create problems later. This was corrected to assignment_id.
  • [Lines 54-55] Next, the assignment_id was never added to the session. This was corrected. This impacts all three issues and resulted in subsequent changes in the file (lines 77-78, 93-95).
  • [Lines 77-78], make sure that assignment_id is set to nil while editing, while lines 93-95 extract assignment from the parameters and then adds assignment_id to the sessions list. Similar operations are performed in line 120 for show.


Fig.B : The changes below simply rename aid to assignment_id in other parts of the file.


Fig.C : The snippet below in from the assignment_form.rb file in the models. Previously, the to_s method was called, instead, to display full error messages full_messages was called.


Fig.D : Variable Renaming and Session Handling. The update includes variable clarification to avoid ambiguity, addition of assignment details to the session, and logging the creation of assignments for better debugging.


Fig.E : Improving code clarity by renaming variables and optimizing session management in Ruby on Rails.


Fig.F : Streamlining Session Data and Refining Redirects. The code enhances stores identifiers in the session and improves readability with variable name changes.


Fig.G : Error Messaging in Assignment Model: Replacing terse error strings with detailed messages for better user feedback.


Fig.H : Automating Navigation to Due Dates Section by redirecting users to the due dates page based on referral URL conditions.


Fig.I : Context-Aware 'Back' Link: Returning to the editing page, utilizing the assignment ID stored in the session.

Test Plan (Phase 1/Program 3)

1. Rspec Automated Testing

Automated tests were added to verify the following:

1. The error message displayed when creating a new late policy is informative and relevant.

2. The "Back" link on the "New Late Policy" page redirects to the "Due Date" tab of the assignment edit page.

3. The "Back" link on the list of late policies page

2. Manual UI Testing

In addition to automated tests, manual testing was conducted to ensure that the user interface behaves as expected:

  • Creating a New Late Policy: Tested the creation of a new late policy to ensure that no erroneous error messages are displayed and that the creation process is smooth.
  • Navigating Back from New Late Policy Page: Verified that clicking the "Back" link on the "New Late Policy" page correctly redirects the user to the "Due Date" tab of the assignment edit page.
  • Navigating Back After Creating Late Policy: Checked that after creating a new late policy, clicking the "Back" link on the list of late policies page correctly redirects the user to the "Due Date" tab of the assignment being edited.

Program 4 (Final Project)

Further Changes

We plan to add tests (Phase 1 did not have comprehensive tests), solve the codeclimate issues, and attempt to solve the additional issue in this phase.

- Additional Issue: If a user directly visits the “New Late Policy” page, without going through the “edit assignment” workflow, there isn’t a “assignment” which they should be editing. In this case, the “Back” link on both “new late policy” and “all late policies” page should go to the Assignments tab on the home screen.

Test Plan

Test create method in AssignmentsController:
 Test case: when creating a new assignment
 Test case: verifies that the error message "Failed to save the assignment: #" does not appear.
 Test case: ensures that the assignment ID is correctly stored in the session.
 Test case: when editing an assignment
 Test case: verifies that the assignment ID is set to nil in the session.
 Test case: ensures that the assignment ID is correctly updated in the session.
Test edit method in AssignmentsController:
 Test case: when editing an assignment
 Test case: verifies that the assignment ID is correctly stored in the session.
 Test case: ensures that the assignment ID is correctly updated in the session.
Test show method in AssignmentsController:
 Test case: when displaying an assignment via ID
 Test case: verifies that the correct assignment ID is stored in the session.
Test update_assignment method in AssignmentForm:
 Test case: when updating assignment attributes
 Test case: verifies that assignment attributes are updated successfully.
 Test case: ensures that errors are correctly handled and logged.
Test update_due_dates method in AssignmentForm:
 Test case: when updating due dates for an assignment
 Test case: verifies that due dates are updated successfully.
 Test case: ensures that errors are correctly handled and logged.
Test JavaScript function in edit.html.erb:
 Test case: when redirecting to the "Due Dates" tab after clicking the "Back" link from the "New Late Policy" page
 Test case: verifies that the user is redirected correctly.
Test JavaScript function in late_policies/index.html.erb:
 Test case: when redirecting to the assignment edit page after clicking the "Back" link from the "New Late Policy" page
 Test case: verifies that the user is redirected correctly.
Test JavaScript function in late_policies/new.html.erb:
 Test case: when redirecting to the assignment edit page after clicking the "Back" link from the "New Late Policy" page
 Test case: verifies that the user is redirected correctly.
Test AssignmentCreationHelper methods in late_policy_features.rb:
 Test case: when creating a new assignment and navigating to the "Due Dates" tab
 Test case: verifies that the user is able to navigate correctly.
 Test case: when interacting with the "Back" button on the "New Late Policy" page
 Test case: verifies that the user is able to navigate correctly.
 Test case: when interacting with the "Back" button on the "New Late Policy" page while creating a late policy
 Test case: verifies that the user is able to navigate correctly.

Design

  • The objective of this project was to address multiple issues related to the creation and navigation of late policies for assignments in the Expertiza system. Our primary focus was on improving reliability, maintainability, and adherence to established design principles.
  • Refactoring, as a systematic process, entails enhancing the codebase without altering its external behavior. As such we aimed to maintain consistency in the codebase by not altering existing design patterns unnecessarily. This approach ensured compatibility with the existing system and minimized the risk of introducing new bugs. Our refactoring efforts were primarily focused on improving the reliability of the Experitza system. By renaming ambiguous variables and ensuring that the refactored code aligned with established standards of object-oriented design, we optimized the codebase and minimized potential points of failure. Before deploying our fixes, we conducted thorough testing to ensure that existing features continued to work as expected. This validation process involved testing all relevant functionalities to verify that our changes did not introduce bugs.
  • By following this approach to refactoring and adhering to established design principles, we successfully addressed the identified issues in the Expertiza system. Our efforts have led to a more reliable and maintainable codebase, consistent with the standards of object-oriented design.

UML Diagram

Demo Video

A demonstration video showcasing the fixes and the improved workflow for creating and managing late policies in Expertiza can be found here: https://youtu.be/02VAeJ1xukE

Project Mentor

Name: Anvitha Reddy Gutha

Email: agutha@ncsu.edu

Team Members

Neel Shah - npshah6@ncsu.edu

Shaival Shah - sshah35@ncsu.edu

Aatman Patel - ahpate25@ncsu.edu

References

Expertiza GitHub Repository: [1](https://github.com/expertiza/expertiza)

RSpec Documentation: [2](https://relishapp.com/rspec)

Ruby on Rails Documentation: [3](https://guides.rubyonrails.org)

Deployment Link - http://152.7.177.234:8080/