You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!! I use this Add-on a lot! (Thank you for creating it :) ) . it used to work really well but today I created some new cards and it doesn't show any answers on the back card. I'll share some screenshots.
##Front code
<script>
// Loading Persistence
// https://github.com/SimonLammer/anki-persistence
// v0.5.2 - https://github.com/SimonLammer/anki-persistence/blob/62463a7f63e79ce12f7a622a8ca0beb4c1c5d556/script.js
if (void 0 === window.Persistence) { var _persistenceKey = "github.com/SimonLammer/anki-persistence/", _defaultKey = "_default"; if (window.Persistence_sessionStorage = function () { var e = !1; try { "object" == typeof window.sessionStorage && (e = !0, this.clear = function () { for (var e = 0; e < sessionStorage.length; e++) { var t = sessionStorage.key(e); 0 == t.indexOf(_persistenceKey) && (sessionStorage.removeItem(t), e--) } }, this.setItem = function (e, t) { void 0 == t && (t = e, e = _defaultKey), sessionStorage.setItem(_persistenceKey + e, JSON.stringify(t)) }, this.getItem = function (e) { return void 0 == e && (e = _defaultKey), JSON.parse(sessionStorage.getItem(_persistenceKey + e)) }, this.removeItem = function (e) { void 0 == e && (e = _defaultKey), sessionStorage.removeItem(_persistenceKey + e) }) } catch (e) { } this.isAvailable = function () { return e } }, window.Persistence_windowKey = function (e) { var t = window[e], i = !1; "object" == typeof t && (i = !0, this.clear = function () { t[_persistenceKey] = {} }, this.setItem = function (e, i) { void 0 == i && (i = e, e = _defaultKey), t[_persistenceKey][e] = i }, this.getItem = function (e) { return void 0 == e && (e = _defaultKey), t[_persistenceKey][e] || null }, this.removeItem = function (e) { void 0 == e && (e = _defaultKey), delete t[_persistenceKey][e] }, void 0 == t[_persistenceKey] && this.clear()), this.isAvailable = function () { return i } }, window.Persistence = new Persistence_sessionStorage, Persistence.isAvailable() || (window.Persistence = new Persistence_windowKey("py")), !Persistence.isAvailable()) { var titleStartIndex = window.location.toString().indexOf("title"), titleContentIndex = window.location.toString().indexOf("main", titleStartIndex); titleStartIndex > 0 && titleContentIndex > 0 && titleContentIndex - titleStartIndex < 10 && (window.Persistence = new Persistence_windowKey("qt")) } }
</script>
<script>
// Generate the table depending on the type.
function generateTable() {
var type = document.getElementById("Card_Type").innerHTML;
var table = document.createElement("table");
var tbody = document.createElement("tbody");
for (var i = 0; i < 5; i++) {
if (type == 0 && i == 0) {
tbody.innerHTML = tbody.innerHTML + '<tr><th>yes</th><th>no</th><th></th></tr>';
}
if (document.getElementById('Q_' + (i + 1)).innerHTML != '') {
var html = [];
html.push('<tr>');
for (var j = 0; j < ((type == 0) ? 2 : 1); j++) {
html.push(
'<td onInput="onCheck()" style="text-align: center"><input name="ans_' + ((type != 2) ? (i + 1) : 'A') + '" type="' +
((type == 1) ? 'checkbox' : 'radio') + '" value="' + ((j == 0) ? 1 : 0) + '"></td>');
}
html.push('<td>' + document.getElementById('Q_' + (i + 1)).innerHTML + '</td>')
html.push('</tr>');
tbody.innerHTML = tbody.innerHTML + html.join("");
}
}
table.appendChild(tbody);
document.getElementById('qtable').innerHTML = table.innerHTML;
onShuffle();
}
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;
}
function onShuffle() {
var solutions = document.getElementById("Q_solutions").innerHTML;
solutions = solutions.split(" ");
for (i = 0; i < solutions.length; i++) {
solutions[i] = Number(solutions[i]);
}
var output = document.getElementById("output");
var qrows = document.getElementById("qtable").getElementsByTagName("tr");
var qanda = new Array();
var type = document.getElementById("Card_Type").innerHTML;
for (i = 0; i < ((type == 0) ? qrows.length - 1 : qrows.length); i++) {
qanda[i] = new Object();
qanda[i].question = qrows[(type == 0) ? i + 1 : i].getElementsByTagName("td")[(type == 0) ? 2 : 1].innerHTML;
qanda[i].answer = solutions[i];
}
qanda = shuffle(qanda);
var mc_solutions = new String();
for (i = 0; i < ((type == 0) ? qrows.length - 1 : qrows.length); i++) {
qrows[(type == 0) ? i + 1 : i].getElementsByTagName("td")[(type == 0) ? 2 : 1].innerHTML = qanda[i].question;
solutions[i] = qanda[i].answer;
mc_solutions += qanda[i].answer + " ";
}
mc_solutions = mc_solutions.substring(0, mc_solutions.lastIndexOf(" "));
document.getElementById("Q_solutions").innerHTML = mc_solutions;
document.getElementById("qtable").HTML = qrows;
onCheck();
}
function onCheck() {
// Generate user_answers
var type = document.getElementById("Card_Type").innerHTML;
var qrows = document.getElementById("qtable").getElementsByTagName('tbody')[0].getElementsByTagName("tr");
document.getElementById("user_answers").innerHTML = "";
for (i = 0; i < ((type == 0) ? qrows.length - 1 : qrows.length); i++) {
var j;
if (type == 0) {
j = i + 1;
} else j = i;
if (qrows[j].getElementsByTagName("td")[0].getElementsByTagName("input")[0].checked) {
document.getElementById("user_answers").innerHTML += "1 ";
} else if (type != 0 && !qrows[j].getElementsByTagName("td")[(type == 0) ? 1 : 0].getElementsByTagName("input")[0].checked) {
document.getElementById("user_answers").innerHTML += "0 ";
} else if (type == 0 && qrows[j].getElementsByTagName("td")[(type == 0) ? 1 : 0].getElementsByTagName("input")[0].checked) {
document.getElementById("user_answers").innerHTML += "0 ";
} else {
document.getElementById("user_answers").innerHTML += "- ";
}
}
document.getElementById("user_answers").innerHTML = document.getElementById("user_answers").innerHTML.trim();
// Send Stuff to Persistence
if (Persistence.isAvailable()) {
Persistence.clear();
Persistence.setItem('user_answers', document.getElementById("user_answers").innerHTML);
Persistence.setItem('Q_solutions', document.getElementById("Q_solutions").innerHTML);
Persistence.setItem('qtable', document.getElementById("qtable").innerHTML);
}
}
/*
The following block is from Glutanimate's Cloze Overlapper card template.
The Cloze Overlapper card template is licensed under the CC BY-SA 4.0
license (https://creativecommons.org/licenses/by-sa/4.0/).
*/
if (document.readyState === "complete") {
setTimeout(generateTable(), 1);
} else {
document.addEventListener("DOMContentLoaded", function () {
setTimeout(generateTable(), 1);
}, false);
}
</script>
{{#Title}}<h3 id="myH1">{{Title}}</h3>{{/Title}}
{{#Question}}<p>{{Question}}</p>{{/Question}}
<table style="boder: 1px solid black" id="qtable"></table>
<div class="hidden" id="Q_solutions">{{Answers}}</div>
<div class="hidden" id="user_answers">- - - -</div>
<div class="hidden" id="Card_Type">{{QType (0=kprim,1=mc,2=sc)}}</div>
<div class="hidden" id="Q_1">{{Q_1}}</div>
<div class="hidden" id="Q_2">{{Q_2}}</div>
<div class="hidden" id="Q_3">{{Q_3}}</div>
<div class="hidden" id="Q_4">{{Q_4}}</div>
<div class="hidden" id="Q_5">{{Q_5}}</div>
Back code
<script>
// Loading Persistence
// https://github.com/SimonLammer/anki-persistence
// v0.5.2 - https://github.com/SimonLammer/anki-persistence/blob/62463a7f63e79ce12f7a622a8ca0beb4c1c5d556/script.js
if (void 0 === window.Persistence) { var _persistenceKey = "github.com/SimonLammer/anki-persistence/", _defaultKey = "_default"; if (window.Persistence_sessionStorage = function () { var e = !1; try { "object" == typeof window.sessionStorage && (e = !0, this.clear = function () { for (var e = 0; e < sessionStorage.length; e++) { var t = sessionStorage.key(e); 0 == t.indexOf(_persistenceKey) && (sessionStorage.removeItem(t), e--) } }, this.setItem = function (e, t) { void 0 == t && (t = e, e = _defaultKey), sessionStorage.setItem(_persistenceKey + e, JSON.stringify(t)) }, this.getItem = function (e) { return void 0 == e && (e = _defaultKey), JSON.parse(sessionStorage.getItem(_persistenceKey + e)) }, this.removeItem = function (e) { void 0 == e && (e = _defaultKey), sessionStorage.removeItem(_persistenceKey + e) }) } catch (e) { } this.isAvailable = function () { return e } }, window.Persistence_windowKey = function (e) { var t = window[e], i = !1; "object" == typeof t && (i = !0, this.clear = function () { t[_persistenceKey] = {} }, this.setItem = function (e, i) { void 0 == i && (i = e, e = _defaultKey), t[_persistenceKey][e] = i }, this.getItem = function (e) { return void 0 == e && (e = _defaultKey), t[_persistenceKey][e] || null }, this.removeItem = function (e) { void 0 == e && (e = _defaultKey), delete t[_persistenceKey][e] }, void 0 == t[_persistenceKey] && this.clear()), this.isAvailable = function () { return i } }, window.Persistence = new Persistence_sessionStorage, Persistence.isAvailable() || (window.Persistence = new Persistence_windowKey("py")), !Persistence.isAvailable()) { var titleStartIndex = window.location.toString().indexOf("title"), titleContentIndex = window.location.toString().indexOf("main", titleStartIndex); titleStartIndex > 0 && titleContentIndex > 0 && titleContentIndex - titleStartIndex < 10 && (window.Persistence = new Persistence_windowKey("qt")) } }
</script>
<script>
function onLoad() {
// Check if Persistence is Available
if (Persistence.isAvailable) {
// Parsing solutions
solutions = Persistence.getItem('Q_solutions').split(" ");
for (i = 0; i < solutions.length; i++) {
solutions[i] = Number(solutions[i]);
}
var answers = Persistence.getItem('user_answers').split(" ");
var type = document.getElementById('CardType').innerHTML;
var qtable = document.getElementById('qtable');
qtable.innerHTML = Persistence.getItem('qtable');
var output = document.getElementById("output");
var atable = qtable.cloneNode(true);
atable.setAttribute("id", "atable");
output.innerHTML = "<hr id='answer' />" + atable.outerHTML;
document.getElementById('qtable').innerHTML = qtable.innerHTML;
var qrows = qtable.getElementsByTagName('tbody')[0].getElementsByTagName("tr");
for (i = 0; i < answers.length; i++) {
//Set the radio buttons in the qtable.
if (type == 0) {
if (answers[i] === "1") {
qrows[i + 1].getElementsByTagName("td")[0].getElementsByTagName("input")[0].checked = true;
} else if (answers[i] === "0") {
qrows[i + 1].getElementsByTagName("td")[1].getElementsByTagName("input")[0].checked = true;
}
} else {
qrows[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0].checked = (answers[i]==1) ? true : false;
}
//Colorize the qtable.
if (solutions[i] && answers[i] === "1") {
qrows[(type != 0) ? i : i + 1].setAttribute("class", "correct");
} else if (!solutions[i] && answers[i] === "0") {
qrows[(type != 0) ? i : i + 1].setAttribute("class", "correct");
} else {
qrows[(type != 0) ? i : i + 1].setAttribute("class", "wrong");
}
}
var arows = document.getElementById("atable").getElementsByTagName("tbody")[0].getElementsByTagName("tr");
for (i = 0; i < solutions.length; i++) {
//Rename the radio buttons of the atable to avoid interference with those in the qtable.
if (type==0) arows[i + 1].getElementsByTagName("td")[1].getElementsByTagName("input")[0].setAttribute("name", "ans_" + ((type != 2) ? String(i + 1) : 'A') + "_solution");
arows[(type!=0) ? i : i+1].getElementsByTagName("td")[0].getElementsByTagName("input")[0].setAttribute("name", "ans_" + ((type != 2) ? String(i + 1) : 'A') + "_solution");
//Set the radio buttons in the atable.
if (type==0) arows[i + 1].getElementsByTagName("td")[solutions[i] ? 0 : 1].getElementsByTagName("input")[0].checked = true;
else arows[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0].checked = solutions[i] ? true : false;
}
Persistence.clear();
}
}
if (document.readyState === "complete") {
setTimeout(onLoad, 1);
} else {
document.addEventListener("DOMContentLoaded", function () {
setTimeout(onLoad, 1);
}, false);
}
</script>
{{#Title}}<h3 id="myH1">{{Title}}</h3>{{/Title}}
{{#Question}}<p>{{Question}}</p>{{/Question}}
<table id="qtable"></table>
<p id="output"></p>
<div class="hidden" id="MC_solutions">solutions_here</div>
<div class="hidden" id="user_answers">user_answers_here</div>
<div class="hidden" id="CardType">{{QType (0=kprim,1=mc,2=sc)}}</div>
{{#Sources}}<p class="small" id="sources"><b>Sources:</b><br />{{Sources}}</p>{{/Sources}}
{{#Extra 1}}<p class="small" id="extra1"><b>Extra 1:</b><br />{{Extra 1}}</p>{{/Extra 1}}
Using Version 24.04 (429bc9e1) Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Anki 24.04 (429bc9e1) (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Windows-10-10.0.22621
===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Clear all fields ['261351307', 2023-12-23T05:05, 'None', '']
Image Occlusion Enhanced ['1374772155', 2022-04-09T01:15, 'None', '']
Large and Colorful Buttons ['1829090218', 2018-10-02T11:41, 'None', '']
Multiple Choice for Anki ['1566095810', 2023-11-17T14:59, 'None', '']
Review Heatmap ['1771074083', 2022-06-29T19:43, 'None', '']
Symbols As You Type ['2040501954', 2024-01-19T23:42, 'None', '']
===IDs of active AnkiWeb add-ons===
1374772155 1566095810 1771074083 1829090218 2040501954 261351307
===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
AMBOSS Official Medical School Step Shelf Study Resource ['1044112126', 2998-12-31T18:00, 'None', mod]
Image Editor ['307397307', 2022-09-07T22:09, 'None', '']
I'll be really thankful for your help if anyone knows what's wrong :(
The text was updated successfully, but these errors were encountered:
hola eugenia, te escribo en español por que sé lo que manejas, cómo hiciste para crear ese tipo de pregunta con verdadero y falso? hay fuente en tipo de pregunta para poder descargar?
Hi!! I use this Add-on a lot! (Thank you for creating it :) ) . it used to work really well but today I created some new cards and it doesn't show any answers on the back card. I'll share some screenshots.
##Front code
Back code
Using Version 24.04 (429bc9e1) Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
I'll be really thankful for your help if anyone knows what's wrong :(
The text was updated successfully, but these errors were encountered: