summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--courses.go20
-rw-r--r--frontend/style.css2
-rw-r--r--index.go27
-rw-r--r--tmpl/student.html5
4 files changed, 34 insertions, 20 deletions
diff --git a/courses.go b/courses.go
index 80f0506..d9f15e0 100644
--- a/courses.go
+++ b/courses.go
@@ -77,21 +77,23 @@ const (
tt3 courseGroupT = "TT3"
)
-var courseGroups = map[courseGroupT]bool{
- mw1: true,
- mw2: true,
- mw3: true,
- tt1: true,
- tt2: true,
- tt3: true,
+var courseGroups = map[courseGroupT]string{
+ mw1: "Monday/Wednesday CCA1",
+ mw2: "Monday/Wednesday CCA2",
+ mw3: "Monday/Wednesday CCA3",
+ tt1: "Tuesday/Thursday CCA1",
+ tt2: "Tuesday/Thursday CCA2",
+ tt3: "Tuesday/Thursday CCA3",
}
func checkCourseType(ct courseTypeT) bool {
- return courseTypes[ct]
+ _, ok := courseTypes[ct]
+ return ok
}
func checkCourseGroup(cg courseGroupT) bool {
- return courseGroups[cg]
+ _, ok := courseGroups[cg]
+ return ok
}
var courses sync.Map /* int, *courseT */
diff --git a/frontend/style.css b/frontend/style.css
index 92564f6..76ba587 100644
--- a/frontend/style.css
+++ b/frontend/style.css
@@ -321,7 +321,7 @@ a.btn {
padding: 0rem 1rem;
}
-table#table-of-courses {
+table.table-of-courses {
width: 100%;
}
diff --git a/index.go b/index.go
index 508c5ae..4617b98 100644
--- a/index.go
+++ b/index.go
@@ -111,12 +111,21 @@ func handleIndex(w http.ResponseWriter, req *http.Request) {
return
}
- /*
- * Copy courses to _courses. The former is a sync.Map and the latter is
- * a map[int]*courseT, and the former is very difficult to access from
- * HTML templates.
- */
- _courses := make(map[int]*courseT)
+ /* TODO: The below should be completed on-update. */
+ type groupT struct {
+ Handle courseGroupT
+ Name string
+ Courses *map[int]*courseT
+ }
+ _groups := make(map[courseGroupT]groupT)
+ for k, v := range courseGroups {
+ _coursemap := make(map[int]*courseT)
+ _groups[k] = groupT{
+ Handle: k,
+ Name: v,
+ Courses: &_coursemap,
+ }
+ }
courses.Range(func(key, value interface{}) bool {
courseID, ok := key.(int)
if !ok {
@@ -126,7 +135,7 @@ func handleIndex(w http.ResponseWriter, req *http.Request) {
if !ok {
panic("courses map has non-\"*courseT\" items")
}
- _courses[courseID] = course
+ (*_groups[course.Group].Courses)[courseID] = course
return true
})
@@ -139,12 +148,12 @@ func handleIndex(w http.ResponseWriter, req *http.Request) {
Open bool
Name string
Department string
- Courses *map[int]*courseT
+ Groups *map[courseGroupT]groupT
}{
true,
userName,
userDepartment,
- &_courses,
+ &_groups,
},
)
}()
diff --git a/tmpl/student.html b/tmpl/student.html
index 4d82111..0294105 100644
--- a/tmpl/student.html
+++ b/tmpl/student.html
@@ -114,7 +114,7 @@
</div>
<div class="need-connection">
<div id="alreadyopen" class="reading-width">
- <table id="table-of-courses">
+ <table class="table-of-courses">
<thead>
<tr>
<th scope="col">Tick</th>
@@ -131,6 +131,8 @@
</tr>
</thead>
<tbody>
+ {{- range .Groups }}
+ <tr><th colspan="6">{{ .Name }}</th></tr>
{{- range .Courses }}
<tr class="courseitem" id="course{{.ID}}">
{{ if lt .Selected .Max -}}
@@ -145,6 +147,7 @@
<td>{{.Location}}</td>
</tr>
{{- end }}
+ {{- end }}
</tbody>
<tfoot>
<tr>