Skip to content

Conversation

@klown
Copy link
Collaborator

@klown klown commented Oct 14, 2022

Create the "group 2" popover dialogs and define their targets such that they show when the relevant page is loaded, and the criteria for showing them is met.

Note that since this PR is an extension of the group 1 popovers, it is based on and includes the changes in PR #323. Going forward this PR will track changes for both group 1 and group 2 enhanced tooltips.

JIRAs:

klown and others added 21 commits October 4, 2022 10:41
- add content for 'view' and 'readaloud' popovers
- switch to popover styles and classes
Converted tooltips to popovers for settings, wordbank, switch,
context, book_actions, and activity.
The `kind` field denotes whether the tip is a popup tooltip or a
dialog popover.  The latter are associated with "robust tooltips" and
tours.
- the `kind` of tip -- tooltip vs dialog -- is not used anywhere; remove
  for now.
- fix the name of the settings teacher resource to link to in the
  `popover_tour.html` template.
The migrations cancel each other.  The first adds a `kind` field to
the `TipType` model while the second removes it.
Added:
- reading_details (Active Reading time and Details),
- reading_data (Student reading data),
- cluey, but only partially (Cluey),
- thoughts (Your thoughts).

With respect to Cluey, the popover dialog is ready, but there is no target
element to attach the popover to.  See comment in CSL-2040:
https://castudl.atlassian.net/browse/CSL-2040?focusedCommentId=36759
@klown klown changed the title Feature/csl 2040 group 2 enhanced tooltips Feature/CSL-2040 group 2 enhanced tooltips Oct 14, 2022
@klown klown marked this pull request as ready for review October 18, 2022 14:51
@klown
Copy link
Collaborator Author

klown commented Oct 18, 2022

@bgoldowsky , while I've marked this as "ready for review", there are changes to both the kind of tip for Cluey, and its content. It looks like it will revert to an actual tooltip that is shown on mouse hover, and not a spontaneous display that depends on the history of when it was last shown. See Kristen's comment in the JIRA.

Given that change, I need to at least change the logic for showing Cluey's popover, likely remove it from that logic.

@klown
Copy link
Collaborator Author

klown commented Oct 18, 2022

Based on a conversation with Kristen in the JIRA for CSL-2007, the group 2 Active Reading time and Details is a duplicate of the group 1 Tooltip_student activity. The latter is a replacement for an existing tooltip and implemented in PR #323. The former was implemented in this PR as a new popover. I will remove the new popover from here. This entails removing a TipType from the database and adjusting priorities as appropriate.

The conversation in the JIRA starts with a note that the group 1 popover is missing from the Dashboard tour.

@klown
Copy link
Collaborator Author

klown commented Oct 28, 2022

@bgoldowsky @mbrambilla This is ready for review. All the group 1 and group 2 "enhanced tooltips" are in place, including the recent two for the student Dashboard.

The last code I added was a couple of unit tests for changes I made to TipType.can_show(). Good thing, since I found and fixed bug in my changes. I'm inclined to add more automated tests for the logic underlying what/if a popover should show. What do you think?

As we discussed at the technical meeting, this PR is ready to merge @mbrambilla's code from PR #333 into it. Alternatively, this could be reviewed and merged for Q/A while the tour work continues on its branch. Let me know how you think we should proceed.

klown added 6 commits October 31, 2022 12:24
…tamp

When `register_show()` is called with a timestamp that is earlier than
the current history's `last_show`, the value of `last_show` should not
change.
The relevance of a tip history's `last_show` time's seconds and
microseconds are minor. and are excluded from one test.
context = super().get_context_data(**kwargs)
context['search_form'] = self.search_form
context['tip_name'] = self.tip_shown.name if self.tip_shown else None
# BEGIN: Sample Tour
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a sample, as opposed to something that should remain for production use?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is kind of a hybrid mode between the tooltips (tip_name) and the popovers (tours). This has been cleaned up in PR #336. I was originally planning on add the tour chains into the original PR, but things forked in two different directions into this PR and then the tour PR.

