Rename Note to Grade
This commit is contained in:
parent
2b467c2747
commit
ddbfc6893a
@ -7,6 +7,5 @@ or LSF Served Fabulously
|
||||
- documentation
|
||||
- tests
|
||||
- webapi
|
||||
- rename session to client?
|
||||
- wrap errors correctly. run cmd/lsf without an internet connection and get inspired by the standard libary
|
||||
- use english terms only
|
||||
- username/password prompt stderr
|
||||
|
@ -46,12 +46,11 @@ func main() {
|
||||
func cmdGrades(cmd *cli.Cmd) {
|
||||
cmd.Before = sessionNeeded
|
||||
cmd.Action = func() {
|
||||
noten, err := s.Noten()
|
||||
grades, err := s.Grades()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println("Noten:")
|
||||
noten.Print()
|
||||
grades.Print()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,22 +9,23 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Note is a grade with associated data like the related module
|
||||
type Note struct {
|
||||
Nr string
|
||||
Name string
|
||||
Semester string
|
||||
Note string
|
||||
Status string
|
||||
CPs string
|
||||
Versuch string
|
||||
// Grade is a grade with associated data like the related module
|
||||
type Grade struct {
|
||||
Nr string
|
||||
Name string
|
||||
Term string
|
||||
Grade string
|
||||
Status string
|
||||
Credits string
|
||||
Try string
|
||||
}
|
||||
|
||||
type Noten []*Note
|
||||
// Grades is an Array of Grade pointers
|
||||
type Grades []*Grade
|
||||
|
||||
func (n *Note) String() string {
|
||||
func (g *Grade) String() string {
|
||||
var status string
|
||||
switch n.Status {
|
||||
switch g.Status {
|
||||
case "angemeldet":
|
||||
status = "⏳ - "
|
||||
case "bestanden":
|
||||
@ -34,18 +35,19 @@ func (n *Note) String() string {
|
||||
default:
|
||||
status = "❓"
|
||||
}
|
||||
return fmt.Sprintf("%s%s %s", status, n.Note, n.Name)
|
||||
return fmt.Sprintf("%s%s %s", status, g.Grade, g.Name)
|
||||
}
|
||||
|
||||
func (nn Noten) Print() {
|
||||
for _, n := range nn {
|
||||
fmt.Println(n)
|
||||
// Print prints a clear overview of the grades in the given list
|
||||
func (gg Grades) Print() {
|
||||
for _, g := range gg {
|
||||
fmt.Println(g)
|
||||
}
|
||||
}
|
||||
|
||||
// Noten returns a list of the grades of all graded or signed up modules
|
||||
func (s *Session) Noten() (Noten, error) {
|
||||
var noten Noten
|
||||
// Grades returns a list of the grades of all graded or signed up modules
|
||||
func (s *Session) Grades() (Grades, error) {
|
||||
var grades Grades
|
||||
client := &http.Client{}
|
||||
url := "https://lsf.hs-worms.de/qisserver/rds?state=notenspiegelStudent&next=list.vm&nextdir=qispos/notenspiegel/student&createInfos=Y&struct=auswahlBaum&nodeID=auswahlBaum%7Cabschluss%3Aabschl%3D05%2Cstgnr%3D1%7Cstudiengang%3Astg%3D938%2Cpversion%3D2018&expand=0&asi=" + s.ASI
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
@ -69,17 +71,17 @@ func (s *Session) Noten() (Noten, error) {
|
||||
vals := row.ChildrenFiltered("td").Map(func(i int, cell *goquery.Selection) string {
|
||||
return strings.TrimSpace(cell.Text())
|
||||
})
|
||||
note := Note{
|
||||
Nr: vals[0],
|
||||
Name: vals[1],
|
||||
Semester: vals[2],
|
||||
Note: vals[3],
|
||||
Status: vals[4],
|
||||
CPs: vals[5],
|
||||
Versuch: vals[7],
|
||||
grade := &Grade{
|
||||
Nr: vals[0],
|
||||
Name: vals[1],
|
||||
Term: vals[2],
|
||||
Grade: vals[3],
|
||||
Status: vals[4],
|
||||
Credits: vals[5],
|
||||
Try: vals[7],
|
||||
}
|
||||
noten = append(noten, ¬e)
|
||||
grades = append(grades, grade)
|
||||
})
|
||||
|
||||
return noten, nil
|
||||
return grades, nil
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user