code: def assigned_state(instance):
      
      analyses = instance.getAnalyses()
      if not analyses:
          return "unassigned"
      for analysis in analyses:
          analysis_object = api.get_object(analysis)
          if not analysis_object.getWorksheet():
              return "unassigned"
      return "assigned"
docs: Returns `assigned` or `unassigned` depending on the state of the
      analyses the analysisrequest contains. Return `unassigned` if the Analysis
      Request has at least one analysis in `unassigned` state.
      Otherwise, returns `assigned`