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

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

Copy link
Member

Choose a reason for hiding this comment

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

Note: This is still removed in the current state of your branch.

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
evap/results/templates/results_evaluation_detail.html 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
evap/results/tests/test_views.py Show resolved Hide resolved
evap/results/tests/test_views.py Outdated Show resolved Hide resolved
evap/results/tools.py Outdated Show resolved Hide resolved
@@ -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?

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.

This is for enabling / disabling the buttons on the page (see evap/results/templates/results_evaluation_detail.html).
Since some people can use the general buttons (general_textanswers), the full and ratings of contributor (contributor_textanswers) and some can use the personal button as well (contributor_personal). As per request the buttons should be disabled if they dont have an effect on the results (e.g. bc user is not contributor but reponsible in this eval).

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I'm afraid that we're duplicating access control logic here, even if it is just for adding a html disabled attribute, it is very likely that we will foget to update this view if we ever want to change the access control logic in can_textanswer_be_seen_by. Optimally, both would reuse the same decision logic.

Maybe it helps if we make this more declarative and use more precise naming, although that doesn't fully resolve the underlying issue.

Would something like this work? (Helper is made up, would need to be added)

buttons_enabled = {
    "general_full": view_as_user.is_reviewer or represents_or_is_contributor_or_responsible(view_as_user, evaluation)
    "general_ratings": # ...
    "contributor_full": # ...
    "contributor_ratings": # ...
    "contributor_personal": # ...
}

Why is contributor_personal = True if view_as_user is a contributor, independently of what the contribution's textanswer_visibility is, but in the loop for the represented users, it is only set to true if the contribution has TextAnswerVisibility.GENERAL_TEXTANSWERS? It seems to me that both would need to be filtered for the contribution's text answer visibility.

Maybe, the helper we want here is def has_textanswer_visibility(user: UserProfile, evaluation: Evaluation, visibility: TextAnswerVisibility), which would answer the question

Is this user allowed to see text answers with this visibility classification (by being a reviewer, a contributor, a responsible, or by being a representative of a reviewer, contributor or responsible

(There might be better names) (Optimally, can_textanswer_be_seen_by would then also use that.)

@niklasmohrin any ideas on how to solve this nicely, here?

evap/results/views.py Outdated Show resolved Hide resolved
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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously there was a view called "public" which now would be Genereral textanswers on ratings and contributor textanswers on ratings. But even in a preview, there are textanswers, so a user might want to hide these as well. So we dont want to force the user into a view which is hiding all textanswers.

Copy link
Member

Choose a reason for hiding this comment

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

You mean "which is showing all textanswers"? Hmm, ok.

@janno42 can you confirm that we no longer want to have this "redirect" here? I see that it made sense in the old system, I'm not sure how exactly we want to handle it in the new system.

evap/staff/templates/staff_user_form.html Show resolved Hide resolved
evap/results/tools.py Outdated Show resolved Hide resolved
evap/results/tools.py Outdated Show resolved Hide resolved
evap/results/tools.py Outdated Show resolved Hide resolved
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,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I though the first "evaluation" is from the ORM (so a column in the database) and the second "evaluation" (after the =) is the defined at the beginning with evaluation = get_object_or_404(semester.evaluations, id=evaluation_id, course__semester=semester) and then in the if statement a couple lines earlier with evaluation = get_evaluations_with_course_result_attributes(prefetched)[0]. Is this how it works?

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

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.

ybrnr and others added 27 commits December 16, 2024 21:32
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
jooooosef and others added 2 commits December 16, 2024 22:19
implemented smaller changes that were quested in PR.
- removed comments
- itereated over enums directly
- changed the name in this itereation from con_view to contributor_view (same for gen_view)
- correclty formatted HTML comment
- made things that should be in one line to be in one line
- implemented variables for reused expected answers (on method and instance level) in test_views.py

Co-authored-by: Yannik <[email protected]>
showing a tooltip with title is not possible since the tag has the disabled class and therefore does not accept any mouse events.
Also: formatted code.

Co-authored-by: Yannik <[email protected]>
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
5 participants