Skip to content

Unique Id for Block #218

Open
Open

Description

@cpennington

Reported by @pmitros: "To construct useful XBlocks, I need access to a unique ID per element. Cale mentioned this is available in self.scope_ids.usage_id. This is good and useful, but entirely undocumented."

@nedbat: "Yes, let's add this to the list of useful factoids that can be retrieved from the information service, along with student name, course name, etc."

Activity

  1. cpennington commented on May 29, 2014

    @cpennington
    ContributorAuthor

    I'm not sure it makes sense to have general "information service". I'd rather be more specific/selective, and have services for info about the course, about the current user, and perhaps about the block. Although, simply exposing self.scope_ids.usage_id (or a function of that) as a known unique id (without getting a service involved) seems reasonable to me as well. In particular, the fact that that id is unique is a property of the general XBlock structure, rather than optional functionality that only some runtimes might provide.

  2. pmitros commented on May 29, 2014

    @pmitros
    Contributor

    I'd tend to agree with cpennington. This feels core. I'd rather have this available in the XBlock than in an external service. It's not really clear how to write a lot of the client-side code clearly, in particular, without having unique IDs if there are multiple of the same type of XBlock on the same page.

    My personal preference would be towards something like self.usage or self.id. This would
    (1) be concise and readable to use
    (2) developers learning the framework could find it through introspection (.dict), rather than introspection on class members or looking for services
    (3) we wouldn't be exposing the scope_ids data structure
    (4) it could easilt be exposed in the string representation of the XBlock on the console when printing it, for debugging.

  3. taniwallach commented on Jun 7, 2021

    @taniwallach
  4. pmitros commented on Jun 7, 2021

    @pmitros
    Contributor

    @taniwallach I believe @cpennington is now at Reify Health (and sports an awesome beard). I'm also no longer actively involved in Open edX development (and don't appear to have commit access anymore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions