diff --git a/mo/web/templates/org_contest_solutions.html b/mo/web/templates/org_contest_solutions.html index 3e4f392f6fdb0d1a63658e19c0769da3ef9eec5a..3b52c2ea68632ff7f7e3868a89d076e278d14afe 100644 --- a/mo/web/templates/org_contest_solutions.html +++ b/mo/web/templates/org_contest_solutions.html @@ -6,6 +6,34 @@ {% set edit_create = rights.can_create_solutions() %} {% set edit_both = edit_points and edit_create %} +{% block head %} +<script type="text/javascript"> + checkAllAbove = function() { + var states = []; + return function (e, col) { + e.preventDefault(); + var table = e.target; + while (table.tagName != 'TABLE') { table = table.parentNode; } + var checkboxes = table.querySelectorAll('tr.state-active td:nth-child('+(2+2*(col-1)+1)+') input[type=checkbox]'); + + if (states[col] === true) { + Array.prototype.forEach.call(checkboxes, function(el, i){ + el.checked = false; + }); + e.target.innerHTML = '<span class="glyphicon glyphicon-arrow-up"></span> Zaškrtnout vše'; + states[col] = false; + } else { + Array.prototype.forEach.call(checkboxes, function(el, i){ + el.checked = true; + }); + e.target.innerHTML = '<span class="glyphicon glyphicon-arrow-up"></span> Odškrtnout vše'; + states[col] = true; + } + } + }(); +</script> +{% endblock %} + {% block title %} {{ "Založení řešení" if edit_form else "Tabulka řešení" }} kategorie {{ round.category }} {% if site %}soutěžního místa {{ site.name }}{% else %}{{ contest.place.name_locative() }}{% endif %} {% endblock %} @@ -142,6 +170,13 @@ Přes ikonku <span class="icon">🔍</span> se dostanete na detail, kde můžete <tfoot> <tr><td><td> {% for task in tasks[4*i:4*(i+1)] %} + {% if edit_form %} + <td colspan="4"> + <a class="btn btn-xs btn-default" href="#" onclick="checkAllAbove(event, {{ loop.index }})"> + <span class="glyphicon glyphicon-arrow-up"></span> + Zaškrtnout vše + </a> + {% else %} <td> <a class='btn btn-xs btn-default' href="{{ ctx.url_for('org_generic_batch_download', task_id=task.task_id) }}" title="Stáhnout ZIP řešení úlohy {{ task.code }}"><span class="glyphicon glyphicon-cloud-download"></span></a> <td> @@ -154,6 +189,7 @@ Přes ikonku <span class="icon">🔍</span> se dostanete na detail, kde můžete {% endif %} <td> <a class="btn btn-xs btn-primary" href="{{ ctx.url_for('org_contest_task', task_id=task.task_id) }}" title="Podrobný výpis odevzdaných řešení k úloze {{ task.code }}"><span class="glyphicon glyphicon-search"></span></a> + {% endif %} {% endfor %} {% if last_loop %} <td> diff --git a/mo/web/templates/org_contest_task.html b/mo/web/templates/org_contest_task.html index 4964b57af038231b4059b3bd1daba2b188ed19af..9325ff65b427b9fd790f87baeb074adf086543f7 100644 --- a/mo/web/templates/org_contest_task.html +++ b/mo/web/templates/org_contest_task.html @@ -33,14 +33,10 @@ <form class="form" method="POST"> {{ edit_form.csrf_token }} {% endif %} -{% with for_user=None, for_task=ctx.task, rows=rows %} +{% with for_user=None, for_task=ctx.task, rows=rows, cancel_url=ctx.url_for('org_contest_task') %} {% include "parts/org_solution_table.html" %} {% endwith %} {% if edit_form %} - <div> - {{ wtf.form_field(edit_form.submit, class="btn btn-primary" ) }} - <a class="btn btn-default" href="{{ ctx.url_for('org_contest_task') }}">Zrušit</a> - </div> </form> {% else %} <p> diff --git a/mo/web/templates/parts/org_solution_table.html b/mo/web/templates/parts/org_solution_table.html index 92ad225e451f852e67a2ab94a5e0fd5688638995..956981fc0813e3ff4f17b8edd7d266f9b24a04a0 100644 --- a/mo/web/templates/parts/org_solution_table.html +++ b/mo/web/templates/parts/org_solution_table.html @@ -145,6 +145,19 @@ finální (ve výchozím stavu poslední nahrané).{% elif rights.can_upload_sol </div> </tr> {% endfor %} +{% if edit_form %} +<tfoot> + <tr><td><td><td> + <td colspan="3" class="text-center"> + <a class="btn btn-sm btn-default" href="#" onclick="checkAllAbove(event)"> + <span class="glyphicon glyphicon-arrow-up"></span> + Zaškrtnout vše + </a> + <td colspan="2"> + {{ wtf.form_field(edit_form.submit, class="btn btn-primary") }} + <a class="btn btn-default" href="{{ cancel_url }}">Zrušit</a> +</tfoot> +{% endif %} </table> </div> @@ -163,4 +176,30 @@ finální (ve výchozím stavu poslední nahrané).{% elif rights.can_upload_sol i.oninput(); } }); + + checkAllAbove = function() { + var state = false; + return function (e) { + e.preventDefault(); + var table = e.target; + while (table.tagName != 'TABLE') { table = table.parentNode; } + var checkboxes = table.querySelectorAll('tr.state-active input[type=checkbox]'); + + if (state) { + Array.prototype.forEach.call(checkboxes, function(el, i){ + el.checked = false; + el.onchange(); + }); + e.target.innerHTML = '<span class="glyphicon glyphicon-arrow-up"></span> Zaškrtnout vše'; + state = false; + } else { + Array.prototype.forEach.call(checkboxes, function(el, i){ + el.checked = true; + el.onchange(); + }); + e.target.innerHTML = '<span class="glyphicon glyphicon-arrow-up"></span> Odškrtnout vše'; + state = true; + } + } + }(); </script>