From 329f8dfe029025d591cf3e111dc842a7f4c2a43f Mon Sep 17 00:00:00 2001 From: Juan Roig Date: Tue, 14 Nov 2023 18:04:29 -0500 Subject: [PATCH] Reorganization --- aplus.go | 61 +++++++++++++++++++++++++++---------------------------- canvas.go | 1 + main.go | 6 +++--- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/aplus.go b/aplus.go index ec17ac2..b9e6a13 100644 --- a/aplus.go +++ b/aplus.go @@ -10,37 +10,9 @@ import ( "strings" ) -func launch_aplus(course_code int, attendance_code string) { - 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) - body, _ := io.ReadAll(resp.Body) - - form_str := get_form_from_request_body(body) - form_values := parse_form(form_str) - - resp, _ = client.PostForm("https://floridapoly.aplusattendance.com/canvas", form_values) - body, _ = io.ReadAll(resp.Body) - - submit_code(string(body), attendance_code, "https://floridapoly.aplusattendance.com/canvas/student/") - - // fmt.Println(string(body)) -} - -func get_aplus(token string, link string, client http.Client) string { - resp, _ := client.Get(link) - - body, _ := io.ReadAll(resp.Body) - - var aplus Aplus - json.Unmarshal(body, &aplus) - - return aplus.URL -} - -func submit_code(cur_body string, attendance_code string, current_url string) { +func submit_code(course_code int, attendance_code string) { + cur_body := launch_aplus(course_code) + current_url := fmt.Sprintf("%s/student/", base_aplus_link) // the links to submit the code for a class is under the dayPanel div daypanel_start := strings.Index(cur_body, "