Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable evaluation results filters #2232

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
915800f
alle changes ohne tests
ybrnr Jul 1, 2024
9753d7e
tests jetzt hinzugefügt mit neuer struktur (schon wieder) test_tools.…
ybrnr Jul 1, 2024
8adf9cb
minimal_test_data_results.json geändert, ist jetzt cooler, außerdem t…
ybrnr Jul 1, 2024
aa37c8b
vscode hat komische dinge in results_evaluation_detail.html gemacht, …
ybrnr Jul 2, 2024
4f09e20
button description
ybrnr Jul 8, 2024
27d9ef1
correct redirect link when exporting as manager
ybrnr Jul 8, 2024
e423086
tests shortened, new test for contributor
ybrnr Jul 8, 2024
ca0144f
added tests for delegates for contributor and responsible in contribu…
ybrnr Jul 8, 2024
1c7f31d
test
jooooosef Jul 8, 2024
48af815
changed contributor test
ybrnr Jul 15, 2024
c8866ae
changed tests again, trying to satisfy linter
ybrnr Jul 15, 2024
0384ca6
linter happy now :)
ybrnr Jul 15, 2024
4480937
Update evap/results/templates/results_evaluation_detail.html
ybrnr Jul 15, 2024
9ce9da9
Update evap/results/templates/results_evaluation_detail.html
ybrnr Jul 29, 2024
3a93972
Update evap/results/templates/results_evaluation_detail.html
ybrnr Jul 29, 2024
da932a7
Update evap/results/templates/results_evaluation_detail.html
ybrnr Jul 29, 2024
ff1eece
Update evap/results/templates/results_evaluation_detail.html
ybrnr Jul 29, 2024
4522907
Apply suggestions from code review
ybrnr Jul 29, 2024
80dd0f4
user with Textanswervisibility OWN cannot see general buttons
ybrnr Jul 29, 2024
573de4a
standard values for button parameters defined as suggested by janno
ybrnr Jul 29, 2024
98b866b
removed old comments
ybrnr Jul 29, 2024
d473e98
added small test for contributor default view
ybrnr Jul 29, 2024
6fccb35
new can_textanswer_be_seen_by structure
ybrnr Aug 5, 2024
debabec
disable general view buttons if user cannot view general textanswers
ybrnr Aug 5, 2024
538ee33
disable filter buttons, if user cannot see general/contributor textan…
ybrnr Aug 12, 2024
f724a3f
enum for differnet button filter options
ybrnr Aug 12, 2024
05fdb07
fixed imports
ybrnr Oct 14, 2024
451a56a
started to change test structure... (again)
ybrnr Oct 14, 2024
5098e26
tests weiter geändert
ybrnr Oct 21, 2024
dee4ee0
changed some tests
jooooosef Oct 28, 2024
942dcec
manager test now with staff mode and removed old tests
ybrnr Oct 28, 2024
c0f0b72
removed unnecessary test
jooooosef Oct 28, 2024
1376153
made the active conitions for buttons use proper Enums
jooooosef Oct 28, 2024
20c9769
added helper test to see if buttons are disabled
ybrnr Oct 28, 2024
62a040b
buttons cannot be active, when disabled; created next_step file to tr…
ybrnr Oct 28, 2024
90204e8
added comments in code to work on next time
ybrnr Oct 28, 2024
bb95b59
reformatted files
ybrnr Oct 28, 2024
312e12c
(partially) fixed display of button groups
jooooosef Nov 11, 2024
67cb1a6
changed filter logic for general
jooooosef Nov 18, 2024
cb4f781
added prints for testing
jooooosef Nov 18, 2024
2fed8bb
added comment
jooooosef Nov 18, 2024
2b6c649
disable textanswer buttons
jooooosef Nov 18, 2024
042aff9
linter happy now :)
jooooosef Nov 18, 2024
fc76287
removed comments
jooooosef Nov 18, 2024
49f0467
cleanup
jooooosef Nov 18, 2024
be6f262
removed txt file
ybrnr Nov 25, 2024
49fb0b5
reverted bootstrap submodule
jooooosef Dec 16, 2024
49d1c67
Implemented requested changes
jooooosef Dec 16, 2024
522df3f
select ratings button when group disabled
jooooosef Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions evap/results/fixtures/minimal_test_data_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,6 @@
"type": 2
}
},
{
"pk": 6,
"model": "evaluation.question",
"fields": {
"questionnaire": 2,
"text_en": "can you see me?",
"text_de": "can you see me?",
"allows_additional_textanswers": false,
"type": 0
}
},
{
"pk": "00000000-0000-0000-0000-000000000001",
"model": "evaluation.textanswer",
Expand All @@ -135,7 +124,7 @@
"pk": "00000000-0000-0000-0000-000000000002",
"model": "evaluation.textanswer",
"fields": {
"answer": ".general_orig_hidden.",
"answer": ".general_orig_deleted.",
"question": 3,
"original_answer": null,
"contribution": 1,
Expand Down Expand Up @@ -190,7 +179,7 @@
"pk": "00000000-0000-0000-0000-000000000012",
"model": "evaluation.textanswer",
"fields": {
"answer": ".responsible_contributor_orig_hidden.",
"answer": ".responsible_contributor_orig_deleted.",
"question": 1,
"original_answer": null,
"contribution": 6,
Expand Down Expand Up @@ -223,24 +212,13 @@
"pk": "00000000-0000-0000-0000-000000000015",
"model": "evaluation.textanswer",
"fields": {
"answer": ".responsible_contributor_orig_notreviewed.",
"answer": ".responsible_contributor_orig_unreviewed.",
"question": 1,
"original_answer": null,
"contribution": 6,
"review_decision": "UN"
}
},
{
"pk": "00000000-0000-0000-0000-000000000016",
"model": "evaluation.textanswer",
"fields": {
"answer": ".proxy_user_visibility_info.",
"question": 6,
"original_answer": null,
"contribution": 1,
"review_decision": "PU"
}
},
{
"pk": "00000000-0000-0000-0000-000000000017",
"model": "evaluation.textanswer",
Expand All @@ -256,7 +234,7 @@
"pk": "00000000-0000-0000-0000-000000000018",
"model": "evaluation.textanswer",
"fields": {
"answer": ".responsible_contributor_additional_orig_hidden.",
"answer": ".responsible_contributor_additional_orig_deleted.",
"question": 2,
"original_answer": null,
"contribution": 6,
Expand All @@ -278,7 +256,7 @@
"pk": "00000000-0000-0000-0000-000000000020",
"model": "evaluation.textanswer",
"fields": {
"answer": ".general_additional_orig_hidden.",
"answer": ".general_additional_orig_deleted.",
"question": 4,
"original_answer": null,
"contribution": 1,
Expand Down
134 changes: 70 additions & 64 deletions evap/results/templates/results_evaluation_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% if evaluation.state != evaluation.State.PUBLISHED %}
<div class="alert alert-warning">{% translate 'This is a preview. The results have not been published yet.' %}</div>
{% endif %}

{# manager is automatically a reviewer (so this are all groups that can see the buttons) #}
{% if is_reviewer or is_responsible_or_contributor_or_delegate %}
{% if evaluation.course.is_private %}
<div class="alert alert-info d-print-none">
Expand All @@ -32,68 +32,74 @@
<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">{% translate '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="{% blocktranslate %}Shows filtered view meant for personal export. Other contributors' results and private answers are hidden.{% endblocktranslate %}"
>
{% translate 'Export' context 'view mode' %}
</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="{% translate 'Shows all results available for you.' %}"
>
{% translate '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="{% blocktranslate %}The results of this evaluation have not been published because it didn't get enough votes.{% endblocktranslate %}"
>
{% if evaluation.course.is_private %}
{% translate 'Participant' %}
{% else %}
{% translate '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 %}
{% translate 'Shows results available for the participants.' %}"
>
{% translate 'Participant' %}
{% else %}
{% translate 'Shows results available for everyone logged in.' %}"
>
{% translate 'Public' %}
{% endif %}
</a>
{% endif %}
<div class="row">
<div class="col-auto">
<div class="btn-switch btn-switch-light my-auto d-print-none">
<div class="btn-switch-label">{% translate 'General results' %}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when disabled, "Ratings" should be selected/active and its tooltip should be shown on hover.
a different tooltip should be shown for "All" when disabled: "You can't see text answers for general questions in this evaluation."

<div class="btn-switch btn-group">
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results=full&view_contributor_results={{ view_contributor_results.value }}"
role="button"
class="btn btn-sm btn-light {% if not general_textanswers %} disabled {% elif view_general_results == ViewGeneralResults.FULL %} active {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% blocktranslate %}All results of general questions (including text answers){% endblocktranslate %}"
>
{% translate 'Full' %}
</a>
<a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users with TextAnswerVisibility.OWN_TEXTANSWERS should not be able to select "Full" here. Instead, "Ratings" should be selected and the button group should be disabled.

href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results=ratings&view_contributor_results={{ view_contributor_results.value }}"
role="button"
class="btn btn-sm btn-light {% if not general_textanswers %} disabled {% endif %} {% if view_general_results == ViewGeneralResults.RATINGS or not general_textanswers %} active{% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% translate 'Only rating results of general questions (without text answers)' %}"
>
{% translate 'Ratings' %}
</a>
</div>
</div>
</div>
</div>

<div class="row mt-1">
<div class="col-auto">
<div class="btn-switch btn-switch-light my-auto d-print-none">
<div class="btn-switch-label">{% translate 'Contributor results' %}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when disabled, "Ratings" should be selected/active and its tooltip should be shown on hover.
a different tooltip should be shown for the other buttons when disabled: "You can't see text answers for contributor questions because you aren't a contributor."

Copy link
Collaborator Author

@jooooosef jooooosef Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We added that ratings is selected when the button group is disabled.
Showing the tooltip is not this easily possible since the buttons are disabled and therefore dont accept any mouse events (inlcuding mouse hover), thus the title is not shown.

I think this could be fixed with some js?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we found a way of having tooltips on disabled buttons in #1931.

<div class="btn-switch btn-group">
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results={{ view_general_results.value }}&view_contributor_results=full"
role="button"
class="btn btn-sm btn-light {% if not contributor_textanswers %} disabled {% elif view_contributor_results == ViewContributorResults.FULL %} active {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% blocktranslate %}All results of contributor questions available for you (including text answers){% endblocktranslate %}"
>
{% translate 'Full' %}
</a>
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results={{ view_general_results.value }}&view_contributor_results=ratings"
role="button"
class="btn btn-sm btn-light {% if not contributor_textanswers %} disabled {% endif %} {% if view_contributor_results == ViewContributorResults.RATINGS or not contributor_textanswers %} active{% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% translate 'Only rating results of contributor questions (without text answers)' %}"
>
{% translate 'Ratings' %}
</a>
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results={{ view_general_results.value }}&view_contributor_results=personal"
role="button"
class="btn btn-sm btn-light {% if not contributor_personal or not contributor_textanswers %} disabled {% elif view_contributor_results == ViewContributorResults.PERSONAL %} active {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% translate 'All results of contributor questions regarding yourself, hiding other contributors' %}"
>
{% translate 'Personal' %}
</a>
</div>
</div>
</div>
</div>
</div>
Expand All @@ -106,8 +112,8 @@ <h3>{{ evaluation.full_name }} ({{ evaluation.course.semester.name }})</h3>
<div class="card-header d-flex">
<div class="me-auto">{% translate 'Overview' %}</div>
{% if can_export_text_answers %}
<a class="btn btn-sm btn-light d-print-none" href="{% url 'results:evaluation_text_answers_export' evaluation.id %}?view={{ view }}{% if contributor_id is not None %}&contributor_id={{ contributor_id }}{% endif %}" type="button">
{% translate 'Export text answers' %}
<a class="btn btn-sm btn-light d-print-none" href="{% url 'results:evaluation_text_answers_export' evaluation.id %}?view_general_results={{ view_general_results.value }}&view_contributor_results={{ view_contributor_results.value }}{% if contributor_id is not None %}&contributor_id={{ contributor_id }}{% endif %}" type="button">
{% translate 'Export visible text answers' %}
</a>
{% endif %}
{% if evaluation.course.grade_documents.count == 1 and can_download_grades %}
Expand Down
10 changes: 8 additions & 2 deletions evap/results/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
)
from evap.evaluation.tests.tools import TestCase, make_rating_answer_counters
from evap.results.tools import (
ViewContributorResults,
ViewGeneralResults,
cache_results,
calculate_average_course_distribution,
calculate_average_distribution,
Expand Down Expand Up @@ -562,8 +564,12 @@ def test_contributors_and_delegate_count_in_textanswer_visibility_info(self):
for user in UserProfile.objects.all():
represented_users = [user] + list(user.represented_users.all())
for i, textanswer in enumerate(textanswers):
if can_textanswer_be_seen_by(user, represented_users, textanswer, "full"):
if can_textanswer_be_seen_by(user, [user], textanswer, "full"):
if can_textanswer_be_seen_by(
user, represented_users, textanswer, ViewGeneralResults.FULL, ViewContributorResults.FULL
):
if can_textanswer_be_seen_by(
user, [user], textanswer, ViewGeneralResults.FULL, ViewContributorResults.FULL
):
users_seeing_contribution[i][0].add(user)
else:
users_seeing_contribution[i][1].add(user)
Expand Down
Loading
Loading