-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Edit section and subsection at course outline page. #4425
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,52 @@ | ||
| define(["backbone", "underscore", "js/utils/module"], function(Backbone, _, ModuleUtils) { | ||
| define( | ||
| ['backbone', 'underscore', 'underscore.string', 'js/utils/module'], | ||
| function(Backbone, _, str, ModuleUtils) { | ||
| 'use strict'; | ||
| var XBlockInfo = Backbone.Model.extend({ | ||
|
|
||
| urlRoot: ModuleUtils.urlRoot, | ||
|
|
||
| // NOTE: 'publish' is not an attribute on XBlockInfo, but it is used to signal the publish | ||
| // and discard changes actions. Therefore 'publish' cannot be introduced as an attribute. | ||
| defaults: { | ||
| "id": null, | ||
| "display_name": null, | ||
| "category": null, | ||
| "data": null, | ||
| "metadata" : null, | ||
| 'id': null, | ||
| 'display_name': null, | ||
| 'category': null, | ||
| 'data': null, | ||
| 'metadata' : null, | ||
| /** | ||
| * The Studio URL for this xblock, or null if it doesn't have one. | ||
| */ | ||
| "studio_url": null, | ||
| 'studio_url': null, | ||
| /** | ||
| * An optional object with information about the children as well as about | ||
| * the primary xblock type that is supported as a child. | ||
| */ | ||
| "child_info": null, | ||
| 'child_info': null, | ||
| /** | ||
| * An optional object with information about each of the ancestors. | ||
| */ | ||
| "ancestor_info": null, | ||
| 'ancestor_info': null, | ||
| /** | ||
| * Date of the last edit to this xblock or any of its descendants. | ||
| */ | ||
| "edited_on":null, | ||
| 'edited_on':null, | ||
| /** | ||
| * User who last edited the xblock or any of its descendants. | ||
| */ | ||
| "edited_by":null, | ||
| 'edited_by':null, | ||
| /** | ||
| * True iff a published version of the xblock exists. | ||
| */ | ||
| "published": null, | ||
| /** | ||
| * Date of the last publish of this xblock, or null if never published. | ||
| */ | ||
| "published_on": null, | ||
| 'published_on': null, | ||
| /** | ||
| * User who last published the xblock, or null if never published. | ||
| */ | ||
| "published_by": null, | ||
| 'published_by': null, | ||
| /** | ||
| * True if the xblock has changes. | ||
| * Note: this is not always provided as a performance optimization. It is only provided for | ||
|
|
@@ -58,23 +61,53 @@ define(["backbone", "underscore", "js/utils/module"], function(Backbone, _, Modu | |
| /** | ||
| * True iff the release date of the xblock is in the past. | ||
| */ | ||
| "released_to_students": null, | ||
| 'released_to_students': null, | ||
| /** | ||
| * If the xblock is published, the date on which it will be released to students. | ||
| * This can be null if the release date is unscheduled. | ||
| */ | ||
| "release_date": null, | ||
| 'release_date': null, | ||
| /** | ||
| * The xblock which is determining the release date. For instance, for a unit, | ||
| * this will either be the parent subsection or the grandparent section. | ||
| * This can be null if the release date is unscheduled. | ||
| */ | ||
| "release_date_from":null, | ||
| 'release_date_from':null, | ||
| /** | ||
| * True if this xblock is currently visible to students. This is computed server-side | ||
| * so that the logic isn't duplicated on the client. | ||
| */ | ||
| "currently_visible_to_students": null | ||
| 'currently_visible_to_students': null, | ||
| /** | ||
| * If xblock is graded, the date after which student assessment will be evaluated. | ||
| * It has same format as release date, for example: 'Jan 02, 2015 at 00:00 UTC'. | ||
| */ | ||
| 'due_date': null, | ||
| /** | ||
| * Grading policy for xblock. | ||
| */ | ||
| 'format': null, | ||
| /** | ||
| * List of course graders names. | ||
| */ | ||
| 'course_graders': null, | ||
| /** | ||
| * True if this xblock contributes to the final course grade. | ||
| */ | ||
| 'graded': null, | ||
| /** | ||
| * The same as `release_date` but as an ISO-formatted date string. | ||
| */ | ||
| 'start': null, | ||
| /** | ||
| * The same as `due_date` but as an ISO-formatted date string. | ||
| */ | ||
| 'due': null | ||
| }, | ||
|
|
||
| initialize: function () { | ||
| // Extend our Model by helper methods. | ||
| _.extend(this, this.getCategoryHelpers()); | ||
| }, | ||
|
|
||
| parse: function(response) { | ||
|
|
@@ -100,6 +133,31 @@ define(["backbone", "underscore", "js/utils/module"], function(Backbone, _, Modu | |
| hasChildren: function() { | ||
| var childInfo = this.get('child_info'); | ||
| return childInfo && childInfo.children.length > 0; | ||
| }, | ||
|
|
||
| /** | ||
| * Return a list of convenience methods to check affiliation to the category. | ||
| * @return {Array} | ||
| */ | ||
| getCategoryHelpers: function () { | ||
| var categories = ['course', 'chapter', 'sequential', 'vertical'], | ||
| helpers = {}; | ||
|
|
||
| _.each(categories, function (item) { | ||
|
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. Nice! @andy-armstrong, take a quick look. |
||
| helpers['is' + str.titleize(item)] = function () { | ||
| return this.get('category') === item; | ||
| }; | ||
| }, this); | ||
|
|
||
| return helpers; | ||
| }, | ||
|
|
||
| /** | ||
| * Check if we can edit current XBlock or not on Course Outline page. | ||
| * @return {Boolean} | ||
| */ | ||
| isEditableOnCourseOutline: function() { | ||
| return this.isSequential() || this.isChapter(); | ||
| } | ||
| }); | ||
| return XBlockInfo; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| define(['backbone', 'js/models/xblock_info'], | ||
| function(Backbone, XBlockInfo) { | ||
| describe('XblockInfo isEditableOnCourseOutline', function() { | ||
| it('works correct', function() { | ||
| expect(new XBlockInfo({'category': 'chapter'}).isEditableOnCourseOutline()).toBe(true); | ||
| expect(new XBlockInfo({'category': 'course'}).isEditableOnCourseOutline()).toBe(false); | ||
| expect(new XBlockInfo({'category': 'sequential'}).isEditableOnCourseOutline()).toBe(true); | ||
| expect(new XBlockInfo({'category': 'vertical'}).isEditableOnCourseOutline()).toBe(false); | ||
| }); | ||
| }); | ||
| } | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is the format of the date?
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.
Fixed: "What is the format of the date?"