Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
fixed loader and seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
JibrilExe committed May 16, 2024
1 parent 1cbb520 commit ffd47a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
10 changes: 3 additions & 7 deletions backend/seeder/seeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -179,7 +179,7 @@ def into_the_db(my_uid):
session, course_id, students)
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()
Expand Down Expand Up @@ -209,12 +209,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)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Courses/CourseDetailTeacher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function CourseDetailTeacher(): JSX.Element {
);
}
};

return (
<>
<Title title={course.name}></Title>
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/components/Courses/CourseUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ export const dataLoaderCourseDetail = async ({
const projects = await dataLoaderProjects(courseId);
const admins = await dataLoaderAdmins(courseId);
const students = await dataLoaderStudents(courseId);

const adminMes = await fetchMes([course.teacher, ...admins]);
const studentMes = await fetchMes(students);
const admin_uids = admins.map((admin: {uid: string}) => getIdFromLink(admin.uid));
const student_uids = students.map((student: {uid: string}) => getIdFromLink(student.uid));
const adminMes = await fetchMes([course.teacher, ...admin_uids]);
const studentMes = await fetchMes(student_uids);
return { course, projects, adminMes, studentMes };
};

0 comments on commit ffd47a8

Please sign in to comment.