Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
987fe723
Commit
987fe723
authored
May 10, 2016
by
Sanford Student
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding link clicked event and associated tests
parent
6eb2e184
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
84 additions
and
16 deletions
+84
-16
common/test/acceptance/tests/lms/test_lms_courseware.py
+18
-5
lms/envs/common.py
+2
-1
lms/static/js/courseware/courseware_factory.js
+17
-2
lms/static/js/fixtures/courseware/link_clicked_events.html
+3
-0
lms/static/js/spec/courseware/bookmark_button_view_spec.js
+0
-0
lms/static/js/spec/courseware/bookmarks_list_view_spec.js
+0
-0
lms/static/js/spec/courseware/course_home_events_spec.js
+3
-1
lms/static/js/spec/courseware/link_clicked_events_spec.js
+32
-0
lms/static/js/spec/courseware/updates_visibility_spec.js
+0
-0
lms/static/js/spec/main.js
+6
-4
lms/static/lms/js/build.js
+1
-1
lms/templates/courseware/courseware.html
+2
-2
No files found.
common/test/acceptance/tests/lms/test_lms_courseware.py
View file @
987fe723
...
...
@@ -507,15 +507,14 @@ class CoursewareMultipleVerticalsTest(UniqueCourseTest, EventsTestMixin):
sequence_ui_events
)
def
test_
accordion
_events
(
self
):
def
test_
outline_selected
_events
(
self
):
self
.
course_nav
.
go_to_section
(
'Test Section 1'
,
'Test Subsection 1,2'
)
self
.
course_nav
.
go_to_section
(
'Test Section 2'
,
'Test Subsection 2,1'
)
# test UI events emitted by navigating via the course outline
filter_outline_ui_event
=
lambda
event
:
event
.
get
(
'name'
,
''
)
==
'edx.ui.lms.outline.selected'
outline_ui_events
=
self
.
wait_for_events
(
event_filter
=
filter_outline_ui_event
,
timeout
=
2
)
filter_selected_events
=
lambda
event
:
event
.
get
(
'name'
,
''
)
==
'edx.ui.lms.outline.selected'
selected_events
=
self
.
wait_for_events
(
event_filter
=
filter_selected_events
,
timeout
=
2
)
# note: target_url is tested in unit tests, as the url changes here with every test (it includes GUIDs).
self
.
assert_events_match
(
...
...
@@ -534,12 +533,26 @@ class CoursewareMultipleVerticalsTest(UniqueCourseTest, EventsTestMixin):
'event'
:
{
'target_name'
:
'Test Subsection 2,1 '
,
'widget_placement'
:
'accordion'
,
}
},
],
outline_ui
_events
selected
_events
)
def
test_link_clicked_events
(
self
):
"""
Given that I am a user in the courseware
When I navigate via the left-hand nav
Then a link clicked event is logged
"""
self
.
course_nav
.
go_to_section
(
'Test Section 1'
,
'Test Subsection 1,2'
)
self
.
course_nav
.
go_to_section
(
'Test Section 2'
,
'Test Subsection 2,1'
)
filter_link_clicked
=
lambda
event
:
event
.
get
(
'name'
,
''
)
==
'edx.ui.lms.link_clicked'
link_clicked_events
=
self
.
wait_for_events
(
event_filter
=
filter_link_clicked
,
timeout
=
2
)
self
.
assertEqual
(
len
(
link_clicked_events
),
2
)
def
assert_navigation_state
(
self
,
section_title
,
subsection_title
,
subsection_position
,
next_enabled
,
prev_enabled
):
...
...
lms/envs/common.py
View file @
987fe723
...
...
@@ -1672,10 +1672,11 @@ REQUIRE_JS_PATH_OVERRIDES = {
'jquery.url'
:
'js/vendor/url.min.js'
,
'js/courseware/course_home_events'
:
'js/courseware/course_home_events.js'
,
'js/courseware/accordion_events'
:
'js/courseware/accordion_events.js'
,
'js/courseware/link_clicked_events'
:
'js/courseware/link_clicked_events.js'
,
'js/courseware/toggle_element_visibility'
:
'js/courseware/toggle_element_visibility.js'
,
'js/student_account/logistration_factory'
:
'js/student_account/logistration_factory.js'
,
'js/student_profile/views/learner_profile_factory'
:
'js/student_profile/views/learner_profile_factory.js'
,
'js/
bookmarks/bookmarks_factory'
:
'js/bookmarks/bookmarks
_factory.js'
,
'js/
courseware/courseware_factory'
:
'js/courseware/courseware
_factory.js'
,
'js/groups/views/cohorts_dashboard_factory'
:
'js/groups/views/cohorts_dashboard_factory.js'
,
'afontgarde'
:
'edx-pattern-library/js/afontgarde.js'
,
'edxicons'
:
'edx-pattern-library/js/edx-icons.js'
,
...
...
lms/static/js/
bookmarks/bookmarks
_factory.js
→
lms/static/js/
courseware/courseware
_factory.js
View file @
987fe723
;(
function
(
define
)
{
'use strict'
;
define
([
'jquery'
,
'logger'
,
'js/bookmarks/views/bookmarks_list_button'
],
function
(
BookmarksListButton
)
{
function
(
$
,
Logger
,
BookmarksListButton
)
{
return
function
()
{
return
new
BookmarksListButton
();
// This function performs all actions common to all courseware.
// 1. adding an event to all link clicks.
$
(
'a:not([href^="#"])'
).
click
(
function
(
event
)
{
Logger
.
log
(
"edx.ui.lms.link_clicked"
,
{
current_url
:
window
.
location
.
href
,
target_url
:
event
.
currentTarget
.
href
});
});
// 2. instantiating this button attaches events to all buttons in the courseware.
new
BookmarksListButton
();
// jshint ignore:line
};
}
);
...
...
lms/static/js/fixtures/courseware/link_clicked_events.html
0 → 100644
View file @
987fe723
<a
class=
"external-link"
href=
"http://example.com/"
/>
<a
class=
"internal-link"
href=
"/some/internal/link"
/>
<a
class=
"page-nav"
href=
"#some-page-section"
/>
lms/static/js/spec/
bookmarks
/bookmark_button_view_spec.js
→
lms/static/js/spec/
courseware
/bookmark_button_view_spec.js
View file @
987fe723
File moved
lms/static/js/spec/
bookmarks
/bookmarks_list_view_spec.js
→
lms/static/js/spec/
courseware
/bookmarks_list_view_spec.js
View file @
987fe723
File moved
lms/static/js/spec/courseware/course_home_events.js
→
lms/static/js/spec/courseware/course_home_events
_spec
.js
View file @
987fe723
...
...
@@ -11,7 +11,9 @@ define(['jquery', 'logger', 'js/courseware/course_home_events'], function ($, Lo
it
(
'sends an event when "Resume Course" is clicked'
,
function
()
{
$
(
'.last-accessed-link'
).
click
();
expect
(
Logger
.
log
).
toHaveBeenCalledWith
(
'edx.course.home.resume_course.clicked'
,
{
url
:
"/courses/course-v1:edX+DemoX+Demo_Course/courseware/19a30717eff543078a5d94ae9d6c18a5/"
url
:
"http://"
+
window
.
location
.
host
+
"/courses/course-v1:edX+DemoX+Demo_Course/courseware/19a30717eff543078a5d94ae9d6c18a5/"
});
});
...
...
lms/static/js/spec/courseware/link_clicked_events_spec.js
0 → 100644
View file @
987fe723
define
([
'jquery'
,
'logger'
,
'js/courseware/courseware_factory'
],
function
(
$
,
Logger
,
coursewareFactory
)
{
'use strict'
;
describe
(
'Courseware link click eventing'
,
function
()
{
beforeEach
(
function
()
{
loadFixtures
(
'js/fixtures/courseware/link_clicked_events.html'
);
coursewareFactory
();
spyOn
(
Logger
,
'log'
);
});
it
(
'sends an event when an external link is clicked'
,
function
()
{
$
(
'.external-link'
).
click
();
expect
(
Logger
.
log
).
toHaveBeenCalledWith
(
'edx.ui.lms.link_clicked'
,
{
target_url
:
"http://example.com/"
,
current_url
:
"http://"
+
window
.
location
.
host
+
"/context.html"
});
});
it
(
'sends an event when an internal link is clicked'
,
function
()
{
$
(
'.internal-link'
).
click
();
expect
(
Logger
.
log
).
toHaveBeenCalledWith
(
'edx.ui.lms.link_clicked'
,
{
target_url
:
"http://"
+
window
.
location
.
host
+
"/some/internal/link"
,
current_url
:
"http://"
+
window
.
location
.
host
+
"/context.html"
});
});
it
(
'does not send an event when a page navigation link is clicked'
,
function
()
{
$
(
'.page-nav'
).
click
();
expect
(
Logger
.
log
).
not
.
toHaveBeenCalledWith
(
'edx.ui.lms.link_clicked'
);
});
});
});
lms/static/js/spec/courseware/updates_visibility.js
→
lms/static/js/spec/courseware/updates_visibility
_spec
.js
View file @
987fe723
File moved
lms/static/js/spec/main.js
View file @
987fe723
...
...
@@ -92,7 +92,7 @@
// Discussion classes loaded explicitly until they are converted to use RequireJS
'DiscussionModuleView'
:
'xmodule_js/common_static/coffee/src/discussion/discussion_module_view'
,
'js/bookmarks/collections/bookmarks'
:
'js/bookmarks/collections/bookmarks'
,
'js/bookmarks/models/bookmark'
:
'js/bookmarks/models/bookmark'
,
'js/bookmarks/views/bookmarks_list_button'
:
'js/bookmarks/views/bookmarks_list_button'
,
...
...
@@ -655,13 +655,15 @@
var
testFiles
=
[
'js/spec/api_admin/catalog_preview_spec.js'
,
'js/spec/
bookmarks
/bookmark_button_view_spec.js'
,
'js/spec/
bookmarks
/bookmarks_list_view_spec.js'
,
'js/spec/
courseware
/bookmark_button_view_spec.js'
,
'js/spec/
courseware
/bookmarks_list_view_spec.js'
,
'js/spec/ccx/schedule_spec.js'
,
'js/spec/commerce/receipt_view_spec.js'
,
'js/spec/components/card/card_spec.js'
,
'js/spec/components/header/header_spec.js'
,
'js/spec/courseware/updates_visibility.js'
,
'js/spec/courseware/course_home_events_spec.js'
,
'js/spec/courseware/link_clicked_events_spec.js'
,
'js/spec/courseware/updates_visibility_spec.js'
,
'js/spec/dashboard/donation.js'
,
'js/spec/dashboard/dropdown_spec.js'
,
'js/spec/dashboard/track_events_spec.js'
,
...
...
lms/static/lms/js/build.js
View file @
987fe723
...
...
@@ -34,7 +34,7 @@
'teams/js/teams_tab_factory'
,
'support/js/certificates_factory'
,
'support/js/enrollment_factory'
,
'js/
bookmarks/bookmarks
_factory'
,
'js/
courseware/courseware
_factory'
,
'js/learner_dashboard/program_details_factory'
,
'js/learner_dashboard/program_list_factory'
,
'js/api_admin/catalog_preview_factory'
...
...
lms/templates/courseware/courseware.html
View file @
987fe723
...
...
@@ -80,8 +80,8 @@ ${static.get_page_title_breadcrumbs(course_name())}
</
%
static:require
_module
>
% endif
<
%
static:require_module
module_name=
"js/
bookmarks/bookmarks_factory"
class_name=
"Bookmarks
Factory"
>
Bookmarks
Factory();
<
%
static:require_module
module_name=
"js/
courseware/courseware_factory"
class_name=
"Courseware
Factory"
>
Courseware
Factory();
</
%
static:require
_module
>
<
%
include
file=
"../discussion/_js_body_dependencies.html"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment