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 46 commits into
base: main
Choose a base branch
from

Conversation

jooooosef
Copy link
Collaborator

@jooooosef jooooosef commented Jun 24, 2024

fix #1786

@jooooosef jooooosef marked this pull request as draft June 24, 2024 20:49
@jooooosef jooooosef changed the title Customizable evaluation results filters #1786 Customizable evaluation results filters Jun 24, 2024
@ybrnr ybrnr force-pushed the iss1786 branch 4 times, most recently from 0127464 to ca11745 Compare July 8, 2024 15:48
Copy link
Member

@janno42 janno42 left a comment

Choose a reason for hiding this comment

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

  • looks good, most parts work as expected
  • tests not reviewed yet

evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/views.py Outdated Show resolved Hide resolved
evap/results/views.py Outdated Show resolved Hide resolved
evap/results/views.py Outdated Show resolved Hide resolved
evap/results/views.py Outdated Show resolved Hide resolved
evap/results/views.py Outdated Show resolved Hide resolved
evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/templates/results_evaluation_detail.html Outdated Show resolved Hide resolved
evap/results/views.py Show resolved Hide resolved
evap/results/tests/test_views.py Outdated Show resolved Hide resolved
evap/results/tests/test_views.py Outdated Show resolved Hide resolved
@@ -567,24 +582,6 @@ def test_invalid_contributor_id(self):
self.app.get(self.url + "?contributor_id=asd", user=self.manager, status=400)
self.app.get(self.url + "?contributor_id=1234", user=self.manager, status=404)

def test_evaluation_sorting(self):
Copy link
Member

Choose a reason for hiding this comment

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

Why was this removed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

that was an accident I added it again

