sambit2 / dataanalytics-web-based-education Goto Github PK
View Code? Open in Web Editor NEWContains the design of the tool in JS and the analysis of log files in R
Contains the design of the tool in JS and the analysis of log files in R
It's better if you process per viewer, instead of all the events together
You could export the sessionevent.json from mongodb so
that
$oid
fieldsYou have inconsistent code indentation. Formatting is really important for readability
Instead of having an array for each indicator like so:
var exercise = [];
var connected = [];
var focus = [];
var idle = [];
var input = [];
var submitted = [];
you could have one array with an object that has all indicators. Like this:
var indicators = [];
users.forEach(function(user){
var iObj = {
connected: undefined,
focus: undefined,
idle:undefined,
input: undefined,
submitted: undefined
};
indicators.push(iObj)
})
Using line 48 to 57 is a waste of your time since step 4 of the munge scripts in the R repo (4_add_user_field_to_session_events.R
) will create cache/sessionevents_with_user_<date>.csv
which will have the normalized userid information
You may also want to use the native JavaScript date objects to get seconds etc. [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date][https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date]
lines 85-147 are too complex.
This how I would get the events per user:
var startTime = event[0].time;
var endTime = event[0].time;
var eventsPerUser = {};
/**
* This function is used to make sure each events has its
* properties in our desired format
*/
function preprocessEvent(evt){
// make sure time is in a format we want
// make sure userids are fine
return evt
}
/**
* The following loop will create an array for each user
* in eventsPerUser and push the corresponding user events.
* It will also find the min and max time the events take place
*/
events.forEach(function(evt){
evt = preprocessEvent(evt)
// if we don't have an entry for this userid, create one
if (eventsPerUser[evt.userid]){
eventsPerUser[evt.userid] = []
}
eventsPerUser[evt.userid].push(eventsPerUser[evt.userid]);
if (evt.time < startTime) {
startTime = evt.time
}
if (evt.time > endTime) {
endTime = evt.time
}
})
Now you can have the unique users like so:
var users = Object.keys(userEvents);
Now you can generate the state for each user like so:
function generateState(timeMin, timeMax, userEvents){
var duration = timeMax - timeMin
// initialize state array
for(var i=0; i<= duration, i++){
var iObj = {
connected: undefined,
focus: undefined,
idle:undefined,
input: undefined,
submitted: undefined
};
userState.push(iObj)
}
userEvents.forEach(function(){
// user here something to EventstoIndicators
})
}
// map will return an array whose elements are the return values of all
// the `mapFunction` calls
allUsersState = users.map(function mapFunction(userid){
var userState = generateState(timeMin, timeMax, eventsPerUser[userid] )
return userState;
})
don't use strings for binary (0/1, true/false) states. Use either true
, false
or integers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.