mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-24 10:20:30 -05:00
Add flags, update README
This commit is contained in:
parent
329f8dfe02
commit
e28dc92307
15
README.md
15
README.md
@ -1,23 +1,16 @@
|
|||||||
# aplus
|
# aplus command line utility
|
||||||
|
|
||||||
This is an aplus cli utility created for students at Florida Polytechnic University to submit their aplus codes through the CLI.
|
This is an cli utility initially created for students at Florida Polytechnic University to submit their aplus codes.
|
||||||
In time, we intend to generalize this utility to all universities.
|
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.
|
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
|
||||||
|
|
||||||
### List all courses and canvas course codes
|
### List all courses and canvas course codes
|
||||||
aplus
|
aplus --list-all
|
||||||
aplus --list-courses
|
|
||||||
aplus -l
|
|
||||||
|
|
||||||
### List favorite courses and canvas course codes
|
### List favorite courses and canvas course codes
|
||||||
aplus --list-favorites
|
aplus --list-favorites
|
||||||
|
|
||||||
### Enter code immediately for an active code
|
|
||||||
aplus -c <code>
|
|
||||||
aplus --code <code>
|
|
||||||
|
|
||||||
### Enter code for a specified course
|
### Enter code for a specified course
|
||||||
aplus -c <code> --course <course_code>
|
aplus --code <code> --course <canvas_course_number>
|
||||||
aplus --code <code> --course <course_code>
|
|
11
aplus.go
11
aplus.go
@ -12,6 +12,9 @@ import (
|
|||||||
|
|
||||||
func submit_code(course_code int, attendance_code string) {
|
func submit_code(course_code int, attendance_code string) {
|
||||||
cur_body := launch_aplus(course_code)
|
cur_body := launch_aplus(course_code)
|
||||||
|
|
||||||
|
fmt.Printf("%s", cur_body)
|
||||||
|
|
||||||
current_url := fmt.Sprintf("%s/student/", base_aplus_link)
|
current_url := fmt.Sprintf("%s/student/", base_aplus_link)
|
||||||
// the links to submit the code for a class is under the dayPanel div
|
// the links to submit the code for a class is under the dayPanel div
|
||||||
daypanel_start := strings.Index(cur_body, "<div class=\"dayPanel\"")
|
daypanel_start := strings.Index(cur_body, "<div class=\"dayPanel\"")
|
||||||
@ -37,21 +40,13 @@ func submit_code(course_code int, attendance_code string) {
|
|||||||
resp, _ := client.Get(link_url)
|
resp, _ := client.Get(link_url)
|
||||||
body, _ := io.ReadAll(resp.Body)
|
body, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
fmt.Println(string(body))
|
|
||||||
|
|
||||||
form_str := get_form_from_request_body(body)
|
form_str := get_form_from_request_body(body)
|
||||||
form_values := parse_form(form_str)
|
form_values := parse_form(form_str)
|
||||||
form_values["ctl01$sessionCode"][0] = attendance_code
|
form_values["ctl01$sessionCode"][0] = attendance_code
|
||||||
|
|
||||||
//fmt.Println(form_str)
|
|
||||||
//fmt.Println(form_values)
|
|
||||||
|
|
||||||
resp, _ = client.PostForm(link_url, form_values)
|
resp, _ = client.PostForm(link_url, form_values)
|
||||||
body, _ = io.ReadAll(resp.Body)
|
body, _ = io.ReadAll(resp.Body)
|
||||||
|
|
||||||
fmt.Println(string(body))
|
|
||||||
fmt.Println(resp)
|
|
||||||
|
|
||||||
if strings.Index(string(body), "ctl01_errorMessage") != -1 {
|
if strings.Index(string(body), "ctl01_errorMessage") != -1 {
|
||||||
errormsg_start := strings.Index(string(body), "ctl01_errorMessage")
|
errormsg_start := strings.Index(string(body), "ctl01_errorMessage")
|
||||||
errormsg_start += strings.Index(string(body)[errormsg_start:], "Text\">")
|
errormsg_start += strings.Index(string(body)[errormsg_start:], "Text\">")
|
||||||
|
2
go.mod
2
go.mod
@ -2,4 +2,4 @@ module codeberg.org/flpolyaplus/aplus
|
|||||||
|
|
||||||
go 1.21.3
|
go 1.21.3
|
||||||
|
|
||||||
require golang.org/x/net v0.18.0 // indirect
|
require golang.org/x/net v0.18.0
|
||||||
|
25
main.go
25
main.go
@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,8 +15,25 @@ var client http.Client
|
|||||||
func main() {
|
func main() {
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
course_code := 7326
|
code := flag.String("code", "", "Code to enter")
|
||||||
submit_code(course_code, "A1B2C")
|
course := flag.Int("course", -1, "Canvas course number")
|
||||||
|
list_all := flag.Bool("list-all", false, "List all courses")
|
||||||
|
list_favorites := flag.Bool("list-favorites", false, "List favorite courses")
|
||||||
|
|
||||||
// enter_code()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *list_all {
|
||||||
|
list_all_courses()
|
||||||
|
}
|
||||||
|
|
||||||
|
if *list_favorites {
|
||||||
|
list_favorite_courses()
|
||||||
|
}
|
||||||
|
|
||||||
|
if *code != "" && *course != -1 {
|
||||||
|
fmt.Printf("%d %s", *course, *code)
|
||||||
|
submit_code(*course, *code)
|
||||||
|
}
|
||||||
|
|
||||||
|
submit_code(7329, "asdkl")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user