-
Notifications
You must be signed in to change notification settings - Fork 51
840 short description for each video #1510
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
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it locally and it looks good to me 👍
Just two more general questions:
- Should the personal lecture title be displayed only in the course-view, or also in the "Recent VODs" and videoplayer/stream-view?
- Should lecturers/admins of a course be allowed to add personal lecture titles, or would it be better to have the button set the actual lecture title to avoid confusion?
Yes, thanks for catching that. Somehow thought the title was not displayed there and didn't check. I'll change that.
It probably shouldn't be left like this as I agree with the confusion part. I'm not sure, whether we should hide the menu option for admins or make it change the title globally. After all, that's what the admin page is for. I lean towards the "hide it"-approach, but I'm open for other opinions. |
I think we can leave it out for now and add it in the future in a separate PR if necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty nice! Left just a few comments
dao/user_defined_lecture_titles.go
Outdated
// Upsert updates the entry if it exists, inserts it else | ||
func (d userDefinedLectureTitlesDao) Upsert(userLectureTitle *model.UserDefinedLectureTitle) error { | ||
return d.db.Save(userLectureTitle).Error | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need upserting? With user_id and stream_id being composite primary keys, we can use create with a conflict clause to update a record. See e.g.
Line 58 in fe0190d
err2 = DB.Clauses(clause.OnConflict{ |
I would go that way and rename the method to
Save
and drop Create
and Upsert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
model/stream.go
Outdated
if len(s.CustomLectureTitles) > 0 { | ||
customLectureName = s.CustomLectureTitles[0].Title | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is happening here? We just use the first title? Wouldn't we send a random users title to someone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this isn't set to a random users title, this should definitely be changed, yes, Idk what I was thinking. It wasn't set to a random title, because the CustomLectureTitles in this PR only get preloaded in conjunction with a Where clause, that checks the userId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now fixed. However, is there a cleaner way using Gorm to achieve the same to avoid having to add it manually afterwards?
// BeforeCreate is a GORM hook that is called before a new user is created. | ||
// UserDefinedLectureTitle will not be saved if the title is too long | ||
func (u *UserDefinedLectureTitle) BeforeCreate(tx *gorm.DB) (err error) { | ||
if len(u.Title) > 256 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you trim the whitespace? https://pkg.go.dev/strings#TrimSpace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any particular reason for this? Wouldn't this lead to a title being falsely accepted by BeforeCreate
and then failing Save
, if #whitespace + #meaningfulLetters > 256, but #meaningfulLetters < 256? Is this a best practice I'm not aware of?
Maybe there should also be a button for the user to delete the custom title, as just removing it to reset it to the lecturers title may not be intuitive. |
I'd postpone this change as this would require changing the signature of two methods, which are heavily used throughout the project, which would inflate this PR. |
Motivation and Context
#840. Having the ability to make short notes or add/change the title of the lecture is useful for organising lectures when titles are not provided by the course admins.
Description
There's an additional option in the dropdown menu for each stream on the course overview page that allows users to input their own (limited to 80 characters) lecture title. There's a new API endpoint, that takes the new title and stores it in a new table in the database.
Steps for Testing
Prerequisites:
5.1 Pressing "Enter" or clicking outside the input field changes the title
5.2 Pressing "Escape" disregards any changes
5.3 Deleting the value of the input field resets the title to the actual title provided by the lecturer
Screenshots
Screencast.from.2025-03-08.15-19-45.mp4