Conversation
carlobortolan
left a comment
There was a problem hiding this comment.
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. |
joschahenningsen
left a comment
There was a problem hiding this comment.
Pretty nice! Left just a few comments
| // 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.
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
I would go that way and rename the method to
Save and drop Create and Upsert
| if len(s.CustomLectureTitles) > 0 { | ||
| customLectureName = s.CustomLectureTitles[0].Title | ||
| } |
There was a problem hiding this comment.
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.
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.
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.
Can you trim the whitespace? https://pkg.go.dev/strings#TrimSpace
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Added strings.TrimSpace in both the model's BeforeCreate hook (model/lecture_titles.go) and in the API handler (api/stream.go) before the empty-check, so whitespace-only titles are correctly treated as a delete/reset. Commit: 681b37a.
|
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. |
|
@copilot resolve the merge conflicts in this pull request. |
Agent-Logs-Url: https://github.com/TUM-Dev/gocast/sessions/3e52aecf-8cbc-4bde-a8dc-d086283d8439 Co-authored-by: alexanderstephan <30267166+alexanderstephan@users.noreply.github.com>
Merge conflicts were already resolved in commit |
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