Commit 241c9bb1 by Don Mitchell

Checkpoint to rebase

parent a9233dfd
CMS.Models.Location = Backbone.Models.extend({
defaults: {
tag: "",
name: "",
course: "",
category: "",
name: ""
},
toUrl: function(overrides) {
return
(overrides['tag'] ? overrides['tag'] : this.get('tag')) + "://" +
(overrides['name'] ? overrides['name'] : this.get('name')) + "/" +
(overrides['course'] ? overrides['course'] : this.get('course')) + "/" +
(overrides['category'] ? overrides['category'] : this.get('category')) + "/" +
(overrides['name'] ? overrides['name'] : this.get('name')) + "/";
},
_tagPattern = /[^:]+/g,
_fieldPattern = new RegExp('[^/]+','g'),
parse: function(payload) {
if (payload instanceof Array) {
return {
tag: payload[0],
name: payload[1],
course: payload[2],
category: payload[3],
name: payload[4]
}
}
else if (payload instanceof String) {
var foundTag = this._tagPattern.exec(payload);
if (foundTag) {
this._fieldPattern.lastIndex = this._tagPattern.lastIndex;
return {
tag: foundTag,
name: this._fieldPattern.exec(payload),
course: this._fieldPattern.exec(payload),
category: this._fieldPattern.exec(payload),
name: this._fieldPattern.exec(payload)
}
}
else return null;
}
else {
return payload;
}
}
});
CMS.Models.CourseRelative = Backbone.Models.extend({
defaults: {
course_location : null, // must never be null, but here to doc the field
idx : null // the index making it unique in the containing collection (no implied sort)
}
});
CMS.Models.CourseRelativeCollection = Backbone.Collections.extend({
model : CourseRelative
});
\ No newline at end of file
CMS.Models.Settings.CourseDetails = Backbone.Models.extend({
defaults: {
location : null, # a Location model, required
start_date: null,
end_date: null,
milestones: null, # a CourseRelativeCollection
syllabus: null,
overview: "",
statement: "",
intro_video: null,
requirements: "",
effort: null, # an int or null
textbooks: null, # a CourseRelativeCollection
prereqs: null, # a CourseRelativeCollection
faqs: null # a CourseRelativeCollection
},
// When init'g from html script, ensure you pass {parse: true} as an option (2nd arg to reset)
parse: function(attributes) {
if (attributes['location']) {
attributes.location = new CMS.Models.Location(attributes.location);
};
if (attributes['milestones']) {
attributes.milestones = new CMS.Models.CourseRelativeCollection(attributes.milestones);
};
if (attributes['textbooks']) {
attributes.textbooks = new CMS.Models.CourseRelativeCollection(attributes.textbooks);
};
if (attributes['prereqs']) {
attributes.prereqs = new CMS.Models.CourseRelativeCollection(attributes.prereqs);
};
if (attributes['faqs']) {
attributes.faqs = new CMS.Models.CourseRelativeCollection(attributes.faqs);
};
},
urlRoot: function() {
// TODO impl
}
});
CMS.Models.Settings.CourseSettings = Backbone.Model.extend({
// a container for the models representing the n possible tabbed states
defaults: {
courseLocation: null,
// NOTE: keep these sync'd w/ the data-section names in settings-page-menu
details: null,
faculty: null,
grading: null,
problems: null,
discussions: null
}
// write getters which get the relevant sub model from the server if not already loaded
})
\ No newline at end of file
CMS.Views.Settings.Main = Backbone.View.extend({
// Model class is CMS.Models.Settings.CourseSettings
// allow navigation between the tabs
events: {
'click .settings-page-menu a': "showSettingsTab"
},
initialize: function() {
// load templates
},
render: function() {
// create any necessary subviews and put them onto the page
},
currentTab: null,
showSettingsTab: function(e) {
this.currentTab = $(e.target).attr('data-section');
$('.settings-page-section > section').hide();
$('.settings-' + this.currentTab).show();
$('.settings-page-menu .is-shown').removeClass('is-shown');
$(e.target).addClass('is-shown');
// fetch model for the tab if not loaded already
if (!this.model.has(this.currentTab)) {
// TODO disable screen until fetch completes?
this.model.retrieve(this.currentTab, function() { this.render(); });
}
}
})
\ No newline at end of file
class CourseRelativeMember:
def __init__(self, location, idx):
self.course_location = location # a Location obj
self.idx = idx # which milestone this represents. Hopefully persisted # so we don't have race conditions
### ??? If 2+ courses use the same textbook or other asset, should they point to the same db record?
class linked_asset(CourseRelativeMember):
"""
Something uploaded to our asset lib which has a name/label and location. Here it's tracked by course and index, but
we could replace the label/url w/ a pointer to a real asset and keep the join info here.
"""
def __init__(self, location, idx):
CourseRelativeMember.__init__(self, location, idx)
self.label = ""
self.url = None
class summary_detail_pair(CourseRelativeMember):
"""
A short text with an arbitrary html descriptor used for paired label - details elements.
"""
def __init__(self, location, idx):
CourseRelativeMember.__init__(self, location, idx)
self.summary = ""
self.detail = ""
\ No newline at end of file
from common.djangoapps.models.course_relative import CourseRelativeMember
### A basic question is whether to break the details into schedule, intro, requirements, and misc sub objects
class CourseDetails:
def __init__(self, location):
self.course_location = location # a Location obj
self.start_date = None
self.end_date = None
self.milestones = []
self.syllabus = None # a pdf file asset
self.overview = "" # html to render as the overview
self.statement = ""
self.intro_video = None # a video pointer
self.requirements = "" # html
self.effort = None # int hours/week
self.textbooks = [] # linked_asset
self.prereqs = [] # linked_asset
self.faqs = [] # summary_detail_pair
@classmethod
def fetch(cls, course_location):
"""
Fetch the course details for the given course from persistence and return a CourseDetails model.
"""
course = cls(course_location)
# TODO implement
return course
class CourseMilestone(CourseRelativeMember):
def __init__(self, location, idx):
CourseRelativeMember.__init__(self, location, idx)
self.date = None
self.description = ""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment