Score:0

How can I build a specific data structure?

cn flag

I have a Course content type which has several "modules." (A module is just a name.) There are also several "units," which may or not belong to a module. A unit has several fields, for example Location, Description.

I have created a Course unit paragraph type, and a Units field in the "course" content type, which references this paragraph type. That way I can create units that belong to the course.

However, I'm not sure how to deal with modules. I could create a Course module paragraph type, but I don't think it would enable me to attach a unit to a module, since there's no way to select an existing paragraph.

Basically I need to create several modules inside a node, then several units, and optionally attach these units to one of the modules I've created.

sonfd avatar
in flag
Are modules unique to a course? Can units belong to multiple modules? Can multiple units belong to the same module? What's different about a unit if it's attached to a module vs not?
Hubert avatar
cn flag
Yes, modules are unique to a course. Units cannot belong to multiple modules, but multiple units can belong to the same module. There is no difference between a unit that belong to a module vs not. In a way units are tagged with a module, so I've ended up setting up modules as a taxonomy vocabulary (with a content reference field that point to a course)
Score:1
cn flag

Given what you have done so far I would recommend:

  • Create a "Modules" taxonomy.
  • Make this a hierarchical taxonomy that includes course names (as if courses were top level modules) and then add the modules under those.
  • Add a taxonomy reference field to your Unit paragraph
  • This will be flexible in a couple of ways:
    • It will let modules receive descriptive fields as needed later.
    • It will allow site search and filter by module in a hierarchy that includes courses.
    • It will allow for modules within modules if that becomes a later requirement.

Optional improvements

  • Make the module selector field on the Unit paragraph form use a view that filters by the current course name as parent (with depth)
Hubert avatar
cn flag
Thank you, that's a great idea! I've ended up setting up a "course module" taxonomy (although I kept it simple, with just a name and course reference), and tagged each course unit with a term.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.