vale981_fahrschule/templates/auswertung_user_all.html

128 lines
5.2 KiB
HTML
Raw Normal View History

2014-04-29 20:27:42 +02:00
{% extends 'quizzes.html' %}
{% block main %}
<script>
$( document ).ready(hideTables);
function hideTables(){
{% for result_group in result_group %}
$("#Result{{ result_group.id }}").hide();
{% endfor %}
}
</script>
{% 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 }}">{{ result_group.quiz.fragen.count }}</x></th>
</tr>
</table>
<br>
<h1>{{ result_group.res_time.date }}</h1>
<table id="summary{{ result_group.id }}" class="bordered" style="width:100px;">
<tr>
<th width="30px">Modul: </th><td>{{ result_group.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 + '%');
</script>
<br>
<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">
<br><br>
{% endfor %}
<br>
{% endif %}
<script>
function printDiv()
{
{% for result_group in result_group %}
var divToPrint{{ result_group.id }}=document.getElementById('summary{{ result_group.id }}');
{% endfor %}
var sim_res = $('#sim_res').val();
newWin= window.open("");
newWin.document.write("<style>th{text-align: left;} #bd{background-size: 100%; background-image: url(/media/pics/urkunde.jpg); width:1000px; height:1410px;-webkit-print-color-adjust:exact; margin:-8px;padding:0;} table{display:inline-table;}#name{position:absolute;top:405px;left:100px;width:800px;height:100px; text-align:center;}#results{position: absolute; top: 775px; left:100px; width:800px;}</style><div id='bd'><body style='font-family: Arial; background-color:#84FF3E;'><div id='name'><span style='line-height:1.9em; font-size:50px; font-family:fantasy;'>{{ user_akt.get_full_name }}</span></div><div id='results' align='center'>" {% for result_group in result_group %}+ divToPrint{{ result_group.id }}.outerHTML + " "{% endfor %} + "</div><span style='font-weight:bold; position:absolute; top:910px; left:100px; width:800px; text-align: center;'>Simulator Ergebnis: " + sim_res + "</span></body></div>");
}
</script>
<label for="sim_res">Simulator Ergebnis:</label>
<input type="Text" id="sim_res">
<input type="button" onclick="printDiv()" value="Zeugnis Drucken">
<br>
<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>
{% endblock %}