Documentation
¶
Overview ¶
Package gradebook is a library to read and write gradebook files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignmentCategories ¶
type AssignmentCategories []string
AssignmentCategories stores basic assignment categories, the broad groupings such as "major" and "minor".
type AssignmentRecord ¶ added in v0.2.0
AssignmentRecord represents a grade for a particular student on a particular assignment. If AssignmentRecord.Grade is nil, then the student was absent on the day of the assignment and should not be counted when calculating grades.
type AssignmentRecords ¶ added in v0.2.0
type AssignmentRecords []*AssignmentRecord
AssignmentRecords stores AssignmentRecord structs.
type AverageResult ¶
AverageResult represents the result of *Student.Average. The result is only valid for use if the given Student has scores of a given type to average.
func (AverageResult) String ¶
func (ar AverageResult) String() string
String returns a string representation of an AverageResult.
type CategoriesByAssignmentType ¶
CategoriesByAssignmentType maps categories by their assignment type. (E.g., "test", "essay", and "project" all have the category "major". Every assignment type must belong to one and only one category, and every assignment type must be present in CategoriesByAssignmentType. Also, and this is less obvious, every assignment category must have an assignment type. If a category has only a single assignment type, the category and type will often have the same name. E.g., both the category and the type are "cp"."
type Class ¶
type Class struct {
TermsByID `json:"terms_by_id"`
LabelsByAssignmentCategory `json:"labels_by_assignment_category"`
WeightsByAssignmentCategory `json:"weights_by_assignment_category"`
CategoriesByAssignmentType `json:"categories_by_assignment_type"`
StudentsByEmail `json:"students_by_email"`
Name string `json:"name"`
AssignmentCategories `json:"assignment_categories"`
}
Class represents a class and its students.
func UnmarshalCalcClass ¶
UnmarshalCalcClass unmarshals a class.json file into a pointer to Class. Unlike UnmarshalClass, this function creates the Grades map needed to store grades.
func UnmarshalClass ¶
UnmarshalClass unmarshals a class.json file into a pointer to Class.
func (*Class) AssignmentCategoriesSortedByLabel ¶
AssignmentCategoriesSortedByLabel returns a slice of categories sorted by label.
func (*Class) EmailsSortedByStudentName ¶
EmailsSortedByStudentName returns a slice of student emails sorted by student name.
func (*Class) LoadGrades ¶
LoadGrades scans a given directory for *.gradebook files and adds grades from those files to students. The method returns an error if there is a problem reading, unmarshaling, or closing a file.
func (*Class) StudentsSortedByName ¶
StudentsSortedByName returns a slice of students sorted by last and first name.
type Gradebook ¶
type Gradebook struct {
AssignmentDate string `json:"assignment_date"`
AssignmentName string `json:"assignment_name"`
AssignmentType string `json:"assignment_type"`
AssignmentCategory string `json:"assignment_category"`
AssignmentRecords AssignmentRecords `json:"assignment_records"`
}
Gradebook represents a single gradebook file.
func UnmarshalGradebook ¶
UnmarshalGradebook unmarshals a gradebook file into a pointer to Gradebook.
type LabelsByAssignmentCategory ¶
LabelsByAssignmentCategory maps human-readable labels by a category of assignment. E.g., the category "cp" has the label "Class Participation", and the category "major" has the label "Major Assessments".
type Student ¶
type Student struct {
GradesByCategory map[string][]float64
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
}
Student represents a student.
func NewStudent ¶
NewStudent a new *Student. If firstName or lastName is empty, the method returns an error.
func (*Student) Average ¶
func (s *Student) Average(category string) AverageResult
Average calculates the average for a slice of scores in a given category and returns an AverageResult and an error. If the category is unknown, the method returns an error. If the slice of scores is empty, the method returns an invalid AverageResult.
func (*Student) TotalAverage ¶
func (s *Student) TotalAverage(weights WeightsByAssignmentCategory) AverageResult
TotalAverage returns an AverageResult and error for all of a student's scores. The method will return an invalid result if the student has no scores in any category. The method will return an error if any call to Average for a given category returns an error.
type StudentsByEmail ¶
StudentsByEmail maps students by their email. (NB: an email is an appropriate equivalent to a database's primary key because emails are unique.)
type WeightsByAssignmentCategory ¶
WeightsByAssignmentCategory maps percentage values in a grading rubric by assignment category. The sum of the weights must equal 100 in order for this type to be valid.