Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added confirmation prompt for late days #2249

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Nita242004
Copy link

@Nita242004 Nita242004 commented Dec 8, 2024

Added a Confirmation Prompt for Late Days

Description

Adjusted UI by adding a confirmation prompt for the use of late days that appears when pressing the late submit button.

Changed UI:
Screenshot 2024-12-07 at 10 27 59 PM

To implement the confirmation feature, I first identified the handin HTML erb form where users submit assignments and inspected the DOM to trace the submit button’s functionality. Debugging revealed that the button was a "fake" submit, controlled by a JavaScript event listener, preventing direct interaction with the controller. Through console logging in the Javascript file I found that I had no access to the database. I also did not have the ability to modify the controller’s redirect-heavy logic. I focused on the ERB file and discovered an embedded Ruby method that creates a confirmation popup before clicking the button would be processed. By leveraging existing code that calculated late day usage and using the embedded method, I implemented a solution that provided users with accurate feedback in a confirmation prompt.

Motivation and Context

Students mistakenly submit to the wrong assignments, either wasting late days unnecessarily or submitting to assignments where late days are not allowed. As a solution, we can add a confirmation prompt when students are about to use late days. Fixes #2211

How Has This Been Tested?

Tested locally to make sure that the confirmation prompt appears when submitting (see screenshots).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run rubocop and erblint for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting
  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

@Nita242004 Nita242004 marked this pull request as ready for review December 8, 2024 20:51
Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request focus on the _handin_form.html.erb file, specifically modifying the submission form for late submissions. A data attribute has been added to the submit button, which includes a confirmation message related to late submission status. The button's display logic remains unchanged, ensuring it appears only when the assignment is past due. Overall, the form's structure and submission handling remain intact, maintaining existing control flow and error handling.

Changes

File Change Summary
app/views/assessments/_handin_form.html.erb Added a data attribute with a confirm key to the late submission button to prompt user confirmation.

Assessment against linked issues

Objective Addressed Explanation
Confirm use of late days (#2211)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
app/views/assessments/_handin_form.html.erb (3)

56-56: LGTM! Consider enhancing the confirmation message.

The implementation correctly adds a confirmation prompt for late submissions. However, the message could be more explicit to better prevent accidental submissions.

Consider this improved message format:

-<%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "You are #{grace_late_info}. Are you sure you want to continue?" }) %>
+<%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "Warning: You are about to make a late submission.\n\nDetails: #{grace_late_info}\n\nDo you want to proceed with this late submission?" }) %>

56-56: Consider adding ARIA attributes for accessibility.

To improve accessibility, consider adding ARIA attributes to better communicate the late submission status to screen readers.

-<%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "You are #{grace_late_info}. Are you sure you want to continue?" }) %>
+<%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", aria: { label: "Submit assignment late using #{grace_late_info}" }, data: { confirm: "You are #{grace_late_info}. Are you sure you want to continue?" }) %>

Line range hint 18-22: Consider unifying late submission warnings.

Currently, there are multiple places showing late submission information:

  1. Warning message above the form
  2. Confirmation dialog
  3. Small text below the submit button

Consider consolidating these to provide a more cohesive user experience.

Some suggestions:

  1. Use consistent wording across all messages
  2. Consider adding a visual indicator (e.g., warning icon) next to the submit button
  3. Consider moving the grace day calculation logic to a helper method to ensure consistency

Also applies to: 56-56

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fe44b53 and 92490d9.

📒 Files selected for processing (1)
  • app/views/assessments/_handin_form.html.erb (1 hunks)
🔇 Additional comments (1)
app/views/assessments/_handin_form.html.erb (1)

56-56: Verify disabled button behavior with confirmation dialog.

The button has a 'disabled' class which might interfere with the confirmation dialog. Let's verify this interaction.

✅ Verification successful

The disabled class will not interfere with the confirmation dialog

Based on the codebase analysis:

  1. The JavaScript in handin.js properly manages the disabled class on the #fake-submit button, toggling it based on form validation state
  2. The confirmation dialog is implemented using Rails' built-in data: { confirm: } attribute, which works independently of the button's disabled state
  3. Multiple examples in the codebase show similar patterns of using data: { confirm: } with various button states, indicating this is a well-established pattern

The disabled state only affects the visual appearance and click behavior of the button, while the confirmation dialog is handled by Rails UJS at a different level. When the button becomes enabled through JavaScript, both the click handler and confirmation dialog will work as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for JavaScript that might enable/disable the submit button
rg -t js "fake-submit|handin-btn|submissionForm" --type-add 'js:*.{js,coffee}'

# Look for similar confirmation dialogs with disabled buttons
rg -t erb 'data: { confirm:.*disabled'

Length of output: 956


Script:

#!/bin/bash
# Search for confirmation dialog patterns in ERB files with better regex
rg -t erb 'data:\s*{\s*confirm:'

# Look for any JavaScript that handles confirmation dialogs
rg -t js 'confirm|data-confirm' --type-add 'js:*.{js,coffee}'

# Check for any Rails UJS or Turbolinks confirmation handlers
rg 'rails.*confirm|turbolinks.*confirm|data-confirm'

Length of output: 977


Script:

#!/bin/bash
# Search for confirmation dialog patterns in ERB files (fixed regex)
rg "data: \{ confirm:" -t erb

# Look specifically for the handin form's JavaScript behavior
rg "handin.*submit|submit.*handin" -t js --type-add 'js:*.{js,coffee}'

# Check for Rails UJS confirmation handling (fixed search)
rg "data-confirm|rails-ujs.*confirm" app/assets/javascripts/

Length of output: 6067

@evelynzhengg
Copy link

The message can be refined to be more urgent, but the pop up looks great and functional.

@RongYYYY
Copy link

RongYYYY commented Dec 9, 2024

The implementation looks great and effectively resolves the issue by introducing a clear confirmation prompt for late day submissions. The UI design aligns well with user experience best practices by providing clear messaging to users about the implications of their late submission, including the number of late days being used. The confirmation dialog is intuitive, with both "Cancel" and "OK" options prominently displayed.

I tested the changes across multiple scenarios, including submissions within the grace period and significantly late submissions, and found the functionality to work as expected. The prompt consistently displayed accurate information and ensured users had the opportunity to confirm or cancel their actions.

This update is ready to be merged. Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confirm use of late days
3 participants