-
Notifications
You must be signed in to change notification settings - Fork 1
/
student.go
147 lines (125 loc) · 2.7 KB
/
student.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package main
import (
"encoding/json"
"fmt"
"math/rand"
"time"
)
// TaskMap struct which contains
// an array of requirements
type Student struct {
StudentId string `json:"id"`
Name string `json:"name"`
TaskMapList []string `json:"taskMapList"`
ActivityLogList []string `json:"activityLogList"`
TaskAuditList []string `json:"taskAuditList"`
WhatsLeftList []string `json:"whatsLeftList"`
Metadata StudentMetaData
AuditConfig StudentAuditConfig
ShouldUpdateAuditFlag bool
NumReportsRan int `json:"numReportsRan,omitempty"`
}
type StudentMetaData struct {
ReportRan int
NumMaps int
NumActs int
MainMajorComplete string
MainMajor string
SIS string
Advisor string
Contact string
}
type StudentAuditConfig struct {
AutoRun bool
ExcludeMaps []string
MostRecentActivity bool
}
func TestStudentLoop() {
meta := StudentMetaData{}
config := StudentAuditConfig{
true,
[]string{},
true,
}
student := Student{
"75e7c8",
"David Holtz",
[]string{
"KRBEMFDZDC",
"BZRJXAWNWE",
},
[]string{
"LDNJOBCSNV",
},
[]string{},
[]string{},
meta,
config,
true,
0,
}
jsonData, _ := json.Marshal(student)
fmt.Println(string(jsonData))
}
func GetNRandom(n int, list []string) []string {
s1 := rand.NewSource(time.Now().UnixNano())
r1 := rand.New(s1)
var tskLst []string
for i := 0; i < n; i++ {
indx := r1.Intn(len(list))
tskLst = append(tskLst, list[indx])
}
// fmt.Println(tskLst)
return tskLst
}
func MakeStudent(idf string, name string, taskList []string, actList []string) Student {
tskLst := GetNRandom(10, taskList)
stdLst := GetNRandom(1, actList)
meta := StudentMetaData{}
config := StudentAuditConfig{
true,
[]string{},
true,
}
student := Student{
idf,
name,
tskLst,
stdLst,
[]string{},
[]string{},
meta,
config,
true,
0,
}
// fmt.Println("\n\n")
// spew.Dump(student)
return student
}
func MakeStudents() {
// client.OpenBoltDb()
students := GetStudentKeys()
fmt.Println("\nNumber of students:\t", len(students), "\n")
// for i := 0; i < len(students); i++ {
// student := GetStudent(students[i])
// fmt.Println(student.StudentId)
// }
tasks := GetTaskMapKeys()
acts := GetActivityKeys()
for i := 0; i < 1; i++ {
s1 := rand.NewSource(time.Now().UnixNano())
b := make([]rune, 6)
for i := range b {
r1 := rand.New(s1)
b[i] = letters[r1.Intn(len(letters))]
}
idf := string(b)
stu := MakeStudent(idf, randSeq(8), tasks, acts)
// key :=
AddStudent(stu)
// spew.Dump(stu)
// spew.Dump(key)
// fmt.Println(string(key))
}
}