Skip to content

Instantly share code, notes, and snippets.

@yamakk
Last active December 8, 2021 06:44
Show Gist options
  • Save yamakk/6c305142a375bd3c53d6ecb105cd6f17 to your computer and use it in GitHub Desktop.
Save yamakk/6c305142a375bd3c53d6ecb105cd6f17 to your computer and use it in GitHub Desktop.
An anki template for shuffled choices - 文法の4択問題などは選択肢の並び順で正解を記憶してしまうことがあるため毎回選択肢をシャッフルできるAnkiテンプレート
<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>
@yamakk
Copy link
Author

yamakk commented Dec 8, 2021

Screen Shot 2021-12-08 at 15 43 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment