Skip to content

Commit 545529a

Browse files
committed
Fix content being randomly orded
1 parent eff0606 commit 545529a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backend/internal/handlers/courses.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/gofiber/fiber/v2"
1010
"github.com/sandbox-science/online-learning-platform/configs/database"
1111
"github.com/sandbox-science/online-learning-platform/internal/entity"
12+
"gorm.io/gorm"
1213
)
1314

1415
// Courses function retrieves enrolled course titles and descriptions based on user_id from the URL
@@ -58,7 +59,9 @@ func Course(c *fiber.Ctx) error {
5859
if err := database.DB.
5960
Preload("Students").
6061
Preload("Modules").
61-
Preload("Modules.Content").
62+
Preload("Modules.Content", func(db *gorm.DB) *gorm.DB {
63+
return db.Order("id ASC")
64+
}).
6265
Preload("Tags").
6366
Where("id = ?", courseID).
6467
First(&course).Error; err != nil {

0 commit comments

Comments
 (0)