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

Improve view of variant history when a previous variant is selected #9782

Merged
merged 24 commits into from May 21, 2024

Conversation

jonatanschroeder
Copy link
Member

@jonatanschroeder jonatanschroeder commented Apr 29, 2024

Follow-up to #6105, resolves #9780. Minor improvements to the view of the variant history, especially when viewing a previous history. Namely:

  • If there is an open variant (i.e., a variant that has been created but still has attempts left), it is listed as "Open" (it wasn't listed before), with a different color.
  • When viewing a previous variant, the variant itself is shown in the history with a different style (I'm open to suggestions for different options).
  • "Try a new variant" button in question footer has label changed to "Go to latest variant" if there is an open variant.
  • Label for variant history changed to account for the fact that the variants listed may not be "previous" to the one being shown.

One thing to consider: when a new variant is created, it will not be shown immediately in the variant list, since the variant is created after the query that finds previous variants. It will be shown as soon as the page is refreshed or a submission is made, or when going to the assessment overview. Should this be changed to either (a) always show this variant or (b) show only open variants with at least one submission?

Copy link
Contributor

github-actions bot commented Apr 29, 2024

All images

Image Platform Old Size New Size Change
prairielearn/executor:e719a7865f12901d79df6c15aad3445bba30f465 null 1642.80 MB 1642.80 MB -0.00%
prairielearn/prairielearn:e719a7865f12901d79df6c15aad3445bba30f465 linux/amd64 1642.96 MB 1642.80 MB -0.01%

@mwest1066
Copy link
Member

Another possible improvement might be to highlight the currently-displayed variant in the list of variants when showing an old variant. Furthermore, when we are viewing an old variant, we could show the current one in the different color and show the open variant in the same color as the old ones.

@jonatanschroeder
Copy link
Member Author

Another possible improvement might be to highlight the currently-displayed variant in the list of variants when showing an old variant. Furthermore, when we are viewing an old variant, we could show the current one in the different color and show the open variant in the same color as the old ones.

This is done in this PR...

@mwest1066
Copy link
Member

This is done in this PR...

Haha, that will teach me to comment before actually running the code 😄

@@ -24,13 +24,20 @@
<% } %>
<% for (var i = 0; i < previous_variants.length; i++) { %>
<a
class="badge badge-secondary <%= collapseClass %>"
class="badge <%= previous_variants[i].variant_id == current_variant_id ? 'badge-light' : previous_variants[i].open ? 'badge-primary' : 'badge-secondary' %> <%= collapseClass %>"
Copy link
Member

Choose a reason for hiding this comment

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

I find the .badge-light is too easy to overlook, especially in comparison to the .badge-primary of the open variant. I actually think that there isn't a need to highlight the open variant, so I suggest changing the current variant to .badge-primary (or maybe .badge-info?) and removing the special handling of the open variant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in bec5ce0:
image

@@ -74,7 +76,6 @@ WITH
LEFT JOIN variant_max_submission_scores AS vmss ON (vmss.variant_id = v.id)
WHERE
v.instance_question_id = $instance_question_id
AND NOT v.open
AND NOT v.broken
Copy link
Member

Choose a reason for hiding this comment

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

I almost wonder whether we should also include broken variants here? That would allow students to go back to any variant that they had seen, rather than hiding broken variants? I'm a bit torn being being transparent (showing broken variants) and keeping things simple (hiding broken variants).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think allowing a student to open a broken variant may cause more confusion than necessary. Besides, in some cases a broken variant will cause an issue to be created just by opening it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we don't want to generate any more issues than we already do 😬

@mwest1066
Copy link
Member

Note that #9851 includes another copy of the query. We'll need to at least remove WHERE v.open from that query as well. If there's a clean way to pull this out into a library or model function then that would be even better.

@jonatanschroeder
Copy link
Member Author

Note that #9851 includes another copy of the query. We'll need to at least remove WHERE v.open from that query as well.

Done in 8b9f2cc.

@jonatanschroeder
Copy link
Member Author

If there's a clean way to pull this out into a library or model function then that would be even better.

Done in 8a90a70.

@jonatanschroeder
Copy link
Member Author

@mwest1066 one question: as I was testing this, I noticed that single-variant questions still show the "All variants" prompt in the side panel. I believe this information is confusing and brings no additional information. Should I remove this if the question is single variant?

@jonatanschroeder
Copy link
Member Author

@mwest1066 one question: as I was testing this, I noticed that single-variant questions still show the "All variants" prompt in the side panel. I believe this information is confusing and brings no additional information. Should I remove this if the question is single variant?

Since there are cases where single variant may not be set but a single variant ends up being there in effect, and cases where the question changed from multi-variant to single-variant later, I decided to instead make the logic for this to show the list of variants in the score panel if there are other variants. This means that, in effect, if the current variant is the first and only variant, the "All variants" (or "Previous variants" in the master version) will not show, though creating a new variant will then start showing the list. I'm open to discussing other alternatives. The assessment overview is not affected, and always shows the list of variants, even if there is only one.

Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 97.95918% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 66.44%. Comparing base (6a80757) to head (e719a78).

Files Patch % Lines
apps/prairielearn/src/lib/question-render.js 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9782      +/-   ##
==========================================
+ Coverage   66.43%   66.44%   +0.01%     
==========================================
  Files         453      453              
  Lines       70289    70319      +30     
  Branches     5647     5653       +6     
==========================================
+ Hits        46694    46723      +29     
  Misses      23171    23171              
- Partials      424      425       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 16 to 17
<%# Only show previous variants if the question allows multiple variants, and there is at least one variant other than the current one %>
<% if (instance_question_info.previous_variants?.some((previous_variant) => previous_variant.id != locals.variant?.id)) { %>
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 the comment is now slightly wrong (we don't require the question to allow multiple variants).

@mwest1066
Copy link
Member

@mwest1066 one question: as I was testing this, I noticed that single-variant questions still show the "All variants" prompt in the side panel. I believe this information is confusing and brings no additional information. Should I remove this if the question is single variant?

Since there are cases where single variant may not be set but a single variant ends up being there in effect, and cases where the question changed from multi-variant to single-variant later, I decided to instead make the logic for this to show the list of variants in the score panel if there are other variants. This means that, in effect, if the current variant is the first and only variant, the "All variants" (or "Previous variants" in the master version) will not show, though creating a new variant will then start showing the list. I'm open to discussing other alternatives. The assessment overview is not affected, and always shows the list of variants, even if there is only one.

I think that we should also show "All variants" if the question allows multiple variants, even if we don't currently have any old variants. It's already clear from the UI that other variants are possible in principle, so I think it's helpful to explicitly show that there aren't any others. What do you think?

@jonatanschroeder
Copy link
Member Author

I think that we should also show "All variants" if the question allows multiple variants, even if we don't currently have any old variants. It's already clear from the UI that other variants are possible in principle, so I think it's helpful to explicitly show that there aren't any others. What do you think?

I'm ok with that. For completeness I included the case where single-variant was false at some point in the past, such that multiple variants exist. See latest commit.

@jonatanschroeder jonatanschroeder added this pull request to the merge queue May 21, 2024
Merged via the queue into master with commit 42959d3 May 21, 2024
9 checks passed
@jonatanschroeder jonatanschroeder deleted the previous-variants-open-view branch May 21, 2024 18:29
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.

Review button for new variant when in previous variants
2 participants