context['tip_name'] = self.tip_shown.name if self.tip_shown else None
context['clusive_user'] = self.clusive_user
# BEGIN: Sample Tour
# Sample tour with single item list
Copy link
Contributor

Choose a reason for hiding this comment

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

sample?

Copy link
Contributor

Choose a reason for hiding this comment

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

Transitional hybrid mode resulting from trying to do too much in one PR, cleaned up in PR #336.

'cuelist': json.dumps(cuelist),
'hide_cues': hide_cues,
'tip_name': self.tip_shown.name if self.tip_shown else None,
# BEGIN: Sample Tour
Copy link
Contributor

Choose a reason for hiding this comment

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

sample?

Copy link
Contributor

Choose a reason for hiding this comment

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

Transitional hybrid mode resulting from trying to do too much in one PR, cleaned up in PR #336.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What are the implications for this PR, then? Is it simply a matter of removing the "sample tour" comments? It goes back to the issue of whether the singleton popovers can be merged vs. combining this branch with the tour branch.

"""Test whether this tip can be shown on a particular page"""
# Teacher/parent-only tips
if user.role == Roles.STUDENT and self.name in ['book_actions', 'activity']:
if user.role == Roles.STUDENT and self.name in TEACHER_ONLY_TIPS:
Copy link
Contributor

Choose a reason for hiding this comment

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

Also Roles.GUEST or use something like "not user.can_manage_periods". Currently guests are being assigned teacher-only tips.

Copy link
Collaborator Author

@klown klown Nov 2, 2022

Choose a reason for hiding this comment

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

I should have included a GUEST user in the tests. When GUEST is tested, the TipType.can_show() fails for the activity tip on the Dashboard.

By implication, teacher tips should also show for guests using the current version in production where only book_actions and activity tips are checked in TipType.can_show(). Do book_actions or activity tooltip pop-up for guests? I suspect not because the Dashboard for guests does no include the relevant activity panel nor the book_actions menu. As such, there is nothing for the tooltip to point to.

But, in the current situation, there are more TEACHER_ONLY_TIPS some of whose targets appear for guest users. So, I'll check for guest users.

if self.name == 'switch':
return page == 'Reading' and version_count > 1
# Thoughts TipType is only for students
if self.name == 'thoughts' and user.role != Roles.STUDENT:
Copy link
Contributor

Choose a reason for hiding this comment

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

Also GUEST, see above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right.

</div>
{% elif tour_name == "book_actions" %}
<!-- book_actions -->
{% if clusive_user.role == 'TE' %}
Copy link
Contributor

Choose a reason for hiding this comment

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

This file with all of its 'if' statements feels extremely fragile, it would be great to do some refactoring. Why is this one just TE, while most are TE or PA? Is there some reason that parents should not get to see the video?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'll see if I can refactor and simplify the template. As for the missing "or PA", that's something like a copy-paste error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mbrambilla what kind of grief am I going to cause you due to a refactoring of the popover_tour.html template?

Copy link
Contributor

@mbrambilla mbrambilla Nov 2, 2022

Choose a reason for hiding this comment

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

@klown Most of my refactoring in popover_tour.html was around the 'footer' section, as seen here - you will need to click the 'load diff' link to see the changes: #336 - popover_tour.html

The goal was to create a re-usable template for the footer section to reduce redundant template markup.

Copy link
Collaborator Author

@klown klown Nov 2, 2022

Choose a reason for hiding this comment

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

Thanks @mbrambilla. I thought about merging just your footer change into this PR, but it has features that don't apply here or might break things. I'll work on making a suitable version. Since that is where most of your refactoring was done, it should make merge conflicts smaller.
🤞

<p>Click “More actions” (three dots) to assign or customize any book, and for books you uploaded to Clusive, to edit information or delete a book.</p>
<div class="row gx-0_5 flex-items-center">
<div class="col">
{% if has_teacher_resource %}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of passing in the 'has_teacher_resource' variable, given that this template has hard-coded the URL of any teacher resource that exists already? In this case, has_teacher_resource is passed in as false by LibraryView. Clearly there is one, but the link is not displayed.

