Check if effective_user is anonymous before trying to get grade
I saw locally that it caused an error if you hit the endpoint directly so just being defensive.
This commit is contained in:
@@ -210,9 +210,11 @@ class CoursewareMeta:
|
|||||||
@property
|
@property
|
||||||
def user_has_passing_grade(self):
|
def user_has_passing_grade(self):
|
||||||
""" Returns a boolean on if the effective_user has a passing grade in the course """
|
""" Returns a boolean on if the effective_user has a passing grade in the course """
|
||||||
course = get_course_by_id(self.course_key)
|
if not self.effective_user.is_anonymous:
|
||||||
user_grade = CourseGradeFactory().read(self.effective_user, course).percent
|
course = get_course_by_id(self.course_key)
|
||||||
return user_grade >= course.lowest_passing_grade
|
user_grade = CourseGradeFactory().read(self.effective_user, course).percent
|
||||||
|
return user_grade >= course.lowest_passing_grade
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def course_exit_page_is_active(self):
|
def course_exit_page_is_active(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user