adapt-authoring-adaptframework 1.8.0 → 1.8.2

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.
@@ -79,7 +79,7 @@ class AdaptFrameworkImport {
79
79
  constructor ({ importPath, userId, language, assetFolders, tags, isDryRun, importContent = true, importPlugins = true, migrateContent = true, updatePlugins = false, removeSource = true }) {
80
80
  const e = App.instance.errors.INVALID_PARAMS
81
81
  if (!importPath) throw e.setData({ params: ['importPath'] })
82
- if (!userId) throw e.INVALID_PARAMS.setData({ params: ['userId'] })
82
+ if (!userId) throw e.setData({ params: ['userId'] })
83
83
  /**
84
84
  * Reference to the package.json data
85
85
  * @type {Object}
@@ -109,7 +109,7 @@ class AdaptFrameworkImport {
109
109
  * List of tags to apply to the course
110
110
  * @type {Array<String>}
111
111
  */
112
- this.tags = tags
112
+ this.tags = tags ?? []
113
113
  /**
114
114
  * Path to the import course folder
115
115
  * @type {String}
@@ -307,7 +307,8 @@ class AdaptFrameworkImport {
307
307
  this.coursePath = courseDirs[0]
308
308
  try {
309
309
  await this.loadContentFile(`${this.coursePath}/config.json`)
310
- this.langPath = `${this.coursePath}/${this.language ?? this.contentJson.config._defaultLanguage}`
310
+ this.language = this.language ?? this.contentJson.config._defaultLanguage
311
+ this.langPath = `${this.coursePath}/${this.language}`
311
312
  await fs.readdir(this.langPath)
312
313
  } catch (e) {
313
314
  this.framework.log('error', e)
@@ -1,8 +1,6 @@
1
1
  import AdaptCli from 'adapt-cli'
2
2
  import { App } from 'adapt-authoring-core'
3
3
  import bytes from 'bytes'
4
- import FrameworkBuild from './AdaptFrameworkBuild.js'
5
- import FrameworkImport from './AdaptFrameworkImport.js'
6
4
  import fs from 'fs/promises'
7
5
  /* eslint-disable import/no-named-default */import { default as fsSync } from 'fs'
8
6
  import path from 'upath'
@@ -239,15 +237,15 @@ class AdaptFrameworkUtils {
239
237
  * @return {Promise}
240
238
  */
241
239
  static async postHandler (req, res, next) {
242
- const startTime = Date.now()
243
240
  const framework = await App.instance.waitForModule('adaptframework')
241
+ const startTime = Date.now()
244
242
  const action = AdaptFrameworkUtils.inferBuildAction(req)
245
243
  const courseId = req.params.id
246
244
  const userId = req.auth.user._id.toString()
247
245
 
248
246
  AdaptFrameworkUtils.log('info', `running ${action} for course '${courseId}' initiated by ${userId}`)
249
247
  try {
250
- const { isPreview, buildData } = await FrameworkBuild.run({ action, courseId, userId })
248
+ const { isPreview, buildData } = await framework.buildCourse({ action, courseId, userId })
251
249
  const duration = Math.round((Date.now() - startTime) / 10) / 100
252
250
  AdaptFrameworkUtils.log('info', `finished ${action} for course '${courseId}' in ${duration} seconds`)
253
251
  const urlRoot = isPreview ? framework.rootRouter.url : framework.apiRouter.url
@@ -270,13 +268,14 @@ class AdaptFrameworkUtils {
270
268
  */
271
269
  static async importHandler (req, res, next) {
272
270
  try {
271
+ const framework = await App.instance.waitForModule('adaptframework')
273
272
  let importPath = req.body.importPath
274
273
  if (req.get('Content-Type').indexOf('multipart/form-data') === 0) {
275
274
  await AdaptFrameworkUtils.handleImportFile(req, res)
276
275
  const [course] = req.fileUpload.files.course
277
276
  importPath = course.filepath
278
277
  }
279
- const importer = await FrameworkImport.run({
278
+ const importer = await framework.importCourse({
280
279
  importPath,
281
280
  userId: req.auth.user._id.toString(),
282
281
  isDryRun: AdaptFrameworkUtils.toBoolean(req.body.dryRun),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-adaptframework",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
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",