Last active
December 8, 2021 06:44
-
-
Save yamakk/6c305142a375bd3c53d6ecb105cd6f17 to your computer and use it in GitHub Desktop.
An anki template for shuffled choices - 文法の4択問題などは選択肢の並び順で正解を記憶してしまうことがあるため毎回選択肢をシャッフルできるAnkiテンプレート
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="ankiCard"> | |
<div id="front-text" style="padding:15px; text-align:left;">{{Front}}</div> | |
<div id="hide" style="display:none;"> | |
<div id="choices">{{choices}}</div> | |
</div> | |
<div id="selections" style="text-align:left; margin-left:10px;"> | |
</div> | |
</div> | |
<script> | |
(() => { | |
function shuffleArray(inputArray){ | |
inputArray.sort(()=> Math.random() - 0.5); | |
} | |
function rgb(){ | |
var v = [] | |
for(var i=0; i<3; i++){ | |
v.push(parseInt(Math.random() * 255)); | |
} | |
return 'rgb('+v.join(',')+', 0.2)' | |
} | |
function randomRadius() { | |
//border-radius: 50% 50% 50% 70%/50% 50% 70% 60%; | |
var s = ''; | |
for(var i=0; i<4; i++){ | |
s += parseInt(Math.random() * 50); | |
s+='% ' | |
} | |
s += '/' | |
for(var i=0; i<4; i++){ | |
s += parseInt(Math.random() * 50); | |
s+='% ' | |
} | |
return s | |
} | |
var title = document.getElementById('front-text') | |
title.style.borderRadius = randomRadius() | |
title.style.backgroundColor = rgb() | |
var choices = document.getElementById("choices").textContent; | |
var selections = document.getElementById("selections") | |
choices = choices.split('|') | |
shuffleArray(choices) | |
var lis = "" | |
for(var i=0; i<choices.length; i++){ | |
lis += '<div style="margin:6px;">'+choices[i].trim()+'</div>'; | |
} | |
selections.innerHTML = lis | |
})() | |
</script> |
Author
yamakk
commented
Dec 8, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment