Skip to content

Feature/ai feedback rating#862

Open
aadhakal wants to merge 10 commits intodevelopfrom
feature/ai-feedback-rating
Open

Feature/ai feedback rating#862
aadhakal wants to merge 10 commits intodevelopfrom
feature/ai-feedback-rating

Conversation

@aadhakal
Copy link
Collaborator

Description

Adds structured AI‑draft feedback capture in the response‑new flow. Teachers now must rate the draft and provide written feedback before bringing it down, then select how they intend to use the draft via a checkbox survey. This keeps AI drafts evaluable and ties usage intent to the draft lifecycle. The UI is compact and consistent with existing styling, and the AI button now works after refresh by preloading the answer relationship.

Feature Components:

  1. Required AI draft rating (5‑star) + written feedback
  2. Usage survey checkboxes before copying AI text
  3. Compact layout + styling for AI draft actions
  4. Fix AI “Draft From AI” disabled state after refresh

Implementation – Rating & Feedback Gate:

  • Add aiDraftRating and aiWrittenFeedback tracked state
  • Require both before enabling “Bring it Down” (rating set + 10+ chars feedback)
  • Reset rating/feedback when a new draft is generated
  • Add star tooltips and required‑field indicators for clarity

Implementation – Usage Survey:

  • “Bring it Down” shows a usage checkbox list instead of copying immediately
  • User must choose at least one usage option before continuing
  • “Continue” then copies the draft into the editor

Implementation – UI Layout:

  • Star rating and written feedback sit inline to save space
  • Labels are standardized in size and aligned horizontally
  • Checkbox survey now renders as a centered, compact popover card aligned to the “Bring it Down” action row for quicker review without shifting the page layout

Implementation – Refresh Fix:

  • Preload the answer relationship in the submission route
  • Prevents the AI button from being incorrectly disabled after refresh (when data only exists on answer)

Changes

Modified Files

  • app/components/response-new.js

    • Added rating + written feedback state (aiDraftRating, aiWrittenFeedback)
    • Enforced bring‑down gate requiring rating + 10‑character feedback
    • Added usage survey state + validation (usageOptions, showUsageCheckboxes, hasSelectedUsageOption)
    • Modified flow: “Bring it Down” → show usage survey → “Continue” copies AI draft
    • Reset rating/feedback/usage when a new AI draft is generated
  • app/components/response-new.hbs

    • Added 5‑star rating UI with tooltips and required indicator
    • Added written feedback textarea and label
    • Added usage survey checkbox list with required prompt and “Continue” button
  • app/styles/_response-mentor-thread.scss

    • Styled rating controls, star hover tooltips, and compact layout
    • Added compact horizontal layout for written feedback
    • Styled usage checkbox panel with light background and spacing
  • app/routes/responses/new/submission.js

    • Preloaded submission.answer to fix AI button disabled state after refresh

Testing

Manual

  • Generated AI draft and verified rating + feedback are required before “Bring it Down”
  • Verified usage checkboxes appear and at least one is required before continuing
  • Confirmed “Continue” copies AI draft into the editor
  • Confirmed AI button works immediately after page refresh

Automated

  • Not run

- Implemented 5-star rating system for AI draft quality assessment
- Added @Tracked aiDraftRating property to store rating (1-5)
- Created starDefinitions array with rating values and tooltip descriptions:
  * 1 star: Not usable - requires complete rewrite
  * 2 stars: Has significant errors or disconnects that prevent use
  * 3 stars: Usable but requires editing before sending
  * 4 stars: Ready to use - could be sent as is
  * 5 stars: Exceptional quality - exceeds expectations
