vale981_fahrschule/templates/auswertung_user_qzuiz.html
2014-04-29 20:27:42 +02:00

122 lines
No EOL
4.3 KiB
HTML

{% extends 'quizzes.html' %}
{% block main %}
{% if user.is_staff == False %}
<h1>Kein Zutrit!</h1>
{% else %}
{% for result_group in result_group %}
<div id="ResultDiv{{ result_group.id }}">
<table class="bordered" id="Result{{ result_group.id }}" border="0">
<tr>
<th>Frage</th>
<th>Richtig</th>
<th colspan="2">Punkte</th>
</tr>
{% for results in result_group.results.all %}
{% for fragen in fragen %}
{% if fragen == results.frage %}
{% if results.richtig == True %}
{% if results.choice == True %}
<tr style="background-color: MediumAquamarine">
<td style="color: white;">{{ fragen.content }}</td>
<td style="color: white;">Richtig</td>
<td class="addition" colspan="2" style="color: white;" align="center">1/1</td>
</tr>
{% elif results.choice == False %}
<tr style="background-color: #F08080">
<td style="color: white;">{{ fragen.content }}</td>
<td style="color: white;">Falsch</td>
<td class="addition" colspan="2" style="color: white;" align="center">0/1</td>
</tr>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
<tr>
<th>{{ result_group.res_time }}</th>
<th></th>
<th align="center"> <x id="1{{ result_group.id }}"><x id="sumall{{ result_group.id }}" align="center">SUMALL</x></x>/<x id="2{{ result_group.id }}">{{ quiz.fragen.count }}</x></th>
</tr>
</table>
<br>
<table id="summary{{ result_group.id }}" class="bordered">
<tr>
<th>Name: </th><td>{{ user_akt.get_full_name }}</td>
</tr>
<tr>
<th>Datum:</th><td>{{ result_group.res_time }}</td>
</tr>
<tr>
<th>Modul: </th><td>{{ quiz.title }}</td>
</tr>
<tr>
<th>Ergebnis: </th>
<td><div>
<div id="prozent{{ result_group.id }}">Prozent</div>
</div></td>
</tr>
</table>
</div>
<script>
var Points = 0.0;
$('#Result{{ result_group.id }} td.addition').each(function(){
Points += parseFloat($(this).text());
});
$("#sumall{{ result_group.id }}").text(Points);
var rowCount = $('#myTable tr').length;
var prozent = parseInt($("#1{{ result_group.id }}").text()) / parseInt($("#2{{ result_group.id }}").text()) * 100;
$("#prozent{{ result_group.id }}").text(prozent + '%' + ' richtige Antworten');
</script>
<script>
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
window.location.href = uri + base64(format(template, ctx))
}
})()
</script>
<script>
function printDiv()
{
var img = '<img src="/media/pics/1.png" align="center">';
var divToPrint=document.getElementById('summary{{ result_group.id }}');
newWin= window.open("");
newWin.document.write(img + "<style>th{text-align: left;} div{margin-left: -1px;}</style><body style='font-family: Arial; text-align: left;'><hr><br>" + divToPrint.outerHTML + "<br><hr>Ausgestellt von Tobermann GmbH</body>");
setTimeout(printClose(),2000);
function printClose(){
newWin.print();
newWin.close();
}
}
</script>
<br>
<input type="button" onclick="printDiv()" value="Ergebnis Drucken">
<input type="button" download="{{ user_akt.get_full_name }} | {{ result_group.res_time }} | Ergebnis.csv" onclick="tableToExcel('ResultDiv{{ result_group.id }}', '{{ user_akt.get_full_name }} | {{ result_group.res_time }} | Ergebnis.csv')" value="Export to Excel">
{% endfor %}
<br>
{% endif %}
{% endblock %}