Ändere Wochenfeld zu mehr Auswahl.

Closes #28
This commit is contained in:
Gonne 2025-04-02 14:50:42 +02:00
parent 5e954ca751
commit e05d30b886
Signed by: Gonne
SSH key fingerprint: SHA256:J8w3ZCNyz9MoTLV+eU7YRTVw59NYig44i0IWhbsgQG8
7 changed files with 13 additions and 11 deletions

View file

@ -73,8 +73,8 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
if err != nil {
errors = append(errors, "Die Vorlesungswoche muss eine ganze Zahl sein.")
}
if !(week >= 0 && week <= 2) {
errors = append(errors, "Sprechstunden müssen jede, jede gerade oder jede ungerade Vorlesungswoche stattfinden.")
if !(week >= 0 && week <= 5) {
errors = append(errors, "Bitte wähle eine der vorgegebenen Optionen für Vorlesungswochen.")
}
day, err := strconv.Atoi(req.FormValue("tag"))
if err != nil {

View file

@ -5,7 +5,7 @@ import (
)
type Date struct {
Week int // Set whether the date is all weeks (0), odd weeks (1) or even weeks (2).
Week int // Set whether the date is all weeks (0), weeks with exercise session (1) or weeks without exercise session (2), even weeks (3), odd weeks (4) or other (5).
Day int
Hour int
Minute int

View file

@ -245,9 +245,7 @@ func (r *OfficeHourRepo) NumberByTimeSpanAndRoom(date models.Date, duration int,
for _, officeHour := range officeHours {
// 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 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 {

View file

@ -59,9 +59,12 @@
<div class="form-floating mb-3">
<select class="form-control form-select required" required name="woche" id="woche">
<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="2"{{if eq 2 $.Date.Week}} selected{{end}}>Gerade</option>
<option value="0"{{if eq 0 $.Date.Week}} selected{{end}}>Jede Woche</option>
<option value="1"{{if eq 1 $.Date.Week}} selected{{end}}>In Wochen mit Übung</option>
<option value="2"{{if eq 2 $.Date.Week}} selected{{end}}>In Wochen ohne Übung</option>
<option value="1"{{if eq 3 $.Date.Week}} selected{{end}}>In geraden Vorlesungswochen</option>
<option value="2"{{if eq 4 $.Date.Week}} selected{{end}}>In ungeraden Vorlesungswochen</option>
<option value="2"{{if eq 5 $.Date.Week}} selected{{end}}>Etwas anderes (nutze Infofeld)</option>
</select>
<label for="woche">Vorlesungswoche</label>
</div>

View file

@ -5,6 +5,7 @@ mit deiner Emailadresse soll eine Sprechstunde mit folgenden Daten {{if eq .Requ
{{.Request.OfficeHour.Course.Name}}
{{DayName .Request.OfficeHour.Date.Day}}
{{printf "%02d" .Request.OfficeHour.Date.Hour}}:{{printf "%02d" .Request.OfficeHour.Date.Minute}} Uhr bis {{printf "%02d" .Request.OfficeHour.EndDate.Hour}}:{{printf "%02d" .Request.OfficeHour.EndDate.Minute}} Uhr
{{if eq 0 .Request.OfficeHour.Date.Week}}Jede Woche{{end}}{{if eq 1 .Request.OfficeHour.Date.Week}}In Wochen mit Übung{{end}}{{if eq 2 .Request.OfficeHour.Date.Week}}In Wochen ohne Übung{{end}}{{if eq 3 .Request.OfficeHour.Date.Week}}In geraden Vorlesungswochen{{end}}{{if eq 4 .Request.OfficeHour.Date.Week}}In ungeraden Vorlesungswochen{{end}}
{{.Request.OfficeHour.Tutor.Name}}
{{.Request.OfficeHour.Room.Name}}

View file

@ -11,7 +11,7 @@
<p>
Willst du die Sprechstunde<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 Vorlesungswochen<br>{{end}}{{if eq .OfficeHour.Date.Week 2}}in geraden Vorlesungswochen<br>{{end}}
{{if eq 0 $.Date.Week}}>Jede Woche<br>{{end}}{{if eq 1 $.Date.Week}}In Wochen mit Übung<br>{{end}}{{if eq 2 $.Date.Week}}In Wochen ohne Übung<br>{{end}}{{if eq 3 $.Date.Week}}In geraden Vorlesungswochen<br>{{end}}{{if eq 4 $.Date.Week}}In ungeraden Vorlesungswochen<br>{{end}}
{{.OfficeHour.Course.Name}}<br>
{{.OfficeHour.Tutor.Name}}<br>
{{.OfficeHour.Room.Name}}<br>

View file

@ -1,7 +1,7 @@
<td class="officeHour" rowspan="{{divide .OfficeHour.Duration .MinuteGranularity}}">
{{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>
{{if eq .OfficeHour.Date.Week 1}}in ungeraden Vorlesungswochen<br>{{end}}{{if eq .OfficeHour.Date.Week 2}}in geraden Vorlesungswochen<br>{{end}}
{{if eq 1 .OfficeHour.Date.Week}}In Wochen mit Übung<br>{{end}}{{if eq 2 .OfficeHour.Date.Week}}In Wochen ohne Übung<br>{{end}}{{if eq 3 .OfficeHour.Date.Week}}In geraden Vorlesungswochen<br>{{end}}{{if eq 4 .OfficeHour.Date.Week}}In ungeraden Vorlesungswochen<br>{{end}}
{{.OfficeHour.Course.Name}}<br>
{{.OfficeHour.Tutor.Name}}<br>
{{.OfficeHour.Room.Name}}