Skip to content

Commit

Permalink
style(course): add reference_timeline_for
Browse files Browse the repository at this point in the history
  • Loading branch information
purfectliterature committed Jan 16, 2023
1 parent 103ec73 commit 2c31997
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ def email_settings_with_enabled_components
setting_emails.where(component: email_settings_enabled_components)
end

def reference_timeline_for(course_user)
# TODO: [PR#5491] Return only `default_reference_timeline.id` if Multiple Reference Timelines component is disabled.
course_user&.reference_timeline_id || default_reference_timeline.id
end

private

# Set default values
Expand Down
2 changes: 1 addition & 1 deletion app/models/course/lesson_plan/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def personal_time_for(course_user)

def reference_time_for(course_user)
default_reference_timeline_id = course.default_reference_timeline.id
reference_timeline_id = course_user&.reference_timeline_id || default_reference_timeline_id
reference_timeline_id = course.reference_time_for(course_user)

# This reversion anticipates if course_user is on a non-default timeline which does not override the
# default time for this lesson plan item.
Expand Down
3 changes: 1 addition & 2 deletions app/views/course/users/_user_list_data.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ json.name course_user.name.strip
json.imageUrl user_image(course_user.user)
json.email course_user.user.email

reference_timeline_id = course_user.reference_timeline_id
json.referenceTimelineId reference_timeline_id || current_course.default_reference_timeline.id
json.referenceTimelineId current_course.reference_timeline_for(course_user)
json.timelineAlgorithm course_user.timeline_algorithm if should_show_timeline

json.role course_user.role
Expand Down

0 comments on commit 2c31997

Please sign in to comment.