sensei icon indicating copy to clipboard operation
sensei copied to clipboard

Fix timed quiz still working for students even after time ends

Open Imran92 opened this issue 1 year ago β€’ 6 comments

Resolves https://github.com/Automattic/sensei-pro/issues/2606

Proposed Changes

In timed quizzes, when time is up, the frontend code clicks the completion button to submit the quiz. But in the cases where the quiz was paginated, completion button only got rendered on the last page. So if the student was not on the last page, the quiz didn't get submitted, and the student was still able to answer.

To fix that, we're rendering the button even in the middle pages so that the completion function still works, but keeping it hidden in those cases so that UI doesn't break or change from before.

Testing Instructions

  1. Create a Course with a lesson that has a quiz with many questions
  2. Make sure you have Sensei Pro enabled
  3. From the quiz settings, set pagination to Multi Page and set per page value to 1 or a small number to generate many pages
  4. Also enable Quiz Timer option, set a small time
  5. Now take the quiz as a student, be on any page other than the last page
  6. Make sure when time is up, the quiz gets submitted
  7. Now take the quiz as another student, finish the quiz normally and make sure it works
  8. Now take the quiz as a student for the third time, stay on the last page of the quiz without submitting, make sure the quiz gets submitted automatically when the time is up.

Pre-Merge Checklist

  • [x] PR title and description contain sufficient detail and accurately describe the changes
  • [x] Acceptance criteria is met
  • [x] Decisions are publicly documented
  • [x] Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • [ ] All strings are translatable (without concatenation, handles plurals)
  • [x] Follows our naming conventions (P6rkRX-4oA-p2)
  • [ ] Hooks (p6rkRX-1uS-p2) and functions are documented
  • [ ] New UIs are responsive and use a mobile-first approach
  • [ ] New UIs match the designs
  • [ ] Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • [ ] Legacy courses (course without blocks) are tested
  • [ ] Code is tested on the minimum supported PHP and WordPress versions
  • [ ] User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • [ ] "Needs Documentation" label is added if this change requires updates to documentation
  • [ ] Known issues are created as new GitHub issues

Imran92 avatar Sep 04 '24 07:09 Imran92

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Sep 04 '24 07:09 github-actions[bot]

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Sep 04 '24 07:09 github-actions[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 52.37%. Comparing base (f13414e) to head (1708578). Report is 110 commits behind head on trunk.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##              trunk    #7675      +/-   ##
============================================
+ Coverage     51.92%   52.37%   +0.44%     
- Complexity    11449    11463      +14     
============================================
  Files           651      653       +2     
  Lines         48659    48761     +102     
  Branches        468      480      +12     
============================================
+ Hits          25268    25537     +269     
+ Misses        23012    22835     -177     
- Partials        379      389      +10     

see 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update ca19e19...1708578. Read the comment docs.

codecov[bot] avatar Sep 04 '24 07:09 codecov[bot]

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Sep 04 '24 13:09 github-actions[bot]

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Sep 04 '24 13:09 github-actions[bot]

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Sep 04 '24 13:09 github-actions[bot]

@Imran92 Can you please address the feedback in this one? πŸ™‡πŸ»β€β™€οΈ

donnapep avatar Oct 28 '24 15:10 donnapep

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Oct 30 '24 06:10 github-actions[bot]

WordPress Dependencies Report

The github-action-wordpress-dependencies-report action has detected some script changes between the commit b54aec37315242076ff038c00a03e0fe1087e26d and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Dependencies Removed Dependencies Total Size Size Diff
blocks/quiz/style.js wp-polyfill 24 B +24 B ( +100% πŸ”Ό )

This comment was automatically generated by the github-action-wordpress-dependencies-report action.

github-actions[bot] avatar Oct 30 '24 06:10 github-actions[bot]

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Oct 30 '24 06:10 github-actions[bot]

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Oct 30 '24 06:10 github-actions[bot]

@Imran92 Can you please address the feedback in this one? πŸ™‡πŸ»β€β™€οΈ

Thanks Donna! I've updated it here https://github.com/Automattic/sensei/pull/7675#discussion_r1821990573

Imran92 avatar Oct 30 '24 07:10 Imran92

Test the previous changes of this PR with WordPress Playground.

github-actions[bot] avatar Oct 30 '24 15:10 github-actions[bot]