Skip to content

Commit

Permalink
Reposition View Selection Buttons (#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
fekoch authored Nov 6, 2023
1 parent e7d7d9b commit 7e1726a
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 60 deletions.
2 changes: 1 addition & 1 deletion evap/grades/templates/grades_semester_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{ block.super }}
{% show_infotext "grades_pages" %}

<div class="row mb-3 align-items-center">
<div class="row mb-3 align-items-end">
<h3 class="col-8 mb-0">
{{ semester.name }}
</h3>
Expand Down
96 changes: 63 additions & 33 deletions evap/results/templates/results_evaluation_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,73 @@
<span class="fas fa-lock"></span> {% trans 'This evaluation is private. Only contributors and participants can see the results.' %}
</div>
{% endif %}
<div class="d-flex">
<h3 class="me-auto">{{ evaluation.full_name }} ({{ evaluation.course.semester.name }})</h3>
<div class="row align-items-end mb-3">
<div class="col">
<h3 class="mb-0">{{ evaluation.full_name }} ({{ evaluation.course.semester.name }})</h3>
</div>

<div class="col-auto">
<div class="btn-switch btn-switch-light my-auto d-print-none">
<div class="btn-switch-label">{% trans 'View' %}</div>
<div class="btn-switch btn-group">
{% if user.is_staff and view == 'export' or is_contributor %}
<a
href="{% if is_contributor %}{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view=export{% endif %}"
role="button"
class="btn btn-sm btn-light{% if view == 'export' %} active{% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% blocktrans %}Shows filtered view meant for personal export. Other contributors' results and private answers are hidden.{% endblocktrans %}"
>
{% trans 'Export' context 'view mode' %}
</a>

