-
Notifications
You must be signed in to change notification settings - Fork 292
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
Populate new courses so that they can be previewed #1683
Conversation
@@ -0,0 +1,24 @@ | |||
// LICENCE https://github.com/adaptlearning/adapt_authoring/blob/master/LICENSE |
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.
I don't think this file will be necessary after the refactor PR
Block layoutOptions are not populated. Not sure if that matters? Otherwise looks good. |
I wondered about that to. It didn't seem to do any harm when I took them out, so I left them out. Am happy to put them back in if that's the standard thing though |
I have added the block layout options to be on the safe side. (I'm off next week so I don't want things waiting on me) |
componentModel.save({ | ||
_courseId: model.get('_id'), | ||
_parentId: blockModel.get('_id'), | ||
body: 'This is a text component', |
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.
It would ne nice if we can make this localizable ... or maybe use "Lorem ipsum ..." instead.
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.
+1, think that's a good idea @lc-thomasberger
027a298
to
4c76ce2
Compare
Just noticed that various colorPicker assets have changed permissions, was this intentional? |
No im not sure how that even happened must have been during the rebase. |
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.
All works well :)
Could we maybe remove the nesting in the main function for readability? Something like:
populateNewCourse: function(model, response, options) {
this.createGenericPage(model);
},
createGenericPage: function(courseModel) {
var contentObjectModel = new ContentObjectModel({
title: Origin.l10n.t('app.placeholdernewpage'),
displayTitle: Origin.l10n.t('app.placeholdernewpage'),
_type: 'page',
_courseId: courseModel.get('_id'),
_parentId: courseModel.get('_id')
});
contentObjectModel.save(null, {
error: _.bind(this.onSaveError, this),
success: _.bind(this.createGenericArticle, this)
});
},
createGenericArticle: function(pageModel) {
var articleModel = new ArticleModel({
_courseId: pageModel.get('_courseId'),
_parentId: pageModel.get('_id'),
_type: 'article'
});
articleModel.save(null, {
error: _.bind(this.onSaveError, this),
success: _.bind(this.createGenericBlock, this)
});
},
createGenericBlock: function(articleModel) {
var blockModel = new BlockModel({
_courseId: articleModel.get('_courseId'),
_parentId: articleModel.get('_id'),
_type: 'block',
layoutOptions: [
{ type: 'left', name: 'app.layoutleft', pasteZoneRenderOrder: 2 },
{ type: 'full', name: 'app.layoutfull', pasteZoneRenderOrder: 1 },
{ type: 'right', name: 'app.layoutright', pasteZoneRenderOrder: 3 }
]
});
blockModel.save(null, {
error: _.bind(this.onSaveError, this),
success: _.bind(this.createGenericComponent, this)
});
},
createGenericComponent: function(blockModel) {
// Store the component types
var componentTypes = new EditorCollection(null, {
model: ComponentTypeModel,
url: '/api/componenttype',
_type: 'componentTypes'
});
componentTypes.fetch({
error: _.bind(this.onSaveError, this),
success: _.bind(function() {
var componentModel = new ComponentModel({
_courseId: blockModel.get('_courseId'),
_parentId: blockModel.get('_id'),
body: Origin.l10n.t('app.projectcontentbody'),
_type: 'component',
_component: 'text',
_componentType: componentTypes.findWhere({ component: 'text' }).attributes._id,
_layout: 'full'
});
componentModel.save(null, {
error: _.bind(this.onSaveError, this),
success: function() {
Origin.router.navigateTo('/editor/' + componentModel.get('_courseId') + '/menu');
}
});
}, this)
});
}
I have made changes on the pr since i reviewed it initially
@taylortom I've refactored as per your suggestion (thanks for the code!). We have removed those colourPicker asset changes - sorry we didn't notice those as they didn't show on bitbucket. |
ae34331
to
4f4cdae
Compare
var contentObjectModel = new ProjectContentObjectModel(); | ||
contentObjectModel.save({ | ||
title: 'Page Title', | ||
displayTitle: 'Page Title', |
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.
Localizable Strings would be nice.
Fixes #1678
When you create a course the new course contains a page, article, block and text component. This means that the course can be previewed immediately.
I've put some text in the text component for now which I don't think will be final. We discussed some sort of welcome text in the stand up but didn't specify what it would be. Do we want just a straightforward 'This is an adapt course' type message or something a little more detailed that explains ABC?