- Added isStarFilled() action to determine filled/empty star state
- Modified canBringDown getter to require rating before enabling button
- Added showRatingControls getter to hide controls after draft is used
- Reset aiDraftRating when generating new AI draft
- Used {{#each}} loop in template to reduce repetitive star markup
- Star rating is required before user can bring AI draft down to editor
- Also minimized the line break for existing and AI text separator
- Styled stars with amber filled (#f5af4e) and gray empty (#ddd) colors
- Created horizontal layout (stars + button side-by-side) with flexbox
- Implemented custom CSS tooltips using ::after pseudo-element
- Tooltips display with paddy green background (#8BC34A)
- Positioned tooltips above stars with proper centering
- Added required asterisk indicator in red on rating label
- Optimized CSS by removing unnecessary transitions and redundant properties
- Stars are 24px for adequate touch target size
- Compact layout with star-rating-container fitting content width
- Added `await submission.answer` in model hook to preload answer relationship
- Wrapped in try/catch since non-VMT submissions may not have answers
- For VMT submissions, answer relationship wasn't loaded into Ember Data cache
- Service uses peekRecord() which only checks cache, doesn't trigger load
- Button now works immediately after page refresh without requiring user interaction

Bug: Button stayed disabled after refresh even with student work present
Root cause: Answer relationship not preloaded for some submissions
- Added @Tracked properties for checkbox states:
  * showUsageCheckboxes - controls visibility of checkbox UI
  * usageNotForStudents - won't use with students
  * usageNotForSelf - won't use for personal learning
  * usageForStudents - will use with students
  * usageToThinkAbout - will save for future consideration
  * usageFeedbackOnAI - will provide AI performance feedback
- Created usageOptions array with checkbox keys and labels
- Modified bringAiDraftDown() to show checkboxes instead of immediate copy
- Added continueWithAIDraft() action to validate and process selections
- Added hasSelectedUsageOption getter to ensure at least one checkbox selected
- Updated showRatingControls to hide when checkboxes are visible
- Checkbox selections logged (TODO: backend integration) before copying draft
- Added conditional .ai-usage-checkboxes section after star rating
- Displays when showUsageCheckboxes is true
- Used {{#each this.usageOptions}} loop to render checkboxes dynamically
- Each checkbox binds to tracked property via {{get this option.key}}
- Added usage-prompt with required asterisk indicator
- Included "Continue" button to proceed after selections
- Validates at least one checkbox selected before allowing continuation
- Compact template using array iteration reduces repetitive markup

UI flow: Rate stars → Click "Bring it Down" → Select usage options →
Click "Continue" → Content copied to editor
- Created .ai-usage-checkboxes styles with light background (#f9f9f9)
- Styled checkbox options with flexbox layout and proper spacing
- Added usage-prompt header with bold font and required asterisk
- Checkbox inputs have pointer cursor for better UX
- Continue button has top margin for visual separation
- Clean, compact design matching existing AI draft section styles
- Add @Tracked aiWrittenFeedback property to store user's written feedback
- Update canBringDown getter to require minimum 10 characters of feedback
- Validation: aiDraftRating !== null && aiWrittenFeedback.trim().length >= 10
- Implement updateAiWrittenFeedback(event) action following standard Ember pattern
- Reset aiWrittenFeedback to empty string when generating new AI draft
- Add written feedback textarea using Ember <Textarea> component
- Implement two-way binding with @value={{this.aiWrittenFeedback}}
- Add {{on 'input' this.updateAiWrittenFeedback}} event handler
- Include label with required asterisk indicator for clarity
- Set placeholder: "Share your thoughts on this AI-generated draft..."
- Use rows={{1}} for compact horizontal layout
- Follow standard form field patterns from codebase
- Create .ai-feedback-container with horizontal layout (flex-direction: row)
- Add align-items: center to align label and textarea side by side
- Set white-space: nowrap on label to prevent text wrapping
- Style textarea: height 30px, padding 4px 8px, font-size 13px
- Set max-width: 450px for balanced usability and compact appearance
- Change .star-rating-container to flex-direction: row for horizontal stars
- Change .ai-draft-actions to align-items: center for uniform alignment
- Standardize all labels to 13px font-size for visual consistency
response-new.hbs: AI draft section now focuses on rating + usage‑intent flow, keeping the editor area clean for the PR scope
response-new.js: action/state logic now aligned to the rating + usage‑intent gate only
_response-mentor-thread.scss: refined usage‑checkbox card positioning (centered, compact, and closer to the action row)
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.

1 participant