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

Feature: Sortable Student Solutions #4315

Merged
merged 1 commit into from
Jan 16, 2024
Merged

Conversation

KevinMulhern
Copy link
Member

@KevinMulhern KevinMulhern commented Jan 7, 2024

#4222

Motivation

Currently, we only display a limited list of 10 solutions ordered by most liked on the project page. With no easy way to reorder the list, these 10 most liked solutions are all what most users will ever see and any new solutions have little chance of been seen. This significantly reduces the incentive of using this feature.

Being able to easily reorder the list in different ways, such as newest, oldest and most liked will allow users to view a much larger range of solutions and will greatly increase how often recent solutions are seen.

Screen.Recording.2024-01-13.at.15.55.55.mov

Redesigned Lesson UI

Our existing UI posed a few problems with sorting, mainly with how we display the current users solution. We "pin" it to the top of the list so its always in the same predictable place when the user goes looking for it.

For reference this is how it looks in production at the moment:
Screenshot 2024-01-13 at 15 59 02

That doesn't work well with sorting. It looks odd if other items change position but the top item stays the same after changing the sort order. This problem necessitated a rethink of our solutions UI with the following user experience in mind:

  • The current users solution should always be in the same predicable place
  • It should be obvious if a user has submitted a solution for a project or not
  • Viewing other learners solutions besides your own should still be easy and accessible

A new "Your solution" component will be displayed within the lesson 2 column layout:
Screenshot 2024-01-13 at 15 57 00

A dedicated component for the users project solution allows us to have nicer empty state which should makes it obvious if a solution has been submitted or not:
Screenshot 2024-01-13 at 15 57 18

When viewing other learners solutions, we redirect users to the "All solutions" page for a individual projects. Using a full page instead of a limited view on the project itself will give us plenty of room to expand the feature set of this area in the future:

Screen.Recording.2024-01-13.at.15.58.01.mov

Bonus

With the solutions component moved within the two column layout, it made sense to move the complete and navigation buttons too. I think this is generally a better fit rather than having them off on their own “island” as per the old design.

Screenshot 2024-01-13 at 15 58 18

@KevinMulhern KevinMulhern added the create-review-app Create a Heroku review app for pull request label Jan 7, 2024
@github-actions github-actions bot removed the create-review-app Create a Heroku review app for pull request label Jan 7, 2024
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 7, 2024 10:36 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 8, 2024 08:39 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 10, 2024 16:44 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 10, 2024 18:44 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 11, 2024 08:39 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 11, 2024 09:52 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 11, 2024 09:54 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 12, 2024 18:48 Inactive
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 12, 2024 19:10 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from b2b41d5 to fb77174 Compare January 13, 2024 10:46
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 13, 2024 10:46 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from fb77174 to 50cf074 Compare January 13, 2024 11:08
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 13, 2024 11:08 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from 50cf074 to e262b06 Compare January 13, 2024 12:03
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 13, 2024 12:04 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from e262b06 to b84f48e Compare January 13, 2024 12:11
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 13, 2024 12:12 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from b84f48e to 4768e0c Compare January 13, 2024 12:49
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 13, 2024 12:49 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from 4768e0c to a40ecab Compare January 13, 2024 15:06
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 13, 2024 15:07 Inactive
@KevinMulhern KevinMulhern marked this pull request as ready for review January 13, 2024 16:42
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 14, 2024 23:48 Inactive
@@ -52,6 +52,10 @@ Layout/EmptyLinesAroundAttributeAccessor:
Layout/SpaceAroundMethodCallOperator:
Enabled: true

Layout/MultilineMethodCallIndentation:
Copy link
Member Author

@KevinMulhern KevinMulhern Jan 15, 2024

Choose a reason for hiding this comment

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

Made this change because Rubocop was popping off about the project submissions query in the submissions controller.

I personally think the indented version is nicer/easer to read. But happy to revert this if that view isn't shared.

def selected?(option)
return option[:default] if selected.compact.empty?

option[:value] == selected[:value] && option[:direction] == selected[:direction]
Copy link
Member Author

Choose a reason for hiding this comment

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

It's not great using a hash for this, I may do a follow up refactor to move this into a SortOption value object - this PR was getting too big.

@@ -46,7 +46,7 @@

expect { course_builder }
.to change { existing_course.reload.title }.from('Development 101').to('Foundations')
.and change { existing_course.position }.from(2).to(1)
.and change { existing_course.position }.from(2).to(1)
Copy link
Member Author

Choose a reason for hiding this comment

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

Consequence of the Layout/MultilineMethodCallIndentation: Rubocop rule change

Copy link
Member

Choose a reason for hiding this comment

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

Agree this is much nicer

FlagNotification.with(flag:, title: message.title, message: message.content, url: message.url)
.deliver_later(flag.project_submission.user)

FlagNotification
Copy link
Member Author

Choose a reason for hiding this comment

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

Consequence of the Layout/MultilineMethodCallIndentation: Rubocop rule change

@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from a40ecab to 0d8ed5d Compare January 15, 2024 00:35
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 15, 2024 00:35 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from 0d8ed5d to 3b171d6 Compare January 15, 2024 00:39
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 15, 2024 00:39 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from 3b171d6 to 797cb07 Compare January 15, 2024 00:40
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 15, 2024 00:41 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from 797cb07 to 609ed0e Compare January 15, 2024 00:54
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 15, 2024 00:55 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from 609ed0e to 5939963 Compare January 15, 2024 01:31
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 15, 2024 01:31 Inactive
@KevinMulhern KevinMulhern added the Status: Needs Review This issue/PR needs an initial or additional review label Jan 15, 2024
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from 5939963 to a752126 Compare January 15, 2024 18:36
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 15, 2024 18:36 Inactive
@KevinMulhern KevinMulhern requested review from CouchofTomato and a team January 15, 2024 19:33
Copy link
Member

@CouchofTomato CouchofTomato left a comment

Choose a reason for hiding this comment

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

Works really well. I left a couple of small comments but they aren't blockers at all.

Awesome addition mate 🥳


<div class="flex items-center mb-4 md:mb-0">
<%= render ProjectSubmissions::LikeComponent.new(project_submission:, current_users_submission: current_users_submission?) %>
<%= render ProjectSubmissions::LikeComponent.new(project_submission:, current_users_submission: false) %>
Copy link
Member

Choose a reason for hiding this comment

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

Since the LikeComponent has a default value for current_users_submission do we need to specify that it's false or are you preferring to be explicit here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice spot, I don't mind this being implicit instead.

<h3 class="mt-2 text-xl font-semibold text-gray-900 dark:text-gray-200">No solutions</h3>
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Be the first</p>
<h3 class="mt-2 text-xl font-semibold text-gray-900 dark:text-gray-200">No solutions</h3>
<%= link_to 'Submit your solution', lesson_path(@lesson, anchor: 'project-solution'), class: 'mt-2 text-sm button button--secondary py-2', data: { turbo_frame: '_top'} %>
Copy link
Member

Choose a reason for hiding this comment

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

It feels a bit janky to navigate them back to the lesson page to submit their solution so they effectively have to click twice on the same text to submit their solution. Couldn't we use turbo's power here to just load the solution component in place? Maybe one for a future PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call out - yeah this was a bit of a cop out. The new user solution component being different from the item component we use on this page makes it a little bit more difficult to create a solution here. But I'll have a think about ways around that.

In the meantime I think we're probably better off prompting users to return to the project page instead of submitting. That feels a bit less janky.

@@ -46,7 +46,7 @@

expect { course_builder }
.to change { existing_course.reload.title }.from('Development 101').to('Foundations')
.and change { existing_course.position }.from(2).to(1)
.and change { existing_course.position }.from(2).to(1)
Copy link
Member

Choose a reason for hiding this comment

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

Agree this is much nicer

Because:
- Being able to sort solutions will give users the ability to view solutions in different ways. Currently we only display solutions in order of most liked, which has resulted in the most liked solutions being all that a majority of our users ever see.

This commit:
- Adds a reusable sort component
- Add the ability for users to sort solutions by newest, oldest and most liked
- Includes redesigned UI for project and lesson pages
  - The user solution is now the only solution visible on project pages and moved into the lessons two column layout
  - The lesson complete/navigation buttons have also been moved into the lessons two column layout.
- Adds a dedicated user solution component instead of using the project submission item component for both the current user and other user submissions.

---

-
@KevinMulhern KevinMulhern force-pushed the feature/sorting-solutions branch from a752126 to 2a00fe0 Compare January 16, 2024 14:14
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-4315 January 16, 2024 14:14 Inactive
@KevinMulhern KevinMulhern merged commit 38e724a into main Jan 16, 2024
3 checks passed
@KevinMulhern KevinMulhern deleted the feature/sorting-solutions branch January 16, 2024 21:22
KevinMulhern added a commit that referenced this pull request Jan 16, 2024
Seems to be a bit of a performance issues with solution pages, probably
missing an index. Reverting for now.
Reverts #4315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review This issue/PR needs an initial or additional review
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants