Commit 84671f80 by Sarina Canelake

Merge pull request #5267 from lduarte1991/lduarte-harvardx-pr27

Annotation Tools: Adding Try-Catch for anonyous_student_id issue in staging
parents 35fdcf43 bb4cfaba
......@@ -108,12 +108,15 @@ class ImageAnnotationModule(AnnotatableFields, XModule):
self.instructions = self._extract_instructions(xmltree)
self.openseadragonjson = html_to_text(etree.tostring(xmltree.find('json'), encoding='unicode'))
self.user = ""
self.user_email = ""
self.is_course_staff = False
if self.runtime.get_user_role() in ['instructor', 'staff']:
self.is_course_staff = True
if self.runtime.get_real_user is not None:
self.user = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
try:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
except: # pylint: disable=broad-except
self.user_email = _("No email address found.")
def _extract_instructions(self, xmltree):
""" Removes <instructions> from the xmltree and returns them as a string, otherwise None. """
......@@ -124,7 +127,7 @@ class ImageAnnotationModule(AnnotatableFields, XModule):
context = {
'display_name': self.display_name_with_default,
'instructions_html': self.instructions,
'token': retrieve_token(self.user, self.annotation_token_secret),
'token': retrieve_token(self.user_email, self.annotation_token_secret),
'tag': self.instructor_tags,
'openseadragonjson': self.openseadragonjson,
'annotation_storage': self.annotation_storage_url,
......
......@@ -107,7 +107,10 @@ class TextAnnotationModule(AnnotatableFields, XModule):
if self.runtime.get_user_role() in ['instructor', 'staff']:
self.is_course_staff = True
if self.runtime.get_real_user is not None:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
try:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
except: # pylint: disable=broad-except
self.user_email = _("No email address found.")
def _extract_instructions(self, xmltree):
""" Removes <instructions> from the xmltree and returns them as a string, otherwise None. """
......
......@@ -107,7 +107,10 @@ class VideoAnnotationModule(AnnotatableFields, XModule):
if self.runtime.get_user_role() in ['instructor', 'staff']:
self.is_course_staff = True
if self.runtime.get_real_user is not None:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
try:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
except: # pylint: disable=broad-except
self.user_email = _("No email address found.")
def _extract_instructions(self, xmltree):
""" Removes <instructions> from the xmltree and returns them as a string, otherwise None. """
......
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