Index: lams_admin/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_admin/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_admin/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('
').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_admin/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_admin/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_admin/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_central/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_central/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_central/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_central/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_central/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_central/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_central/web/includes/javascript/websocket.js
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_central/web/includes/javascript/websocket.js (.../websocket.js) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_central/web/includes/javascript/websocket.js (.../websocket.js) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -60,7 +60,7 @@
}
};
-function initWebsocket(instanceName, url){
+function initWebsocket(instanceName, url, onMessageFunction){
let websocket = lamsWebsockets[instanceName];
if (!websocket) {
websocket = {
@@ -72,6 +72,9 @@
};
lamsWebsockets[instanceName] = websocket;
} else if (websocket.instance) {
+ if (!onMessageFunction) {
+ onMessageFunction = websocket.instance.onmessage;
+ }
try {
websocket.instance.close(1000);
} catch (e) {
@@ -99,9 +102,26 @@
websocketReconnect(instanceName);
}
};
+ if (onMessageFunction) {
+ websocket.instance.onmessage = onMessageFunction;
+ }
// set up timer for the first time
websocketPing(instanceName, true);
return websocket.instance;
+}
+
+function sendToWebsocket(instanceName, message) {
+ let websocket = lamsWebsockets[instanceName];
+ if (!websocket) {
+ console.error("Websocket not initialized: " + instanceName);
+ return;
+ }
+ if (websocket.instance.readyState == WebSocket.CLOSING
+ || websocket.instance.readyState == WebSocket.CLOSED){
+ websocketReconnect(instanceName);
+ return;
+ }
+ websocket.instance.send(message);
}
\ No newline at end of file
Index: lams_gradebook/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_gradebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_gradebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_gradebook/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_gradebook/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_gradebook/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_learning/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_learning/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_learning/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_learning/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_learning/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_learning/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_learning/web/includes/javascript/kumalive.js
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_learning/web/includes/javascript/kumalive.js (.../kumalive.js) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_learning/web/includes/javascript/kumalive.js (.../kumalive.js) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -26,8 +26,92 @@
ANIMATION_DURATION = 1000,
websocket = initWebsocket('kumalive' + orgId,
LEARNING_URL.replace('http', 'ws')
- + 'kumaliveWebsocket?organisationID=' + orgId + '&role=' + role);
+ + 'kumaliveWebsocket?organisationID=' + orgId + '&role=' + role,
+ function (e) {
+ // read JSON object
+ var message = JSON.parse(e.data),
+ type = message.type;
+ // check what is this message about
+ switch(type) {
+ case 'start' : {
+ // user tried to join a Kumalive which is not started yet
+ // try to start it, if user is a teacher
+ // otherwise just wait for a teacher
+ this.send(JSON.stringify({
+ 'type' : 'start',
+ 'role' : role
+ }));
+ }
+ break;
+ case 'create' : {
+ // user is a teacher and will now create a new Kumalive
+ // hide splash screen
+ $('#initDiv').hide();
+ // show name input
+ var createDiv = $('#createKumaliveDiv'),
+ rubricsDiv = $('#rubrics .panel-body', createDiv);
+ if (message.rubrics) {
+ $.each(message.rubrics, function(){
+ if (this) {
+ var checkbox = $('').addClass('checkbox').appendTo(rubricsDiv),
+ label = $('').appendTo(checkbox);
+ $('').text(this).appendTo(label);
+ $('').attr('type', 'checkbox')
+ .prop('checked', true)
+ .prependTo(label);
+ }
+ });
+ }
+ // do not show the box at all if there are no rubrics
+ // (exactly: there is the single default blank one)
+ if ($('.checkbox', rubricsDiv).length == 0){
+ rubricsDiv.remove();
+ }
+
+ var createButton = createDiv.show().children('button').click(create).prop('disabled', true);
+ createDiv.children('input').focus().keyup(function(){
+ // name can not be empty
+ createButton.prop('disabled', !$(this).val());
+ })
+ }
+ break;
+ case 'join' : {
+ // server tell user to join Kumalive, so user obeys
+ this.send(JSON.stringify({
+ 'type' : 'join'
+ }));
+ }
+ break;
+ case 'init' : {
+ if (!initialised) {
+ // it is the first refresh message ever
+ init(message);
+ }
+ }
+ break;
+ case 'refresh': {
+ if (refreshing) {
+ // set current message as the next one to be processed
+ queuedMessage = message;
+ } else {
+ // no refresh is running, so process current message
+ processRefresh(message);
+ }
+ }
+ break;
+ case 'finish' : {
+ // tell user that Kumalive is finished and close the window
+ window.alert(LABELS.FINISH_KUMALIVE_MESSAGE);
+ window.close();
+ }
+ break;
+ }
+
+ // reset ping timer
+ websocketPing('kumalive' + orgId, true);
+ });
+
if (websocket) {
/**
* Fetches existing Kumalive session
@@ -37,92 +121,6 @@
'type' : 'start'
}));
};
-
- // when the server pushes new inputs
- websocket.onmessage = function (e) {
- // read JSON object
- var message = JSON.parse(e.data),
- type = message.type;
- // check what is this message about
- switch(type) {
- case 'start' : {
- // user tried to join a Kumalive which is not started yet
- // try to start it, if user is a teacher
- // otherwise just wait for a teacher
- websocket.send(JSON.stringify({
- 'type' : 'start',
- 'role' : role
- }));
- }
- break;
- case 'create' : {
- // user is a teacher and will now create a new Kumalive
-
- // hide splash screen
- $('#initDiv').hide();
- // show name input
- var createDiv = $('#createKumaliveDiv'),
- rubricsDiv = $('#rubrics .panel-body', createDiv);
- if (message.rubrics) {
- $.each(message.rubrics, function(){
- if (this) {
- var checkbox = $('').addClass('checkbox').appendTo(rubricsDiv),
- label = $('').appendTo(checkbox);
- $('').text(this).appendTo(label);
- $('').attr('type', 'checkbox')
- .prop('checked', true)
- .prependTo(label);
- }
- });
- }
- // do not show the box at all if there are no rubrics
- // (exactly: there is the single default blank one)
- if ($('.checkbox', rubricsDiv).length == 0){
- rubricsDiv.remove();
- }
-
- var createButton = createDiv.show().children('button').click(create).prop('disabled', true);
- createDiv.children('input').focus().keyup(function(){
- // name can not be empty
- createButton.prop('disabled', !$(this).val());
- })
- }
- break;
- case 'join' : {
- // server tell user to join Kumalive, so user obeys
- websocket.send(JSON.stringify({
- 'type' : 'join'
- }));
- }
- break;
- case 'init' : {
- if (!initialised) {
- // it is the first refresh message ever
- init(message);
- }
- }
- break;
- case 'refresh': {
- if (refreshing) {
- // set current message as the next one to be processed
- queuedMessage = message;
- } else {
- // no refresh is running, so process current message
- processRefresh(message);
- }
- }
- break;
- case 'finish' : {
- // tell user that Kumalive is finished and close the window
- window.alert(LABELS.FINISH_KUMALIVE_MESSAGE);
- window.close();
- }
- break;
- }
-
- // reset ping timer
- websocketPing('kumalive' + orgId, true);
- };
}
/**
@@ -691,25 +689,25 @@
}
function raiseHandPrompt() {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'raiseHandPrompt'
}));
}
function downHandPrompt() {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'downHandPrompt'
}));
}
function raiseHand() {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'raiseHand'
}));
}
function downHand() {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'downHand'
}));
}
@@ -727,15 +725,14 @@
&& !confirm(LABELS.SPEAK_CONFIRM)){
return;
}
-
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'speak',
'speaker' : speakerId
}));
}
function stopSpeak() {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'speak'
}));
}
@@ -756,7 +753,7 @@
}
if (score !== null) {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'score',
'userID' : container.attr('userId'),
'rubricId' : container.attr('rubricId'),
@@ -927,7 +924,7 @@
}
$('#pollSetup').hide();
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'startPoll',
'poll' : poll
}));
@@ -942,7 +939,7 @@
return;
}
pollId = null;
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'votePoll',
'answerIndex' : checkedAnswer.val()
}));
@@ -955,7 +952,7 @@
if (!confirm(LABELS.POLL_RELEASE_VOTES_CONFIRM)){
return;
}
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'releasePollResults',
'votesReleased' : true
}));
@@ -969,7 +966,7 @@
if (!confirm(LABELS.POLL_RELEASE_VOTERS_CONFIRM)){
return;
}
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'releasePollResults',
'votersReleased' : true
}));
@@ -987,7 +984,7 @@
if (!confirm(LABELS.POLL_FINISH_CONFIRM)) {
return;
}
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'finishPoll',
'pollId' : pollId
}));
@@ -999,7 +996,7 @@
* Hide poll for everyone
*/
function closePoll() {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'closePoll'
}));
}
@@ -1015,7 +1012,7 @@
$('#rubrics input:checked', createDiv).each(function(){
rubrics.push($(this).siblings('span').text());
});
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'start',
'role' : role,
'name' : name,
@@ -1029,7 +1026,7 @@
*/
function finish(){
if (confirm(LABELS.FINISH_KUMALIVE_CONFIRM)) {
- websocket.send(JSON.stringify({
+ sendToWebsocket('kumalive' + orgId, JSON.stringify({
'type' : 'finish'
}));
}
Index: lams_learning/web/includes/javascript/presence.js
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_learning/web/includes/javascript/presence.js (.../presence.js) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_learning/web/includes/javascript/presence.js (.../presence.js) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -88,14 +88,11 @@
// update presenceTabLabel
$("#presenceUserCount").html(labelUsers + " (" + users.length + ")");
}
- },
- presenceWebsocket = initWebsocket('presence' + lessonId,
- APP_URL.replace('http', 'ws') + 'presenceChatWebsocket?lessonID=' + lessonId);
+ };
- if (presenceWebsocket) {
- // when the server pushes new inputs
- presenceWebsocket.onmessage = function (e) {
-
+ initWebsocket('presence' + lessonId,
+ APP_URL.replace('http', 'ws') + 'presenceChatWebsocket?lessonID=' + lessonId,
+ function (e) {
// create JSON object
var input = JSON.parse(e.data);
if (input.roster) {
@@ -149,8 +146,7 @@
// reset ping timer
websocketPing('presence' + lessonId, true);
- };
- }
+ });
});
@@ -215,9 +211,8 @@
'type' : 'fetchConversation',
'to' : nick
};
-
- presenceWebsocket.send(JSON.stringify(data));
-
+ sendToWebsocket('presence' + lessonId, JSON.stringify(data));
+
return tab;
}
@@ -276,9 +271,8 @@
'to' : tag == groupChatInfo.tag ? '' : receiver,
'message' : message
};
-
- presenceWebsocket.send(JSON.stringify(data));
-
+ sendToWebsocket('presence' + lessonId, JSON.stringify(data));
+
// reset ping timer
websocketPing('presence' + lessonId, true);
}
Index: lams_monitoring/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_monitoring/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_monitoring/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_monitoring/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_monitoring/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_monitoring/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_assessment/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_assessment/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_assessment/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_assessment/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_assessment/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_assessment/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_assessment/web/pages/learning/learning.jsp
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -147,38 +147,33 @@
});
}
- let websocket = initWebsocket('assessmentTimeLimit${sessionMap.assessment.contentId}',
+ initWebsocket('assessmentTimeLimit${sessionMap.assessment.contentId}',
''.replace('http', 'ws')
- + 'learningWebsocket?toolContentID=${sessionMap.assessment.contentId}');
+ + 'learningWebsocket?toolContentID=${sessionMap.assessment.contentId}',
+ function (e) {
+ // read JSON object
+ var input = JSON.parse(e.data);
- if (websocket) {
- // when the server pushes new inputs
- websocket.onmessage = function (e) {
-
- // read JSON object
- var input = JSON.parse(e.data);
-
- if (input.clearTimer == true) {
- // teacher stopped the timer, destroy it
- $('#countdown').countdown('destroy').remove();
- } else {
- // teacher updated the timer
- var secondsLeft = +input.secondsLeft,
- counterInitialised = $('#countdown').length > 0;
-
- if (counterInitialised) {
- // just set the new time
- $('#countdown').countdown('option', 'until', secondsLeft + 'S');
+ if (input.clearTimer == true) {
+ // teacher stopped the timer, destroy it
+ $('#countdown').countdown('destroy').remove();
} else {
- // initialise the timer
- displayCountdown(secondsLeft);
+ // teacher updated the timer
+ var secondsLeft = +input.secondsLeft,
+ counterInitialised = $('#countdown').length > 0;
+
+ if (counterInitialised) {
+ // just set the new time
+ $('#countdown').countdown('option', 'until', secondsLeft + 'S');
+ } else {
+ // initialise the timer
+ displayCountdown(secondsLeft);
+ }
}
- }
- // reset ping timer
- websocketPing('assessmentTimeLimit${sessionMap.assessment.contentId}', true);
- };
- }
+ // reset ping timer
+ websocketPing('assessmentTimeLimit${sessionMap.assessment.contentId}', true);
+ });
//autocomplete for VSA
$('.ui-autocomplete-input').each(function(){
Index: lams_tool_chat/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_chat/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_chat/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_chat/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_chat/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_chat/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_chat/web/includes/javascript/learning.js
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -17,14 +17,12 @@
});
// only Monitor can send a personal message
- let selectedUser = null,
- websocket = initWebsocket('chat' + TOOL_SESSION_ID,
- APP_URL.replace('http', 'ws')
- + 'learningWebsocket?toolSessionID=' + TOOL_SESSION_ID);
+ let selectedUser = null;
- if (websocket) {
- // when the server pushes new inputs
- websocket.onmessage = function (e) {
+ initWebsocket('chat' + TOOL_SESSION_ID,
+ APP_URL.replace('http', 'ws')
+ + 'learningWebsocket?toolSessionID=' + TOOL_SESSION_ID,
+ function (e) {
// create JSON object
var input = JSON.parse(e.data);
// clear old messages
@@ -78,9 +76,8 @@
// reset ping timer
websocketPing('chat' + TOOL_SESSION_ID, true);
- };
- }
-
+ });
+
function userSelected(userDiv) {
var userDivContent = userDiv.children().last().html().trim();
// is Monitor clicked the already selectedd user, desect him and make message go to everyone
@@ -101,18 +98,15 @@
return false; // do not send empty messages.
}
sendMessageArea.val('');
-
+
// only Monitor can send a personal message
var isPrivate = MODE == 'teacher' && selectedUser,
output = {
- 'toolSessionID' : TOOL_SESSION_ID,
- 'toUser' : isPrivate ? selectedUser : '',
- 'message' : isPrivate ? '[' + selectedUser + '] ' + message : message
+ 'toolSessionID' : TOOL_SESSION_ID,
+ 'toUser' : isPrivate ? selectedUser : '',
+ 'message' : isPrivate ? '[' + selectedUser + '] ' + message : message
};
-
- // send it to server
- websocket.send(JSON.stringify(output));
-
+ sendToWebsocket('chat' + TOOL_SESSION_ID, JSON.stringify(output));
// reset ping timer
websocketPing('chat' + TOOL_SESSION_ID, true);
}
Index: lams_tool_daco/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_daco/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_daco/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_daco/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_doku/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_doku/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_doku/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_doku/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_doku/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_doku/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_doku/web/pages/learning/learning.jsp
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_doku/web/pages/learning/learning.jsp (.../learning.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_doku/web/pages/learning/learning.jsp (.../learning.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -71,45 +71,41 @@
});
- let websocket = initWebsocket('dokuTimeLimit${sessionMap.toolContentID}',
+ let timeLimitExceeded = ${timeLimitExceeded};
+ initWebsocket('dokuTimeLimit${sessionMap.toolContentID}',
''.replace('http', 'ws')
- + 'learningWebsocket?toolContentID=${sessionMap.toolContentID}'),
- timeLimitExceeded = ${timeLimitExceeded};
+ + 'learningWebsocket?toolContentID=${sessionMap.toolContentID}',
+ function (e) {
+ // create JSON object
+ var input = JSON.parse(e.data);
- if (websocket) {
- // when the server pushes new inputs
- websocket.onmessage = function (e) {
- // create JSON object
- var input = JSON.parse(e.data);
+ if (input.clearTimer == true) {
+ // teacher stopped the timer, destroy it
+ $('#countdown').countdown('destroy').remove();
+ } else if (typeof input.secondsLeft != 'undefined'){
+ // teacher updated the timer
+ var secondsLeft = +input.secondsLeft,
+ counterInitialised = $('#countdown').length > 0;
- if (input.clearTimer == true) {
- // teacher stopped the timer, destroy it
- $('#countdown').countdown('destroy').remove();
- } else if (typeof input.secondsLeft != 'undefined'){
- // teacher updated the timer
- var secondsLeft = +input.secondsLeft,
- counterInitialised = $('#countdown').length > 0;
+ if (counterInitialised) {
+ // just set the new time
+ $('#countdown').countdown('option', 'until', secondsLeft + 'S');
+ } else if (timeLimitExceeded){
+ if (secondsLeft > 0) {
+ // teacher gave extra time, reload to writable Etherpad
+ location.reload();
+ return;
+ }
+ } else {
+ // initialise the timer
+ displayCountdown(secondsLeft);
+ }
+ }
- if (counterInitialised) {
- // just set the new time
- $('#countdown').countdown('option', 'until', secondsLeft + 'S');
- } else if (timeLimitExceeded){
- if (secondsLeft > 0) {
- // teacher gave extra time, reload to writable Etherpad
- location.reload();
- return;
- }
- } else {
- // initialise the timer
- displayCountdown(secondsLeft);
- }
- }
+ // reset ping timer
+ websocketPing('dokuTimeLimit${sessionMap.toolContentID}', true);
+ });
- // reset ping timer
- websocketPing('dokuTimeLimit${sessionMap.toolContentID}', true);
- };
- }
-
$('[data-toggle="tooltip"]').bootstrapTooltip();
});
Index: lams_tool_forum/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_forum/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_forum/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_forum/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_gmap/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_gmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_gmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_gmap/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_gmap/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_gmap/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_images/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_images/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_images/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_images/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_images/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_images/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_imscc/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_imscc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_imscc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_imscc/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_imscc/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_imscc/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_lamc/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_lamc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_lamc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_lamc/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_lamc/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_lamc/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_laqa/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_laqa/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_laqa/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_laqa/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_laqa/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_laqa/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_larsrc/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_larsrc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_larsrc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_larsrc/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_larsrc/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_larsrc/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_leader/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_leader/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_leader/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_leader/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_leader/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_leader/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_leader/web/pages/learning/leaderselection.jsp
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_leader/web/pages/learning/leaderselection.jsp (.../leaderselection.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_leader/web/pages/learning/leaderselection.jsp (.../leaderselection.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -36,26 +36,20 @@
keyboard: true
});
- let websocket = initWebsocket('leaderSelection${toolSessionID}',
+ initWebsocket('leaderSelection${toolSessionID}',
''.replace('http', 'ws')
- + 'learningWebsocket?toolSessionID=${toolSessionID}');
+ + 'learningWebsocket?toolSessionID=${toolSessionID}',
+ function (e) {
+ // create JSON object
+ var input = JSON.parse(e.data);
- if (websocket) {
- // when the server pushes new inputs
- websocket.onmessage = function (e) {
- // no need to reset ping timer as the only possible message is page refresh
-
- // create JSON object
- var input = JSON.parse(e.data);
-
- // The leader has just been selected and all non-leaders should refresh their pages in order
- // to see new leader's name and a Finish button.
- if (input.pageRefresh) {
- location.reload();
- return;
- }
- };
- }
+ // The leader has just been selected and all non-leaders should refresh their pages in order
+ // to see new leader's name and a Finish button.
+ if (input.pageRefresh) {
+ location.reload();
+ return;
+ }
+ });
});
function leaderSelection() {
Index: lams_tool_mindmap/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_mindmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_mindmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_mindmap/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_mindmap/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_mindmap/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_mindmap/web/common/mapjs.jsp
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_mindmap/web/common/mapjs.jsp (.../mapjs.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_mindmap/web/common/mapjs.jsp (.../mapjs.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -63,69 +63,65 @@
<%-- Websockets used to get the node updates from the server --%>
<%-- init the connection with server using server URL but with different protocol --%>
- let websocket = initWebsocket('mindmapNodes${sessionId}',
+ initWebsocket('mindmapNodes${sessionId}',
''.replace('http', 'ws')
- + 'learningWebsocket?toolSessionID=${sessionId}&lastActionId=' + initialActionId);
+ + 'learningWebsocket?toolSessionID=${sessionId}&lastActionId=' + initialActionId,
+ function (e) {
+ // create JSON object
+ var response = JSON.parse(e.data);
- if (websocket) {
- // when the server pushes new inputs
- websocket.onmessage = function (e) {
- // create JSON object
- var response = JSON.parse(e.data);
-
- if ( ! response.actions ) {
- return;
- }
-
- var valuesChanged = false;
- for ( i=0; i');
+ if ( ! response.actions ) {
return;
}
- // only process requests we have not done already otherwise we would redo any we trigger
- if ( requestId > initialActionId && requestsProcessed.indexOf(requestId) == -1 ) {
- if ( action.type == 0 ) {
- customRemoveSubIdea(action.nodeId);
- } else if ( action.type == 1 ) {
- updateUnsavedNodeIds(action.childNodeId);
- // add node response.nodeId, response.title, response.color
- contentAggregate.addSubIdea(action.nodeId, action.title, action.childNodeId);
- var newChildNode = contentAggregate.findSubIdeaById(action.childNodeId);
- newChildNode.attr = {};
- newChildNode.attr.contentLocked = true;
- newChildNode.creator = action.creator;
- if ( action.color ) {
- newChildNode.attr.style = {};
- newChildNode.attr.style.background = action.color;
- }
- } else if ( action.type == 2 ) {
- // update colour - this call updates the node on screen but also triggers the change
- // action which will call onIdeaChangedLAMS() - so the change to the other user's node
- // will need to be ignored.
- contentAggregate.mergeAttrProperty(action.nodeId, 'style', 'background', action.color);
- } else if ( action.type == 3 ) {
- // update title
- var ideaToUpdate = contentAggregate.findSubIdeaById(action.nodeId);
- ideaToUpdate.title = action.title;
- } else {
+
+ var valuesChanged = false;
+ for ( i=0; i');
+ return;
}
- requestsProcessed.push( requestId );
- updateLastActionId( requestId );
- valuesChanged = true;
+ // only process requests we have not done already otherwise we would redo any we trigger
+ if ( requestId > initialActionId && requestsProcessed.indexOf(requestId) == -1 ) {
+ if ( action.type == 0 ) {
+ customRemoveSubIdea(action.nodeId);
+ } else if ( action.type == 1 ) {
+ updateUnsavedNodeIds(action.childNodeId);
+ // add node response.nodeId, response.title, response.color
+ contentAggregate.addSubIdea(action.nodeId, action.title, action.childNodeId);
+ var newChildNode = contentAggregate.findSubIdeaById(action.childNodeId);
+ newChildNode.attr = {};
+ newChildNode.attr.contentLocked = true;
+ newChildNode.creator = action.creator;
+ if ( action.color ) {
+ newChildNode.attr.style = {};
+ newChildNode.attr.style.background = action.color;
+ }
+ } else if ( action.type == 2 ) {
+ // update colour - this call updates the node on screen but also triggers the change
+ // action which will call onIdeaChangedLAMS() - so the change to the other user's node
+ // will need to be ignored.
+ contentAggregate.mergeAttrProperty(action.nodeId, 'style', 'background', action.color);
+ } else if ( action.type == 3 ) {
+ // update title
+ var ideaToUpdate = contentAggregate.findSubIdeaById(action.nodeId);
+ ideaToUpdate.title = action.title;
+ } else {
+ abortLoad('');
+ }
+ requestsProcessed.push( requestId );
+ updateLastActionId( requestId );
+ valuesChanged = true;
+ }
}
- }
- if ( valuesChanged ) {
- window.mapModel.rebuildRequired();
- }
-
+ if ( valuesChanged ) {
+ window.mapModel.rebuildRequired();
+ }
// reset ping timer
websocketPing('mindmapNodes${sessionId}', true);
- };
- }
+ });
+
},
error: function (response) {
Index: lams_tool_nb/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_nb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_nb/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_nb/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_nb/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_nb/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_notebook/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_notebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_notebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_notebook/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_notebook/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_notebook/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_pixlr/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_pixlr/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_pixlr/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_pixlr/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_pixlr/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_pixlr/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_preview/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_preview/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_preview/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_preview/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_preview/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_preview/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_sbmt/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_sbmt/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_sbmt/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_sbmt/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_sbmt/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_sbmt/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_scratchie/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_scratchie/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_scratchie/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_scratchie/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_scratchie/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_scratchie/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_scratchie/web/pages/learning/learning.jsp
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -325,61 +325,57 @@
$(document).ready(function(){
// time limit feature
- let websocket = initWebsocket('scratchieTimeLimit${scratchie.contentId}',
+ initWebsocket('scratchieTimeLimit${scratchie.contentId}',
''.replace('http', 'ws')
- + 'learningWebsocket?toolSessionID=${toolSessionID}&toolContentID=${scratchie.contentId}');
+ + 'learningWebsocket?toolSessionID=${toolSessionID}&toolContentID=${scratchie.contentId}',
+ function (e) {
- if (websocket) {
- // when the server pushes new inputs
- websocket.onmessage = function (e) {
+ // create JSON object
+ var input = JSON.parse(e.data);
- // create JSON object
- var input = JSON.parse(e.data);
+ if (input.pageRefresh) {
+ location.reload();
+ return;
+ }
- if (input.pageRefresh) {
- location.reload();
- return;
- }
+ if (input.clearTimer == true) {
+ // teacher stopped the timer, destroy it
+ $('#countdown').countdown('destroy').remove();
+ } else if (typeof input.secondsLeft != 'undefined'){
+ // teacher updated the timer
+ var secondsLeft = +input.secondsLeft,
+ counterInitialised = $('#countdown').length > 0;
- if (input.clearTimer == true) {
- // teacher stopped the timer, destroy it
- $('#countdown').countdown('destroy').remove();
- } else if (typeof input.secondsLeft != 'undefined'){
- // teacher updated the timer
- var secondsLeft = +input.secondsLeft,
- counterInitialised = $('#countdown').length > 0;
+ if (counterInitialised) {
+ // just set the new time
+ $('#countdown').countdown('option', 'until', secondsLeft + 'S');
+ } else {
+ // initialise the timer
+ displayCountdown(secondsLeft);
+ }
+ } else if (${not isUserLeader}){
+ // reflect the leader's choices
+ $.each(input, function(itemUid, options) {
+ $.each(options, function(optionUid, optionProperties){
- if (counterInitialised) {
- // just set the new time
- $('#countdown').countdown('option', 'until', secondsLeft + 'S');
- } else {
- // initialise the timer
- displayCountdown(secondsLeft);
- }
- } else if (${not isUserLeader}){
- // reflect the leader's choices
- $.each(input, function(itemUid, options) {
- $.each(options, function(optionUid, optionProperties){
+ if (optionProperties.isVSA) {
+ var answer = optionUid;
+ optionUid = hashCode(optionUid);
- if (optionProperties.isVSA) {
- var answer = optionUid;
- optionUid = hashCode(optionUid);
-
- //check if such image exists, create it otherwise
- if ($('#image-' + itemUid + '-' + optionUid).length == 0) {
- paintNewVsaAnswer(eval(itemUid), answer);
+ //check if such image exists, create it otherwise
+ if ($('#image-' + itemUid + '-' + optionUid).length == 0) {
+ paintNewVsaAnswer(eval(itemUid), answer);
+ }
}
- }
- scratchImage(itemUid, optionUid, optionProperties.isCorrect);
+ scratchImage(itemUid, optionUid, optionProperties.isCorrect);
+ });
});
- });
- }
+ }
- // reset ping timer
- websocketPing('scratchieTimeLimit${scratchie.contentId}', true);
- };
- }
+ // reset ping timer
+ websocketPing('scratchieTimeLimit${scratchie.contentId}', true);
+ });
});
function displayCountdown(secondsLeft){
Index: lams_tool_scribe/web/WEB-INF/tags/Page.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_scribe/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_scribe/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -231,51 +231,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_scribe/web/WEB-INF/tags/Page5.tag
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_scribe/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_scribe/web/WEB-INF/tags/Page5.tag (.../Page5.tag) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -233,51 +233,47 @@
});
}
- let commandWebsocket = initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
- + 'commandWebsocket?lessonID=' + lessonId);
-
- if (commandWebsocket) {
- // when the server pushes new inputs
- commandWebsocket.onmessage = function (e) {
- // read JSON object
- var command = JSON.parse(e.data);
- if (command.message) {
- // some tools implement autosave feature
- // if it is such a tool, trigger it
- if (command.message === 'autosave') {
- // the name of this function is same in all tools
- if (typeof learnerAutosave == 'function') {
- learnerAutosave(true);
+ initWebsocket('commandWebsocket', LEARNING_URL.replace('http', 'ws')
+ + 'commandWebsocket?lessonID=' + lessonId,
+ function (e) {
+ // read JSON object
+ var command = JSON.parse(e.data);
+ if (command.message) {
+ // some tools implement autosave feature
+ // if it is such a tool, trigger it
+ if (command.message === 'autosave') {
+ // the name of this function is same in all tools
+ if (typeof learnerAutosave == 'function') {
+ learnerAutosave(true);
+ }
+ } else {
+ alert(command.message);
}
- } else {
- alert(command.message);
}
- }
- // if learner's currently displayed page has hookTrigger same as in the JSON
- // then a function also defined on that page will run
- if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
- && typeof commandWebsocketHook === 'function') {
- commandWebsocketHook(command.hookParams);
- }
+ // if learner's currently displayed page has hookTrigger same as in the JSON
+ // then a function also defined on that page will run
+ if (command.hookTrigger && command.hookTrigger == commandWebsocketHookTrigger
+ && typeof commandWebsocketHook === 'function') {
+ commandWebsocketHook(command.hookParams);
+ }
- if (command.redirectURL) {
- window.location.href = command.redirectURL;
- }
+ if (command.redirectURL) {
+ window.location.href = command.redirectURL;
+ }
- if (command.discussion) {
- var discussionCommand = $('#discussion-sentiment-command');
- if (discussionCommand.length === 0) {
- discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ if (command.discussion) {
+ var discussionCommand = $('#discussion-sentiment-command');
+ if (discussionCommand.length === 0) {
+ discussionCommand = $('').attr('id', 'discussion-sentiment-command').appendTo('body');
+ }
+ discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
+ lessonId : lessonId
+ });
}
- discussionCommand.load(LEARNING_URL + "discussionSentiment/" + command.discussion + ".do", {
- lessonId : lessonId
- });
- }
- // reset ping timer
- websocketPing('commandWebsocket', true);
- };
- }
+ // reset ping timer
+ websocketPing('commandWebsocket', true);
+ });
}
});
}
Index: lams_tool_scribe/web/pages/learning/learning.jsp
===================================================================
diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6
--- lams_tool_scribe/web/pages/learning/learning.jsp (.../learning.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7)
+++ lams_tool_scribe/web/pages/learning/learning.jsp (.../learning.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6)
@@ -38,60 +38,57 @@