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

From Expertiza_Wiki
Jump to navigation Jump to search

Late Policy Feature Fixes in Expertiza

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.

Test Login Credentials

UserId: instructor6

Password: password

Problem Statement

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.

Test Plan

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

Manual UI Testing

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

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

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

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

Demo Video

A demonstration video showcasing the fixes and the improved workflow for creating and managing late policies in Expertiza can be found [here](#).

Project Mentor

Name: Anvitha Reddy Gutha

Email: agutha@ncsu.edu

Team Members

Neel Shah

Shaival Shah

Aatman Patel

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)