From 7dde170c772c8bd0d23d6548d752588b519bbd1e Mon Sep 17 00:00:00 2001 From: Steve Brownlee Date: Tue, 14 May 2024 16:33:07 -0500 Subject: [PATCH] Assign new students to first project of client side course --- LearningAPI/views/profile.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/LearningAPI/views/profile.py b/LearningAPI/views/profile.py index 55d1b81..79f7610 100644 --- a/LearningAPI/views/profile.py +++ b/LearningAPI/views/profile.py @@ -42,12 +42,22 @@ def list(self, request): nss_user.save() if cohort is not None: - coh = Cohort.objects.get(pk=cohort) + # First time authenticating with Github, so add user to cohort + cohort_assignment = Cohort.objects.get(pk=cohort) usercohort = NssUserCohort() - usercohort.cohort = coh + usercohort.cohort = cohort_assignment usercohort.nss_user = nss_user usercohort.save() + # Assign student to first project in cohort's course + cohort_first_course = cohort_assignment.courses.get(index=0) + course_first_book = cohort_first_course.course.books.get(index=0) + book_first_project = course_first_book.projects.get(index=0) + student_project = StudentProject() + student_project.student = nss_user + student_project.project = book_first_project + student_project.save() + try: personality = StudentPersonality.objects.get(student=nss_user) except StudentPersonality.DoesNotExist: