|
@@ -16,22 +16,27 @@ type Student struct {
|
|
|
DSA bool
|
|
|
BES bool
|
|
|
|
|
|
+ TutorID uint `schema:"tutor_id"`
|
|
|
ClassID uint `schema:"class_id"`
|
|
|
|
|
|
Class *Class
|
|
|
+ Tutor *Teacher
|
|
|
Teachers []*Teacher
|
|
|
Activities []*Activity
|
|
|
}
|
|
|
|
|
|
type StudentForUpdate struct {
|
|
|
- Student Student
|
|
|
- AllClasses []*Class
|
|
|
+ Student Student
|
|
|
+ AllClasses []*Class
|
|
|
+ AllTeachers []*Teacher
|
|
|
|
|
|
- SelectedClass map[uint]string
|
|
|
+ SelectedClass map[uint]string
|
|
|
+ SelectedTeacher map[uint]string
|
|
|
}
|
|
|
|
|
|
type StudentForAdd struct {
|
|
|
- AllClasses []*Class
|
|
|
+ AllClasses []*Class
|
|
|
+ AllTeachers []*Teacher
|
|
|
}
|
|
|
|
|
|
var (
|
|
@@ -109,6 +114,12 @@ func UpdateStudent(args map[string]string, r *http.Request) (IDer, error) {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
+ // FIXME: Should not be hard set.
|
|
|
+ student.(*Student).Handicap = false
|
|
|
+ student.(*Student).DSA = false
|
|
|
+ student.(*Student).BES = false
|
|
|
+
|
|
|
err = renderer.Decode(student, r)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
@@ -169,9 +180,16 @@ func GetStudentForUpdate(args map[string]string) (interface{}, error) {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
+ if err := DB().Find(&data.AllTeachers).Error; err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
data.SelectedClass = make(map[uint]string)
|
|
|
data.SelectedClass[data.Student.ClassID] = "selected"
|
|
|
|
|
|
+ data.SelectedTeacher = make(map[uint]string)
|
|
|
+ data.SelectedTeacher[data.Student.TutorID] = "selected"
|
|
|
+
|
|
|
return data, nil
|
|
|
}
|
|
|
|
|
@@ -181,6 +199,11 @@ func GetStudentForAdd(args map[string]string) (interface{}, error) {
|
|
|
if err := DB().Find(&data.AllClasses).Error; err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
+ if err := DB().Find(&data.AllTeachers).Error; err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
return data, nil
|
|
|
}
|
|
|
|