mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-21 17:00:30 -05:00
Add list courses functions, remove unnecessary functions, update README.
This commit is contained in:
parent
dc7d8df66b
commit
aa16b741d5
18
README.md
18
README.md
@ -1,13 +1,23 @@
|
||||
# aplus
|
||||
|
||||
aplus cli
|
||||
This is an aplus cli utility created for students at Florida Polytechnic University to submit their aplus codes through the CLI.
|
||||
In time, we intend to generalize this utility to all universities.
|
||||
In the meantime however, any students from other universities wishing to use the utility may change the base_link and external_tools_code (you see this in the URL when you navigate to Aplus attendance within your course) variables.
|
||||
|
||||
# Usage
|
||||
## Usage
|
||||
|
||||
# Launch interactive prompt
|
||||
### List all courses and canvas course codes
|
||||
aplus
|
||||
aplus --list-courses
|
||||
aplus -l
|
||||
|
||||
# Enter code immediately
|
||||
### List favorite courses and canvas course codes
|
||||
aplus --list-favorites
|
||||
|
||||
### Enter code immediately for an active code
|
||||
aplus -c <code>
|
||||
aplus --code <code>
|
||||
|
||||
### Enter code for a specified course
|
||||
aplus -c <code> --course <course_code>
|
||||
aplus --code <code> --course <course_code>
|
3
aplus.go
3
aplus.go
@ -11,7 +11,8 @@ import (
|
||||
)
|
||||
|
||||
func launch_aplus(course_code int) {
|
||||
aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=913&access_token=%s", base_link, course_code, token) // 7329 always works
|
||||
aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=%d&access_token=%s",
|
||||
base_link, course_code, external_tools_code, token)
|
||||
aplus := get_aplus(token, aplus_link, client)
|
||||
|
||||
resp, _ := client.Get(aplus)
|
||||
|
31
canvas.go
31
canvas.go
@ -14,7 +14,7 @@ import (
|
||||
func initialize() {
|
||||
base_link = "https://floridapolytechnic.instructure.com/api/v1"
|
||||
token = os.Getenv("CANVAS_API_KEY")
|
||||
|
||||
external_tools_code = 913
|
||||
jar, _ := cookiejar.New(&cookiejar.Options{
|
||||
PublicSuffixList: publicsuffix.List,
|
||||
})
|
||||
@ -48,27 +48,24 @@ func get_courses(token string, link string, client http.Client) []CanvasCourse {
|
||||
return canvas_courses
|
||||
}
|
||||
|
||||
// Need to change this to grab both ID and name, return as pairs.
|
||||
func get_course_id_name_pair(canvas_courses []CanvasCourse) []uint64 {
|
||||
var courses []uint64
|
||||
func list_all_courses() {
|
||||
all_courses := fmt.Sprintf("%s/courses?access_token=%s&per_page=100", base_link, token)
|
||||
|
||||
canvas_courses := get_courses(token, all_courses, client)
|
||||
|
||||
for _, course := range canvas_courses {
|
||||
courses = append(courses, course.ID%10000)
|
||||
fmt.Printf("%s, %d\n", course.Name, course.ID%10000)
|
||||
}
|
||||
return courses
|
||||
}
|
||||
|
||||
/*
|
||||
func select_course() int {
|
||||
func list_favorite_courses() {
|
||||
|
||||
// course selection by user happens below
|
||||
favorites := fmt.Sprintf("%s/users/self/favorites/courses?access_token=%s&per_page=100", base_link, token)
|
||||
all_courses := fmt.Sprintf("%s/courses?access_token=%s&per_page=100", base_link, token)
|
||||
var canvas_courses []CanvasCourse
|
||||
canvas_courses = get_courses(token, favorites, client)
|
||||
var course_ids []uint64
|
||||
course_ids = get_course_ids(canvas_courses)
|
||||
//selected := 1 // course_ids[selected]
|
||||
// course selection by user happens above
|
||||
return 0
|
||||
|
||||
canvas_courses := get_courses(token, favorites, client)
|
||||
|
||||
for _, course := range canvas_courses {
|
||||
fmt.Printf("%s, %d\n", course.Name, course.ID%10000)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user