diff --git a/client/admin/category-reports.js b/client/admin/category-reports.js index 6e484cab..0266f4cd 100644 --- a/client/admin/category-reports.js +++ b/client/admin/category-reports.js @@ -54,7 +54,6 @@ function TossupCard({ const reason = tossup.reports.map(report => report.description).join('; ') || 'None given'; document.getElementById('report-reason').value = reason; } - const powerParts = tossup.question.split('(*)'); return /*#__PURE__*/React.createElement("div", { className: "card my-2" }, /*#__PURE__*/React.createElement("div", { @@ -68,13 +67,13 @@ function TossupCard({ className: "card-body" }, /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: powerParts.length > 1 ? '' + powerParts[0] + '(*)' + powerParts[1] : tossup.question + __html: tossup.question } }), /*#__PURE__*/React.createElement("hr", { className: "my-3" }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("b", null, "ANSWER:"), " ", /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: tossup?.formatted_answer ?? tossup.answer + __html: tossup?.answer } }))), /*#__PURE__*/React.createElement("div", { className: "card-footer clickable", @@ -102,7 +101,7 @@ function BonusCard({ } function getBonusPartLabel(index, defaultValue = 10, defaultDifficulty = '') { const value = bonus.values ? bonus.values[index] ?? defaultValue : defaultValue; - const difficulty = bonus.difficulties ? bonus.difficulties[index] ?? defaultDifficulty : defaultDifficulty; + const difficulty = bonus.difficultyModifiers ? bonus.difficultyModifiers[index] ?? defaultDifficulty : defaultDifficulty; return `[${value}${difficulty}]`; } function onClick() { @@ -127,7 +126,7 @@ function BonusCard({ key: `${bonus._id}-${i}` }, /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("span", null, getBonusPartLabel(i), " "), /*#__PURE__*/React.createElement("span", null, bonus.parts[i])), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("b", null, "ANSWER: "), /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: (bonus?.formatted_answers ?? bonus.answers)[i] + __html: bonus?.answers[i] } }))))), /*#__PURE__*/React.createElement("div", { className: "card-footer clickable", diff --git a/client/admin/category-reports.jsx b/client/admin/category-reports.jsx index 15f9b3f2..1d18dbe2 100644 --- a/client/admin/category-reports.jsx +++ b/client/admin/category-reports.jsx @@ -59,8 +59,6 @@ function TossupCard({ tossup }) { document.getElementById('report-reason').value = reason; } - const powerParts = tossup.question.split('(*)'); - return (
@@ -73,13 +71,9 @@ function TossupCard({ tossup }) {
- 1 ? '' + powerParts[0] + '(*)' + powerParts[1] : tossup.question, - }}> +
-
ANSWER:
+
ANSWER:
{packetName ? 'Packet ' + packetName :  } @@ -105,7 +99,7 @@ function BonusCard({ bonus }) { function getBonusPartLabel(index, defaultValue = 10, defaultDifficulty = '') { const value = bonus.values ? (bonus.values[index] ?? defaultValue) : defaultValue; - const difficulty = bonus.difficulties ? (bonus.difficulties[index] ?? defaultDifficulty) : defaultDifficulty; + const difficulty = bonus.difficultyModifiers ? (bonus.difficultyModifiers[index] ?? defaultDifficulty) : defaultDifficulty; return `[${value}${difficulty}]`; } @@ -140,7 +134,7 @@ function BonusCard({ bonus }) {

ANSWER: - +
, )} diff --git a/client/admin/geoword/compare.js b/client/admin/geoword/compare.js index 5522fb79..57ae55fb 100644 --- a/client/admin/geoword/compare.js +++ b/client/admin/geoword/compare.js @@ -127,7 +127,7 @@ document.getElementById('form').addEventListener('submit', event => {
Given answer: ${escapeHTML(myBuzz.givenAnswer)}
-
Answer: ${removeParentheses(myBuzz.formatted_answer ?? myBuzz.answer)}
+
Answer: ${removeParentheses(myBuzz.answer)}
Celerity: ${(opponentBuzz.celerity ?? 0.0).toFixed(3)}
Points: ${opponentBuzz.points}
Given answer: ${escapeHTML(opponentBuzz.givenAnswer)}
diff --git a/client/admin/geoword/protests.js b/client/admin/geoword/protests.js index c9a2bc4e..a508c813 100644 --- a/client/admin/geoword/protests.js +++ b/client/admin/geoword/protests.js @@ -15,7 +15,7 @@ fetch('/api/admin/geoword/protests?' + new URLSearchParams({ packetName, divisio const { questionNumber } = tossup; innerHTML += `
${tossup.questionNumber}. ${tossup.question}
`; // innerHTML += '
'; - innerHTML += `
ANSWER: ${tossup.formatted_answer ?? tossup.answer}
`; + innerHTML += `
ANSWER: ${tossup.answer}
`; innerHTML += `

<${tossup.category} / ${tossup.subcategory}>

`; if (protests.filter(protest => protest.questionNumber === questionNumber).length === 0) { @@ -55,7 +55,7 @@ fetch('/api/admin/geoword/protests?' + new URLSearchParams({ packetName, divisio a.addEventListener('click', () => { document.getElementById('resolve-protest-id').value = a.id; document.getElementById('resolve-protest-given-answer').value = document.getElementById(`given-answer-${a.id}`).textContent; - document.getElementById('resolve-protest-actual-answer').innerHTML = packet[parseInt(a.attributes.question.value) - 1].formatted_answer; + document.getElementById('resolve-protest-actual-answer').innerHTML = packet[parseInt(a.attributes.question.value) - 1].answer; }); }); }); diff --git a/client/admin/geoword/stats.js b/client/admin/geoword/stats.js index 4f6f2bac..3140b08b 100644 --- a/client/admin/geoword/stats.js +++ b/client/admin/geoword/stats.js @@ -19,7 +19,7 @@ fetch('/api/admin/geoword/stats?' + new URLSearchParams({ packetName, division }
#${stats[i].tossup.questionNumber}
Times heard: ${stats[i].timesHeard}
Number correct: ${stats[i].numberCorrect}
-
Answer: ${stats[i].tossup.formatted_answer}
+
Answer: ${stats[i].tossup.answer}
Best buzz: ${stats[i].bestUsername}
diff --git a/client/api-docs/schemas.html b/client/api-docs/schemas.html index db5d0273..713a9922 100644 --- a/client/api-docs/schemas.html +++ b/client/api-docs/schemas.html @@ -159,7 +159,7 @@

Tossup

  • - formatted_answer: string + answer: string optional
    The answerline, formatted with HTML.
    @@ -290,7 +290,7 @@

    Bonus

  • - formatted_answers: [string, string, string] + answers: [string, string, string] optional
    The answerlines, formatted with HTML.
    diff --git a/client/database/index.js b/client/database/index.js index 5fc1bf30..0bd6ff9c 100644 --- a/client/database/index.js +++ b/client/database/index.js @@ -22,7 +22,7 @@ function escapeCSVString(string) { return `"${string.replace(/"/g, '""').replace(/\n/g, '\\n')}"`; } function downloadTossupsAsCSV(tossups, filename = 'tossups.csv') { - const header = ['_id', 'set.name', 'packet.number', 'number', 'question', 'answer', 'formatted_answer', 'category', 'subcategory', 'alternate_subcategory', 'difficulty', 'set._id', 'packet._id', 'createdAt', 'updatedAt']; + const header = ['_id', 'set.name', 'packet.number', 'number', 'question', 'answer', 'answer', 'category', 'subcategory', 'alternate_subcategory', 'difficulty', 'set._id', 'packet._id', 'createdAt', 'updatedAt']; let csvdata = header.join(',') + '\n'; for (const tossup of tossups) { for (const key of header) { @@ -47,7 +47,7 @@ function downloadTossupsAsCSV(tossups, filename = 'tossups.csv') { hiddenElement.click(); } function downloadBonusesAsCSV(bonuses, filename = 'bonuses.csv') { - const header = ['_id', 'set.name', 'packet.number', 'number', 'leadin', 'parts.0', 'parts.1', 'parts.2', 'answers.0', 'answers.1', 'answers.2', 'formatted_answers.0', 'formatted_answers.1', 'formatted_answers.2', 'category', 'subcategory', 'alternate_subcategory', 'difficulty', 'set._id', 'packet._id', 'createdAt', 'updatedAt']; + const header = ['_id', 'set.name', 'packet.number', 'number', 'leadin', 'parts.0', 'parts.1', 'parts.2', 'answers_sanitized.0', 'answers_sanitized.1', 'answers_sanitized.2', 'answers.0', 'answers.1', 'answers.2', 'category', 'subcategory', 'alternate_subcategory', 'difficulty', 'set._id', 'packet._id', 'createdAt', 'updatedAt']; let csvdata = header.join(',') + '\n'; for (const bonus of bonuses) { for (const key of header) { @@ -77,7 +77,7 @@ function downloadQuestionsAsText(tossups, bonuses, filename = 'data.txt') { textdata += `${tossup.set.name} Packet ${tossup.packet.number}\n`; textdata += `Question ID: ${tossup._id}\n`; textdata += `${tossup.number}. ${tossup.question}\n`; - textdata += `ANSWER: ${tossup.answer}\n`; + textdata += `ANSWER: ${tossup.answer_sanitized}\n`; textdata += `<${tossup.category} / ${tossup.subcategory}${tossup.alternate_subcategory ? ' (' + tossup.alternate_subcategory + ')' : ''}>\n\n`; } for (const bonus of bonuses) { @@ -85,7 +85,7 @@ function downloadQuestionsAsText(tossups, bonuses, filename = 'data.txt') { textdata += `${bonus.set.name} Packet ${bonus.packet.number}\n`; textdata += `${bonus.number}. ${bonus.leadin}\n`; for (let i = 0; i < bonus.parts.length; i++) { - textdata += `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}\nANSWER: ${bonus.answers[i]}\n`; + textdata += `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}\nANSWER: ${bonus.answers_sanitized[i]}\n`; } textdata += `<${bonus.category} / ${bonus.subcategory}${bonus.alternate_subcategory ? ' (' + bonus.alternate_subcategory + ')' : ''}>\n\n`; } @@ -107,7 +107,7 @@ function downloadQuestionsAsText(tossups, bonuses, filename = 'data.txt') { */ function getBonusPartLabel(bonus, index, defaultValue = 10, defaultDifficulty = '') { const value = bonus.values ? bonus.values[index] ?? defaultValue : defaultValue; - const difficulty = bonus.difficulties ? bonus.difficulties[index] ?? defaultDifficulty : defaultDifficulty; + const difficulty = bonus.difficultyModifiers ? bonus.difficultyModifiers[index] ?? defaultDifficulty : defaultDifficulty; return `[${value}${difficulty}]`; } function getMatchIndices(clean, regex) { @@ -195,14 +195,10 @@ function highlightTossupQuery({ const words = ignoreWordOrder ? queryString.split(' ').filter(word => word !== '').map(word => new RegExp(word, 'ig')) : [regExp]; for (const word of words) { if (searchType === 'question' || searchType === 'all') { - tossup.question = insertMatches(tossup.question, tossup.unformatted_question, word); + tossup.question = insertMatches(tossup.question, tossup.question_sanitized, word); } if (searchType === 'answer' || searchType === 'all') { - if (tossup.formatted_answer) { - tossup.formatted_answer = insertMatches(tossup.formatted_answer, tossup.unformatted_answer, word); - } else { - tossup.answer = insertMatches(tossup.answer, tossup.unformatted_answer, word); - } + tossup.answer = insertMatches(tossup.answer, tossup.answer_sanitized, word); } } return tossup; @@ -217,20 +213,14 @@ function highlightBonusQuery({ const words = ignoreWordOrder ? queryString.split(' ').filter(word => word !== '').map(word => new RegExp(word, 'ig')) : [regExp]; for (const word of words) { if (searchType === 'question' || searchType === 'all') { - bonus.leadin = insertMatches(bonus.leadin, bonus.unformatted_leadin, word); + bonus.leadin = insertMatches(bonus.leadin, bonus.leadin_sanitized, word); for (let i = 0; i < bonus.parts.length; i++) { - bonus.parts[i] = insertMatches(bonus.parts[i], bonus.unformatted_parts[i], word); + bonus.parts[i] = insertMatches(bonus.parts[i], bonus.parts_sanitized[i], word); } } if (searchType === 'answer' || searchType === 'all') { - if (bonus.formatted_answers) { - for (let i = 0; i < bonus.formatted_answers.length; i++) { - bonus.formatted_answers[i] = insertMatches(bonus.formatted_answers[i], bonus.unformatted_answers[i], word); - } - } else { - for (let i = 0; i < bonus.answers.length; i++) { - bonus.answers[i] = insertMatches(bonus.answers[i], bonus.unformatted_answers[i], word); - } + for (let i = 0; i < bonus.answers.length; i++) { + bonus.answers[i] = insertMatches(bonus.answers[i], bonus.answers_sanitized[i], word); } } } @@ -246,7 +236,7 @@ function TossupCard({ const _id = tossup._id; const packetName = tossup.packet.name; function clickToCopy() { - let textdata = `${tossup.question}\nANSWER: ${tossup.answer}`; + let textdata = `${tossup.question}\nANSWER: ${tossup.answer_sanitized}`; let tag = ''; if (tossup.category && tossup.subcategory && tossup.category !== tossup.subcategory) { tag += `${tossup.category} / ${tossup.subcategory}`; @@ -326,7 +316,6 @@ function TossupCard({ console.error('Error:', error); }); } - const powerParts = highlightedTossup.question.split('(*)'); return /*#__PURE__*/React.createElement("div", { className: "card my-2" }, /*#__PURE__*/React.createElement("div", { @@ -348,13 +337,13 @@ function TossupCard({ } }, /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: powerParts.length > 1 ? '' + powerParts[0] + '(*)' + powerParts[1] : highlightedTossup.question + __html: highlightedTossup.question } }), /*#__PURE__*/React.createElement("hr", { className: "my-3" }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("b", null, "ANSWER:"), " ", /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: hideAnswerline ? '' : highlightedTossup?.formatted_answer ?? highlightedTossup.answer + __html: hideAnswerline ? '' : highlightedTossup?.answer } }))), /*#__PURE__*/React.createElement("div", { className: `card-footer clickable ${!showCardFooter && 'd-none'}`, @@ -391,7 +380,7 @@ function BonusCard({ let textdata = `${bonus.leadin}\n`; for (let i = 0; i < bonus.parts.length; i++) { textdata += `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}\n`; - textdata += `ANSWER: ${bonus.answers[i]}\n`; + textdata += `ANSWER: ${bonus.answers_sanitized[i]}\n`; } let tag = ''; if (bonus.category && bonus.subcategory && bonus.category !== bonus.subcategory) { @@ -502,7 +491,7 @@ function BonusCard({ } })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("b", null, "ANSWER: "), /*#__PURE__*/React.createElement("span", { dangerouslySetInnerHTML: { - __html: hideAnswerlines ? '' : (highlightedBonus?.formatted_answers ?? highlightedBonus.answers)[i] + __html: hideAnswerlines ? '' : highlightedBonus?.answers[i] } }))))), /*#__PURE__*/React.createElement("div", { className: `card-footer clickable ${!showCardFooter && 'd-none'}`, diff --git a/client/database/index.jsx b/client/database/index.jsx index a8f2d7da..e879cbbd 100644 --- a/client/database/index.jsx +++ b/client/database/index.jsx @@ -97,7 +97,7 @@ function downloadTossupsAsCSV(tossups, filename = 'tossups.csv') { 'number', 'question', 'answer', - 'formatted_answer', + 'answer', 'category', 'subcategory', 'alternate_subcategory', @@ -145,12 +145,12 @@ function downloadBonusesAsCSV(bonuses, filename = 'bonuses.csv') { 'parts.0', 'parts.1', 'parts.2', + 'answers_sanitized.0', + 'answers_sanitized.1', + 'answers_sanitized.2', 'answers.0', 'answers.1', 'answers.2', - 'formatted_answers.0', - 'formatted_answers.1', - 'formatted_answers.2', 'category', 'subcategory', 'alternate_subcategory', @@ -195,7 +195,7 @@ function downloadQuestionsAsText(tossups, bonuses, filename = 'data.txt') { textdata += `${tossup.set.name} Packet ${tossup.packet.number}\n`; textdata += `Question ID: ${tossup._id}\n`; textdata += `${tossup.number}. ${tossup.question}\n`; - textdata += `ANSWER: ${tossup.answer}\n`; + textdata += `ANSWER: ${tossup.answer_sanitized}\n`; textdata += `<${tossup.category} / ${tossup.subcategory}${tossup.alternate_subcategory ? ' (' + tossup.alternate_subcategory + ')' : ''}>\n\n`; } @@ -204,7 +204,7 @@ function downloadQuestionsAsText(tossups, bonuses, filename = 'data.txt') { textdata += `${bonus.set.name} Packet ${bonus.packet.number}\n`; textdata += `${bonus.number}. ${bonus.leadin}\n`; for (let i = 0; i < bonus.parts.length; i++) { - textdata += `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}\nANSWER: ${bonus.answers[i]}\n`; + textdata += `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}\nANSWER: ${bonus.answers_sanitized[i]}\n`; } textdata += `<${bonus.category} / ${bonus.subcategory}${bonus.alternate_subcategory ? ' (' + bonus.alternate_subcategory + ')' : ''}>\n\n`; } @@ -228,7 +228,7 @@ function downloadQuestionsAsText(tossups, bonuses, filename = 'data.txt') { */ function getBonusPartLabel(bonus, index, defaultValue = 10, defaultDifficulty = '') { const value = bonus.values ? (bonus.values[index] ?? defaultValue) : defaultValue; - const difficulty = bonus.difficulties ? (bonus.difficulties[index] ?? defaultDifficulty) : defaultDifficulty; + const difficulty = bonus.difficultyModifiers ? (bonus.difficultyModifiers[index] ?? defaultDifficulty) : defaultDifficulty; return `[${value}${difficulty}]`; } @@ -331,15 +331,11 @@ function highlightTossupQuery({ tossup, regExp, searchType = 'all', ignoreWordOr for (const word of words) { if (searchType === 'question' || searchType === 'all') { - tossup.question = insertMatches(tossup.question, tossup.unformatted_question, word); + tossup.question = insertMatches(tossup.question, tossup.question_sanitized, word); } if (searchType === 'answer' || searchType === 'all') { - if (tossup.formatted_answer) { - tossup.formatted_answer = insertMatches(tossup.formatted_answer, tossup.unformatted_answer, word); - } else { - tossup.answer = insertMatches(tossup.answer, tossup.unformatted_answer, word); - } + tossup.answer = insertMatches(tossup.answer, tossup.answer_sanitized, word); } } @@ -354,21 +350,15 @@ function highlightBonusQuery({ bonus, regExp, searchType = 'all', ignoreWordOrde for (const word of words) { if (searchType === 'question' || searchType === 'all') { - bonus.leadin = insertMatches(bonus.leadin, bonus.unformatted_leadin, word); + bonus.leadin = insertMatches(bonus.leadin, bonus.leadin_sanitized, word); for (let i = 0; i < bonus.parts.length; i++) { - bonus.parts[i] = insertMatches(bonus.parts[i], bonus.unformatted_parts[i], word); + bonus.parts[i] = insertMatches(bonus.parts[i], bonus.parts_sanitized[i], word); } } if (searchType === 'answer' || searchType === 'all') { - if (bonus.formatted_answers) { - for (let i = 0; i < bonus.formatted_answers.length; i++) { - bonus.formatted_answers[i] = insertMatches(bonus.formatted_answers[i], bonus.unformatted_answers[i], word); - } - } else { - for (let i = 0; i < bonus.answers.length; i++) { - bonus.answers[i] = insertMatches(bonus.answers[i], bonus.unformatted_answers[i], word); - } + for (let i = 0; i < bonus.answers.length; i++) { + bonus.answers[i] = insertMatches(bonus.answers[i], bonus.answers_sanitized[i], word); } } } @@ -382,7 +372,7 @@ function TossupCard({ tossup, highlightedTossup, hideAnswerline, showCardFooter, const packetName = tossup.packet.name; function clickToCopy() { - let textdata = `${tossup.question}\nANSWER: ${tossup.answer}`; + let textdata = `${tossup.question}\nANSWER: ${tossup.answer_sanitized}`; let tag = ''; if (tossup.category && tossup.subcategory && tossup.category !== tossup.subcategory) { @@ -471,8 +461,6 @@ function TossupCard({ tossup, highlightedTossup, hideAnswerline, showCardFooter, }); } - const powerParts = highlightedTossup.question.split('(*)'); - return (
    @@ -485,14 +473,10 @@ function TossupCard({ tossup, highlightedTossup, hideAnswerline, showCardFooter,
    - 1 ? '' + powerParts[0] + '(*)' + powerParts[1] : highlightedTossup.question, - }}> +
    - ANSWER: + ANSWER:
    @@ -523,7 +507,7 @@ function BonusCard({ bonus, highlightedBonus, hideAnswerlines, showCardFooter, f let textdata = `${bonus.leadin}\n`; for (let i = 0; i < bonus.parts.length; i++) { textdata += `${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}\n`; - textdata += `ANSWER: ${bonus.answers[i]}\n`; + textdata += `ANSWER: ${bonus.answers_sanitized[i]}\n`; } let tag = ''; @@ -636,7 +620,7 @@ function BonusCard({ bonus, highlightedBonus, hideAnswerlines, showCardFooter, f
    ANSWER:
    , diff --git a/client/geoword/compare.js b/client/geoword/compare.js index 1f8aceb3..29e2239a 100644 --- a/client/geoword/compare.js +++ b/client/geoword/compare.js @@ -79,7 +79,7 @@ document.getElementById('form').addEventListener('submit', event => {
    Given answer: ${escapeHTML(myBuzz.givenAnswer)}
    -
    Answer: ${removeParentheses(myBuzz.formatted_answer ?? myBuzz.answer)}
    +
    Answer: ${removeParentheses(myBuzz.answer)}
    Celerity: ${(opponentBuzz.celerity ?? 0.0).toFixed(3)}
    Points: ${opponentBuzz.points}
    Given answer: ${escapeHTML(opponentBuzz.givenAnswer)}
    diff --git a/client/geoword/packet.js b/client/geoword/packet.js index 9b473c0a..677121d0 100644 --- a/client/geoword/packet.js +++ b/client/geoword/packet.js @@ -18,7 +18,7 @@ fetch('/api/geoword/packet?' + new URLSearchParams({ packetName, division })) for (const tossup of packet) { innerHTML += `
    ${tossup.questionNumber}. ${tossup.question}
    `; - innerHTML += `
    ANSWER: ${tossup.formatted_answer ?? tossup.answer}
    `; + innerHTML += `
    ANSWER: ${tossup.answer}
    `; innerHTML += `

    <${tossup.category} / ${tossup.subcategory}>

    `; innerHTML += '
    '; } diff --git a/client/geoword/stats.js b/client/geoword/stats.js index e035ab63..0666400a 100644 --- a/client/geoword/stats.js +++ b/client/geoword/stats.js @@ -44,7 +44,7 @@ fetch('/api/geoword/stats?' + new URLSearchParams({ packetName }))
    Best celerity: ${(leaderboard[i].bestCelerity ?? 0.0).toFixed(3)}
    Average correct celerity: ${(leaderboard[i].averageCorrectCelerity ?? 0).toFixed(3)}
    Average points: ${(leaderboard[i].averagePoints ?? 0.0).toFixed(2)}
    -
    Answer: ${buzzArray[i].formatted_answer}
    +
    Answer: ${buzzArray[i].answer}

    diff --git a/client/multiplayer/room.js b/client/multiplayer/room.js index c39290f4..b9f56d72 100644 --- a/client/multiplayer/room.js +++ b/client/multiplayer/room.js @@ -147,20 +147,10 @@ socket.onmessage = function (event) { break; case 'reveal-answer': { + document.getElementById('question').innerHTML = tossup.question; document.getElementById('answer').innerHTML = 'ANSWER: ' + data.answer; document.getElementById('pause').disabled = true; showNextButton(); - - question = document.getElementById('question').innerHTML; - if (powermarkPosition) { - question = question.slice(0, powermarkPosition) + '(*) ' + question.slice(powermarkPosition); - } - const powerParts = question.split('(*)'); - if (powerParts.length > 1) { - document.getElementById('question').innerHTML = `${powerParts[0]}(*)${powerParts[1]}`; - } else { - document.getElementById('question').textContent = question; - } break; } diff --git a/client/singleplayer/bonuses.js b/client/singleplayer/bonuses.js index 515b3c09..c2494618 100644 --- a/client/singleplayer/bonuses.js +++ b/client/singleplayer/bonuses.js @@ -326,14 +326,7 @@ async function loadRandomBonuses({ alternateSubcategories, categories, difficult await fetch('/api/random-bonus?' + new URLSearchParams({ alternateSubcategories, categories, difficulties, maxYear, minYear, number, subcategories, threePartBonuses })) .then(response => response.json()) .then(response => response.bonuses) - .then(questions => { - for (let i = 0; i < questions.length; i++) { - if (Object.prototype.hasOwnProperty.call(questions[i], 'formatted_answers')) - questions[i].answers = questions[i].formatted_answers; - } - - randomQuestions = questions; - }); + .then(questions => { randomQuestions = questions; }); } diff --git a/client/singleplayer/tossups.js b/client/singleplayer/tossups.js index c2013b5d..e5b647ca 100644 --- a/client/singleplayer/tossups.js +++ b/client/singleplayer/tossups.js @@ -196,7 +196,7 @@ async function advanceQuestion() { } while (!isValidCategory(questions[questionNumber - 1], query.categories, query.subcategories)); if (Object.keys(questions[0]).length > 0) { - questionText = questions[questionNumber - 1].question; + questionText = questions[questionNumber - 1].question_sanitized; questionTextSplit = questionText.split(' ').filter(word => word !== ''); document.getElementById('question-number-info').textContent = questionNumber; } @@ -344,14 +344,7 @@ async function loadRandomTossups({ alternateSubcategories, categories, difficult await fetch('/api/random-tossup?' + new URLSearchParams({ alternateSubcategories, categories, difficulties, maxYear, minYear, number, powermarkOnly, subcategories, standardOnly })) .then(response => response.json()) .then(response => response.tossups) - .then(questions => { - for (let i = 0; i < questions.length; i++) { - if (Object.prototype.hasOwnProperty.call(questions[i], 'formatted_answer')) - questions[i].answer = questions[i].formatted_answer; - } - - randomQuestions = questions; - }); + .then(questions => { randomQuestions = questions; }); } @@ -476,13 +469,8 @@ function readQuestion(expectedReadTime) { function revealQuestion() { + document.getElementById('question').innerHTML = questions[questionNumber - 1].question; document.getElementById('answer').innerHTML = 'ANSWER: ' + questions[questionNumber - 1].answer; - let question = (document.getElementById('question').innerHTML); - if (powermarkPosition) - question = question.slice(0, powermarkPosition) + '(*) ' + question.slice(powermarkPosition); - - const powerParts = (question + questionTextSplit.join(' ')).split('(*)'); - document.getElementById('question').innerHTML = `${powerParts.length > 1 ? '' + powerParts[0] + '(*)' + powerParts[1] : powerParts[0]}`; document.getElementById('buzz').disabled = true; document.getElementById('buzz').textContent = 'Buzz'; diff --git a/client/user/stars/bonuses.js b/client/user/stars/bonuses.js index 3d5931b1..43807059 100644 --- a/client/user/stars/bonuses.js +++ b/client/user/stars/bonuses.js @@ -11,7 +11,7 @@ fetch('/auth/stars/bonuses')

    ${getBonusPartLabel(bonus, i)} ${bonus.parts[i]}

    -
    ANSWER: ${(bonus?.formatted_answers ?? bonus.answers)[i]}
    +
    ANSWER: ${bonus?.answers[i]}
    `; } @@ -65,6 +65,6 @@ fetch('/auth/stars/bonuses') function getBonusPartLabel(bonus, index, defaultValue = 10, defaultDifficulty = '') { const value = bonus.values ? (bonus.values[index] ?? defaultValue) : defaultValue; - const difficulty = bonus.difficulties ? (bonus.difficulties[index] ?? defaultDifficulty) : defaultDifficulty; + const difficulty = bonus.difficultyModifiers ? (bonus.difficultyModifiers[index] ?? defaultDifficulty) : defaultDifficulty; return `[${value}${difficulty}]`; } diff --git a/client/user/stars/tossups.js b/client/user/stars/tossups.js index 4fc6234d..297a947a 100644 --- a/client/user/stars/tossups.js +++ b/client/user/stars/tossups.js @@ -20,7 +20,7 @@ fetch('/auth/stars/tossups')
    ${tossup.question} 
    -
    ANSWER: ${tossup.formatted_answer ?? tossup.answer}
    +
    ANSWER: ${tossup.answer}