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

List own courses first when copying a course #3049

Closed
wants to merge 2 commits into from

Conversation

TimonDB
Copy link
Contributor

@TimonDB TimonDB commented Aug 30, 2021

This pull request lists the user's own courses (course admin) first in the course table when copying a course. To accomplish this, I split up the courses into 2 sets, one where the user is course admin of the courses and one where the user is not course admin.

Closes #1661.

@TimonDB TimonDB requested a review from a team as a code owner August 30, 2021 12:07
@TimonDB TimonDB requested review from bmesuere and chvp and removed request for a team August 30, 2021 12:07
app/controllers/courses_controller.rb Outdated Show resolved Hide resolved
@TimonDB TimonDB requested a review from chvp August 30, 2021 14:00
Comment on lines +32 to +38
@featured_courses = @courses.where(featured: true)
@own_courses = @courses.where(featured: false)
.reorder(year: :desc, name: :asc)
.select { |course| current_user.course_admin?(course) }
@other_courses = @courses.where(featured: false)
.reorder(year: :desc, name: :asc)
.reject { |course| current_user.course_admin?(course) }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@featured_courses = @courses.where(featured: true)
@own_courses = @courses.where(featured: false)
.reorder(year: :desc, name: :asc)
.select { |course| current_user.course_admin?(course) }
@other_courses = @courses.where(featured: false)
.reorder(year: :desc, name: :asc)
.reject { |course| current_user.course_admin?(course) }
featured_courses = @courses.where(featured: true)
own_courses = @courses.where(featured: false)
.reorder(year: :desc, name: :asc)
.select { |course| current_user.course_admin?(course) }
other_courses = @courses.where(featured: false)
.reorder(year: :desc, name: :asc)
.reject { |course| current_user.course_admin?(course) }
@courses = featured_courses + own_courses + other_courses

This way, no changes to the HTML are necessary. (Make sure to check this locally, I'm not entirely sure if the + works if the actual data hasn't been loaded yet.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to result in an error:
Screenshot from 2021-08-30 16-50-11

It would be nice if that was possible because now there is a lot of redundant code in the HTML

Copy link
Member

Choose a reason for hiding this comment

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

You can look at the server log to see the actual error. Probably an explicit load is necessary for the featured_courses.

@chvp chvp added the enhancement A change that isn't substantial enough to be called a feature label Aug 31, 2021
@chvp chvp marked this pull request as draft September 4, 2021 13:51
@chvp chvp added the on hold Awaiting analysis on how to proceed label Sep 4, 2021
@chvp chvp deleted the feature/list-own-courses-first branch January 10, 2022 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A change that isn't substantial enough to be called a feature on hold Awaiting analysis on how to proceed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy course page does not list own courses first
3 participants