本文整理汇总了Golang中github.com/andrewcharlton/school-dashboard/env.Env.HistoricalResults方法的典型用法代码示例。如果您正苦于以下问题:Golang Env.HistoricalResults方法的具体用法?Golang Env.HistoricalResults怎么用?Golang Env.HistoricalResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/andrewcharlton/school-dashboard/env.Env
的用法示例。
在下文中一共展示了Env.HistoricalResults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: subjectBroadsheet
func subjectBroadsheet(e env.Env, subj *subject.Subject, sheet *xlsx.Sheet, g group.Group) error {
// Get a list of all resultsets for historical data
resultsets := e.Resultsets
// Create set of maps, keyed by resultsetID, then UPN
historical := map[string](map[string]string){}
for _, rs := range resultsets {
historical[rs.ID] = map[string]string{}
}
// Load all historical data from the database
for _, s := range g.Students {
grds, err := e.HistoricalResults(s.UPN, subj.SubjID)
switch err {
case nil:
for rs, grd := range grds {
historical[rs][s.UPN] = grd
}
case sql.ErrNoRows:
continue
default:
return err
}
}
// Create set of empty resultsets
empty := map[string]bool{}
for rs, results := range historical {
if len(results) == 0 {
empty[rs] = true
}
}
// Write headers to the sheet
row := sheet.AddRow()
row.SetHeightCM(4.5)
newCell(row, "Name", newStyle("Bold", "None", "Bottom", "Left"))
newCell(row, "Class", newStyle("Bold", "None", "Bottom", "Left"))
headers := []string{"Gender", "PP", "KS2", "SEN", "Grade",
"Effort", "VA", "Attendance"}
for _, h := range headers {
newCell(row, h, newStyle("Bold", "None", "Bottom", "Center"))
}
// Add historical resultsets to the headers
for _, rs := range resultsets {
if !empty[rs.ID] {
newCell(row, rs.Name, newStyle("Bold", "None", "Bottom", "Vertical"))
}
}
for _, h := range []string{"Barriers to Learning", "Intervention"} {
newCell(row, h, newStyle("Bold", "None", "Bottom", "Center"))
}
// Add Student data
for _, s := range g.Students {
row := sheet.AddRow()
newCell(row, s.Name(), newStyle("Default", "None", "None", "Left"))
newCell(row, s.Class(subj.Subj), newStyle("Default", "None", "None", "Left"))
newCell(row, s.Gender.String(), newStyle("Default", "None", "None", "Center"))
newBool(row, s.PP, newStyle("Default", "None", "None", "Center"))
newCell(row, s.KS2.Score(subj.KS2Prior), newStyle("Default", "None", "None", "Center"))
newCell(row, s.SEN.Status, newStyle("Default", "None", "None", "Center"))
newCell(row, s.SubjectGrade(subj.Subj), newStyle("Default", "None", "None", "Center"))
newCell(row, s.SubjectEffort(subj.Subj), newStyle("Default", "None", "None", "Center"))
newFloat(row, s.SubjectVA(subj.Subj).Score(), "+0.00;-0.00;0.00", newStyle("Default", "None", "None", "Center"))
newFloat(row, s.Attendance.Latest(), "0.0%", newStyle("Default", "None", "None", "Center"))
for _, rs := range resultsets {
if !empty[rs.ID] {
grd, _ := historical[rs.ID][s.UPN]
newCell(row, grd, newStyle("Default", "None", "None", "Center"))
}
}
}
return nil
}