forked from openedx-unsupported/edx-analytics-dashboard
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AN-6205
- Loading branch information
Showing
34 changed files
with
1,145 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 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 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,4 @@ | ||
apps directory | ||
============== | ||
|
||
This directory is for organizing static assets in a per-application basis. |
This file contains 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 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 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,46 @@ | ||
/** | ||
* Controller object for the learners application. Handles business | ||
* logic of showing different 'pages' of the application. | ||
* | ||
* Requires the following values in the options hash: | ||
* - learnerCollection: A `LearnerCollection` instance. | ||
* - rootView: A `LearnersRootView` instance. | ||
*/ | ||
define([ | ||
'backbone', | ||
'marionette', | ||
'learners/js/views/roster-view' | ||
], function (Backbone, Marionette, LearnerRosterView) { | ||
'use strict'; | ||
|
||
var LearnersController = Marionette.Object.extend({ | ||
initialize: function (options) { | ||
this.options = options || {}; | ||
}, | ||
|
||
showLearnerRosterPage: function () { | ||
this.options.rootView.showChildView('main', new LearnerRosterView({ | ||
collection: this.options.learnerCollection | ||
})); | ||
}, | ||
|
||
showLearnerDetailPage: function (username) { | ||
// TODO: we'll eventually have to fetch the learner either | ||
// from the cached collection, or from the server. See | ||
// https://openedx.atlassian.net/browse/AN-6191 | ||
this.options.rootView.showChildView('main', new (Backbone.View.extend({ | ||
render: function () {this.$el.text(username); return this;} | ||
}))()); | ||
}, | ||
|
||
showNotFoundPage: function () { | ||
// TODO: Implement this page in https://openedx.atlassian.net/browse/AN-6697 | ||
var message = gettext("Sorry, we couldn't find the page you're looking for."); // jshint ignore:line | ||
this.options.rootView.showChildView('main', new (Backbone.View.extend({ | ||
render: function () {this.$el.text(message); return this;} | ||
}))()); | ||
} | ||
}); | ||
|
||
return LearnersController; | ||
}); |
File renamed without changes.
This file contains 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,14 @@ | ||
define(['marionette'], function (Marionette) { | ||
'use strict'; | ||
|
||
var LearnersRouter = Marionette.AppRouter.extend({ | ||
appRoutes: { | ||
// TODO: handle 'queryString' arguments in https://openedx.atlassian.net/browse/AN-6668 | ||
'(/)(?*queryString)': 'showLearnerRosterPage', | ||
':username(/)(?*queryString)': 'showLearnerDetailPage', | ||
'*notFound': 'showNotFoundPage' | ||
} | ||
}); | ||
|
||
return LearnersRouter; | ||
}); |
57 changes: 57 additions & 0 deletions
57
analytics_dashboard/static/apps/learners/js/spec/controller-spec.js
This file contains 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,57 @@ | ||
define([ | ||
'jquery', | ||
'learners/js/collections/learner-collection', | ||
'learners/js/controller', | ||
'marionette' | ||
], function ($, LearnerCollection, LearnersController, Marionette) { | ||
'use strict'; | ||
|
||
describe('LearnersController', function () { | ||
beforeEach(function () { | ||
var collection; | ||
setFixtures('<div class="root-view"><div class="main"></div></div>'); | ||
this.rootView = new (Marionette.LayoutView.extend({ | ||
regions: { | ||
main: '.main' | ||
} | ||
}))({el: '.root-view'}); | ||
// The learner roster view looks at the first learner in | ||
// the collection in order to render a last updated | ||
// message. | ||
collection = new LearnerCollection([ | ||
{ | ||
name: 'learner', | ||
username: 'learner', | ||
email: 'learner@example.com', | ||
account_url: 'example.com/learner', | ||
enrollment_mode: 'audit', | ||
enrollment_date: new Date(), | ||
cohort: null, | ||
segments: ['highly_engaged'], | ||
engagements: {}, | ||
last_updated: new Date(), | ||
course_id: 'test/course/id' | ||
} | ||
]); | ||
this.controller = new LearnersController({rootView: this.rootView, learnerCollection: collection}); | ||
}); | ||
|
||
it('should show the learner roster page', function () { | ||
this.controller.showLearnerRosterPage(); | ||
expect(this.rootView.$('.learner-roster')).toBeInDOM(); | ||
}); | ||
|
||
it('should show the learner detail page', function () { | ||
// The current learner detail page is a stub. The actual | ||
// page will be implemented in | ||
// https://openedx.atlassian.net/browse/AN-6191 | ||
this.controller.showLearnerDetailPage('example-username'); | ||
expect(this.rootView.$el.html()).toContainText('example-username'); | ||
}); | ||
|
||
it('should show the not found page', function () { | ||
this.controller.showNotFoundPage(); | ||
expect(this.rootView.$el.html()).toContainText('Sorry, we couldn\'t find the page you\'re looking for.'); | ||
}); | ||
}); | ||
}); |
This file contains 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
2 changes: 1 addition & 1 deletion
2
...tatic/js/test/specs/learner-model-spec.js → ...ps/learners/js/spec/learner-model-spec.js
This file contains 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
32 changes: 32 additions & 0 deletions
32
analytics_dashboard/static/apps/learners/js/spec/root-view-spec.js
This file contains 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,32 @@ | ||
define([ | ||
'jquery', | ||
'learners/js/views/root-view', | ||
'marionette' | ||
], function ($, LearnersRootView, Marionette) { | ||
'use strict'; | ||
|
||
describe('LearnersRootView', function () { | ||
beforeEach(function () { | ||
setFixtures('<div class=root-view-container></div>'); | ||
this.rootView = new LearnersRootView({el: '.root-view-container'}).render(); | ||
}); | ||
|
||
it('renders a main region', function () { | ||
this.rootView.showChildView('main', new (Backbone.View.extend({ | ||
render: function () { | ||
this.$el.html('example view'); | ||
} | ||
}))()); | ||
expect(this.rootView.$('.learners-main-region').html()).toContainText('example view'); | ||
}); | ||
|
||
it('renders and clears errors', function () { | ||
var childView = new Marionette.View(); | ||
this.rootView.showChildView('main', childView); | ||
childView.triggerMethod('appError', 'This is the error copy'); | ||
expect(this.rootView.$('.learners-error-region')).toHaveText('This is the error copy'); | ||
this.rootView.triggerMethod('clearError', 'This is the error copy'); | ||
expect(this.rootView.$('.learners-error-region')).not.toHaveText('This is the error copy'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.