constructTutorialModel static method

Future<TutorialModel> constructTutorialModel(
  1. MemberModel? member,
  2. AppModel app,
  3. String tutorialID,
  4. String name,
  5. String title,
  6. String description,
  7. String assetRoot,
  8. List<String?> assetLocations,
  9. List<String?> codes,
  10. List<String> descriptions,
)

Implementation

static Future<TutorialModel> constructTutorialModel(
    MemberModel? member,
    AppModel app,
    String tutorialID,
    String name,
    String title,
    String description,
    String assetRoot,
    List<String?> assetLocations,
    List<String?> codes,
    List<String> descriptions) async {
  assert(assetLocations.length == descriptions.length);
  List<TutorialEntryModel> items = [];
  for (int i = 0; i < assetLocations.length; i++) {
    String assetLocation;
    PlatformMediumModel? image;
    if (assetLocations[i] != null) {
      assetLocation = assetRoot + assetLocations[i]!;
      image = await ImageTools.uploadPlatformPhoto(
          app,
          member!.documentID,
          assetLocation,
          PrivilegeLevelRequiredSimple.noPrivilegeRequiredSimple);
    }
    String documentID = i.toString();
    items.add(TutorialEntryModel(
        documentID: documentID,
        description: descriptions[i],
        image: image,
        code: codes[i]));
  }

  return TutorialModel(
    documentID: tutorialID,
    appId: app.documentID,
    name: name,
    title: title,
    description: description,
    tutorialEntries: items,
    conditions: StorageConditionsModel(
        privilegeLevelRequired:
            PrivilegeLevelRequiredSimple.noPrivilegeRequiredSimple),
  );
}