Copy link
Collaborator Author

@klown klown Nov 2, 2022

Choose a reason for hiding this comment

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

The general rationale of has_teacher_resource was flexibility in showing the link. It should have been named has_teacher_resource_link or, even better, show_teacher_resource_link.

Admittedly it's somewhat muddled in that the link is not shown for student and guest users, somthing that could be handled by show_teacher_resource_link. But the template covers that situation by the check for a TE or PA role*.

Still, there are cases where the user is a teacher or a parent and the link should not be shown. For example, if the user has navigated to the Manage page and the Manage popover shows, the link in the popover is odd since it just navigates to the page the user is viewing. It should not be shown in this case.

As for the Library case, that's a bug; it should not be false.

*Perhaps this is part of the refactoring: Move the role check logic to views.py to set show_teacher_resource_link and then use only that boolean in the template. It would remove some clutter.

@bgoldowsky
Copy link
Contributor

The PR is a little confusing because it contains things related to the tour, but doesn't actually implement the tour. So I think things like the 'tour samples' passed in context variables are harmless, but hope they will be cleaned up in the next PR.

There are defintely some logic errors, mostly due to checking for STUDENT or TEACHER but forgetting about GUEST and PARENT.

@klown
Copy link
Collaborator Author

klown commented Nov 7, 2022

@boris, @mbrambrilla, I have made changes in response to the review comments, mainly to refactor and reorganize the popover_tour.html template. I think it could be simplified further if some context such as the title of the popover and the video link were set in the views.py. But I'm not sure what belongs in the template and what belongs in the code; and am leaning towards the titles being in the template. On the other hand, if they and other context were in the code, then the large {% if %} could be eliminated. Or, perhaps just moved into the views.py code.

{% if tour_name == ...%} 
... 
{% elif tour_name == ... %}
...
{ % elif ... %}
...
{% endif %}

In addition, I noticed another page that was not included in the show-tip logic. The page is the ResourcePage. The result is that when using the Reader to view a teacher resource, there are no popovers, and, by implication, there will be no tour. I modified the code to treat the ResourcePage as having the same tip types as the Reading page. Does that make sense?

@klown
Copy link
Collaborator Author

klown commented Nov 7, 2022

Regarding more refactoring, I think there is a structure for each popover along the following lines:

tour_properties: {
    'settings': {
        'title': 'Settings',
        'video': 'https://videos.sproutvideo.com/embed/a79edbb41414e7c72e/96f3dfacf85e2603?type=hd',
        'tip_text': '<p>Change the font, colors, and more! Settings let you choose the look, supports, and reading tools to make Clusive all your own.</p>',
        'resource_id': 'SSETTINGS',
        'resource_name': 'settings',
    },
    'readaloud': {
        'title': 'Read-aloud',
        'video': 'https://videos.sproutvideo.com/embed/449edbb51c1ae6cecd/90717ea3b61bbdd3?type=hd',
        'tip_text': '<p>Click the page read aloud icon to hear the entire page. Select text and click read aloud in the context menu to hear a smaller selection or a single word read aloud.</p>',
        'resource_id': None,
        'resource_name': 'None,
    },
    ...
}

It's a lookup-table where each tip type (e.g., settings) defines a set of values for that popover dialog, namely, its title, the link to its video, the tip text, and its teacher resource link, if any. The properties appropriate to the response are keyed by the tip_shown in the context and are set as tour_properties.

In that case, I think the template's {%if tour_name == ...%) ... {% elif %} ... {% endif %} is reduced to just one template where the tour_properties fields fill at the appropriate places.

@klown
Copy link
Collaborator Author

klown commented Nov 8, 2022

I wrote:

Regarding more refactoring, I think there is a structure for each popover along the following lines:

I pushed a version of this approach to another branch based on this one. This shows the markup for all but one of the popover dialogs. The context popover turns out to be a special case.

Allow the test to pass if the actual time is within a minute of the
expected time since, in reality, the actual time is later than the
time passed in when set.
@bgoldowsky bgoldowsky merged commit b7396dc into development Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants