From 8d74a52266142b07ebaadda6e1a33b7af83c6d06 Mon Sep 17 00:00:00 2001 From: cmekeirl Date: Fri, 17 May 2024 10:13:31 +0200 Subject: [PATCH 1/2] teacher added as student to course for real this time --- backend/seeder/seeder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/seeder/seeder.py b/backend/seeder/seeder.py index 005cb871..a85be82d 100644 --- a/backend/seeder/seeder.py +++ b/backend/seeder/seeder.py @@ -177,6 +177,8 @@ def into_the_db(my_uid): course_id = insert_course_into_db_get_id(session, teacher_uid) subscribed_students = populate_course_students( session, course_id, students) + session.add(CourseStudent(course_id=course_id, uid=my_uid)) + session.commit() subscribed_students.append(my_uid) # my_uid is also a student populate_course_projects( session, course_id, subscribed_students, teacher_uid) From aaca99bb7880c8f9fa72ec5b1df64855fd9fdc3a Mon Sep 17 00:00:00 2001 From: cmekeirl Date: Tue, 21 May 2024 00:04:45 +0200 Subject: [PATCH 2/2] teacher is not admin --- backend/seeder/seeder.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/backend/seeder/seeder.py b/backend/seeder/seeder.py index a85be82d..d56d0e0f 100644 --- a/backend/seeder/seeder.py +++ b/backend/seeder/seeder.py @@ -170,7 +170,7 @@ def into_the_db(my_uid): subscribed_students = populate_course_students( session, course_id, students) populate_course_projects( - session, course_id, subscribed_students, my_uid) + session, course_id, subscribed_students) for _ in range(5): # 5 courses where my_uid is a student teacher_uid = teachers[random.randint(0, len(teachers)-1)].uid @@ -181,7 +181,7 @@ def into_the_db(my_uid): session.commit() subscribed_students.append(my_uid) # my_uid is also a student populate_course_projects( - session, course_id, subscribed_students, teacher_uid) + session, course_id, subscribed_students) except SQLAlchemyError as e: if session: # possibly error resulted in session being null session.rollback() @@ -211,12 +211,8 @@ def populate_course_students(session, course_id, students): return [student.uid for student in subscribed_students] -def populate_course_projects(session, course_id, students, teacher_uid): +def populate_course_projects(session, course_id, students): """Populates the course with projects and submissions, also creates the files""" - teacher_relation = course_admin_generator(course_id, teacher_uid) - session.add(teacher_relation) - session.commit() - num_projects = random.randint(1, 3) projects = generate_projects(course_id, num_projects) session.add_all(projects)