adapt-authoring-adaptframework 1.9.7 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -604,9 +604,7 @@ class AdaptFrameworkImport {
604
604
  const pluginsToInstall = []
605
605
  const pluginsToUpdate = []
606
606
 
607
- if (!this.settings.updatePlugins) {
608
- this.statusReport.warn.push({ code: 'MANAGED_PLUGIN_UPDATE_DISABLED' })
609
- }
607
+ let managedPluginUpdateBlocked = false
610
608
  Object.keys(this.usedContentPlugins).forEach(p => {
611
609
  const installedP = this.installedPlugins[p]
612
610
  let { version: importVersion } = this.usedContentPlugins[p]
@@ -628,6 +626,7 @@ class AdaptFrameworkImport {
628
626
  return
629
627
  }
630
628
  if (!this.settings.updatePlugins) {
629
+ if (!isLocalInstall && semver.gt(importVersion, installedVersion)) managedPluginUpdateBlocked = true
631
630
  return
632
631
  }
633
632
  if (semver.eq(importVersion, installedVersion)) {
@@ -641,6 +640,9 @@ class AdaptFrameworkImport {
641
640
  }
642
641
  pluginsToUpdate.push(p)
643
642
  })
643
+ if (managedPluginUpdateBlocked) {
644
+ this.statusReport.warn.push({ code: 'MANAGED_PLUGIN_UPDATE_DISABLED' })
645
+ }
644
646
  if (pluginsToInstall.length) {
645
647
  if (!this.settings.importPlugins) {
646
648
  if (this.settings.isDryRun) return this.statusReport.error.push({ code: 'MISSING_PLUGINS', data: pluginsToInstall })
@@ -687,19 +689,26 @@ class AdaptFrameworkImport {
687
689
  * @return {Promise}
688
690
  */
689
691
  async importCourseData () {
692
+ const stringifyError = e => {
693
+ return e?.data?.schemaName ? `${e.data.schemaName} ${e.data.data._id} ${e.data.errors}` : App.instance.lang.translate(undefined, e)
694
+ }
690
695
  /**
691
696
  * Note: the execution order is important here
692
697
  * - config requires course to exist
693
698
  * - Defaults cannot be applied until the config exists
694
699
  * - Everything else requires course + config to exist
695
700
  */
696
- const course = await this.importContentObject({ ...this.contentJson.course, tags: this.tags })
697
- /* config */ await this.importContentObject(this.contentJson.config)
698
- // we need to run an update with the same data to make sure all extension schema settings are applied
699
- await this.importContentObject({ ...this.contentJson.course, _id: course._id }, { isUpdate: true })
700
-
701
+ try {
702
+ const course = await this.importContentObject({ ...this.contentJson.course, tags: this.tags })
703
+ /* config */ await this.importContentObject(this.contentJson.config)
704
+ // we need to run an update with the same data to make sure all extension schema settings are applied
705
+ await this.importContentObject({ ...this.contentJson.course, _id: course._id }, { isUpdate: true })
706
+ } catch (e) {
707
+ throw App.instance.errors.FW_IMPORT_CONTENT_FAILED.setData({ errors: stringifyError(e) })
708
+ }
701
709
  const { sorted, hierarchy } = await this.getSortedData()
702
710
  const errors = []
711
+
703
712
  for (const ids of sorted) {
704
713
  for (const _id of ids) {
705
714
  try {
@@ -709,10 +718,7 @@ class AdaptFrameworkImport {
709
718
  ...itemJson // note that JSON sort order will override the deduced one
710
719
  })
711
720
  } catch (e) {
712
- errors.push(e?.data?.schemaName
713
- ? `${e.data.schemaName} ${_id} ${e.data.errors}`
714
- : App.instance.lang.translate(undefined, e)
715
- )
721
+ errors.push(stringifyError(e))
716
722
  }
717
723
  }
718
724
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-adaptframework",
3
- "version": "1.9.7",
3
+ "version": "1.9.9",
4
4
  "description": "Adapt framework integration for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-adaptframework",
6
6
  "license": "GPL-3.0",