Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Success mesage on feedback submit (#6)
Browse files- Success mesage on feedback submit (b7f6d8bf7e882f5c21c6415608977b5e5d6567de)
- Update chat_application/main.py (fc39adf31ea34f60f39b2a10503357d269d41d1f)
- Update chat_application/static/styles/styles.css (2bee08e65bb19df0147edc8b14b8d426282d493c)
- Update chat_application/templates/room.html (e571747bcf09e7aa757b3ea29f9443e124648afe)
chat_application/main.py
CHANGED
|
@@ -647,8 +647,6 @@ def choose():
|
|
| 647 |
"created_at": datetime.utcnow(),
|
| 648 |
# user identity
|
| 649 |
"user_id": user_id,
|
| 650 |
-
# empty feedback history
|
| 651 |
-
"feedbacks": [],
|
| 652 |
})
|
| 653 |
|
| 654 |
session['room'] = room_id
|
|
@@ -842,9 +840,12 @@ def handle_message(payload):
|
|
| 842 |
{"_id": room},
|
| 843 |
{"$push": {"feedback_responses": db_feedback}}
|
| 844 |
)
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
|
|
|
|
|
|
|
|
|
| 848 |
|
| 849 |
@socketio.on('disconnect')
|
| 850 |
def handle_disconnect():
|
|
|
|
| 647 |
"created_at": datetime.utcnow(),
|
| 648 |
# user identity
|
| 649 |
"user_id": user_id,
|
|
|
|
|
|
|
| 650 |
})
|
| 651 |
|
| 652 |
session['room'] = room_id
|
|
|
|
| 840 |
{"_id": room},
|
| 841 |
{"$push": {"feedback_responses": db_feedback}}
|
| 842 |
)
|
| 843 |
+
|
| 844 |
+
if result:
|
| 845 |
+
print(result)
|
| 846 |
+
if result.modified_count > 0:
|
| 847 |
+
return {'status':'True'}
|
| 848 |
+
return {'ststus':'False'}
|
| 849 |
|
| 850 |
@socketio.on('disconnect')
|
| 851 |
def handle_disconnect():
|
chat_application/static/styles/styles.css
CHANGED
|
@@ -462,12 +462,12 @@ hr {
|
|
| 462 |
transition: 0.15s ease-in-out;
|
| 463 |
}
|
| 464 |
|
| 465 |
-
#abortYesBtn, #abortYesBtn-pre {
|
| 466 |
background: #d9534f;
|
| 467 |
color: white;
|
| 468 |
}
|
| 469 |
|
| 470 |
-
#abortYesBtn:hover, #abortYesBtn-pre:hover {
|
| 471 |
background: #c9302c;
|
| 472 |
}
|
| 473 |
|
|
@@ -498,12 +498,12 @@ hr {
|
|
| 498 |
background: #ccc;
|
| 499 |
}
|
| 500 |
|
| 501 |
-
#welcomeOkBtn, #timerOkBtn, #submitFeedbackBtn {
|
| 502 |
background: green;
|
| 503 |
color: white;
|
| 504 |
}
|
| 505 |
|
| 506 |
-
#welcomeOkBtn:hover, #timerOkBtn:hover, #submitFeedbackBtn:hover {
|
| 507 |
background: #016601;
|
| 508 |
}
|
| 509 |
|
|
|
|
| 462 |
transition: 0.15s ease-in-out;
|
| 463 |
}
|
| 464 |
|
| 465 |
+
#abortYesBtn, #abortYesBtn-pre, #cancelFeedbackStatusBtn2 {
|
| 466 |
background: #d9534f;
|
| 467 |
color: white;
|
| 468 |
}
|
| 469 |
|
| 470 |
+
#abortYesBtn:hover, #abortYesBtn-pre:hover, #cancelFeedbackStatusBtn2:hover {
|
| 471 |
background: #c9302c;
|
| 472 |
}
|
| 473 |
|
|
|
|
| 498 |
background: #ccc;
|
| 499 |
}
|
| 500 |
|
| 501 |
+
#welcomeOkBtn, #timerOkBtn, #submitFeedbackBtn, #cancelFeedbackStatusBtn {
|
| 502 |
background: green;
|
| 503 |
color: white;
|
| 504 |
}
|
| 505 |
|
| 506 |
+
#welcomeOkBtn:hover, #timerOkBtn:hover, #submitFeedbackBtn:hover, #cancelFeedbackStatusBtn:hover {
|
| 507 |
background: #016601;
|
| 508 |
}
|
| 509 |
|
chat_application/templates/room.html
CHANGED
|
@@ -30,7 +30,7 @@
|
|
| 30 |
<h2 id="room-code-display">Topic: <span class="topic-title">{{ topic_info.title }}</span></h2>
|
| 31 |
</div>
|
| 32 |
<div class="topic-header-buttons">
|
| 33 |
-
<button id="feedback-btn">
|
| 34 |
<button id="end-exp-btn">End Chat Session</button>
|
| 35 |
<button id="abort-exp-btn">Abort Experiment</button>
|
| 36 |
</div>
|
|
@@ -73,7 +73,7 @@
|
|
| 73 |
<h3>Feedback</h3>
|
| 74 |
<form id="feedback-form">
|
| 75 |
<div class="feedback-col">
|
| 76 |
-
<label for="enter-feedback">
|
| 77 |
<textarea id="enter-feedback" name="feedback"></textarea>
|
| 78 |
</div>
|
| 79 |
<br>
|
|
@@ -84,6 +84,23 @@
|
|
| 84 |
</form>
|
| 85 |
</div>
|
| 86 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
</div>
|
| 88 |
<div id="chat-room-widget">
|
| 89 |
<div id="msgs-container">
|
|
@@ -251,6 +268,8 @@
|
|
| 251 |
//handler for feedback modal popup
|
| 252 |
let feedbackModal = document.getElementById("feedback-modal");
|
| 253 |
let form = document.getElementById("feedback-form");
|
|
|
|
|
|
|
| 254 |
document.getElementById("feedback-btn").onclick = function () {
|
| 255 |
feedbackModal.style.display = "block";
|
| 256 |
};
|
|
@@ -258,6 +277,16 @@
|
|
| 258 |
feedbackModal.style.display = "none";
|
| 259 |
};
|
| 260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
//override form function to instead emit save feedback event
|
| 262 |
form.addEventListener("submit", function (e) {
|
| 263 |
e.preventDefault();
|
|
@@ -266,8 +295,13 @@
|
|
| 266 |
const feedback = data.get("feedback")?.trim();
|
| 267 |
|
| 268 |
if (!feedback) return;
|
| 269 |
-
|
| 270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
form.reset();
|
| 272 |
document.getElementById("feedback-modal").style.display = "none";
|
| 273 |
});
|
|
|
|
| 30 |
<h2 id="room-code-display">Topic: <span class="topic-title">{{ topic_info.title }}</span></h2>
|
| 31 |
</div>
|
| 32 |
<div class="topic-header-buttons">
|
| 33 |
+
<button id="feedback-btn">Share Feedback and Report Bugs</button>
|
| 34 |
<button id="end-exp-btn">End Chat Session</button>
|
| 35 |
<button id="abort-exp-btn">Abort Experiment</button>
|
| 36 |
</div>
|
|
|
|
| 73 |
<h3>Feedback</h3>
|
| 74 |
<form id="feedback-form">
|
| 75 |
<div class="feedback-col">
|
| 76 |
+
<label for="enter-feedback">Tell us if you noticed something confusing, unexpected, or not working.</label>
|
| 77 |
<textarea id="enter-feedback" name="feedback"></textarea>
|
| 78 |
</div>
|
| 79 |
<br>
|
|
|
|
| 84 |
</form>
|
| 85 |
</div>
|
| 86 |
</div>
|
| 87 |
+
|
| 88 |
+
<div id="feedback-status-confirm" class="modal">
|
| 89 |
+
<div class="modal-content">
|
| 90 |
+
<p>Feedback submitted.</p>
|
| 91 |
+
<div class="modal-buttons">
|
| 92 |
+
<button class="modal-btn" id="cancelFeedbackStatusBtn">Ok</button>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
<div id="feedback-status-fail" class="modal">
|
| 97 |
+
<div class="modal-content">
|
| 98 |
+
<p>Feedback failed to submit.</p>
|
| 99 |
+
<div class="modal-buttons">
|
| 100 |
+
<button class="modal-btn" id="cancelFeedbackStatusBtn2">Ok</button>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
</div>
|
| 104 |
</div>
|
| 105 |
<div id="chat-room-widget">
|
| 106 |
<div id="msgs-container">
|
|
|
|
| 268 |
//handler for feedback modal popup
|
| 269 |
let feedbackModal = document.getElementById("feedback-modal");
|
| 270 |
let form = document.getElementById("feedback-form");
|
| 271 |
+
let feedbackConfirm = document.getElementById("feedback-status-confirm");
|
| 272 |
+
let feedbackFail = document.getElementById("feedback-status-fail");
|
| 273 |
document.getElementById("feedback-btn").onclick = function () {
|
| 274 |
feedbackModal.style.display = "block";
|
| 275 |
};
|
|
|
|
| 277 |
feedbackModal.style.display = "none";
|
| 278 |
};
|
| 279 |
|
| 280 |
+
document.getElementById("cancelFeedbackStatusBtn").onclick = function () {
|
| 281 |
+
feedbackConfirm.style.display = "none";
|
| 282 |
+
feedbackFail.style.display = "none";
|
| 283 |
+
};
|
| 284 |
+
|
| 285 |
+
document.getElementById("cancelFeedbackStatusBtn2").onclick = function () {
|
| 286 |
+
feedbackConfirm.style.display = "none";
|
| 287 |
+
feedbackFail.style.display = "none";
|
| 288 |
+
};
|
| 289 |
+
|
| 290 |
//override form function to instead emit save feedback event
|
| 291 |
form.addEventListener("submit", function (e) {
|
| 292 |
e.preventDefault();
|
|
|
|
| 295 |
const feedback = data.get("feedback")?.trim();
|
| 296 |
|
| 297 |
if (!feedback) return;
|
| 298 |
+
|
| 299 |
+
socketio.emit("feedback_given", { feedback }, (response) => {
|
| 300 |
+
if (response?.status === "True" || response?.status === true) {
|
| 301 |
+
feedbackConfirm.style.display = "block";
|
| 302 |
+
}
|
| 303 |
+
});
|
| 304 |
+
|
| 305 |
form.reset();
|
| 306 |
document.getElementById("feedback-modal").style.display = "none";
|
| 307 |
});
|