Documentation
¶
Index ¶
- Constants
- func CookieFilePath() (string, error)
- func GitLabCookieFilePath() (string, error)
- func IsGitLabLink(link string) bool
- func LoadCookie() (string, error)
- func LoadGitLabCookie() (string, error)
- func LoginGitLabWithBrowser(ctx context.Context, timeout time.Duration) (string, error)
- func LoginWithBrowser(ctx context.Context, timeout time.Duration) (string, error)
- func ParseGitLabLink(link string) (string, string, string, bool, bool)
- func SaveCookie(cookie string) error
- func SaveGitLabCookie(cookie string) error
- type APIError
- type ActivitiesPerformance
- type ActivityFull
- type ActivityPerformanceItem
- type ActivityRef
- type Blocker
- type Client
- func (c *Client) DownloadFile(ctx context.Context, material Material, destDir string) (string, error)
- func (c *Client) GetActivitiesPerformance(ctx context.Context, courseID int) (*ActivitiesPerformance, error)
- func (c *Client) GetAllCourses(ctx context.Context) ([]StudentCourse, []StudentCourse, error)
- func (c *Client) GetBffCookie() string
- func (c *Client) GetCourse(ctx context.Context, courseID int) (*Course, error)
- func (c *Client) GetCourseExercises(ctx context.Context, courseID int) (*CourseExercises, error)
- func (c *Client) GetCourseOverview(ctx context.Context, courseID int) (*CourseOverview, error)
- func (c *Client) GetCourseProgress(ctx context.Context, courseID int) (*CourseProgress, error)
- func (c *Client) GetCurrentStudent(ctx context.Context) (*Student, error)
- func (c *Client) GetDeadlines(ctx context.Context, limit int, courseID *int) ([]Deadline, error)
- func (c *Client) GetDownloadLink(ctx context.Context, filename, version string) (string, error)
- func (c *Client) GetLongReadContent(ctx context.Context, longReadID int) (*MaterialsResponse, error)
- func (c *Client) GetLongread(ctx context.Context, longreadID int) (*Longread, error)
- func (c *Client) GetStudentCourses(ctx context.Context, limit int, state string) (*StudentCoursesResponse, error)
- func (c *Client) GetStudentPerformance(ctx context.Context, courseID int) (*StudentPerformance, error)
- func (c *Client) GetTask(ctx context.Context, taskID int) (*Task, error)
- func (c *Client) GetTheme(ctx context.Context, themeID int) (*Theme, error)
- func (c *Client) ResolveCourse(ctx context.Context, query string) (int, string, error)
- func (c *Client) SetBaseURL(baseURL string) bool
- func (c *Client) SetBffCookie(cookie string)
- func (c *Client) ValidateCookie() error
- func (c *Client) ValidateCookieWithContext(ctx context.Context) error
- type Course
- type CourseExercise
- type CourseExercises
- type CourseOverview
- type CourseProgress
- type CourseRef
- type CourseSettings
- type Deadline
- type DeadlineActivity
- type DeadlineExercise
- type DownloadLinkResponse
- type Exercise
- type FileContent
- type GitLabClient
- type Longread
- type LongreadRef
- type Material
- type MaterialsResponse
- type Paging
- type Progress
- type Reviewer
- type Solution
- type Student
- type StudentCourse
- type StudentCoursesResponse
- type StudentPerformance
- type Task
- type TaskExercise
- type TaskScore
- type TaskStudent
- type Theme
- type ThemeRef
Constants ¶
const ( BaseURL = "https://my.centraluniversity.ru" GitLabBaseURL = "https://git.culab.ru" CourseEndpoint = "/api/micro-lms/courses/%d" CourseOverviewEndpoint = "/api/micro-lms/courses/%d/overview" CourseProgressEndpoint = "/api/micro-lms/courses/%d/student/progress" StudentPerformanceEndpoint = "/api/micro-lms/courses/%d/student-performance" ActivitiesPerformanceEndpoint = "/api/micro-lms/courses/%d/activities-performance" CourseExercisesEndpoint = "/api/micro-lms/courses/%d/exercises" StudentCoursesEndpoint = "/api/micro-lms/courses/student" ThemeEndpoint = "/api/micro-lms/themes/%d" LongreadEndpoint = "/api/micro-lms/longreads/%d" LongreadMaterialsEndpoint = "/api/micro-lms/longreads/%d/materials" CurrentStudentEndpoint = "/api/micro-lms/students/me" TaskEndpoint = "/api/micro-lms/tasks/%d" DeadlinesEndpoint = "/api/micro-lms/deadlines" DownloadLinkEndpoint = "/api/micro-lms/content/download-link" DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func CookieFilePath ¶
func GitLabCookieFilePath ¶
func IsGitLabLink ¶
IsGitLabLink checks if a URL is a git.culab.ru link.
func LoadCookie ¶
func LoadGitLabCookie ¶
func LoginGitLabWithBrowser ¶
LoginGitLabWithBrowser opens Chrome for GitLab SSO login and captures _gitlab_session cookie. It waits until the user completes SSO and is redirected away from the sign-in page.
func LoginWithBrowser ¶
LoginWithBrowser opens Chrome for LMS login and captures bff.cookie.
func ParseGitLabLink ¶
ParseGitLabLink extracts project, ref, and path from a git.culab.ru link.
func SaveCookie ¶
func SaveGitLabCookie ¶
Types ¶
type APIError ¶
type APIError struct {
Message string `json:"message"`
Code string `json:"code"`
Details string `json:"details"`
}
APIError represents an API error response.
type ActivitiesPerformance ¶
type ActivitiesPerformance struct {
Items []ActivityPerformanceItem `json:"items"`
TotalWeight float64 `json:"totalWeight"`
TotalScore float64 `json:"totalScore"`
}
ActivitiesPerformance represents performance grouped by activity type.
type ActivityFull ¶
type ActivityFull struct {
AverageScoreThreshold *float64 `json:"averageScoreThreshold"`
Name string `json:"name"`
Weight float64 `json:"weight"`
ID int `json:"id"`
MaxExercisesCount int `json:"maxExercisesCount"`
}
ActivityFull represents an activity with all fields.
type ActivityPerformanceItem ¶
type ActivityPerformanceItem struct {
Activity ActivityFull `json:"activity"`
Total float64 `json:"total"`
Average float64 `json:"average"`
IsBlocker bool `json:"isBlocker"`
}
ActivityPerformanceItem represents one activity's performance.
type ActivityRef ¶
type ActivityRef struct {
Name string `json:"name"`
Weight float64 `json:"weight"`
ID int `json:"id"`
}
ActivityRef is a minimal activity reference.
type Blocker ¶
type Blocker struct {
ActivityName string `json:"activityName"`
AverageScoreThreshold float64 `json:"averageScoreThreshold"`
ActivityID int `json:"activityId"`
}
Blocker represents a blocker activity in performance.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientFromEnv ¶
func NewClientWithOptions ¶
func (*Client) DownloadFile ¶
func (*Client) GetActivitiesPerformance ¶
func (c *Client) GetActivitiesPerformance(ctx context.Context, courseID int) (*ActivitiesPerformance, error)
GetActivitiesPerformance fetches performance grouped by activity type.
func (*Client) GetAllCourses ¶ added in v0.1.4
func (c *Client) GetAllCourses(ctx context.Context) ([]StudentCourse, []StudentCourse, error)
GetAllCourses fetches both active (state=published) and archived (state=archived) student courses. The first return is the active list, the second is the archived list; combine if a flat list is needed.
func (*Client) GetBffCookie ¶
func (*Client) GetCourseExercises ¶
GetCourseExercises fetches all exercises for a course.
func (*Client) GetCourseOverview ¶
func (*Client) GetCourseProgress ¶
GetCourseProgress fetches the student's overall score in a course.
func (*Client) GetCurrentStudent ¶
GetCurrentStudent fetches the authenticated student profile.
func (*Client) GetDeadlines ¶
GetDeadlines fetches student deadlines, optionally filtered by courseId.
func (*Client) GetDownloadLink ¶
func (*Client) GetLongReadContent ¶
func (*Client) GetLongread ¶
func (*Client) GetStudentCourses ¶
func (*Client) GetStudentPerformance ¶
func (c *Client) GetStudentPerformance(ctx context.Context, courseID int) (*StudentPerformance, error)
GetStudentPerformance fetches per-exercise scores for a course.
func (*Client) ResolveCourse ¶
ResolveCourse finds a course by ID (numeric string) or by substring match on course name. Searches both active and archived courses; for numeric IDs the archived list is a fallback when the ID is not in the active set. Returns the matched course ID. If multiple courses match, returns all matches and an error.
func (*Client) SetBaseURL ¶
func (*Client) SetBffCookie ¶
func (*Client) ValidateCookie ¶
type Course ¶
type Course struct {
PublishDate *time.Time `json:"publishDate"`
PublishedAt *time.Time `json:"publishedAt"`
SubjectID *int `json:"subjectId"`
Settings CourseSettings `json:"settings"`
Name string `json:"name"`
State string `json:"state"`
Category string `json:"category"`
CategoryCover string `json:"categoryCover"`
ID int `json:"id"`
IsArchived bool `json:"isArchived"`
}
Course represents course summary information.
type CourseExercise ¶
type CourseExercise struct {
Activity ActivityRef `json:"activity"`
Longread LongreadRef `json:"longread"`
Theme ThemeRef `json:"theme"`
Name string `json:"name"`
Type string `json:"type"`
ID int `json:"id"`
}
CourseExercise is an exercise in the course exercises list.
type CourseExercises ¶
type CourseExercises struct {
Exercises []CourseExercise `json:"exercises"`
Name string `json:"name"`
ID int `json:"id"`
}
CourseExercises represents exercises list for a course.
type CourseOverview ¶
type CourseOverview struct {
PublishDate *time.Time `json:"publishDate"`
PublishedAt *time.Time `json:"publishedAt"`
Settings CourseSettings `json:"settings"`
Themes []Theme `json:"themes"`
Name string `json:"name"`
State string `json:"state"`
ID int `json:"id"`
IsArchived bool `json:"isArchived"`
}
CourseOverview represents the complete course overview response.
type CourseProgress ¶
type CourseProgress struct {
EarnedScore float64 `json:"earnedScore"`
LeftToEarnScore float64 `json:"leftToEarnScore"`
MaxScore float64 `json:"maxScore"`
}
CourseProgress represents the student's overall progress in a course.
type CourseRef ¶
type CourseRef struct {
Name string `json:"name"`
ID int `json:"id"`
IsArchived bool `json:"isArchived"`
}
CourseRef is a minimal course reference.
type CourseSettings ¶
type CourseSettings struct {
SkillLevel string `json:"skillLevel"`
IsSkillLevelEnabled bool `json:"isSkillLevelEnabled"`
}
CourseSettings represents course configuration settings.
type Deadline ¶
type Deadline struct {
Exercise DeadlineExercise `json:"exercise"`
Deadline time.Time `json:"deadline"`
CreatedAt time.Time `json:"createdAt"`
RejectAt *time.Time `json:"rejectAt"`
Reviewer *Reviewer `json:"reviewer"`
Course CourseRef `json:"course"`
Theme ThemeRef `json:"theme"`
Longread LongreadRef `json:"longread"`
State string `json:"state"`
ID int `json:"id"`
}
Deadline represents a student's deadline for an exercise.
type DeadlineActivity ¶
type DeadlineActivity struct {
Name string `json:"name"`
Weight float64 `json:"weight"`
ID int `json:"id"`
IsLateDaysEnabled bool `json:"isLateDaysEnabled"`
}
DeadlineActivity is the activity info in a deadline exercise.
type DeadlineExercise ¶
type DeadlineExercise struct {
StartDate *time.Time `json:"startDate"`
Deadline time.Time `json:"deadline"`
Activity DeadlineActivity `json:"activity"`
Name string `json:"name"`
Type string `json:"type"`
ID int `json:"id"`
MaxScore int `json:"maxScore"`
}
DeadlineExercise is the exercise info embedded in a deadline.
type DownloadLinkResponse ¶
type DownloadLinkResponse struct {
URL string `json:"url"`
}
DownloadLinkResponse represents the response from /api/micro-lms/content/download-link.
type Exercise ¶
type Exercise struct {
Activity *ActivityRef `json:"activity,omitempty"`
Deadline *time.Time `json:"deadline,omitempty"`
Name string `json:"name"`
ID int `json:"id"`
MaxScore int `json:"maxScore"`
}
Exercise represents an exercise within a longread.
type FileContent ¶
type FileContent struct {
Name string `json:"name"`
Filename string `json:"filename"`
MediaType string `json:"mediaType"`
Version string `json:"version"`
Length int `json:"length"`
}
FileContent represents file content information.
type GitLabClient ¶
type GitLabClient struct {
// contains filtered or unexported fields
}
GitLabClient provides access to git.culab.ru using session cookie.
func NewGitLabClient ¶
func NewGitLabClient(sessionCookie string) *GitLabClient
NewGitLabClient creates a client with a _gitlab_session cookie.
func NewGitLabClientFromEnv ¶
func NewGitLabClientFromEnv() (*GitLabClient, error)
NewGitLabClientFromEnv loads the GitLab session cookie from env or file.
func (*GitLabClient) DownloadGitLabLink ¶
func (g *GitLabClient) DownloadGitLabLink(ctx context.Context, link, destDir string) ([]string, error)
DownloadGitLabLink downloads content from a git.culab.ru link and saves to destDir. For blob links — downloads the single file. For tree links — downloads all text files in the directory via GitLab API.
func (*GitLabClient) GetRawFile ¶
func (g *GitLabClient) GetRawFile(ctx context.Context, project, ref, filePath string) ([]byte, error)
GetRawFile downloads a single file from GitLab via the raw endpoint.
type Longread ¶
type Longread struct {
PublishDate *time.Time `json:"publishDate"`
PublishedAt *time.Time `json:"publishedAt"`
Exercises []Exercise `json:"exercises"`
Type string `json:"type"`
Name string `json:"name"`
State string `json:"state"`
Order int `json:"order"`
ID int `json:"id"`
}
Longread represents a learning material within a theme.
type LongreadRef ¶
LongreadRef is a minimal longread reference.
type Material ¶
type Material struct {
PublishDate *time.Time `json:"publishDate"`
PublishedAt *time.Time `json:"publishedAt"`
Content *FileContent `json:"content,omitempty"`
TaskID *int `json:"taskId,omitempty"`
Discriminator string `json:"discriminator"`
ViewContent string `json:"viewContent,omitempty"`
ViewType string `json:"viewType,omitempty"`
MediaType string `json:"mediaType,omitempty"`
Filename string `json:"filename,omitempty"`
Version string `json:"version,omitempty"`
State string `json:"state"`
Type string `json:"type"`
Name string `json:"name,omitempty"`
Length int `json:"length,omitempty"`
ID int `json:"id"`
Order int `json:"order"`
}
Material represents a material item in a longread.
type MaterialsResponse ¶
MaterialsResponse represents the response from /api/micro-lms/longreads/{id}/materials.
type Paging ¶
type Paging struct {
Limit int `json:"limit"`
Offset int `json:"offset"`
TotalCount int `json:"totalCount"`
}
Paging represents pagination information.
type Progress ¶
type Progress struct {
CompletedCount int `json:"completedCount"`
TotalCount int `json:"totalCount"`
Percentage float64 `json:"percentage"`
}
Progress represents course progress information.
type Reviewer ¶
type Reviewer struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
LastName string `json:"lastName"`
FirstName string `json:"firstName"`
}
Reviewer represents a task reviewer.
type Student ¶
type Student struct {
ID string `json:"id"`
LastName string `json:"lastName"`
FirstName string `json:"firstName"`
MiddleName string `json:"middleName"`
UniversityEmail string `json:"universityEmail"`
TimeAccount string `json:"timeAccount"`
StudyStartYear int `json:"studyStartYear"`
StudyLevel string `json:"studyLevel"`
LateDaysBalance int `json:"lateDaysBalance"`
}
Student represents the current student profile.
type StudentCourse ¶
type StudentCourse struct {
PublishDate *time.Time `json:"publishDate"`
PublishedAt *time.Time `json:"publishedAt"`
SubjectID *int `json:"subjectId"`
Progress *Progress `json:"progress,omitempty"`
Settings CourseSettings `json:"settings"`
Name string `json:"name"`
State string `json:"state"`
Category string `json:"category"`
ID int `json:"id"`
IsArchived bool `json:"isArchived"`
}
StudentCourse represents a course in the student courses list.
type StudentCoursesResponse ¶
type StudentCoursesResponse struct {
Items []StudentCourse `json:"items"`
Paging Paging `json:"paging"`
}
StudentCoursesResponse represents the response from /api/micro-lms/courses/student.
type StudentPerformance ¶
type StudentPerformance struct {
Tasks []TaskScore `json:"tasks"`
Blockers []Blocker `json:"blockers"`
}
StudentPerformance represents the student's performance in a course.
type Task ¶
type Task struct {
Score *float64 `json:"score"`
StartedAt *time.Time `json:"startedAt"`
SubmitAt *time.Time `json:"submitAt"`
RejectAt *time.Time `json:"rejectAt"`
EvaluateAt *time.Time `json:"evaluateAt"`
Reviewer *Reviewer `json:"reviewer"`
Solution *Solution `json:"solution"`
CreatedAt time.Time `json:"createdAt"`
Deadline time.Time `json:"deadline"`
Exercise TaskExercise `json:"exercise"`
Course CourseRef `json:"course"`
Theme ThemeRef `json:"theme"`
Longread LongreadRef `json:"longread"`
Student TaskStudent `json:"student"`
Type string `json:"type"`
State string `json:"state"`
ID int `json:"id"`
}
Task represents a full task detail (student's assignment instance).
type TaskExercise ¶
type TaskExercise struct {
StartDate *time.Time `json:"startDate"`
Deadline time.Time `json:"deadline"`
Activity ActivityRef `json:"activity"`
Name string `json:"name"`
Type string `json:"type"`
ViewContent string `json:"viewContent"`
ID int `json:"id"`
MaxScore int `json:"maxScore"`
}
TaskExercise is the exercise info embedded in a task.
type TaskScore ¶
type TaskScore struct {
Score *float64 `json:"score"`
Activity ActivityFull `json:"activity"`
State string `json:"state"`
ID int `json:"id"`
ExerciseID int `json:"exerciseId"`
MaxScore int `json:"maxScore"`
}
TaskScore represents a single task's score in the gradebook.
type TaskStudent ¶
type TaskStudent struct {
ID string `json:"id"`
LastName string `json:"lastName"`
FirstName string `json:"firstName"`
LateDaysBalance int `json:"lateDaysBalance"`
}
TaskStudent is the student info embedded in a task.
type Theme ¶
type Theme struct {
PublishDate *time.Time `json:"publishDate"`
PublishedAt *time.Time `json:"publishedAt"`
Longreads []Longread `json:"longreads"`
Name string `json:"name"`
State string `json:"state"`
ID int `json:"id"`
Order int `json:"order"`
}
Theme represents a course theme/module.