Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock
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
OpenEdx
xblock
Commits
9f6b95b7
Commit
9f6b95b7
authored
Oct 13, 2015
by
Sean Lip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the exploration version to the data payload of each analytics event.
parent
cd5479ee
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
25 deletions
+49
-25
oppia/oppia.py
+5
-2
oppia/static/js/oppia.js
+13
-6
oppia/static/lib/oppia-player-0.0.1-modified.js
+31
-17
No files found.
oppia/oppia.py
View file @
9f6b95b7
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
import
pkg_resources
import
pkg_resources
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
Integer
,
String
from
xblock.fields
import
Scope
,
String
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
...
@@ -83,6 +83,7 @@ class OppiaXBlock(XBlock):
...
@@ -83,6 +83,7 @@ class OppiaXBlock(XBlock):
"""Called when an exploration has loaded."""
"""Called when an exploration has loaded."""
self
.
_log
(
self
.
_EVENT_NAME_EXPLORATION_LOADED
,
{
self
.
_log
(
self
.
_EVENT_NAME_EXPLORATION_LOADED
,
{
'exploration_id'
:
self
.
oppiaid
,
'exploration_id'
:
self
.
oppiaid
,
'exploration_version'
:
data
[
'explorationVersion'
],
})
})
@XBlock.json_handler
@XBlock.json_handler
...
@@ -92,13 +93,15 @@ class OppiaXBlock(XBlock):
...
@@ -92,13 +93,15 @@ class OppiaXBlock(XBlock):
'exploration_id'
:
self
.
oppiaid
,
'exploration_id'
:
self
.
oppiaid
,
'old_state_name'
:
data
[
'oldStateName'
],
'old_state_name'
:
data
[
'oldStateName'
],
'new_state_name'
:
data
[
'newStateName'
],
'new_state_name'
:
data
[
'newStateName'
],
'exploration_version'
:
data
[
'explorationVersion'
],
})
})
@XBlock.json_handler
@XBlock.json_handler
def
on_exploration_completed
(
self
,
data
,
suffix
=
''
):
def
on_exploration_completed
(
self
,
data
,
suffix
=
''
):
"""Called when the exploration has been completed."""
"""Called when the exploration has been completed."""
self
.
_log
(
self
.
_EVENT_NAME_EXPLORATION_COMPLETED
,
{
self
.
_log
(
self
.
_EVENT_NAME_EXPLORATION_COMPLETED
,
{
'exploration_id'
:
self
.
oppiaid
'exploration_id'
:
self
.
oppiaid
,
'exploration_version'
:
data
[
'explorationVersion'
],
})
})
def
studio_view
(
self
,
context
):
def
studio_view
(
self
,
context
):
...
...
oppia/static/js/oppia.js
View file @
9f6b95b7
...
@@ -25,32 +25,39 @@ function OppiaXBlock(runtime, element) {
...
@@ -25,32 +25,39 @@ function OppiaXBlock(runtime, element) {
element
,
'on_exploration_completed'
);
element
,
'on_exploration_completed'
);
$
(
function
(
$
)
{
$
(
function
(
$
)
{
window
.
OPPIA_PLAYER
.
onExplorationLoadedPostHook
=
function
(
iframeNode
)
{
window
.
OPPIA_PLAYER
.
onExplorationLoadedPostHook
=
function
(
iframeNode
,
explorationVersion
)
{
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
onLoadHandlerUrl
,
url
:
onLoadHandlerUrl
,
data
:
JSON
.
stringify
({})
data
:
JSON
.
stringify
({
explorationVersion
:
explorationVersion
})
});
});
};
};
window
.
OPPIA_PLAYER
.
onStateTransitionPostHook
=
function
(
window
.
OPPIA_PLAYER
.
onStateTransitionPostHook
=
function
(
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
)
{
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
,
explorationVersion
)
{
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
onStateTransitionUrl
,
url
:
onStateTransitionUrl
,
data
:
JSON
.
stringify
({
data
:
JSON
.
stringify
({
oldStateName
:
oldStateName
,
oldStateName
:
oldStateName
,
jsonAnswer
:
jsonAnswer
,
jsonAnswer
:
jsonAnswer
,
newStateName
:
newStateName
newStateName
:
newStateName
,
explorationVersion
:
explorationVersion
})
})
});
});
};
};
window
.
OPPIA_PLAYER
.
onExplorationCompletedPostHook
=
function
(
iframeNode
)
{
window
.
OPPIA_PLAYER
.
onExplorationCompletedPostHook
=
function
(
iframeNode
,
explorationVersion
)
{
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
onCompleteHandlerUrl
,
url
:
onCompleteHandlerUrl
,
data
:
JSON
.
stringify
({})
data
:
JSON
.
stringify
({
explorationVersion
:
explorationVersion
})
});
});
};
};
});
});
...
...
oppia/static/lib/oppia-player-0.0.1-modified.js
View file @
9f6b95b7
...
@@ -245,6 +245,8 @@
...
@@ -245,6 +245,8 @@
}
}
},
LOADING_TIMEOUT_SECS
);
},
LOADING_TIMEOUT_SECS
);
// NOTE: Modified for OpenEdX to include exploration version.
/**
/**
* Receives JSON-encoded messages from embedded Oppia iframes. Each
* Receives JSON-encoded messages from embedded Oppia iframes. Each
* message has a title and a payload. The structure of the payload
* message has a title and a payload. The structure of the payload
...
@@ -252,14 +254,16 @@
...
@@ -252,14 +254,16 @@
* - 'heightChange': The payload is an Object with the following fields:
* - 'heightChange': The payload is an Object with the following fields:
* height: a positive integer, and
* height: a positive integer, and
* scroll: boolean -- scroll down to bottom if true.
* scroll: boolean -- scroll down to bottom if true.
* - 'explorationLoaded': The payload is an empty Object.
* - 'explorationLoaded': The payload is an Object with one key:
* - 'stateTransition': The payload is an Object with three keys:
* explorationVersion.
* 'oldStateName', 'jsonAnswer' and 'newStateName'. All three of
* - 'stateTransition': The payload is an Object with four keys:
* these have values of type String.
* 'oldStateName', 'jsonAnswer', 'newStateName' and
* 'explorationVersion'.
* - 'explorationReset': The payload is an Object with a single
* - 'explorationReset': The payload is an Object with a single
* key-value pair. The key is 'stateName', and the value is of
* key-value pair. The key is 'stateName', and the value is of
* type String.
* type String.
* - 'explorationCompleted': The payload is an empty Object.
* - 'explorationCompleted': The payload is an Object with one key:
* explorationVersion.
*/
*/
window
.
addEventListener
(
'message'
,
function
(
evt
)
{
window
.
addEventListener
(
'message'
,
function
(
evt
)
{
// Verify the origin of the message.
// Verify the origin of the message.
...
@@ -284,7 +288,8 @@
...
@@ -284,7 +288,8 @@
case
'explorationLoaded'
:
case
'explorationLoaded'
:
that
.
loadingDiv
.
parentNode
.
removeChild
(
that
.
loadingDiv
);
that
.
loadingDiv
.
parentNode
.
removeChild
(
that
.
loadingDiv
);
that
.
explorationHasLoaded
=
true
;
that
.
explorationHasLoaded
=
true
;
window
.
OPPIA_PLAYER
.
onExplorationLoaded
(
iframeNode
);
window
.
OPPIA_PLAYER
.
onExplorationLoaded
(
iframeNode
,
data
.
payload
.
explorationVersion
);
break
;
break
;
case
'heightChange'
:
case
'heightChange'
:
window
.
OPPIA_PLAYER
.
onHeightChange
(
window
.
OPPIA_PLAYER
.
onHeightChange
(
...
@@ -293,7 +298,7 @@
...
@@ -293,7 +298,7 @@
case
'stateTransition'
:
case
'stateTransition'
:
window
.
OPPIA_PLAYER
.
onStateTransition
(
window
.
OPPIA_PLAYER
.
onStateTransition
(
iframeNode
,
data
.
payload
.
oldStateName
,
data
.
payload
.
jsonAnswer
,
iframeNode
,
data
.
payload
.
oldStateName
,
data
.
payload
.
jsonAnswer
,
data
.
payload
.
newStateName
);
data
.
payload
.
newStateName
,
data
.
payload
.
explorationVersion
);
break
;
break
;
case
'explorationReset'
:
case
'explorationReset'
:
// This needs to be set in order to allow the scrollHeight of the
// This needs to be set in order to allow the scrollHeight of the
...
@@ -304,7 +309,8 @@
...
@@ -304,7 +309,8 @@
iframeNode
,
data
.
payload
.
stateName
);
iframeNode
,
data
.
payload
.
stateName
);
break
;
break
;
case
'explorationCompleted'
:
case
'explorationCompleted'
:
window
.
OPPIA_PLAYER
.
onExplorationCompleted
(
iframeNode
);
window
.
OPPIA_PLAYER
.
onExplorationCompleted
(
iframeNode
,
data
.
payload
.
explorationVersion
);
break
;
break
;
default
:
default
:
_log
(
'Error: event '
+
data
.
title
+
' not recognized.'
);
_log
(
'Error: event '
+
data
.
title
+
' not recognized.'
);
...
@@ -361,24 +367,27 @@
...
@@ -361,24 +367,27 @@
window
.
OPPIA_PLAYER
.
onHeightChangePostHook
(
iframeNode
,
newHeight
);
window
.
OPPIA_PLAYER
.
onHeightChangePostHook
(
iframeNode
,
newHeight
);
},
},
onExplorationLoaded
:
function
(
iframeNode
)
{
onExplorationLoaded
:
function
(
iframeNode
,
explorationVersion
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
// Show the oppia contents after making sure the rendering happened.
// Show the oppia contents after making sure the rendering happened.
iframeNode
.
style
.
position
=
'inherit'
;
iframeNode
.
style
.
position
=
'inherit'
;
iframeNode
.
style
.
visibility
=
'inherit'
;
iframeNode
.
style
.
visibility
=
'inherit'
;
iframeNode
.
style
.
top
=
'inherit'
;
iframeNode
.
style
.
top
=
'inherit'
;
},
0
);
},
0
);
window
.
OPPIA_PLAYER
.
onExplorationLoadedPostHook
(
iframeNode
);
window
.
OPPIA_PLAYER
.
onExplorationLoadedPostHook
(
iframeNode
,
explorationVersion
);
},
},
onStateTransition
:
function
(
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
)
{
onStateTransition
:
function
(
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
,
explorationVersion
)
{
window
.
OPPIA_PLAYER
.
onStateTransitionPostHook
(
window
.
OPPIA_PLAYER
.
onStateTransitionPostHook
(
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
);
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
,
explorationVersion
);
},
},
onExplorationReset
:
function
(
iframeNode
,
stateName
)
{
onExplorationReset
:
function
(
iframeNode
,
stateName
)
{
window
.
OPPIA_PLAYER
.
onExplorationResetPostHook
(
iframeNode
,
stateName
);
window
.
OPPIA_PLAYER
.
onExplorationResetPostHook
(
iframeNode
,
stateName
);
},
},
onExplorationCompleted
:
function
(
iframeNode
)
{
onExplorationCompleted
:
function
(
iframeNode
,
explorationVersion
)
{
window
.
OPPIA_PLAYER
.
onExplorationCompletedPostHook
(
iframeNode
);
window
.
OPPIA_PLAYER
.
onExplorationCompletedPostHook
(
iframeNode
,
explorationVersion
);
}
}
};
};
}(
window
,
document
));
}(
window
,
document
));
...
@@ -401,8 +410,10 @@ window.OPPIA_PLAYER.onHeightChangePostHook = function(iframeNode, newHeight) {
...
@@ -401,8 +410,10 @@ window.OPPIA_PLAYER.onHeightChangePostHook = function(iframeNode, newHeight) {
* Called when the exploration is loaded.
* Called when the exploration is loaded.
* @param {object} iframeNode The iframe node that is the source of the
* @param {object} iframeNode The iframe node that is the source of the
* postMessage call.
* postMessage call.
* @param {int} explorationVersion The version number of the exploration.
*/
*/
window
.
OPPIA_PLAYER
.
onExplorationLoadedPostHook
=
function
(
iframeNode
)
{
window
.
OPPIA_PLAYER
.
onExplorationLoadedPostHook
=
function
(
iframeNode
,
explorationVersion
)
{
};
};
...
@@ -413,9 +424,10 @@ window.OPPIA_PLAYER.onExplorationLoadedPostHook = function(iframeNode) {
...
@@ -413,9 +424,10 @@ window.OPPIA_PLAYER.onExplorationLoadedPostHook = function(iframeNode) {
* @param {string} oldStateName The name of the previous state.
* @param {string} oldStateName The name of the previous state.
* @param {string} jsonAnswer A JSON representation of the reader's answer.
* @param {string} jsonAnswer A JSON representation of the reader's answer.
* @param {string} newStateName The name of the destination state.
* @param {string} newStateName The name of the destination state.
* @param {int} explorationVersion The version number of the exploration.
*/
*/
window
.
OPPIA_PLAYER
.
onStateTransitionPostHook
=
function
(
window
.
OPPIA_PLAYER
.
onStateTransitionPostHook
=
function
(
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
)
{
iframeNode
,
oldStateName
,
jsonAnswer
,
newStateName
,
explorationVersion
)
{
};
};
...
@@ -433,7 +445,9 @@ window.OPPIA_PLAYER.onExplorationResetPostHook = function(iframeNode, stateName)
...
@@ -433,7 +445,9 @@ window.OPPIA_PLAYER.onExplorationResetPostHook = function(iframeNode, stateName)
* Called when the exploration is completed.
* Called when the exploration is completed.
* @param {object} iframeNode The iframe node that is the source of the
* @param {object} iframeNode The iframe node that is the source of the
* postMessage call.
* postMessage call.
* @param {int} explorationVersion The version number of the exploration.
*/
*/
window
.
OPPIA_PLAYER
.
onExplorationCompletedPostHook
=
function
(
iframeNode
)
{
window
.
OPPIA_PLAYER
.
onExplorationCompletedPostHook
=
function
(
iframeNode
,
explorationVersion
)
{
};
};
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