Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions common/djangoapps/student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def anonymous_id_for_user(user, course_id):
if user.is_anonymous():
return None

cached_id = getattr(user, '_anonymous_id', {}).get(course_id)
if cached_id is not None:
return cached_id

# include the secret key as a salt, and to make the ids unique across different LMS installs.
hasher = hashlib.md5()
hasher.update(settings.SECRET_KEY)
Expand Down Expand Up @@ -94,6 +98,11 @@ def anonymous_id_for_user(user, course_id):
# continue
pass

if not hasattr(user, '_anonymous_id'):
user._anonymous_id = {}

user._anonymous_id[course_id] = digest

return digest


Expand Down