only send learning analytics events when specified in config.
This commit is contained in:
@ -29,7 +29,11 @@ var CodeOceanEditor = {
|
|||||||
|
|
||||||
lastCopyText: null,
|
lastCopyText: null,
|
||||||
|
|
||||||
configureEditors: function () {
|
<% @config ||= CodeOcean::Config.new(:code_ocean).read(erb: false) %>
|
||||||
|
sendLearningAnalyticEvents: <%= @config['codeocean_events']['enabled'] %>,
|
||||||
|
learningAnalyticsURL: "<%= @config['codeocean_events']['url'] %>",
|
||||||
|
|
||||||
|
configureEditors: function () {
|
||||||
_.each(['modePath', 'themePath', 'workerPath'], function (attribute) {
|
_.each(['modePath', 'themePath', 'workerPath'], function (attribute) {
|
||||||
ace.config.set(attribute, this.ACE_FILES_PATH);
|
ace.config.set(attribute, this.ACE_FILES_PATH);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@ -363,37 +367,41 @@ var CodeOceanEditor = {
|
|||||||
panel.find('.row .col-sm-9').eq(4).find('a').attr('href', '#output-' + index);
|
panel.find('.row .col-sm-9').eq(4).find('a').attr('href', '#output-' + index);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// move URL to config file, only fire event if desired.
|
||||||
publishCodeOceanEvent: function (eventName, contextData) {
|
publishCodeOceanEvent: function (eventName, contextData) {
|
||||||
|
if(this.sendLearningAnalyticEvents){
|
||||||
|
|
||||||
// enhance contextData hash with the user agent
|
// enhance contextData hash with the user agent
|
||||||
contextData['user_agent'] = navigator.userAgent;
|
contextData['user_agent'] = navigator.userAgent;
|
||||||
|
|
||||||
var payload = {
|
var payload = {
|
||||||
user: {
|
user: {
|
||||||
type: 'User',
|
type: 'User',
|
||||||
uuid: $('#editor').data('user-id'),
|
uuid: $('#editor').data('user-id'),
|
||||||
external_id: $('#editor').data('user-external-id')
|
external_id: $('#editor').data('user-external-id')
|
||||||
},
|
},
|
||||||
verb: {
|
verb: {
|
||||||
type: eventName
|
type: eventName
|
||||||
},
|
},
|
||||||
resource: {
|
resource: {
|
||||||
type: 'page',
|
type: 'page',
|
||||||
uuid: document.location.href
|
uuid: document.location.href
|
||||||
},
|
},
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
with_result: {},
|
with_result: {},
|
||||||
in_context: contextData
|
in_context: contextData
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax("https://open.hpi.de/lanalytics/log", {
|
$.ajax(this.learningAnalyticsURL, {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: payload,
|
data: payload,
|
||||||
success: {},
|
success: {},
|
||||||
error: {}
|
error: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
sendError: function (message, submission_id) {
|
sendError: function (message, submission_id) {
|
||||||
@ -552,6 +560,7 @@ var CodeOceanEditor = {
|
|||||||
$('#description-symbol').toggleClass('fa-chevron-right');
|
$('#description-symbol').toggleClass('fa-chevron-right');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
initializeEverything: function() {
|
initializeEverything: function() {
|
||||||
this.initializeRegexes();
|
this.initializeRegexes();
|
||||||
this.initializeCodePilot();
|
this.initializeCodePilot();
|
||||||
|
Reference in New Issue
Block a user