Documentation
¶
Index ¶
- Constants
- func Code(err error) string
- type APIError
- type AdvancedFeatureEnabled
- type AuthAPI
- type Client
- type ClientOption
- type ClientOptions
- type Course
- type CourseAPI
- type CourseByField
- type CourseClassification
- type CourseFieldType
- type CourseFieldValue
- type CourseFieldValues
- type CourseId
- type CourseIds
- type CoursesByFieldOptions
- type CoursesOptions
- type EnrolMentOptions
- type GradeAPI
- type GradeItem
- type GradeTable
- type GradeTableItem
- type GradeTableItemGroup
- type LoginResponse
- type ManualEnrolUser
- type ManualEnrolUsers
- type Quiz
- type QuizAPI
- type QuizAttempt
- type QuizQuestion
- type SiteAPI
- type SiteFunctionVersion
- type SiteInfo
- type UserAPI
- type UserGrade
- type UserOptions
- type UserRequest
- type UserRequests
- type Warning
- type Warnings
Constants ¶
View Source
const ( CourseClassificationPast CourseClassification = "past" CourseClassificationInProgress CourseClassification = "inprogress" CourseClassificationFuture CourseClassification = "future" CourseFieldCategory CourseFieldType = "category" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIError ¶
type APIError struct {
Err *string `json:"error,omitempty"`
Message *string `json:"message,omitempty"`
ErrorCode string `json:"errorcode"`
StackTrace *string `json:"stacktrace,omitempty"`
Exception *string `json:"exception,omitempty"`
DebugInfo *string `json:"debuginfo,omitempty"`
ReproductionLink *string `json:"reproductionlink,omitempty"`
}
type AdvancedFeatureEnabled ¶
type AuthAPI ¶
type AuthAPI interface {
Login(ctx context.Context, username, password string) (*LoginResponse, error)
}
type Client ¶
type Client struct {
AuthAPI AuthAPI
SiteAPI SiteAPI
UserAPI UserAPI
CourseAPI CourseAPI
QuizAPI QuizAPI
GradeAPI GradeAPI
// contains filtered or unexported fields
}
Client is a Moodle API client scoped to a service.
func NewClient ¶
func NewClient(ctx context.Context, serviceURL *url.URL, authToken string, opt ...ClientOption) (*Client, error)
NewClient creates a new Moodle client.
func NewClientWithLogin ¶
func NewClientWithLogin(ctx context.Context, serviceURL *url.URL, username, password string, opt ...ClientOption) (*Client, error)
NewClientWithLogin creates a new Moodle client with token retrieved from login request.
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
ClientOption is a option to change client configuration.
func WithDebugEnabled ¶
func WithDebugEnabled() ClientOption
WithDebugEnabled enable debug logs this option is should be used in development only.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
type ClientOptions ¶
type Course ¶
type Course struct {
ID int
FullName string
ShortName string
Summary string
SummaryFormat int
StartDate time.Time
EndDate time.Time
Visible bool
FullNameDisplay string
ViewURL string
CourseImage string
Progress int
HasProgress bool
IsSavourite bool
Hidden bool
ShowShortName bool
CourseCategory string
}
type CourseAPI ¶
type CourseAPI interface {
GetEnrolledCoursesByTimelineClassification(ctx context.Context, classification CourseClassification) ([]*Course, error)
GetCoursesByField(ctx context.Context, param CoursesByFieldOptions) ([]*Course, error)
GetCourses(ctx context.Context, param CoursesOptions) ([]*Course, error)
}
type CourseByField ¶ added in v1.0.1
type CourseClassification ¶
type CourseClassification string
type CourseFieldType ¶ added in v1.0.1
type CourseFieldType string
type CourseFieldValue ¶ added in v1.0.1
type CourseFieldValue struct {
Field CourseFieldType `json:"field"`
Value string `json:"value"`
}
type CourseFieldValues ¶ added in v1.0.1
type CourseFieldValues []*CourseFieldValue
func (CourseFieldValues) EncodeValues ¶ added in v1.0.1
func (cs CourseFieldValues) EncodeValues(key string, v *url.Values) error
type CoursesByFieldOptions ¶ added in v1.0.1
type CoursesByFieldOptions struct {
*CourseFieldValues
}
type CoursesOptions ¶ added in v1.0.1
type CoursesOptions struct {
Options CourseIds `url:"options"`
}
type EnrolMentOptions ¶ added in v1.0.1
type EnrolMentOptions struct {
EnrolMents ManualEnrolUsers `url:"enrolments"`
}
type GradeItem ¶
type GradeItem struct {
ID int
ItemName string
ItemType string
ItemModule *string
ItemInstance int
ItemNumber *int
CategoryID *int
OutcomeID *int
ScaleID *int
Locked *bool
CmID int
GradeRaw float64
GradeDateSubmitted *time.Time
GradeDateGraded *time.Time
GradeHiddenByDate bool
GradeNeedsUpdate bool
GradeIsHidden bool
GradeIsLocked *bool
GradeIsOverridden *bool
GradeFormatted string
GradeMin int
GradeMax int
RangeFormatted string
Feedback string
FeedbackFormat int
}
GradeItem represents an grade If you want to know percentage of the grade out of course total grade, see GradeTableItem
type GradeTable ¶
type GradeTable struct {
CourseID int
UserID int
UserFullname string
MaxDepth int
ItemGroups []*GradeTableItemGroup
}
GradeTable represents a grade table for a course
type GradeTableItem ¶
type GradeTableItemGroup ¶
type GradeTableItemGroup struct {
Name string
Items []*GradeTableItem
}
GradeTableItemGroup represents a group of grade items
type LoginResponse ¶
type ManualEnrolUser ¶ added in v1.0.1
type ManualEnrolUser struct {
RoleId int `json:"roleid" url:"roleid"` //Role to assign to the user
UserId int `json:"userid" url:"userid"` //The user that is going to be enrolled
CourseId int `json:"courseid" url:"courseid"` //The course to enrol the user role in
TimeStart *int `json:"timestart" url:"timestart"` //Timestamp when the enrolment start
TimeEnd *int `json:"timeend" url:"timeend"` //Timestamp when the enrolment end
Suspend *int `json:"suspend" url:"suspend"` //set to 1 to suspend the enrolment
}
type ManualEnrolUsers ¶ added in v1.0.1
type ManualEnrolUsers []*ManualEnrolUser
func (ManualEnrolUsers) EncodeValues ¶ added in v1.0.1
func (us ManualEnrolUsers) EncodeValues(key string, v *url.Values) error
type Quiz ¶
type Quiz struct {
ID int
CourseID int
CourseModuleID int
Name string
Intro string
IntroFormat int
TimeOpen time.Time
TimeClose time.Time
TimeLimit int
PreferredBehaviour string
Attempts int
GradeMethod int
DecimalPoints int
QuestionDecimalPoints int
SumGrades int
Grade int
HasFeedback int
Section int
Visible int
GroupMode int
GroupingID int
}
type QuizAPI ¶
type QuizAPI interface {
GetQuizzesByCourse(ctx context.Context, courseID int) ([]*Quiz, error)
GetUserAttempts(ctx context.Context, quizID int) ([]*QuizAttempt, error)
GetAttemptReview(ctx context.Context, attemptID int) (*QuizAttempt, []*QuizQuestion, error)
StartAttempt(ctx context.Context, quizID int) (*QuizAttempt, error)
FinishAttempt(ctx context.Context, attemptID int, timeUp bool) error
}
type QuizAttempt ¶
type QuizQuestion ¶
type SiteFunctionVersion ¶
type SiteInfo ¶
type SiteInfo struct {
SiteName string
Username string
Firstname string
Lastname string
Fullname string
Lang string
UserID int
SiteURL string
UserPictureURL string
Functions []*SiteFunctionVersion
DownloadFiles bool
UploadFiles bool
Release string
Version string
MobileCSSURL string
AdvancedFeatures []*AdvancedFeatureEnabled
UserCanManageOwnFiles bool
UserQuota int
UserMaxUploadFileSize int
UserHomePage int
SiteID int
SiteCalendarType string
UserCalendarType string
Theme string
}
type UserAPI ¶
type UserAPI interface {
CreateUsers(ctx context.Context, param UserOptions) ([]userResponse, error)
UpdateUsers(ctx context.Context, param UserOptions) (*updateUserResponse, error)
ManualEnrolUsers(ctx context.Context, param EnrolMentOptions) error
}
type UserOptions ¶ added in v1.0.1
type UserOptions struct {
Users UserRequests `url:"users"`
}
type UserRequest ¶
type UserRequests ¶
type UserRequests []*UserRequest
func (UserRequests) EncodeValues ¶
func (us UserRequests) EncodeValues(key string, v *url.Values) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.