Skip to content

Commit 0c5be78

Browse files
committed
structure xapi export with --lia-subfolder
1 parent e851c01 commit 0c5be78

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

dist/index.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/export/xapi.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,24 @@ export interface XapiExportArguments {
120120
'xapi-zip'?: boolean
121121
'xapi-mastery-threshold'?: number
122122
'xapi-progress-threshold'?: number
123+
'lia-subfolder'?: boolean
123124
}
124125

125126
export async function exporter(argument: XapiExportArguments, json: any) {
126127
// make temp folder
127128
let tmp = await helper.tmpDir()
128129
const dirname = helper.dirname()
129130
let tmpPath = path.join(tmp, 'pro')
131+
const contentPath = argument['lia-subfolder']
132+
? path.join(tmpPath, 'content')
133+
: tmpPath
130134

131-
// copy assets to temp
135+
// copy assets to temp (always to root)
132136
await fs.copy(path.join(dirname, './assets/xapi'), tmpPath)
133137
await fs.copy(path.join(dirname, './assets/common'), tmpPath)
134138

135-
// copy base path or readme-directory into temp
136-
await fs.copy(argument.path, tmpPath)
139+
// copy user course files into content/ (subfolder mode) or root
140+
await fs.copy(argument.path, contentPath)
137141

138142
// Read and modify index.html
139143
let index = fs.readFileSync(path.join(tmpPath, 'index.html'), 'utf8')
@@ -161,12 +165,16 @@ export async function exporter(argument: XapiExportArguments, json: any) {
161165
)
162166

163167
// Add default course
168+
const courseURL = argument['lia-subfolder']
169+
? 'content/' + path.basename(argument.readme)
170+
: path.basename(argument.readme)
171+
164172
index = helper.inject(
165173
`<script>
166174
if (!window.LIA) {
167175
window.LIA = {}
168176
}
169-
window.LIA.defaultCourseURL = "${path.basename(argument.readme)}"
177+
window.LIA.defaultCourseURL = "${courseURL}"
170178
</script>`,
171179
index,
172180
)

0 commit comments

Comments
 (0)