Skip to content

Commit

Permalink
close #57
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Sep 23, 2022
1 parent ca78541 commit b5144cb
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 5 deletions.
37 changes: 37 additions & 0 deletions client/multiplayer/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,43 @@ <h5 class="text-center">Subcategories</h5>
</div>
</div>

<div class="modal" id="report-question-modal" tabindex="-2">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Report Question</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<div class="mb-3">
<label for="report-question-id" class="col-form-label">Question ID:</label>
<input type="text" class="form-control" id="report-question-id" disabled>
</div>
<div class="mb-3">
<label for="report-question-reason" class="col-form-label">Reason:</label>
<select class="form-select" id="report-question-reason" aria-label="Default select example">
<option value="answerline-formatting" selected>Answerline formatting error</option>
<option value="missing-parts">Missing parts of question/answer</option>
<option value="unnecessary-parts">Unnecessary parts in question/answer</option>
<option value="answerline-parsing">Incorrect answerline parsing</option>
<option value="other">Other</option>
</select>
</div>
<div>
<label for="report-question-description" class="col-form-label">Additional Information:</label>
<textarea class="form-control" id="report-question-description" rows="3"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="report-question-submit">Submit</button>
</div>
</div>
</div>
</div>

<script src="/bootstrap/bootstrap.bundle.min.js"></script>
<script src="/script.js"></script>

Expand Down
19 changes: 14 additions & 5 deletions client/quizbowl.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const createTossupCard = (function () {
<div class="card-body">
<p class="card-text">
${question}
<a href="#" id="report-question-${_id}">Report Question</a>
<a href="#" id="report-question-${_id}" data-bs-toggle="modal" data-bs-target="#report-question-modal">Report Question</a>
</p>
</div>
<div class="card-footer">
Expand All @@ -103,8 +103,7 @@ const createTossupCard = (function () {
document.getElementById('room-history').prepend(card);

document.getElementById('report-question-' + _id).addEventListener('click', function (e) {
e.preventDefault();
reportQuestion(_id);
document.getElementById('report-question-id').value = _id;
});
}
})();
Expand Down Expand Up @@ -188,14 +187,16 @@ function rangeToArray(string, max = 0) {
}


function reportQuestion(_id) {
function reportQuestion(_id, reason="", description="") {
fetch('/api/report-question', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
_id: _id
_id: _id,
reason: reason,
description: description
})
}).then(response => {
if (response.status === 200) {
Expand Down Expand Up @@ -267,6 +268,14 @@ document.getElementById('font-size').addEventListener('input', function () {
document.getElementById('question').style.setProperty('font-size', `${this.value}px`);
});

document.getElementById('report-question-submit').addEventListener('click', function () {
reportQuestion(
document.getElementById('report-question-id').value,
document.getElementById('report-question-reason').value,
document.getElementById('report-question-description').value
);
});

document.getElementById('toggle-high-contrast-question-text').addEventListener('click', function () {
this.blur();
if (this.checked) {
Expand Down
37 changes: 37 additions & 0 deletions client/singleplayer/bonuses.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,43 @@ <h5 class="text-center">Subcategories</h5>
</div>
</div>

<div class="modal" id="report-question-modal" tabindex="-2">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Report Question</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<div class="mb-3">
<label for="report-question-id" class="col-form-label">Question ID:</label>
<input type="text" class="form-control" id="report-question-id" disabled>
</div>
<div class="mb-3">
<label for="report-question-reason" class="col-form-label">Reason:</label>
<select class="form-select" id="report-question-reason" aria-label="Default select example">
<option value="answerline-formatting" selected>Answerline formatting error</option>
<option value="missing-parts">Missing parts of question/answer</option>
<option value="unnecessary-parts">Unnecessary parts in question/answer</option>
<option value="answerline-parsing">Incorrect answerline parsing</option>
<option value="other">Other</option>
</select>
</div>
<div>
<label for="report-question-description" class="col-form-label">Additional Information:</label>
<textarea class="form-control" id="report-question-description" rows="3"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="report-question-submit">Submit</button>
</div>
</div>
</div>
</div>

<script src="/bootstrap/bootstrap.bundle.min.js"></script>
<script src="/script.js"></script>

Expand Down
37 changes: 37 additions & 0 deletions client/singleplayer/tossups.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,43 @@ <h5 class="text-center">Subcategories</h5>
</div>
</div>

<div class="modal" id="report-question-modal" tabindex="-2">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Report Question</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<div class="mb-3">
<label for="report-question-id" class="col-form-label">Question ID:</label>
<input type="text" class="form-control" id="report-question-id" disabled>
</div>
<div class="mb-3">
<label for="report-question-reason" class="col-form-label">Reason:</label>
<select class="form-select" id="report-question-reason" aria-label="Default select example">
<option value="answerline-formatting" selected>Answerline formatting error</option>
<option value="missing-parts">Missing parts of question/answer</option>
<option value="unnecessary-parts">Unnecessary parts in question/answer</option>
<option value="answerline-parsing">Incorrect answerline parsing</option>
<option value="other">Other</option>
</select>
</div>
<div>
<label for="report-question-description" class="col-form-label">Additional Information:</label>
<textarea class="form-control" id="report-question-description" rows="3"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="report-question-submit">Submit</button>
</div>
</div>
</div>
</div>

<script src="/bootstrap/bootstrap.bundle.min.js"></script>
<script src="/script.js"></script>

Expand Down

0 comments on commit b5144cb

Please sign in to comment.