Skip to content

Commit

Permalink
Added new revision question type
Browse files Browse the repository at this point in the history
  • Loading branch information
GrimReaper2654 committed Dec 18, 2024
1 parent 20284dc commit 114d3d0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
42 changes: 40 additions & 2 deletions revision11.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<div class="content">
<h1>Eternal Grindset: Year 11</h1>
<p>Project Eternal Grindset aims to provide a literally endless supply of practice questions by generating variations of existing questions. Theoretically, it should be impossible for any human to complete every question or even see a duplicate for a single topic, even if they spent the entire 2 years of ATAR grinding only these questions. For those who have already completed every last past paper in existence, this is the tool for you.</p>
<p>Alternatively, since these questions are all rather similar, it could be a fun challenge to wite a program that can consistently solve these. It should be possible.</p>
<p>Infinite questions --> "eternal"<br>Constant revision --> "grindset"</p>
<div id="resultCompletingSquare" class="box whiteBackground">
<div class="resultTopRow">
Expand All @@ -35,15 +34,54 @@ <h3 class="alignLeft">[Math] Completing the Square</h3><span class="arrow alignR
<button class="standardButton" onclick="newQuestion('CompletingSquare')">New Question</button>
</div>
</div>
<div id="resultFactorise" class="box whiteBackground">
<div class="resultTopRow">
<button id="buttonFactorise" class="toggleButton" onclick="toggleContent('Factorise', true)">
<h3 class="alignLeft">[Math] Factorising Quadratics</h3><span class="arrow alignRight"></span>
</button>
</div>
<div class="extraContent" id="extraContentFactorise">
<div id="questionFactorise">
<p>Click "New Question" to generate a new question.</p>
</div>
<div id="answerFactorise" class="hidden">

</div>
<div class="verticalSpacer"></div>
<button class="standardButton" onclick="toggleAns('Factorise')">Reveal Answer</button>
<div class="horizontalSpacer"></div>
<button class="standardButton" onclick="newQuestion('Factorise')">New Question</button>
</div>
</div>
<div id="resultSolveCubic" class="box whiteBackground">
<div class="resultTopRow">
<button id="buttonSolveCubic" class="toggleButton" onclick="toggleContent('SolveCubic', true)">
<h3 class="alignLeft">[Math] Solving Cubics</h3><span class="arrow alignRight"></span>
</button>
</div>
<div class="extraContent" id="extraContentSolveCubic">
<div id="questionSolveCubic">
<p>Click "New Question" to generate a new question. Not done yet</p>
</div>
<div id="answerSolveCubic" class="hidden">

</div>
<div class="verticalSpacer"></div>
<button class="standardButton" onclick="toggleAns('SolveCubic')">Reveal Answer</button>
<div class="horizontalSpacer"></div>
<button class="standardButton" onclick="newQuestion('SolveCubic')">New Question</button>
</div>
</div>
</div>
<script>
fetch('navbar.html')
.then(response => response.text())
.then(data => document.getElementById('nav').innerHTML = data);
.then(data => document.getElementById('nav').innerHTML = data)
fetch('header.html')
.then(response => response.text())
.then(data => document.querySelector('header').innerHTML = data);
</script>
<script src="script.js"></script>
</body>
</html>

36 changes: 35 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ if (document.getElementById('subjectSelect')) {
});
}

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

function clearFilters() {
data.filters = {
subject: data.filters.subject,
Expand Down Expand Up @@ -805,6 +809,16 @@ function randchoice(arr) {
return arr[i];
}

function hasFactor(a, b) {
function gcd(x, y) {
while (y !== 0) {
[x, y] = [y, x % y];
}
return x;
}
return gcd(a, b) > 1;
}

async function newQuestion(category) {
const question = document.getElementById(`Question${category}`);
let questionContent = ``;
Expand Down Expand Up @@ -860,7 +874,7 @@ async function newQuestion(category) {
}
case "CompletingSquare": {
let primes = [2, 3, 5, 7, 11, 13];
let ans = [randchoice(['-', '']), randint(1, 13), randchoice([0,0,1,1,2,3]), randchoice(primes), randchoice([1,1,1,1,2,3])]; //[1,1,1,1,2,3]
let ans = [randchoice(['-', '']), randint(1, 13), randchoice([0,0,1,1,2,3]), randchoice(primes), randchoice([1,1,1,1,2,3])];

if (!ans[2]) ans[3] = randint(1, 13);
else if (ans[3] > 5) ans[2] = 1; // Don't make numbers too big
Expand All @@ -881,6 +895,25 @@ async function newQuestion(category) {
answerContent += `${displayAns}</span></p>`;
break;
}
case "Factorise": {
let ans = [randchoice([1,1,1,2,3,4]), randchoice(['-', '+']), randint(1, 13), randchoice([1,1,1,2,3,4]), randchoice(['-', '+']), randint(1, 13)];

while (ans[2] == ans[5] || hasFactor(ans[0], ans[2]) || hasFactor(ans[3], ans[5])) {
ans[2] = randint(1, 13);
ans[5] = randint(1, 13);
}
let displayQuestion = `${ans[0]*ans[3] > 1? ans[0]*ans[3] : ``}<span class="var">x</span><sup>2</sup> + ${ans[0] * ans[5] * (ans[4] == '-'? -1 : 1) + ans[3] * ans[2] * (ans[1] == '-'? -1 : 1)}<span class="var">x</span> + ${ans[5] * ans[2] * (ans[4] == '-'? -1 : 1) * (ans[1] == '-'? -1 : 1)}`.replace(/\+ -/g, "– ");

let displayAns = `(${ans[0] > 1? ans[0] : ``}<span class="var">x</span> ${ans[1]} ${ans[2]})(${ans[3] > 1? ans[3] : ``}<span class="var">x</span> ${ans[4]} ${ans[5]})`.replace(/-/g, "– ");

questionContent = `<p>Factorise: <span class="math">${displayQuestion}</span></p>`;
answerContent += `<p><span class="math">${displayAns}</span></p>`;
break;
}
case "SolveCubic": {
let ans = [randchoice(['-', '+']), randchoice([1,1,1,2,2,3])];
break;
}
default:
console.warn("Not a valid question category!")
break;
Expand Down Expand Up @@ -922,6 +955,7 @@ function adjustZoomForOverflow() {

window.addEventListener("load", async function() {
console.log('loading...');
await sleep(500); // can't figure out how to wait for load
adjustZoomForOverflow();
await load();
document.getElementById('textSearchBox').addEventListener('keydown', function(event) {
Expand Down

0 comments on commit 114d3d0

Please sign in to comment.