@@ -95,6 +95,10 @@ class AnnotatableBlock(LegacyXmlMixin, XBlock):
9595 # List of supported highlight colors for annotations
9696 HIGHLIGHT_COLORS = ["yellow" , "orange" , "purple" , "blue" , "green" ]
9797
98+ @property
99+ def location (self ):
100+ return self .scope_ids .usage_id
101+
98102 def _get_annotation_class_attr (self , index , el ): # pylint: disable=unused-argument
99103 """Returns a dict with the CSS class attribute to set on the annotation
100104 and an XML key to delete from the element.
@@ -247,12 +251,12 @@ def workbench_scenarios():
247251 ]
248252
249253 @classmethod
250- def definition_from_xml (cls , xml_object , system ): # lint-amnesty, pylint: disable=unused-argument
254+ def definition_from_xml (cls , xml_object , system ):
251255 if len (xml_object ) == 0 and len (list (xml_object .items ())) == 0 :
252256 return {'data' : '' }, []
253257 return {'data' : etree .tostring (xml_object , pretty_print = True , encoding = 'unicode' )}, []
254258
255- def definition_to_xml (self , resource_fs ): # lint-amnesty, pylint: disable=unused-argument
259+ def definition_to_xml (self , resource_fs ):
256260 """
257261 Return an Element if we've kept the import OLX, or None otherwise.
258262 """
@@ -278,12 +282,12 @@ def definition_to_xml(self, resource_fs): # lint-amnesty, pylint: disable=unuse
278282 # Can't recover here, so just add some info and
279283 # re-raise
280284 lines = self .data .split ('\n ' )
281- line , offset = err .position
285+ line , offset = err .position # lint-amnesty, pylint: disable=unpacking-non-sequence
282286 msg = (
283287 "Unable to create xml for block {loc}. "
284288 "Context: '{context}'"
285289 ).format (
286290 context = lines [line - 1 ][offset - 40 :offset + 40 ],
287291 loc = self .location ,
288292 )
289- raise SerializationError (self .location , msg ) # lint-amnesty, pylint: disable=raise-missing- from
293+ raise SerializationError (self .location , msg ) from err
0 commit comments