mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-21 17:00:30 -05:00
send attendance code to all current courses when course not specified
This commit is contained in:
parent
1179315d30
commit
cbcc7631a4
8
aplus.go
8
aplus.go
@ -7,12 +7,14 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func submit_code(course_code int, attendance_code string) bool {
|
||||
cur_body := launch_aplus(course_code)
|
||||
if cur_body == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
if verbose {
|
||||
fmt.Printf("%s", cur_body)
|
||||
@ -81,7 +83,7 @@ func launch_aplus(course_code int) string {
|
||||
if err != nil {
|
||||
fmt.Println("Failed to get A+ base URL and tool ID. Try again with a different course code.")
|
||||
fmt.Printf("Error: %s\n", err)
|
||||
os.Exit(1)
|
||||
return ""
|
||||
}
|
||||
|
||||
aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=%d&access_token=%s",
|
||||
@ -172,5 +174,5 @@ func submit_code_sans_course(attendance_code string) {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Could not submit code %s to any course\n", attendance_code)
|
||||
fmt.Println("Could not submit code", attendance_code, "to any course")
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ func get_courses(token string, link string, client http.Client) []CanvasCourse {
|
||||
|
||||
func init_aplus_toolid(course_id int) error {
|
||||
link := fmt.Sprintf("%s/courses/%d/external_tools?access_token=%s&search_term=aplus&include_parents=true", base_link, course_id, token)
|
||||
|
||||
resp, err := client.Get(link)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -68,7 +69,7 @@ func init_aplus_toolid(course_id int) error {
|
||||
}
|
||||
|
||||
for _, tool := range external_tools {
|
||||
if strings.Contains(tool.URL, ".aplusattendance.com/") && base_aplus_link == "" {
|
||||
if strings.Contains(tool.URL, ".aplusattendance.com/") {
|
||||
base_aplus_link = tool.URL
|
||||
external_tools_code = tool.ID
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user