Skip to content

Commit

Permalink
added correct 'memory' code to student_doing_well detector; reverted …
Browse files Browse the repository at this point in the history
…detector adaptivity update temporarily - causes bug on TutorShop
  • Loading branch information
d19fe8 committed Jun 21, 2017
1 parent 04b787b commit 431bab5
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var prevStep = ""
var attemptCorrect;
var windowSize = 7;
var threshold = 6;
var attemptWindow = Array.apply(null, Array(windowSize)).map(Number.prototype.valueOf,0);
var attemptWindow;


function receive_transaction( e ){
Expand All @@ -45,6 +45,8 @@ function receive_transaction( e ){
attemptCorrect = (e.data.tutor_data.action_evaluation.toLowerCase() == "correct") ? 1 : 0;
attemptWindow.shift();
attemptWindow.push(attemptCorrect);
detector_output.history = JSON.stringify(attemptWindow);

var sumCorrect = attemptWindow.reduce(function(pv, cv) { return pv + cv; }, 0);
console.log(attemptWindow);
}
Expand Down Expand Up @@ -100,6 +102,14 @@ self.onmessage = function ( e ) {
detector_output.history = "";
detector_output.value = 0;
}

if (detector_output.history == "" || detector_output.history == null){
attemptWindow = Array.apply(null, Array(windowSize)).map(Number.prototype.valueOf,0);
}
else{
attemptWindow = JSON.parse(detector_output.history);
}

break;
default:
break;
Expand Down
14 changes: 0 additions & 14 deletions HTML/Assets/transaction_mailer_users.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@ TransactionMailerUsers.create = function(path, txDestURL, scriptsDestURL, authTo
}
TransactionMailerUsers.active.push(detector);
console.log("TransactionMailerUsers.create(): s, active["+i+"]=", s, TransactionMailerUsers.active[i]);

detector.onmessage = function(e)
{
var sel = e.data.name;
var action = "UpdateVariable";
var input = e.data.value;

var sai = new CTATSAI();
sai.setSelection(sel);
sai.setAction(action);
sai.setInput(input)
CTATCommShell.commShell.processComponentAction(sai=sai, tutorComponent=false, aTrigger="tutor")
};


}
return TransactionMailerUsers;
Expand Down
81 changes: 81 additions & 0 deletions HTML/Assets/transaction_mailer_users_updateVarTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
TransactionMailerUsers =
{
process_transactions_url: "",
process_detectors_url: "",
authenticity_token: "",
mailerURL: "mail-worker.js",
mailer: null,
mailerPort: null,
scripts: ["Detectors/Lumilo/idle.js",
"Detectors/Lumilo/system_misuse.js",
"Detectors/Lumilo/struggle__moving_average.js",
"Detectors/Lumilo/student_doing_well__moving_average.js",
"Detectors/Lumilo/critical_struggle.js",
"Detectors/Lumilo/invisible_hand_raise.js"],
active: []
};

TransactionMailerUsers.create = function(path, txDestURL, scriptsDestURL, authToken, scriptsInitzer)
{
console.log("TransactionMailerUsers.create(): at entry, scriptsInitzer ", scriptsInitzer );

TransactionMailerUsers.mailer = new Worker(path+'/'+TransactionMailerUsers.mailerURL);

TransactionMailerUsers.mailer.postMessage({ command: "process_transactions_url", "process_transactions_url": txDestURL, "process_detectors_url": scriptsDestURL, "authenticity_token": authToken});
TransactionMailerUsers.process_transactions_url = txDestURL;
TransactionMailerUsers.authenticity_token = authToken;
TransactionMailerUsers.process_detectors_url = scriptsDestURL;

var channel = new MessageChannel();
TransactionMailerUsers.mailer.postMessage(
{ command: "connectTransactionAssembler" },
[ channel.port1 ]
);
TransactionMailerUsers.mailerPort = channel.port2;
TransactionMailerUsers.mailerPort.onmessage = function(event) {
console.log("From mailer: "+event);
};

for(var i = 0; i < TransactionMailerUsers.scripts.length; ++i)
{
var s = path + '/' + TransactionMailerUsers.scripts[i];
var detector = new Worker(s);
var mc = new MessageChannel();
TransactionMailerUsers.mailer.postMessage({ command: "connectDetector" }, [ mc.port1 ]);
detector.postMessage({ command: "connectMailer" }, [ mc.port2 ]);
if(scriptsInitzer)
{
detector.postMessage({ command: "initialize", initializer: scriptsInitzer });
console.log("TransactionMailerUsers.create(): sent command: initialize, scriptsInitzer ", scriptsInitzer );
}
TransactionMailerUsers.active.push(detector);
console.log("TransactionMailerUsers.create(): s, active["+i+"]=", s, TransactionMailerUsers.active[i]);

detector.onmessage = function(e)
{
var sel = e.data.name;
var action = "UpdateVariable";
var input = e.data.value;

var sai = new CTATSAI();
sai.setSelection(sel);
sai.setAction(action);
sai.setInput(input)
CTATCommShell.commShell.processComponentAction(sai=sai, tutorComponent=false, aTrigger="tutor")
};


}
return TransactionMailerUsers;
};

TransactionMailerUsers.sendTransaction = function(tx)
{
TransactionMailerUsers.mailerPort.postMessage(tx); // post to listener in other thread

var tmUsers = TransactionMailerUsers.active;
for(var i = 0; i < tmUsers; ++i)
{
tmUsers[i].postMessage(tx);
}
};

0 comments on commit 431bab5

Please sign in to comment.