Compare commits

...

2 commits

4 changed files with 7 additions and 5 deletions

View file

@ -59,10 +59,10 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
//Parse date //Parse date
week, err := strconv.Atoi(req.FormValue("woche")) week, err := strconv.Atoi(req.FormValue("woche"))
if err != nil { if err != nil {
errors = append(errors, "Die Woche muss eine ganze Zahl sein.") errors = append(errors, "Die Vorlesungswoche muss eine ganze Zahl sein.")
} }
if !(week >= 0 && week <= 2) { if !(week >= 0 && week <= 2) {
errors = append(errors, "Sprechstunden müssen jede, jede gerade oder jede ungerade Woche stattfinden.") errors = append(errors, "Sprechstunden müssen jede, jede gerade oder jede ungerade Vorlesungswoche stattfinden.")
} }
day, err := strconv.Atoi(req.FormValue("tag")) day, err := strconv.Atoi(req.FormValue("tag"))
if err != nil { if err != nil {

View file

@ -240,9 +240,11 @@ func (r *OfficeHourRepo) NumberByTimeSpanAndRoom(date models.Date, duration int,
for _, officeHour := range officeHours { for _, officeHour := range officeHours {
// increase count if officehour starts before this point in time and ends later // increase count if officehour starts before this point in time and ends later
if models.DateLess(officeHour.Date, models.GetEndDate(date, minute, false)) && models.DateLess(models.GetEndDate(date, minute, false), models.GetEndDate(officeHour.Date, officeHour.Duration, false)) { if models.DateLess(officeHour.Date, models.GetEndDate(date, minute, false)) && models.DateLess(models.GetEndDate(date, minute, false), models.GetEndDate(officeHour.Date, officeHour.Duration, false)) {
if date.Week == 0 || officeHour.Week == 0 || date.Week == officeHour.Week { // office hours in alternating weeks should not collide
minuteCount += 1 minuteCount += 1
} }
} }
}
if minuteCount > count { if minuteCount > count {
count = minuteCount count = minuteCount
} }

View file

@ -11,7 +11,7 @@
<option value="{{$course.Id}}"{{if eq $course.Id $.SelectedCourse}} selected{{end}}>{{$course.Name}}</option> <option value="{{$course.Id}}"{{if eq $course.Id $.SelectedCourse}} selected{{end}}>{{$course.Name}}</option>
{{end}} {{end}}
</select><br> </select><br>
<label for="woche">Woche</label>: <label for="woche">Vorlesungswoche</label>:
<select name="woche" id="woche"> <select name="woche" id="woche">
<option value="0"{{if eq 0 $.Date.Week}} selected{{end}}>Jede</option> <option value="0"{{if eq 0 $.Date.Week}} selected{{end}}>Jede</option>
<option value="1"{{if eq 1 $.Date.Week}} selected{{end}}>Ungerade</option> <option value="1"{{if eq 1 $.Date.Week}} selected{{end}}>Ungerade</option>

View file

@ -1,7 +1,7 @@
<td rowspan="{{divide .OfficeHour.Duration .MinuteGranularity}}" style="border: 1px solid"> <td rowspan="{{divide .OfficeHour.Duration .MinuteGranularity}}" style="border: 1px solid">
{{if .DeleteIcons}}<div style="text-align: right;"><a href="/deleteOfficeHour?id={{.OfficeHour.Id}}"></a></div>{{end}} {{if .DeleteIcons}}<div style="text-align: right;"><a href="/deleteOfficeHour?id={{.OfficeHour.Id}}"></a></div>{{end}}
{{printf "%02d" .OfficeHour.Date.Hour}}:{{printf "%02d" .OfficeHour.Date.Minute}} - {{printf "%02d" .OfficeHour.EndDate.Hour}}:{{printf "%02d" .OfficeHour.EndDate.Minute}}<br> {{printf "%02d" .OfficeHour.Date.Hour}}:{{printf "%02d" .OfficeHour.Date.Minute}} - {{printf "%02d" .OfficeHour.EndDate.Hour}}:{{printf "%02d" .OfficeHour.EndDate.Minute}}<br>
{{if eq .OfficeHour.Date.Week 1}}in ungeraden Wochen<br>{{end}}{{if eq .OfficeHour.Date.Week 2}}in geraden Wochen<br>{{end}} {{if eq .OfficeHour.Date.Week 1}}in ungeraden Vorlesungswochen<br>{{end}}{{if eq .OfficeHour.Date.Week 2}}in geraden Vorlesungswochen<br>{{end}}
{{.OfficeHour.Course.Name}}<br> {{.OfficeHour.Course.Name}}<br>
{{.OfficeHour.Tutor.Name}}<br> {{.OfficeHour.Tutor.Name}}<br>
{{.OfficeHour.Room.Name}}<br> {{.OfficeHour.Room.Name}}<br>