{{Question}}
<center><div id=questions style="text-align:left;"></div></center>
<script>
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex ;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
var right = "{{CorrectAnswer}}";
var all = [right, "{{WrongAnswer1}}", "{{WrongAnswer2}}", "{{WrongAnswer3}}"];
var buf = "<ol type=a>";
shuffle(all);
for (var i=0; i<4; i++) {
buf += "<li>"+all[i];
}
buf += "<ol type=a>";
document.getElementById("questions").innerHTML = buf;
</script>
.card {
font-family: arial;
font-size: 20px;
text-align: left;
color: black;
background-color: white;
margin-left:auto; margin-right:auto; width:80%
}
img { margin-bottom: 2em; }
.field_set_col{
margin-bottom: 1em;
border: 2px solid #007868;
border-right: 2px solid #007868;
border-bottom: 2px solid #007868;
}
li{
margin: 20px 0;
}
{{Question}}
<div id=ansArea></div>
<script>
var buf = "<ol type=a>";
var ans;
for (var i=0; i<4; i++) {
ans = all[i];
if (ans == right) {
ans = "<font color='#007868'><b>"+ans+"</font></b>";
}
buf += "<li>"+ans;
}
buf += "<ol type=a>";
document.getElementById("ansArea").innerHTML = buf;
</script>
<hr id=answer>
{{Extra}}
Chechkbox questions contain very similar code:
Front template:
{{Question}}
<center><div id=questions style="text-align:left;"></div></center>
<script>
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex ;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
var right1 = "{{CorrectAnswer1}}";
var right2 = "{{CorrectAnswer2}}";
var all = [right1, right2, "{{WrongAnswer1}}", "{{WrongAnswer2}}", "{{WrongAnswer3}}"];
var buf = "<ol type=a>";
shuffle(all);
for (var i=0; i<5; i++) {
buf += "<li>"+all[i];
}
buf += "<ol type=a>";
document.getElementById("questions").innerHTML = buf;
</script>
Styling:
.card {
font-family: arial;
font-size: 20px;
text-align: left;
color: black;
background-color: white;
margin-left:auto; margin-right:auto; width:80%
}
img { margin-bottom: 1em; }
li{
margin: 20px 0;
}
Back template:
{{Question}}
<div id=ansArea></div>
<script>
var buf = "<ol type=a>";
var ans;
for (var i=0; i<5; i++) {
ans = all[i];
if (ans == right1 | ans == right2) {
ans = "<font color='#007868'><b>"+ans+"</font></b>";
}
buf += "<li>"+ans;
}
buf += "<ol type=a>";
document.getElementById("ansArea").innerHTML = buf;
</script>
<hr id=answer>
{{Extra}}
1 Posted by Damien Elmes on Apr 17, 2018 @ 10:02 AM
I'm afraid it appears AnkiDroid is reloading the web view when revealing the answer, which means there is no way to carry state from the question side over to the answer side.
Support Staff 4 Posted by Damien Elmes on Jun 01, 2018 @ 06:40 AM
It's not something I've personally tried I'm afraid. Perhaps you could ask on the community forum to see if anyone can help you with it.
On Jun 20, 2018, at 1:59 PM, sh88....@gmail.com wrote:
Looks like the topic I created in GitHub is closed. It is claimed that the topic is somehow addressed in another topic. I don't know whether the other topic can provide any help. It's about whiteboard.
--
You received this message because you are subscribed to the Google Groups "AnkiDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anki-android...@googlegroups.com.
To post to this group, send email to anki-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/ea0d2516-8301-4e04-b934-fd75b81f332a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.