adaptlearning / adapt_authoring

A server-based user interface for authoring eLearning courses using the Adapt framework.
https://www.adaptlearning.org/
GNU General Public License v3.0
515 stars 282 forks source link

contentObjects sequence isn't proper in import and export #2538

Closed cksachdev closed 4 years ago

cksachdev commented 4 years ago

Expected Behaviour

Export scenario:

Pre-condition: Create a course with 2 menu items, like below: image image Each page having just one text component.

Steps:

Same is reproducible when trying to import a course which contains menu and page in contentObjects.

Versions

tomgreenfield commented 4 years ago
  • _.map(Adapt.contentObjects._byAdaptID, (co, key) => console.log(co[0].attributes.displayTitle) ); Title should print in a sequence

This arguably shouldn't be the case. The private _byAdaptID property just groups models by their ID. It cannot be replied upon to get an indication of the course structure, either with automatically-generated IDs from the authoring tool or with hand-typed IDs in JSON.

If you told us a bit about the problem you're trying to solve we could advise further with a solution.

For example, to print a sorted list of content object titles in a framework 5.2 course, you could utilise the following code:

Adapt.course.getAllDescendantModels(true).forEach(function(model) {
  var type = model.get('_type');
  if (type === 'menu' || type === 'page') {
    console.log(model.get('displayTitle'));
  }
});

This gets easier in an upgraded framework (version 5.5 or later):

Adapt.course.getAllDescendantModels(true).forEach(model => model.isTypeGroup('contentobject') && console.log(model.get('displayTitle')));
cksachdev commented 4 years ago

@tomgreenfield I have created a footer navigation component, which should allow the user to navigate to "Next", "Back" and "Go back to main menu". In order to achieve this, I needed the sequence of data in the order I am expecting.

Parent1
Parent1 - Page1
Parent2
Parent2 - Page1
Parent2 - Page2

I will try out the getAllDescendantModels method and let you know if it gives me the right sequence.

Update: Tried out the method in console and getting the sequence as expected.