gocodebox / lifterlms

LifterLMS, a WordPress LMS Solution: Easily create, sell, and protect engaging online courses.
https://lifterlms.com
GNU General Public License v3.0
180 stars 134 forks source link

Quiz setting does not obey the Limit Attempts setting. #2092

Closed toyinogun closed 2 years ago

toyinogun commented 2 years ago

Reproduction Steps

Expected Behavior

You should not be allowed to re-take the quiz

Actual Behavior

You can keep taking the quiz as many times as you want by clicking the back button.

Error Messages / Logs


### System and Environment Information

<details>
<summary>System Report</summary>

<!-- Paste your System Report between the three backticks below this line -->

Wordpress

Home Url: [removed] Site Url: [removed] Login Url: [removed]/wp-login.php Version: 5.4.2 Debug Mode: Yes Debug Log: Yes Debug Display: No Locale: en_US Multisite: No Page For Posts: Not Set Page On Front: Home (#2) [[removed]/] Permalink Structure: Show On Front: page Wp Cron: Yes

Settings

Version: 5.6.0 Db Version: 5.6.0 Course Catalog: Course Catalog (#56) [[removed]/?page_id=56] Membership Catalog: Membership Catalog (#57) [[removed]/?page_id=57] Student Dashboard: Dashboard (#59) [[removed]/?page_id=59] Checkout Page: My Courses (#6) [[removed]/?page_id=6] Course Catalog Per Page: 9 Course Catalog Sorting: menu_order,ASC Membership Catalog Per Page: 9 Membership Catalog Sorting: menu_order Site Membership: Not Set Courses Endpoint: my-courses Edit Endpoint: edit-account Lost Password Endpoint: lost-password Vouchers Endpoint: redeem-voucher Autogenerate Username: yes Password Strength Meter: no Minimum Password Strength: strong Terms Required: yes Terms Page: Not Set Checkout Names: required Checkout Address: optional Checkout Phone: optional Checkout Email Confirmation: no Open Registration: no Registration Names: required Registration Address: optional Registration Phone: optional Registration Voucher: optional Registration Email Confirmation: yes Account Names: required Account Address: optional Account Phone: optional Account Email Confirmation: no Confirmation Endpoint: confirm-payment Force Ssl Checkout: yes Country: US Currency: USD Currency Position: left Thousand Separator: , Decimal Separator: . Decimals: 2 Trim Zero Decimals: no Recurring Payments: yes Email From Address: [removed] Email From Name: [removed] Email Footer Text: Email Header Image: 123 Cert Bg Width: 800 Cert Bg Height: 616 Cert Legacy Compat: no

Constants

LLMS_REMOVE_ALL_DATA: undefined LLMS_REST_DISABLE: undefined LLMS_SITE_FEATURE_RECURRING_PAYMENTS: undefined LLMS_SITE_IS_CLONE: undefined

Gateways

PayPal: Enabled PayPal Test Mode: Disabled PayPal Logging: yes PayPal Order: 1 Stripe: Disabled Stripe Test Mode: Disabled Stripe Logging: Stripe Order: 1 Manual: Enabled Manual Logging: no Manual Order: 1

Server

Mysql Version: 10.3.34 Php Curl: Yes Php Default Timezone: UTC Php Fsockopen: Yes Php Max Input Vars: 2000 Php Max Upload Size: 1 GB Php Memory Limit: 1024M Php Post Max Size: 1024M Php Soap: Yes Php Suhosin: No Php Time Limt: 300 Php Version: 7.4.28 Software: LiteSpeed Wp Memory Limit: 40M

Browser

HTTP USER AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.46

Theme

Name: LifterLMS LaunchPad Version: 2.4.6 Themeuri: https://lifterlms.com/launchpad/ Authoruri: https://gocodebox.com Template: Child Theme: No Llms Support: No

Plugins

Activity Log: 2.8.2 All in one Favicon: 4.7 appful: 1.0.130 Appilix: 1.0 Appmaker WP - Convert WordPress to Native Android & iOS App: 0.4.3 Audit Trail: 1.3 Code Snippets: 2.14.3 Debug Bar: 1.1.2 Elementor: 3.5.5 Essential Addons for Elementor: 5.0.6 LifterLMS: 5.6.0 LifterLMS Advanced Quizzes: 2.0.0 LifterLMS Advanced Videos: 1.0.0-beta.17 LifterLMS Custom Fields: 2.0.2 LifterLMS Gravity Forms: 2.1.2 LifterLMS Groups: 1.0.0-beta.18 LifterLMS Helper: 3.4.1 LifterLMS MailChimp Add-on: 3.2.0 LifterLMS PayPal Gateway: 1.3.0 LifterLMS PDFs: 1.0.0 LifterLMS Private Areas: 1.1.5 LifterLMS Social Learning: 1.4.0 LifterLMS Stripe Payment Gateway: 5.4.0 LifterLMS WooCommerce: 2.2.1 LifterLMS WPForms: 1.1.1 LiteSpeed Cache: 4.5.0.1 MobiLoud News: 4.3.8 PDF Poster PRO: 1.6 ProfilePress: 3.2.7 Remove Footer Credit: 1.0.12 UpdraftPlus - Backup/Restore: 1.22.1 Video Conferencing with Zoom: 3.8.4 Visibility Logic for Elementor: 2.2.7 WappPress - Create an Android Mobile App for any WordPress site in just 1 click and 1 minute with AI-Powered Mobile App Builder and Maker: 5.0.0 WP All Export: 1.3.3 WP Force SSL: 1.65 WPForms Lite: 1.7.2.1

Integrations

BbPress: No BuddyPress: No LifterLMS Groups: Yes LifterLMS Gravity Forms: No WooCommerce: No LifterLMS WPForms: Yes LifterLMS MailChimp: No LifterLMS Private Areas: Yes LifterLMS Social Learning: No Videos: Vimeo: No Videos: Wistia: No Videos: YouTube: Yes

Template Overrides



</details>

This issue has be recreated:
+ [x] Locally
+ [x] On a staging site
+ [x] On a production website
+ [x] With only LifterLMS and a default theme

HS-189485
eri-trabiccolo commented 2 years ago

@toyinogun I don't seem to be able to reproduce this locally. You said you reproduced it on a test website, can I look into that? can you also record a video?

eri-trabiccolo commented 2 years ago

Talked with Toyin on slack. I was finally able to reproduce the issue, with Firefox, although not with Chrome. Must be due to my Chrome version (on mac). The thing has to do, as someone would expect, with the browser caching. Clicking on the browser back button loads the page from the cache (at least on firefox). I rapidly tweaked this to disable caching on quizzes too: if ( is_page( $ids ) || is_quiz() ) { but didn't work. I've found that the wp "no cache" headers seem to be not enough to prevent that kind of "caching". But adding no-store to the 'Cache-Control' list fixes the issue.

We could use the filter 'nocache_headers', to tweak that. Would we ever need the quiz page to be stored in the browser? Don't think so.

In any case this is just part of the problem. I think we should also: 1) double check attempts limit was not reached when starting a quiz (via ajax) 2) prevent attempt submission if limit reached.

thomasplevy commented 2 years ago

@eri-trabiccolo all this sounds good to me, thanks