Adding BI event for clicking to learn more about pathways + minor fixes on the page

This commit is contained in:
Dillon Dumesnil
2018-08-17 15:26:53 -04:00
parent f022e98971
commit ea48e7b885
3 changed files with 36 additions and 11 deletions

View File

@@ -11,6 +11,15 @@ import ProgramProgressView from './progress_circle_view';
import sidebarTpl from '../../../templates/learner_dashboard/program_details_sidebar.underscore';
class ProgramDetailsSidebarView extends Backbone.View {
constructor(options) {
const defaults = {
events: {
'click .sidebar-button': 'trackPathwayClicked',
},
};
super(Object.assign({}, defaults, options));
}
initialize(options) {
this.tpl = HtmlUtils.template(sidebarTpl);
this.courseModel = options.courseModel || {};
@@ -18,6 +27,7 @@ class ProgramDetailsSidebarView extends Backbone.View {
this.programCertificate = this.getProgramCertificate();
this.programRecordUrl = options.programRecordUrl;
this.creditPathways = options.creditPathways;
this.programModel = options.model;
this.render();
}
@@ -81,6 +91,18 @@ class ProgramDetailsSidebarView extends Backbone.View {
return type.replace(/\s+/g, '-');
}
trackPathwayClicked(event) {
var button = event.currentTarget;
window.analytics.track('edx.bi.dashboard.program.pathway.clicked', {
category: 'pathways',
// Credentials uses the uuid without dashes so we are converting here for consistency
program_uuid: this.programModel.attributes.uuid.replace(/-/g, ''),
program_name: this.programModel.attributes.title,
pathway_link_id: $(button).data('pathwayId'),
pathway_name: $(button).data('pathwayName'),
});
}
}
export default ProgramDetailsSidebarView;

View File

@@ -8,20 +8,19 @@
<% } %>
</aside>
<aside class="aside js-course-certificates"></aside>
<% if (programRecordUrl) { %>
<aside class="aside js-program-record program-record">
<h2 class="divider-heading"><%- gettext('Program Record') %></h2>
<div class="motivating-section">
<p class="motivating-message"><%- gettext('Once you complete one of the program requirements you have a program record. This record is marked complete once you meet all program requirements. A program record can be used to continue your learning journey and demonstrate your learning to others.') %></p>
</div>
<aside class="aside js-program-record program-record">
<h2 class="divider-heading"><%- gettext('Program Record') %></h2>
<div class="motivating-section">
<p class="motivating-message"><%- gettext('Once you complete one of the program requirements you have a program record. This record is marked complete once you meet all program requirements. A program record can be used to continue your learning journey and demonstrate your learning to others.') %></p>
</div>
<% if (programRecordUrl) { %>
<div class="sidebar-button-wrapper">
<a href="<%- programRecordUrl %>" class="program-record-link">
<button class="btn sidebar-button"><%- gettext('View Program Record') %></button>
</a>
</div>
</aside>
<% } %>
<% } %>
</aside>
<% if (creditPathways.length > 0) { %>
<aside class="aside js-program-pathways program-pathways">
<h2 class = "divider-heading"><%- gettext('Additional Learning Opportunities') %></h2>
@@ -38,7 +37,7 @@
<% if (pathway.destination_url) { %>
<div class="sidebar-button-wrapper">
<a href="<%- pathway.destination_url %>" class="pathway-link">
<button class="btn sidebar-button"><%- gettext('Learn More') %></button>
<button class="btn sidebar-button" data-pathway-id="<%- pathway.id %>" data-pathway-name="<%- pathway.name %>"><%- gettext('Learn More') %></button>
</a>
</div>
<% } %>

View File

@@ -13,12 +13,16 @@ def get_credentials_records_url(program_uuid=None):
"""
Returns a URL for a given records page (or general records list if given no UUID).
May return None if this feature is disabled.
Arguments:
program_uuid (str): Optional program uuid to link for a program records URL
"""
base_url = CredentialsApiConfig.current().public_records_url
if base_url is None:
return None
if program_uuid:
return base_url + 'programs/{}/'.format(program_uuid)
# Credentials expects the uuid without dashes so we are converting here
return base_url + 'programs/{}/'.format(program_uuid.replace('-', ''))
return base_url