本文整理汇总了Golang中github.com/andrewcharlton/school-dashboard/env.Env.GroupByFilteredClass方法的典型用法代码示例。如果您正苦于以下问题:Golang Env.GroupByFilteredClass方法的具体用法?Golang Env.GroupByFilteredClass怎么用?Golang Env.GroupByFilteredClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/andrewcharlton/school-dashboard/env.Env
的用法示例。
在下文中一共展示了Env.GroupByFilteredClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SubjectSpreadsheet
func SubjectSpreadsheet(e env.Env, f database.Filter, subj *subject.Subject, w io.Writer) error {
file := xlsx.NewFile()
g, err := e.GroupByFilteredClass(strconv.Itoa(subj.SubjID), "", f)
if err != nil {
return err
}
sheet, err := file.AddSheet("Progress Grid")
if err != nil {
return err
}
subjectGrid(sheet, g, subj, f.NatYear)
sheet, err = file.AddSheet("Students")
if err != nil {
return err
}
subjectBroadsheet(e, subj, sheet, g)
sheet, err = file.AddSheet("Export Details")
if err != nil {
return err
}
exportInfoSheet(sheet, e, f)
file.Write(w)
return nil
}
示例2: subjectGroupPage
func subjectGroupPage(e env.Env, w http.ResponseWriter, r *http.Request) {
if redir := checkRedirect(e, w, r, 2); redir {
return
}
header(e, w, r, 2)
defer footer(e, w, r)
path := strings.Split(r.URL.Path, "/")
subjID, err := strconv.Atoi(path[3])
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
return
}
subj := e.Subjects[subjID]
f := getFilter(e, r)
g, err := e.GroupByFilteredClass(path[3], "", f)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
}
classes, err := e.Classes(path[3], f.Date)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
}
sort.Sort(sort.StringSlice(classes))
clsGrps := []subGroup{}
for _, c := range classes {
grp := g.SubGroup(group.Class(subj.Subj, c))
if len(grp.Students) > 0 {
clsGrps = append(clsGrps, subGroup{c, template.URL(c), grp})
}
}
data := struct {
Query template.URL
Year string
Subj *subject.Subject
SubGroups []subGroup
Matrix subGroupMatrix
Classes []subGroup
}{
template.URL(r.URL.RawQuery),
f.Year,
subj,
subGroups(g),
groupMatrix(g),
clsGrps,
}
err = e.Templates.ExecuteTemplate(w, "subjectgroups.tmpl", data)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
return
}
}
示例3: progressGridPage
// Performs analysis of the results
func progressGridPage(e env.Env, w http.ResponseWriter, r *http.Request) {
if redir := checkRedirect(e, w, r, 2); redir {
return
}
header(e, w, r, 2)
defer footer(e, w, r)
path := strings.Split(r.URL.Path, "/")
subjID, err := strconv.Atoi(path[3])
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
return
}
subject := e.Subjects[subjID]
class := path[4]
if strings.HasPrefix(path[4], "All") {
class = ""
}
f := getFilter(e, r)
g, err := e.GroupByFilteredClass(path[3], class, f)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
}
data := struct {
Query template.URL
Year string
Subject string
Level string
SubjID string
Class string
KS2Prior string
Group group.Group
ProgressGrid group.ProgressGrid
}{
template.URL(r.URL.RawQuery),
f.Year,
subject.Subj,
subject.Lvl,
path[3],
path[4],
subject.KS2Prior,
g,
g.ProgressGrid(subject, f.NatYear),
}
err = e.Templates.ExecuteTemplate(w, "progressgrid.tmpl", data)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
return
}
}