diff --git a/aplus.go b/aplus.go index 427e2bf..ec17ac2 100644 --- a/aplus.go +++ b/aplus.go @@ -10,7 +10,7 @@ import ( "strings" ) -func launch_aplus(course_code int) { +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) @@ -24,7 +24,9 @@ func launch_aplus(course_code int) { resp, _ = client.PostForm("https://floridapoly.aplusattendance.com/canvas", form_values) body, _ = io.ReadAll(resp.Body) - fmt.Println(string(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 { @@ -38,6 +40,58 @@ func get_aplus(token string, link string, client http.Client) string { return aplus.URL } +func submit_code(cur_body string, attendance_code string, current_url string) { + // the links to submit the code for a class is under the dayPanel div + daypanel_start := strings.Index(cur_body, "
") + errormsg_start += len("Text\">") + errormsg_end := errormsg_start + errormsg_end += strings.Index(string(body)[errormsg_start:], "<") + fmt.Println(string(body)[errormsg_start:errormsg_end]) + } else if strings.Index(string(body), "ctl02_codeSuccessMessage") != -1 { + fmt.Println("Code successfully recorded") + } +} + func get_form_from_request_body(req_body []byte) string { body_str := string(req_body) form_start := strings.Index(body_str, "