From 9e366fe202a6cb17614ff770fcbdff62b8da983f Mon Sep 17 00:00:00 2001 From: Andy Armstrong Date: Thu, 4 Sep 2014 09:39:34 -0400 Subject: [PATCH] Show cohorts on the new instructor dashboard TNL-161 Remove placeholder text --- .../instructor/views/instructor_dashboard.py | 1 + lms/static/js/collections/cohort.js | 11 ++++ lms/static/js/models/cohort.js | 11 ++++ lms/static/js/spec/views/cohorts_spec.js | 64 +++++++++++++++++++ lms/static/js/views/cohort_editor.js | 16 +++++ lms/static/js/views/cohorts.js | 35 ++++++++++ lms/static/js_test.yml | 9 ++- lms/static/templates | 1 + .../cohort-editor.underscore | 6 ++ .../instructor_dashboard_2/cohorts.underscore | 35 ++++++++++ .../instructor_dashboard_2.html | 17 ++++- .../instructor_dashboard_2/membership.html | 30 ++++++++- 12 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 lms/static/js/collections/cohort.js create mode 100644 lms/static/js/models/cohort.js create mode 100644 lms/static/js/spec/views/cohorts_spec.js create mode 100644 lms/static/js/views/cohort_editor.js create mode 100644 lms/static/js/views/cohorts.js create mode 120000 lms/static/templates create mode 100644 lms/templates/instructor/instructor_dashboard_2/cohort-editor.underscore create mode 100644 lms/templates/instructor/instructor_dashboard_2/cohorts.underscore 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 + + + + + + +## Include Underscore templates +<%block name="header_extras"> +% for template_name in ["cohorts", "cohort-editor"]: + +% endfor ## 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 @@ -

${_("Batch Enrollment")}

@@ -112,9 +111,8 @@

%endif -
-
+
## Translators: an "Administration List" is a list, such as Course Staff, that users can be added to.

${_("Administration List Management")}

@@ -216,3 +214,29 @@ %endif
+ +%if course.is_cohorted: +
+
+
+% endif + +<%block name="headextra"> + +