Rename Note to Grade
This commit is contained in:
parent
2b467c2747
commit
ddbfc6893a
@ -7,6 +7,5 @@ or LSF Served Fabulously
|
|||||||
- documentation
|
- documentation
|
||||||
- tests
|
- tests
|
||||||
- webapi
|
- webapi
|
||||||
- rename session to client?
|
|
||||||
- wrap errors correctly. run cmd/lsf without an internet connection and get inspired by the standard libary
|
- 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) {
|
func cmdGrades(cmd *cli.Cmd) {
|
||||||
cmd.Before = sessionNeeded
|
cmd.Before = sessionNeeded
|
||||||
cmd.Action = func() {
|
cmd.Action = func() {
|
||||||
noten, err := s.Noten()
|
grades, err := s.Grades()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
fmt.Println("Noten:")
|
grades.Print()
|
||||||
noten.Print()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,22 +9,23 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Note is a grade with associated data like the related module
|
// Grade is a grade with associated data like the related module
|
||||||
type Note struct {
|
type Grade struct {
|
||||||
Nr string
|
Nr string
|
||||||
Name string
|
Name string
|
||||||
Semester string
|
Term string
|
||||||
Note string
|
Grade string
|
||||||
Status string
|
Status string
|
||||||
CPs string
|
Credits string
|
||||||
Versuch 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
|
var status string
|
||||||
switch n.Status {
|
switch g.Status {
|
||||||
case "angemeldet":
|
case "angemeldet":
|
||||||
status = "⏳ - "
|
status = "⏳ - "
|
||||||
case "bestanden":
|
case "bestanden":
|
||||||
@ -34,18 +35,19 @@ func (n *Note) String() string {
|
|||||||
default:
|
default:
|
||||||
status = "❓"
|
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() {
|
// Print prints a clear overview of the grades in the given list
|
||||||
for _, n := range nn {
|
func (gg Grades) Print() {
|
||||||
fmt.Println(n)
|
for _, g := range gg {
|
||||||
|
fmt.Println(g)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Noten returns a list of the grades of all graded or signed up modules
|
// Grades returns a list of the grades of all graded or signed up modules
|
||||||
func (s *Session) Noten() (Noten, error) {
|
func (s *Session) Grades() (Grades, error) {
|
||||||
var noten Noten
|
var grades Grades
|
||||||
client := &http.Client{}
|
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
|
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)
|
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 {
|
vals := row.ChildrenFiltered("td").Map(func(i int, cell *goquery.Selection) string {
|
||||||
return strings.TrimSpace(cell.Text())
|
return strings.TrimSpace(cell.Text())
|
||||||
})
|
})
|
||||||
note := Note{
|
grade := &Grade{
|
||||||
Nr: vals[0],
|
Nr: vals[0],
|
||||||
Name: vals[1],
|
Name: vals[1],
|
||||||
Semester: vals[2],
|
Term: vals[2],
|
||||||
Note: vals[3],
|
Grade: vals[3],
|
||||||
Status: vals[4],
|
Status: vals[4],
|
||||||
CPs: vals[5],
|
Credits: vals[5],
|
||||||
Versuch: vals[7],
|
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