-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract metadata for ims scorm cp #4258
base: unstable
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<template> | ||
|
||
<VList two-line class="pl-3"> | ||
<EditListItem | ||
:key="nodeId" | ||
v-model="selected" | ||
:nodeId="nodeId" | ||
@input="trackSelect" | ||
@removed="handleRemoved" | ||
/> | ||
<div v-if="getChildren !== undefined"> | ||
<EditListItems | ||
v-for="childId in getChildren" | ||
:key="childId" | ||
v-model="selected" | ||
:nodeId="childId" | ||
:nodes="nodes" | ||
:nodeIds="nodeIds" | ||
@input="trackSelect" | ||
@removed="handleRemoved" | ||
/> | ||
</div> | ||
</VList> | ||
|
||
</template> | ||
|
||
<script> | ||
|
||
import EditListItem from './EditListItem'; | ||
|
||
export default { | ||
name: 'EditListItems', | ||
components: { | ||
EditListItem, | ||
}, | ||
props: { | ||
value: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
nodeIds: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
nodeId: { | ||
type: String, | ||
require: true, | ||
default: null, | ||
}, | ||
nodes: { | ||
type: Object, | ||
default: () => {}, | ||
}, | ||
}, | ||
computed: { | ||
selected: { | ||
get() { | ||
return this.value; | ||
}, | ||
set(items) { | ||
this.$emit('input', items); | ||
}, | ||
}, | ||
getChildren() { | ||
const childrens = []; | ||
Object.keys(this.nodes).forEach(nodeId => { | ||
if (this.nodes[nodeId] === this.nodeId) { | ||
childrens.push(nodeId); | ||
} | ||
}); | ||
return childrens; | ||
}, | ||
}, | ||
methods: { | ||
handleRemoved(nodeId) { | ||
this.$emit('removed', nodeId); | ||
}, | ||
trackSelect(value) { | ||
this.$emit('input', value); | ||
}, | ||
}, | ||
}; | ||
|
||
</script> | ||
|
||
<style lang="less" scoped> | ||
|
||
.v-divider { | ||
margin-top: 0; | ||
} | ||
|
||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,8 @@ | |
<EditList | ||
v-model="selected" | ||
:nodeIds="nodeIds" | ||
@input="enableValidation(nodeIds);" | ||
:parentId="nodeIds[0]" | ||
@input="enableValidation(nodeIds)" | ||
/> | ||
</div> | ||
</FileDropzone> | ||
|
@@ -190,13 +191,14 @@ | |
import ResizableNavigationDrawer from 'shared/views/ResizableNavigationDrawer'; | ||
import Uploader from 'shared/views/files/Uploader'; | ||
import LoadingText from 'shared/views/LoadingText'; | ||
import FormatPresets from 'shared/leUtils/FormatPresets'; | ||
import FormatPresets, { FormatPresetsList } from 'shared/leUtils/FormatPresets'; | ||
import OfflineText from 'shared/views/OfflineText'; | ||
import ToolBar from 'shared/views/ToolBar'; | ||
import BottomBar from 'shared/views/BottomBar'; | ||
import FileDropzone from 'shared/views/files/FileDropzone'; | ||
import { isNodeComplete } from 'shared/utils/validation'; | ||
import { DELAYED_VALIDATION } from 'shared/constants'; | ||
import { DELAYED_VALIDATION, fileErrors } from 'shared/constants'; | ||
import { File } from 'shared/data/resources'; | ||
|
||
const CHECK_STORAGE_INTERVAL = 10000; | ||
|
||
|
@@ -453,7 +455,7 @@ | |
}, | ||
|
||
/* Creation actions */ | ||
createNode(kind, payload = {}) { | ||
createNode(kind, payload = {}, parent = this.$route.params.nodeId) { | ||
this.enableValidation(this.nodeIds); | ||
// Default learning activity on upload | ||
if ( | ||
|
@@ -466,7 +468,7 @@ | |
} | ||
return this.createContentNode({ | ||
kind, | ||
parent: this.$route.params.nodeId, | ||
parent: parent, | ||
channel_id: this.currentChannel.id, | ||
...payload, | ||
}).then(newNodeId => { | ||
|
@@ -498,18 +500,68 @@ | |
.slice(0, -1) | ||
.join('.'); | ||
} | ||
this.createNode( | ||
FormatPresets.has(file.preset) && FormatPresets.get(file.preset).kind_id, | ||
{ title, ...file.metadata } | ||
).then(newNodeId => { | ||
if (index === 0) { | ||
this.selected = [newNodeId]; | ||
} | ||
this.updateFile({ | ||
...file, | ||
contentnode: newNodeId, | ||
if (file.metadata.folders === undefined) { | ||
this.createNode( | ||
FormatPresets.has(file.preset) && FormatPresets.get(file.preset).kind_id, | ||
{ title, ...file.metadata } | ||
).then(newNodeId => { | ||
if (index === 0) { | ||
this.selected = [newNodeId]; | ||
} | ||
this.updateFile({ | ||
...file, | ||
contentnode: newNodeId, | ||
}); | ||
}); | ||
}); | ||
} else if (file.metadata.folders) { | ||
this.createNode('topic', file.metadata).then(newNodeId => { | ||
file.metadata.folders.forEach(org => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update |
||
this.createNode('topic', org, newNodeId).then(topicNodeId => { | ||
org.files.forEach(orgFile => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const extra_fields = {}; | ||
extra_fields['options'] = { entry: orgFile.resourceHref }; | ||
extra_fields['title'] = orgFile.title; | ||
let file_kind = null; | ||
FormatPresetsList.forEach(p => { | ||
if (p.id === file.metadata.preset) { | ||
file_kind = p.kind_id; | ||
} | ||
}); | ||
|
||
this.createNode(file_kind, extra_fields, topicNodeId).then(resourceNodeId => { | ||
return File.uploadUrl({ | ||
checksum: file.checksum, | ||
size: file.file_size, | ||
type: 'application/zip', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's double check if we need to specify this explicitly, or if it should be inferred by existing functionality. |
||
name: file.original_filename, | ||
file_format: file.file_format, | ||
preset: file.metadata.preset, | ||
}).then(data => { | ||
const fileObject = { | ||
...data.file, | ||
loaded: 0, | ||
total: file.size, | ||
}; | ||
if (index === 0) { | ||
this.selected = [resourceNodeId]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change this to set |
||
} | ||
this.updateFile({ | ||
...fileObject, | ||
contentnode: resourceNodeId, | ||
}).catch(error => { | ||
let errorType = fileErrors.UPLOAD_FAILED; | ||
if (error.response && error.response.status === 412) { | ||
errorType = fileErrors.NO_STORAGE; | ||
} | ||
return Promise.reject(errorType); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
}); | ||
}, | ||
updateTitleForPage() { | ||
|
@@ -582,4 +634,4 @@ | |
margin-top: -4px !important; | ||
} | ||
|
||
</style> | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should change this to a length check on the array!