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

Test course feature for lecturers #1425

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

carlobortolan
Copy link
Member

@carlobortolan carlobortolan commented Dec 18, 2024

Motivation and Context

Closes #1418.
While this approach is not optimal, as we need to "reserve" special values for test courses, it is relatively simple and builds on top of the existing code in comparison to more complex approaches (e.g., updating the current course model & table to include a isTestCourse attribute or adding a completely new test course model).

Description

  • Internally, test courses are handled just like regular courses but belong to a special "test-semester" (where the course's year equals 1234).
  • Updated semester API endpoint and course DAO methods to include an optional includeTestSemester flag, which defaults to false. This allows the endpoint & method to return the same information as before (all normal courses), and only if the flag is set, also include the test courses.
  • Updated all current occurrences of the semester-fetching (e.g., on the start page, search page, and admin page) accordingly so that the test semesters and courses are not included there.

Steps for Testing

Prerequisites:

  • 1 Lecturer
  • 1 Student
  1. Log in as a lecturer
  2. Go to the admin panel and press on + Create Test Course to create a new test course
  3. The test course should now appear after reloading the page
  4. Log out and log in as another user
  5. Check that the previously created test course is not visible anywhere and that the semesters don't include the test semester

Screenshots

How to create a test course:
image

How an Admin sees all test courses:
image

@carlobortolan carlobortolan self-assigned this Dec 18, 2024
@carlobortolan carlobortolan linked an issue Dec 18, 2024 that may be closed by this pull request
Copy link

Your Testserver will be ready at https://1425.test.live.mm.rbg.tum.de in a few minutes.

Logins
Kurs1 Kurs2 Kurs3 Kurs4
public public loggedin enrolled
prof1 prof1 prof2 prof1
prof2
student1
student2
student3
student1
student2
student2
student3
student1
student2

@carlobortolan carlobortolan marked this pull request as ready for review January 10, 2025 09:59
@carlobortolan carlobortolan requested a review from SebiWrn January 10, 2025 12:36
func (r coursesRoutes) createTestCourse(c *gin.Context) {
tumLiveContext := c.MustGet("TUMLiveContext").(tools.TUMLiveContext)

_, err := r.StreamsDao.CreateOrGetTestCourse(tumLiveContext.User)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should every user be able to create a test course? If every student can create a test course, they could possibly fill up the entire disk just by streaming nonsense

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only lecturers should be allowed to create test courses, but this should already be the case here, no?

See:

lecturers.Use(tools.AtLeastLecturer)

and:
lecturers.POST("/createTestCourse", routes.createTestCourse)

dao/streams.go Outdated
@@ -405,8 +406,8 @@ func (d streamsDao) CreateOrGetTestStreamAndCourse(user *model.User) (model.Stre
func (d streamsDao) CreateOrGetTestCourse(user *model.User) (model.Course, error) {
var course model.Course
err := DB.FirstOrCreate(&course, model.Course{
Name: "(" + strconv.Itoa(int(user.ID)) + ") " + user.Name + "'s Test Course",
TeachingTerm: "Test",
Name: user.GetPreferredName() + "'s Test Course",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have a fallback if the users preferred name is empty

Copy link
Member Author

@carlobortolan carlobortolan Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out; I updated it so that it defaults to Test Couse if a user has a blank name.

Edit: On a side note, is it an issue for the workers/edge server if all test courses have the same slug? (/should the slug be unique for all courses?) From what I was able to test locally, this is not an issue in the web client.

web/admin.go Outdated
@@ -221,7 +231,7 @@ func (r mainRoutes) CourseStatsPage(c *gin.Context) {
logger.Error("couldn't query courses for user.", "err", err)
courses = []model.Course{}
}
semesters := r.CoursesDao.GetAvailableSemesters(c)
semesters := r.CoursesDao.GetAvailableSemesters(c, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow to see stats of the test courses? Maybe with that users could also test this stats functionality?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there should be any problem if we allow lecturers to see stats for test courses; updated it in my latest commit 👍

web/admin.go Outdated
y, t := tum.GetCurrentSemester()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate with line 284, this should be another function so the test course check can be adjusted if we change the implementation of test courses

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

@carlobortolan carlobortolan requested a review from SebiWrn January 12, 2025 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test courses for lecturers
2 participants