func GetCourses(host string, token string, userid int) (result []Course, body []byte, er ErrorResponse, err error) {
	var resp *http.Response
	resp, err = http.PostForm(host+"webservice/rest/server.php?moodlewsrestformat=json", url.Values{
		"wstoken":    {token},
		"wsfunction": {"core_enrol_get_users_courses"},
		"userid":     {strconv.Itoa(userid)},
	})
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()
	body, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return
	}

	fmt.Println(string(body))

	// Get the content
	err = json.Unmarshal(body, &result)

	// Failed to convert the content, probably because Moodle returned an error
	if err != nil {
		err = json.Unmarshal(body, &er)
	}

	return
}
// GetCourses requests the information of all the courses available to the user
// Request: <host>/webservice/rest/server.php?moodlewsrestformat=json
// Body: wstoken: token, wsfunction: core_enrol_get_users_courses, userid: userid
// Returns a list of Courses and an error (if one was given during the operation)
// result: Returns the courses found
// response: Returns the response received (later to be hashed)
// er: Moodle returned an error
// err: The operation was unsuccessful
GetCourses requests the information of all the courses available to the user
Request: /webservice/rest/server.php?moodlewsrestformat=json
Body: wstoken: token, wsfunction: core_enrol_get_users_courses, userid: userid
Returns a list of Courses and an error (if one was given during the operation)
result: Returns the courses found
response: Returns the response received (later to be hashed)
er: Moodle returned an error
err: The operation was unsuccessful
// GetCourses requests the information of all the courses available to the user // Request : <host > / webservice / rest / server . php?moodlewsrestformat = json // Body : wstoken : token wsfunction : core_enrol_get_users_courses userid : userid // Returns a list of Courses and an error ( if one was given during the operation ) // result : Returns the courses found // response : Returns the response received ( later to be hashed ) // er : Moodle returned an error // err : The operation was unsuccessful
func GetCourses(host string, token string, userid int) (result []Course, body []byte, er ErrorResponse, err error) {
	var resp *http.Response
	resp, err = http.PostForm(host+"webservice/rest/server.php?moodlewsrestformat=json", url.Values{
		"wstoken":    {token},
		"wsfunction": {"core_enrol_get_users_courses"},
		"userid":     {strconv.Itoa(userid)},
	})
	if err != nil {
		log.Println(err)
		return
	}
	defer resp.Body.Close()
	body, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return
	}
	fmt.Println(string(body))
	err = json.Unmarshal(body, &result)
	if err != nil {
		err = json.Unmarshal(body, &er)
	}
	return
}
func GetCourses ( host string , token string , userid int ) ( result [ ] Course , body [ ] byte , er ErrorResponse , err error ) { var resp * http . Response resp , err = http . PostForm ( host + " " , url . Values { " " : { token } , " " : { " " } , " " : { strconv . Itoa ( userid ) } , } ) if err != nil { log . Println ( err ) return } defer resp . Body . Close ( ) body , err = ioutil . ReadAll ( resp . Body ) if err != nil { log . Println ( err ) return } fmt . Println ( string ( body ) ) err = json . Unmarshal ( body , & result ) if err != nil { err = json . Unmarshal ( body , & er ) } return }
GetCourses requests the information of all the courses available to the user
Request: /webservice/rest/server.php?moodlewsrestformat=json
Body: wstoken: token, wsfunction: core_enrol_get_users_courses, userid: userid
Returns a list of Courses and an error (if one was given during the operation)
result: Returns the courses found
response: Returns the response received (later to be hashed)
er: Moodle returned an error
err: The operation was unsuccessful
GetCourses requests the information of all the courses available to the user Request : / webservice / rest / server . php?moodlewsrestformat = json Body : wstoken : token wsfunction : core_enrol_get_users_courses userid : userid Returns a list of Courses and an error ( if one was given during the operation ) result : Returns the courses found response : Returns the response received ( later to be hashed ) er : Moodle returned an error err : The operation was unsuccessful
// Get the content // Failed to convert the content, probably because Moodle returned an error