Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit e89c0c4

Browse files
committed
Fix: Do not hide chat before vote 2
There is a chance that the student could get the enableChat message before their timer has expired which would cause the chat to be hidden right after it was displayed. * add more logging of events so we can be more clear when debugging * Issue warning when resetting studentVoteCount
1 parent 929fb50 commit e89c0c4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

static/js/peer.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function connect(event) {
3737
switch (mess.message) {
3838
// This will be some kind of control message for the page
3939
case "countDownAndStop":
40+
console.log("Got countDownAndStop message");
4041
messarea = document.getElementById("imessage");
4142
let count = 5;
4243
let itimerid = setInterval(async function () {
@@ -45,10 +46,11 @@ function connect(event) {
4546
messarea.innerHTML = `<h3>Finish Up only ${count} seconds remaining</h3>`;
4647
count = count - 1;
4748
} else {
49+
console.log("Timer expired clean up and get ready to chat");
4850
messarea.style.color = "black";
4951
// hide the discussion
5052
let discPanel = document.getElementById("discussion_panel");
51-
if (discPanel) {
53+
if (discPanel && getVoteNum() > 1) {
5254
discPanel.style.display = "none";
5355
}
5456
let currAnswer = window.mcList[currentQuestion].answer;
@@ -89,12 +91,16 @@ function connect(event) {
8991
}, 1000);
9092
break;
9193
case "enableVote":
94+
console.log("Got enableVote message");
9295
window.mcList[currentQuestion].submitButton.disabled = false;
9396
window.mcList[currentQuestion].submitButton.innerHTML = "Submit";
9497
window.mcList[currentQuestion].enableInteraction();
9598
if (typeof studentVoteCount !== "undefined") {
9699
studentVoteCount += 1;
97-
if (studentVoteCount > 2) studentVoteCount = 2;
100+
if (studentVoteCount > 2) {
101+
studentVoteCount = 2;
102+
console.log("WARNING: resetting studentVoteCount to 2");
103+
}
98104
}
99105
messarea = document.getElementById("imessage");
100106
messarea.innerHTML = `<h3>Time to make your 2nd vote</h3>`;

0 commit comments

Comments
 (0)