• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

classconnect-grupo3 / courses-service / 15914402693

26 Jun 2025 11:12PM UTC coverage: 81.843% (-5.9%) from 87.722%
15914402693

Pull #49

github

web-flow
Merge pull request #48 from classconnect-grupo3/notification-messages-and-testing

Notification messages and testing
Pull Request #49: Final merge (thank you for the ride)

1542 of 2153 new or added lines in 24 files covered. (71.62%)

16 existing lines in 5 files now uncovered.

4548 of 5557 relevant lines covered (81.84%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.0
/src/controller/teacher_activity_controller.go
1
package controller
2

3
import (
4
        "log/slog"
5
        "net/http"
6

7
        "courses-service/src/service"
8

9
        "github.com/gin-gonic/gin"
10
)
11

12
type TeacherActivityController struct {
13
        activityService service.TeacherActivityServiceInterface
14
        courseService   service.CourseServiceInterface
15
}
16

17
func NewTeacherActivityController(
18
        activityService service.TeacherActivityServiceInterface,
19
        courseService service.CourseServiceInterface,
20
) *TeacherActivityController {
1✔
21
        return &TeacherActivityController{
1✔
22
                activityService: activityService,
1✔
23
                courseService:   courseService,
1✔
24
        }
1✔
25
}
1✔
26

27
// @Summary Get course activity logs
28
// @Description Get activity logs for auxiliary teachers in a course (only for titular teacher)
29
// @Tags courses
30
// @Accept json
31
// @Produce json
32
// @Param courseId path string true "Course ID"
33
// @Param teacherId query string true "Teacher ID"
34
// @Success 200 {array} model.TeacherActivityLog
35
// @Router /courses/{courseId}/activity-logs [get]
NEW
36
func (c *TeacherActivityController) GetCourseActivityLogs(ctx *gin.Context) {
×
NEW
37
        slog.Debug("Getting course activity logs")
×
NEW
38
        courseID := ctx.Param("courseId")
×
NEW
39
        teacherID := ctx.Query("teacherId")
×
NEW
40

×
NEW
41
        if courseID == "" {
×
NEW
42
                slog.Error("Course ID is required")
×
NEW
43
                ctx.JSON(http.StatusBadRequest, gin.H{"error": "Course ID is required"})
×
NEW
44
                return
×
NEW
45
        }
×
46

NEW
47
        if teacherID == "" {
×
NEW
48
                slog.Error("Teacher ID is required")
×
NEW
49
                ctx.JSON(http.StatusBadRequest, gin.H{"error": "Teacher ID is required"})
×
NEW
50
                return
×
NEW
51
        }
×
52

53
        // Verify that the requesting teacher is the titular teacher of the course
NEW
54
        course, err := c.courseService.GetCourseById(courseID)
×
NEW
55
        if err != nil {
×
NEW
56
                slog.Error("Error getting course", "error", err)
×
NEW
57
                ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
×
NEW
58
                return
×
NEW
59
        }
×
60

NEW
61
        if course.TeacherUUID != teacherID {
×
NEW
62
                slog.Error("Only titular teacher can access activity logs")
×
NEW
63
                ctx.JSON(http.StatusForbidden, gin.H{"error": "Only titular teacher can access activity logs"})
×
NEW
64
                return
×
NEW
65
        }
×
66

NEW
67
        logs, err := c.activityService.GetCourseActivityLogs(courseID)
×
NEW
68
        if err != nil {
×
NEW
69
                slog.Error("Error getting activity logs", "error", err)
×
NEW
70
                ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
×
NEW
71
                return
×
NEW
72
        }
×
73

NEW
74
        slog.Debug("Activity logs retrieved", "courseID", courseID, "count", len(logs))
×
NEW
75
        ctx.JSON(http.StatusOK, logs)
×
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc