adapt-authoring-adaptframework 1.9.7 → 1.9.8
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.
- package/lib/AdaptFrameworkImport.js +13 -9
- package/package.json +1 -1
|
@@ -687,19 +687,26 @@ class AdaptFrameworkImport {
|
|
|
687
687
|
* @return {Promise}
|
|
688
688
|
*/
|
|
689
689
|
async importCourseData () {
|
|
690
|
+
const stringifyError = e => {
|
|
691
|
+
return e?.data?.schemaName ? `${e.data.schemaName} ${e.data.data._id} ${e.data.errors}` : App.instance.lang.translate(undefined, e)
|
|
692
|
+
}
|
|
690
693
|
/**
|
|
691
694
|
* Note: the execution order is important here
|
|
692
695
|
* - config requires course to exist
|
|
693
696
|
* - Defaults cannot be applied until the config exists
|
|
694
697
|
* - Everything else requires course + config to exist
|
|
695
698
|
*/
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
699
|
+
try {
|
|
700
|
+
const course = await this.importContentObject({ ...this.contentJson.course, tags: this.tags })
|
|
701
|
+
/* config */ await this.importContentObject(this.contentJson.config)
|
|
702
|
+
// we need to run an update with the same data to make sure all extension schema settings are applied
|
|
703
|
+
await this.importContentObject({ ...this.contentJson.course, _id: course._id }, { isUpdate: true })
|
|
704
|
+
} catch (e) {
|
|
705
|
+
throw App.instance.errors.FW_IMPORT_CONTENT_FAILED.setData({ errors: stringifyError(e) })
|
|
706
|
+
}
|
|
701
707
|
const { sorted, hierarchy } = await this.getSortedData()
|
|
702
708
|
const errors = []
|
|
709
|
+
|
|
703
710
|
for (const ids of sorted) {
|
|
704
711
|
for (const _id of ids) {
|
|
705
712
|
try {
|
|
@@ -709,10 +716,7 @@ class AdaptFrameworkImport {
|
|
|
709
716
|
...itemJson // note that JSON sort order will override the deduced one
|
|
710
717
|
})
|
|
711
718
|
} catch (e) {
|
|
712
|
-
errors.push(e
|
|
713
|
-
? `${e.data.schemaName} ${_id} ${e.data.errors}`
|
|
714
|
-
: App.instance.lang.translate(undefined, e)
|
|
715
|
-
)
|
|
719
|
+
errors.push(stringifyError(e))
|
|
716
720
|
}
|
|
717
721
|
}
|
|
718
722
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-adaptframework",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.8",
|
|
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",
|