<div class="btn-switch btn-switch-light my-auto d-print-none">
<div class="btn-switch-label">{% trans 'View' %}</div>
<div class="btn-switch btn-group">
{% if user.is_staff and view == 'export' or is_contributor %}
<a href="{% if is_contributor %}{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view=export{% endif %}" role="button" class="btn btn-sm btn-light{% if view == 'export' %} active{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom"
title="{% blocktrans %}Shows filtered view meant for personal export. Other contributors' results and private answers are hidden.{% endblocktrans %}">
{% trans 'Export' context 'view mode' %}
{% endif %}
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view=full"
role="button"
class="btn btn-sm btn-light{% if view == 'full' %} active{% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% trans 'Shows all results available for you.' %}"
>
{% trans 'Full' %}
</a>
{% endif %}
<a href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view=full" role="button" class="btn btn-sm btn-light{% if view == 'full' %} active{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom"
title="{% trans 'Shows all results available for you.' %}">
{% trans 'Full' %}
</a>
{% if not evaluation.can_publish_rating_results %}
<button type="button" disabled class="btn btn-sm btn-light" data-bs-toggle="tooltip" data-bs-placement="bottom"
title="{% blocktrans %}The results of this evaluation have not been published because it didn't get enough votes.{% endblocktrans %}">
{% if evaluation.course.is_private %}
{% trans 'Participant' %}
{% else %}
{% trans 'Public' %}
{% endif %}
</button>
{% else %}
<a href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view=public" role="button" class="btn btn-sm btn-light{% if view == 'public' %} active{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom"
title="
{% if evaluation.course.is_private %}
{% trans 'Shows results available for the participants.' %}">
{% trans 'Participant' %}
{% if not evaluation.can_publish_rating_results %}
<button
type="button"
disabled
class="btn btn-sm btn-light"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% blocktrans %}The results of this evaluation have not been published because it didn't get enough votes.{% endblocktrans %}"
>
{% if evaluation.course.is_private %}
{% trans 'Participant' %}
{% else %}
{% trans 'Public' %}
{% endif %}
</button>
{% else %}
{% trans 'Shows results available for everyone logged in.' %}">
{% trans 'Public' %}
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view=public"
role="button"
class="btn btn-sm btn-light{% if view == 'public' %} active{% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="
{% if evaluation.course.is_private %}
{% trans 'Shows results available for the participants.' %}"
>
{% trans 'Participant' %}
{% else %}
{% trans 'Shows results available for everyone logged in.' %}"
>
{% trans 'Public' %}
{% endif %}
</a>
{% endif %}
</a>
{% endif %}
</div>
</div>
</div>
</div>
Expand Down
18 changes: 9 additions & 9 deletions evap/results/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,20 +471,20 @@ def test_heading_question_filtering(self):
def test_default_view_is_public(self):
cache_results(self.evaluation)

# the view=public button should have class "active". The rest in-between is just noise.
expected_button = (
f'<a href="/results/semester/{self.evaluation.course.semester.pk}/evaluation/{self.evaluation.pk}'
+ '?view=public" role="button" class="btn btn-sm btn-light active"'
)

page_without_get_parameter = self.app.get(self.url, user=self.manager)
self.assertContains(page_without_get_parameter, expected_button)
self.assertEqual(page_without_get_parameter.context["view"], "public")

page_with_get_parameter = self.app.get(self.url + "?view=public", user=self.manager)
self.assertContains(page_with_get_parameter, expected_button)
self.assertEqual(page_with_get_parameter.context["view"], "public")

page_with_random_get_parameter = self.app.get(self.url + "?view=asdf", user=self.manager)
self.assertContains(page_with_random_get_parameter, expected_button)
self.assertEqual(page_with_random_get_parameter.context["view"], "public")

page_with_full_get_parameter = self.app.get(f"{self.url}?view=full", user=self.manager)
self.assertEqual(page_with_full_get_parameter.context["view"], "full")

page_with_export_get_parameter = self.app.get(f"{self.url}?view=export", user=self.manager)
self.assertEqual(page_with_export_get_parameter.context["view"], "export")

def test_wrong_state(self):
helper_exit_staff_mode(self)
Expand Down
54 changes: 37 additions & 17 deletions evap/staff/templates/staff_evaluation_textanswers.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,43 @@
{% block content %}
{{ block.super }}

<div class="d-flex">
<h3 class="me-auto">{{ evaluation.full_name }} ({{ evaluation.course.semester.name }})</h3>
<div class="btn-switch btn-switch-light my-auto d-print-none">
<div class="btn-switch-label">{% trans 'View' %}</div>
<div class="btn-switch btn-group">
<a href="{% url 'staff:evaluation_textanswers' evaluation.id %}" role="button" class="btn btn-sm btn-light{% if view == 'quick' %} active{% endif %}">
{% trans 'Quick' %}
</a>
<a href="{% url 'staff:evaluation_textanswers' evaluation.id %}?view=full" role="button" class="btn btn-sm btn-light{% if view == 'full' %} active{% endif %}">
{% trans 'Full' %}
</a>
<a href="{% url 'staff:evaluation_textanswers' evaluation.id %}?view=undecided" role="button" class="btn btn-sm btn-light{% if view == 'undecided' %} active{% endif %}">
{% trans 'Undecided' %}
</a>
<a href="{% url 'staff:evaluation_textanswers' evaluation.id %}?view=flagged" role="button" class="btn btn-sm btn-light{% if view == 'flagged' %} active{% endif %}">
{% trans 'Flagged' %}
</a>
<div class="row mb-3 align-items-end">
<div class="col">
<h3 class="mb-0">{{ evaluation.full_name }} ({{ evaluation.course.semester.name }})</h3>
</div>
<div class="col-auto">
<div class="btn-switch btn-switch-light my-auto d-print-none">
<div class="btn-switch-label">{% trans 'View' %}</div>
<div class="btn-switch btn-group">
<a
href="{% url 'staff:evaluation_textanswers' evaluation.id %}"
role="button"
class="btn btn-sm btn-light{% if view == 'quick' %} active{% endif %}"
>
{% trans 'Quick' %}
</a>
<a
href="{% url 'staff:evaluation_textanswers' evaluation.id %}?view=full"
role="button"
class="btn btn-sm btn-light{% if view == 'full' %} active{% endif %}"
>
{% trans 'Full' %}
</a>
<a
href="{% url 'staff:evaluation_textanswers' evaluation.id %}?view=undecided"
role="button"
class="btn btn-sm btn-light{% if view == 'undecided' %} active{% endif %}"
>
{% trans 'Undecided' %}
</a>
<a
href="{% url 'staff:evaluation_textanswers' evaluation.id %}?view=flagged"
role="button"
class="btn btn-sm btn-light{% if view == 'flagged' %} active{% endif %}"
>
{% trans 'Flagged' %}
</a>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 7e1726a

Please sign in to comment.