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

Add a progress table eraser tool #7230

Merged
merged 7 commits into from
Oct 20, 2023
Merged

Conversation

merkushin
Copy link
Member

@merkushin merkushin commented Oct 18, 2023

Resolves #5868

Proposed Changes

  • Add a tool that deletes progress tables and quiz submission tables.

Testing Instructions

  1. Enable the feature flag.
  2. Make sure you have progress tables in DB. If not remove the sensei-version option from wp_options table and reload a page (it should run schema update and create tables).
  3. Make sure you don't see the tool ("Delete student progress tables").
  4. Disable the feature flag.
  5. Take a course and submit a quiz to have some rows in tables.
  6. Go to Sensei LMS > Tools.
  7. Find Delete student progress tables, click "Visit Tool".
  8. On the next screen, try to click "Delete Progress Tables" without giving your confirmation.
  9. Must not delete tables, shows a warning.
  10. Now check the confirmation and click "Delete Progress Tables".
  11. Make sure tables were deleted.
  12. Go to Tools and check the tool is not available. (You can see it, but the "Visit Tool" button is disabled.)

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • 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
  • 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

@merkushin merkushin added this to the 4.19.0 milestone Oct 18, 2023
@merkushin merkushin requested a review from a team October 18, 2023 03:28
@merkushin merkushin self-assigned this Oct 18, 2023
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #7230 (4299161) into trunk (cc97590) will increase coverage by 0.03%.
Report is 117 commits behind head on trunk.
The diff coverage is 31.28%.

Impacted file tree graph

@@             Coverage Diff              @@
##              trunk    #7230      +/-   ##
============================================
+ Coverage     50.40%   50.43%   +0.03%     
- Complexity    10888    10909      +21     
============================================
  Files           604      605       +1     
  Lines         45925    45986      +61     
  Branches        402      402              
============================================
+ Hits          23149    23194      +45     
- Misses        22449    22465      +16     
  Partials        327      327              
Files Coverage Δ
includes/admin/class-sensei-admin-notices.php 50.86% <ø> (ø)
includes/admin/class-sensei-learner-management.php 4.20% <ø> (ø)
...-sensei-learners-admin-bulk-actions-controller.php 40.12% <ø> (ø)
.../class-sensei-learners-admin-bulk-actions-view.php 55.47% <ø> (ø)
includes/admin/class-sensei-learners-main.php 5.30% <ø> (ø)
includes/admin/class-sensei-tools.php 21.49% <ø> (ø)
...s/admin/home/class-sensei-home-remote-data-api.php 95.52% <ø> (ø)
...dmin/home/help/class-sensei-home-help-provider.php 97.43% <ø> (ø)
...ome/notices/class-sensei-home-notices-provider.php 100.00% <ø> (ø)
...s/admin/home/notices/class-sensei-home-notices.php 90.98% <ø> (ø)
... and 100 more

... and 3 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 2eeced5...4299161. Read the comment docs.

@merkushin merkushin marked this pull request as draft October 18, 2023 12:43
@merkushin merkushin marked this pull request as ready for review October 19, 2023 06:45
@m1r0
Copy link
Member

m1r0 commented Oct 19, 2023

I've disabled the feature and have the tables but the "Visit Tool" is disabled. Any ideas why?

I'm starting to think that maybe it would be best to introduce this tool after we have the settings UI. That way we can show the tool if the HPPS feature is enabled (same as the migration tool) and make it available if the tables are not used. WDYT?

@merkushin
Copy link
Member Author

merkushin commented Oct 20, 2023

@m1r0
My bad, didn't test well after the last commit.
The problem there is that the class relies on the Schema::get_tables() which returns empty array when the feature is turned off.

Fixed here: 11e0941

I'm starting to think that maybe it would be best to introduce this tool after we have the settings UI. That way we can show the tool if the HPPS feature is enabled (same as the migration tool) and make it available if the tables are not used. WDYT?

Makes sense. So what we should to do with this PR?

m1r0
m1r0 previously approved these changes Oct 20, 2023
Copy link
Member

@m1r0 m1r0 left a comment

Choose a reason for hiding this comment

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

Tests well. 👍 I found a few very minor things that are not a blocker.

Makes sense. So what we should to do with this PR?

Let's merge it as is so it doesn't get stale and improve it later. I will make a new card for the improvements.

includes/class-sensei.php Outdated Show resolved Hide resolved
}

Sensei_Tools::instance()->add_user_message( $message );
wp_safe_redirect( $this->get_tool_url() );
Copy link
Member

@m1r0 m1r0 Oct 20, 2023

Choose a reason for hiding this comment

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

I've noticed that the tool is unavailable after deleting the tables and you get a This tool is not currently available. Please try again later. notice and you are back to the tools main screen.

image

To avoid this, maybe just redirect directly to the tools main screen instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, Miro. Fixed it here: 4299161

I redirect to the Tools page when tables were deleted.

@merkushin merkushin merged commit 9efcb14 into trunk Oct 20, 2023
22 of 23 checks passed
@merkushin merkushin deleted the add/progress-tables-eraser branch October 20, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a tool that deletes the new progress tables
2 participants