Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show alert on course admin page for old semesters #1408

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,13 @@ func (r mainRoutes) EditCoursePage(c *gin.Context) {
if err != nil {
logger.Error("Error getting invited users for course", "err", err)
}
y, t := tum.GetCurrentSemester()

indexData := NewIndexData()
indexData.TUMLiveContext = tumLiveContext
indexData.CurrentYear = y
indexData.CurrentTerm = t

courses, err := r.CoursesDao.GetAdministeredCoursesByUserId(context.Background(), tumLiveContext.User.ID, "", 0)
if err != nil {
logger.Error("couldn't query courses for user.", "err", err)
Expand Down
31 changes: 30 additions & 1 deletion web/template/admin/admin_tabs/edit-course.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{{- /*gotype: github.com/TUM-Dev/gocast/web.AdminPageData*/ -}}
{{$course := .IndexData.TUMLiveContext.Course}}
{{$lecture := .IndexData.TUMLiveContext.Stream}}
{{$currentYear := .IndexData.CurrentYear}}
{{$currentTerm := .IndexData.CurrentTerm}}

<div class="text-1 mt-4" x-data="{userId: {{.IndexData.TUMLiveContext.User.Model.ID}} }">
<div class="min-w-screen items-center justify-center">

Expand All @@ -20,6 +23,32 @@
role="alert">
Course was created successfully.
</div>
{{if (eq $course.TeachingTerm "Test")}}
<div class="p-3 text-md border border-blue-500 text-blue-500 bg-blue-100 dark:bg-blue-200 dark:border-blue-700 dark:text-blue-700 rounded-lg flex items-center" role="alert">
<div class="flex-shrink-0">
<i class="fa-solid fa-info-circle text-4 text-blue-500 dark:text-blue-700"></i>
</div>
<div class="ml-3" x-init="console.log('currentYear: {{$currentYear}}', 'currentTerm: {{$currentTerm}}', 'courseYear: {{$course.Year}}', 'courseTerm: {{$course.TeachingTerm}}')">
<div class="font-bold">Info: Test Course</div>
<div class="text-sm">
This course is your personal test course. It will not be shown in the course overview to students and is only visible to you as an admin. <br>
</div>
</div>
</div>
{{else if or (ne $course.TeachingTerm $currentTerm) (ne $course.Year $currentYear)}}
<div class="p-3 text-md border bg-yellow-100 border-yellow-600 text-yellow-600 dark:bg-yellow-200 dark:border-yellow-700 dark:text-yellow-700 rounded-lg flex items-center" role="alert">
<div class="flex-shrink-0">
<i class="fa-solid fa-warning text-4 text-yellow-500 dark:text-yellow-700"></i>
</div>
<div class="ml-3" x-init="console.log('currentYear: {{$currentYear}}', 'currentTerm: {{$currentTerm}}', 'courseYear: {{$course.Year}}', 'courseTerm: {{$course.TeachingTerm}}')">
<div class="font-bold">Warning: Outdated Semester</div>
<div class="text-sm">
This course is not from the current semester and might not be shown in the course overview to students. <br>
If this is a recurring course, please select the course from the current semester and year.
</div>
</div>
</div>
{{end}}
</div>

<label class="hidden" for="courseID">CourseID<input id="courseID" type="text" class="hidden"
Expand Down Expand Up @@ -114,4 +143,4 @@
</div>
</div>
</div>
{{end}}
{{end}}
Loading