evap/results/tests/test_views.py Outdated Show resolved Hide resolved
evap/results/tests/test_views.py Outdated Show resolved Hide resolved
evap/results/tests/test_views.py Outdated Show resolved Hide resolved
@richardebeling richardebeling changed the title Customizable evaluation results filters Customizable evaluation results filters Oct 14, 2024
@ybrnr ybrnr force-pushed the iss1786 branch 2 times, most recently from 9bd5cea to 8aaee00 Compare October 21, 2024 16:22
@ybrnr ybrnr force-pushed the iss1786 branch 2 times, most recently from e77a156 to 73c3a65 Compare October 28, 2024 22:50
@jooooosef jooooosef marked this pull request as ready for review November 18, 2024 22:04
ybrnr and others added 24 commits November 25, 2024 17:30
made the can_see_general_textanswers and the contributor counterpart also consider the represtened users
make difference between remove_textanswers_that_the_user_must_not_see and can_textanswer_be_seen_by clearer for the future
when users cannot or should not click specific textanswer buttons (because it does not make sense) they should still be there for consistency but should be disabled
removed unnecessary comment and fixed HTML broken indentations and whitespaces
@@ -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)-->
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<!--manager is automatically a reviewer (so this are all groups that can see the buttons)-->
{# manager is automatically a reviewer (so this are all groups that can see the buttons) #}

so this is not part of the rendered output

Comment on lines +488 to +490
def test_default_view(
self,
):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def test_default_view(
self,
):
def test_default_view(self):

self.assertNotIn(".responsible_contributor_orig_notreviewed.", page)
self.assertIn(".responsible_contributor_additional_orig_published.", page)
self.assertNotIn(".responsible_contributor_additional_orig_hidden.", page)
def helper_test_general(self, user, view_general_results, textanswers_in):
Copy link
Member

Choose a reason for hiding this comment

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

Regarding textanswers_in: What do you think about expected_visible_textanswers? (Repeated below)

Comment on lines +797 to +800
user = "[email protected]"

self.helper_test_general(
user,
Copy link
Member

Choose a reason for hiding this comment

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

You should always be able to just use self.student, self.manager, .... This allows someone reading the code to not need to keep context in memory, all lines are verifiable in isolation.

Suggested change
user = "[email protected]"
self.helper_test_general(
user,
self.helper_test_general(
self.manager,

Comment on lines +878 to +881
".responsible_contributor_orig_published.",
".responsible_contributor_changed_published.",
".responsible_contributor_orig_private.",
".responsible_contributor_additional_orig_published.",
Copy link
Member

Choose a reason for hiding this comment

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

We can put this block of 4 expected answers and the block above of 3 expected answers into some well-named variable, which reduced duplication and makes the test easier to read through.

Comment on lines +510 to +511
if view_general_results == ViewGeneralResults.RATINGS:
return False
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 this branch and the corresponding final else branch, can both be removed.

@@ -199,6 +209,30 @@ def evaluation_detail(request, semester_id, evaluation_id):

is_responsible_or_contributor_or_delegate = evaluation.is_user_responsible_or_contributor_or_delegate(view_as_user)

general_textanswers = False
Copy link
Member

Choose a reason for hiding this comment

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

Why is all this new code here necessary now, which part of this is is not covered by the access computation methods above?

Comment on lines +436 to +439
request.GET.get(
"view_contributor_results",
ViewContributorResults.FULL,
)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think these hit the 120 columns limit, do they?

Suggested change
request.GET.get(
"view_contributor_results",
ViewContributorResults.FULL,
)
request.GET.get("view_contributor_results", ViewContributorResults.FULL)

Comment on lines -397 to -399
# redirect to non-public view if there is none because the results have not been published
if not evaluation.can_publish_rating_results and view == "public":
view = "full"
Copy link
Member

Choose a reason for hiding this comment

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

Why is this no longer needed?

@@ -101,7 +101,7 @@ <h5 class="card-title me-auto">{% translate 'Export evaluation results' %}</h5>
{% for evaluation in semester_evaluations.list %}
<li>
{% if evaluation|can_results_page_be_seen_by:form.instance %}
<a href="{% url 'results:evaluation_detail' semester_evaluations.grouper.id evaluation.id %}?view=export&contributor_id={{ form.instance.id }}">
<a href="{% url 'results:evaluation_detail' semester_evaluations.grouper.id evaluation.id %}?view_contributor_results=personal&contributor_id={{ form.instance.id }}">
{{ evaluation.full_name }}
</a>
Copy link
Member

Choose a reason for hiding this comment

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

random line of code: You updated the bootstrap submodule. Was this intentional / required for anything? If not, please revert.

class ViewGeneralResults(Enum):
@property
def do_not_call_in_templates(self):
return False
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return False
return True

@@ -473,49 +493,54 @@ def textanswers_visible_to(contribution):
return TextAnswerVisibility(visible_by_contribution=sorted_contributors, visible_by_delegation_count=num_delegates)


def can_textanswer_be_seen_by( # noqa: PLR0911
# Filter textanswers based on user selection
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Filter textanswers based on user selection

Copy link
Member

Choose a reason for hiding this comment

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

probably not needed

if view_general_results == ViewGeneralResults.RATINGS:
return False
if view_general_results == ViewGeneralResults.FULL:
# reviewer can see everything
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# reviewer can see everything

Comment on lines +226 to +228
if Contribution.objects.filter(
contributor=user,
evaluation=evaluation,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if Contribution.objects.filter(
contributor=user,
evaluation=evaluation,
if evaluation.contributions.filter(
contributor=user,

Comment on lines +759 to +760
contributor_views = [ViewContributorResults.FULL, ViewContributorResults.RATINGS, ViewContributorResults.PERSONAL]
general_views = [ViewGeneralResults.FULL, ViewGeneralResults.RATINGS]
Copy link
Member

Choose a reason for hiding this comment

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

you don't need these, you can iterate over the enums

Comment on lines +770 to +774
for con_view in self.contributor_views:
page = self.app.get(
f"/results/semester/1/evaluation/1?view_general_results={view_general_results.value}&view_contributor_results={con_view.value}",
user=user,
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for con_view in self.contributor_views:
page = self.app.get(
f"/results/semester/1/evaluation/1?view_general_results={view_general_results.value}&view_contributor_results={con_view.value}",
user=user,
)
for contributor_view in self.contributor_views:
page = self.app.get(
f"/results/semester/1/evaluation/1?view_general_results={view_general_results.value}&view_contributor_results={contributor_view.value}",
user=user,
)

Comment on lines +784 to +793
for gen_view in self.general_views:
page = self.app.get(
f"/results/semester/1/evaluation/1?view_contributor_results={view_contributor_results.value}&view_general_results={gen_view.value}",
user=user,
)

for answer in textanswers_in:
self.assertIn(answer, page)
for answer in textanswers_not_in:
self.assertNotIn(answer, page)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for gen_view in self.general_views:
page = self.app.get(
f"/results/semester/1/evaluation/1?view_contributor_results={view_contributor_results.value}&view_general_results={gen_view.value}",
user=user,
)
for answer in textanswers_in:
self.assertIn(answer, page)
for answer in textanswers_not_in:
self.assertNotIn(answer, page)
for general_view in self.general_views:
page = self.app.get(
f"/results/semester/1/evaluation/1?view_contributor_results={view_contributor_results.value}&view_general_results={general_view.value}",
user=user,
)
for answer in textanswers_in:
self.assertIn(answer, page)
for answer in textanswers_not_in:
self.assertNotIn(answer, page)

<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="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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Customizable evaluation results filters
4 participants