diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index ca7aec3ecf..3025e1cfdb 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -253,6 +253,7 @@ def _section_membership(course_key, access): 'modify_access_url': reverse('modify_access', kwargs={'course_id': course_key.to_deprecated_string()}), 'list_forum_members_url': reverse('list_forum_members', kwargs={'course_id': course_key.to_deprecated_string()}), 'update_forum_role_membership_url': reverse('update_forum_role_membership', kwargs={'course_id': course_key.to_deprecated_string()}), + 'cohorts_ajax_url': reverse('cohorts', kwargs={'course_key_string': course_key.to_deprecated_string()}), } return section_data diff --git a/lms/static/js/collections/cohort.js b/lms/static/js/collections/cohort.js new file mode 100644 index 0000000000..c4d83788b3 --- /dev/null +++ b/lms/static/js/collections/cohort.js @@ -0,0 +1,11 @@ +(function(Backbone) { + var CohortCollection = Backbone.Collection.extend({ + model : this.CohortModel, + comparator: "name", + + parse: function(response) { + return response.cohorts; + } + }); + this.CohortCollection = CohortCollection; +}).call(this, Backbone); diff --git a/lms/static/js/models/cohort.js b/lms/static/js/models/cohort.js new file mode 100644 index 0000000000..32d929027a --- /dev/null +++ b/lms/static/js/models/cohort.js @@ -0,0 +1,11 @@ +(function(Backbone) { + var CohortModel = Backbone.Model.extend({ + idAttribute: 'id', + defaults: { + name: '', + user_count: 0 + } + }); + + this.CohortModel = CohortModel; +}).call(this, Backbone); diff --git a/lms/static/js/spec/views/cohorts_spec.js b/lms/static/js/spec/views/cohorts_spec.js new file mode 100644 index 0000000000..d1bdc377a7 --- /dev/null +++ b/lms/static/js/spec/views/cohorts_spec.js @@ -0,0 +1,64 @@ +describe("Cohorts View", function() { + var createMockCohorts, createCohortsView, installTemplateFixture; + + createMockCohorts = function() { + return { + cohorts: [{ + id: 1, + name: 'Cat Lovers', + user_count: 123 + },{ + id: 2, + name: 'Dog Lovers', + user_count: 456 + }] + }; + }; + + createCohortsView = function() { + var cohorts, view; + cohorts = new CohortCollection(createMockCohorts(), {parse: true}); + view = new CohortsView({ + model: cohorts + }); + view.render(); + return view; + }; + + installTemplateFixture = function(templateName, templateDirectory) { + var templateFixture = readFixtures(templateDirectory + templateName + '.underscore'); + appendSetFixtures($(' + - @@ -50,6 +50,21 @@ <%static:js group='module-descriptor-js'/> <%static:js group='instructor_dash'/> + + ## Backbone classes declared explicitly until RequireJS is supported + + + + +%block> + +## Include Underscore templates +<%block name="header_extras"> +% for template_name in ["cohorts", "cohort-editor"]: + +% endfor %block> ## NOTE that instructor is set as the active page so that the instructor button lights up, even though this is the instructor_2 page. diff --git a/lms/templates/instructor/instructor_dashboard_2/membership.html b/lms/templates/instructor/instructor_dashboard_2/membership.html index 03aff4a163..13ffd499d2 100644 --- a/lms/templates/instructor/instructor_dashboard_2/membership.html +++ b/lms/templates/instructor/instructor_dashboard_2/membership.html @@ -26,7 +26,6 @@ -
@@ -112,9 +111,8 @@