Commit dcd3e6ea authored by Bruno Martin's avatar Bruno Martin
Browse files

fix to avoid user from being without a class for

every started course
parent 8d8e9a0c
......@@ -357,7 +357,11 @@ class CourseStudent(models.Model):
return self.course_finished
def get_current_class(self):
return Class.objects.get(students=self.user, course=self.course)
try:
return Class.objects.get(students=self.user, course=self.course)
except Class.DoesNotExist:
self.course.default_class.students.add(self.user)
return self.course.default_class
def min_percent_to_complete(self):
return self.course.min_percent_to_complete
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment