Git Product home page Git Product logo

moodle-enrol_wallet's People

Contributors

fmido88 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

buda9

moodle-enrol_wallet's Issues

Idea: Predefined Wallet Top-Up Amounts

What do you think about this idea? Instead of users manually enter the amount they want to top up their wallet, we could have an option (or a separate page) where they can choose from predefined amounts, for example, buttons with packages of $10, $20, $40, and $80. Once they click an amount, a payment page would open for them where they could finish purchase. The practical application of this is for purchasing 1-on-1 package sessions with teachers at e.g. a language school. Example:

Screenshot_120

or

Screenshot_127

So basically, when someone clicks "package" and buy now button, it should open popup window to make a payment

Would it be to difficult to build this?

PS. Woo example of this is something like this https://woo.com/products/tiered-pricing-table-for-woocommerce/

Invalid @covers

If you run phpunit tests calculating the code coverage, you get 47 warnings:

RUN  PHPUnit tests for enrol_wallet
Moodle 4.2.6+
Php: 8.2.16
PHPUnit 9.5.28

WWWWWWWWW.WWWWWWWWWWWWWWW.WWWWWWWWWWWWWWWWWWWWWWW                 49 / 49 (100%)

Time: 01:42.533, Memory: 231.00 MB

There were 47 warnings:

1) enrol_wallet\coupons_test::test_is_enabled_type
"@covers ::is_enabled_type" is invalid

2) enrol_wallet\coupons_test::test_is_enabled
"@covers ::is_enabled" is invalid

3) enrol_wallet\coupons_test::test_validate_fixed_coupon
"@covers ::validate_coupon" is invalid

4) enrol_wallet\coupons_test::test_validate_enrol_coupon
"@covers ::validate_coupon" is invalid

5) enrol_wallet\coupons_test::test_validate_discount_coupon
"@covers ::validate_coupon" is invalid

6) enrol_wallet\coupons_test::test_validate_category_coupon
"@covers ::validate_coupons" is invalid

7) enrol_wallet\coupons_test::test_apply_fixed_coupon
"@covers ::apply_coupon" is invalid

8) enrol_wallet\coupons_test::test_apply_category_coupon
"@covers ::apply_coupon" is invalid

9) enrol_wallet\coupons_test::test_apply_enrol_coupon
"@covers ::apply_coupon" is invalid

10) enrol_wallet\enrol_wallet_test::test_sync_nothing
"@covers ::sync" is invalid

11) enrol_wallet\enrol_wallet_test::test_longtimnosee
"@covers ::sync" is invalid

12) enrol_wallet\enrol_wallet_test::test_expired
"@covers ::expired" is invalid

13) enrol_wallet\enrol_wallet_test::test_send_expiry_notifications
"@covers ::send_expiry_notification" is invalid

14) enrol_wallet\enrol_wallet_test::test_show_enrolme_link
"@covers ::show_enrolme_link" is invalid

15) enrol_wallet\enrol_wallet_test::test_can_self_enrol
"@covers ::can_self_enrol" is invalid

16) enrol_wallet\enrol_wallet_test::test_get_welcome_email_contact
"@covers ::get_welcome_email_contact" is invalid

17) enrol_wallet\enrol_wallet_test::test_get_user_enrolment_actions
"@covers ::get_user_enrolment_actions" is invalid

18) enrol_wallet\enrol_wallet_test::test_enrol_self
"@covers ::enrol_self" is invalid

19) enrol_wallet\enrol_wallet_test::test_is_course_enrolment_restriction
"@covers ::is_course_enrolment_restriction" is invalid

20) enrol_wallet\enrol_wallet_test::test_hide_due_cheaper_instance
"@covers ::hide_due_cheaper_instance" is invalid

21) enrol_wallet\enrol_wallet_test::test_unenrol_user
"@covers ::unenrol_user" is invalid

22) enrol_wallet\enrol_wallet_test::test_get_unenrolself_link
"@covers ::get_unenrolself_link" is invalid

23) enrol_wallet\externallib_test::test_get_instance_info
"@covers ::get_instance_info" is invalid

24) enrol_wallet\externallib_test::test_enrol_user
"@covers ::enrol_user" is invalid

25) enrol_wallet\notifications_test::test_transaction_notifications
"@covers ::transaction_notify" is invalid

26) enrol_wallet\observer_test::test_wallet_completion_awards
"@covers ::wallet_completion_awards" is invalid

27) enrol_wallet\observer_test::test_wallet_gifting_new_user
"@covers ::wallet_gifting_new_user" is invalid

28) enrol_wallet\observer_test::test_release_referral_gift
"@covers ::release_referral_gift" is invalid

29) enrol_wallet\payment\service_provider_test::test_get_payable_walletenrol
"@covers ::get_payable" is invalid

30) enrol_wallet\payment\service_provider_test::test_get_payable_wallettopup
"@covers ::get_payable" is invalid

31) enrol_wallet\payment\service_provider_test::test_get_success_url_walletenrol
"@covers ::get_success_url" is invalid

32) enrol_wallet\payment\service_provider_test::test_get_success_url_wallettopup
"@covers ::get_success_url" is invalid

33) enrol_wallet\payment\service_provider_test::test_deliver_order_walletenrol
"@covers ::deliver_order" is invalid

34) enrol_wallet\payment\service_provider_test::test_deliver_order_wallettopup
"@covers ::deliver_order" is invalid

35) enrol_wallet\transactions_test::test_credit_debit
"@covers ::payment_topup" is invalid

36) enrol_wallet\transactions_test::test_get_coupon_value
"@covers ::get_coupon_value" is invalid

37) enrol_wallet\turn_non_refundable_test::test_turn_non_refundable
"@covers \turn_non_refundable" is invalid

38) enrol_wallet\turn_non_refundable_test::test_check_transform_validation
"@covers ::check_transform_validation" is invalid

39) enrol_wallet\util\balance_op_test::test_conditional_discount_charging
"@covers ::conditional_discount_charging" is invalid

40) enrol_wallet\util\balance_op_test::test_credit
"@covers ::credit" is invalid

41) enrol_wallet\util\balance_op_test::test_credit_nocat
"@covers ::credit" is invalid

42) enrol_wallet\util\balance_op_test::test_debit
"@covers ::debit" is invalid

43) enrol_wallet\util\balance_op_test::test_debit_nocat
"@covers ::debit" is invalid

44) enrol_wallet\util\balance_op_test::test_free_balance
"@covers ::get_total_free" is invalid

45) enrol_wallet\util\balance_op_test::test_transfer_to_other
"@covers ::transfer_to_other" is invalid

46) enrol_wallet\util\instance_test::test_get_cost_after_discount
"@covers ::get_cost_after_discount" is invalid

47) enrol_wallet\util\instance_test::test_repurchase_discount_and_function
"@covers ::get_cost_after_discount" is invalid

WARNINGS!
Tests: 49, Assertions: 1072, Warnings: 47.

Generating code coverage report in Clover XML format ... done [00:00.475]


Code Coverage Report:
  2024-03-12 04:45:05

 Summary:
  Classes:  0.00% (0/59)
  Methods: 21.98% (91/414)
  Lines:   21.79% (2040/9362)

enrol_wallet\api\balance_op
  Methods:   0.00% ( 0/ 3)   Lines:   0.00% (  0/ 15)
enrol_wallet\api\instance
  Methods:   0.00% ( 0/ 3)   Lines:   0.00% (  0/ 14)
enrol_wallet\api\offers_form
  Methods:   0.00% ( 0/ 3)   Lines:   0.00% (  0/ 17)
enrol_wallet\category\helper
  Methods:  55.56% ( 5/ 9)   Lines:  67.92% ( 36/ 53)
enrol_wallet\category\operations
  Methods:  58.33% ( 7/12)   Lines:  85.15% ( 86/101)
enrol_wallet\category\options
  Methods:   0.00% ( 0/ 9)   Lines:   0.00% (  0/ 93)
enrol_wallet\coupons
  Methods:  40.00% (12/30)   Lines:  74.77% (249/333)
enrol_wallet\deleteselectedusers_form
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
enrol_wallet\deleteselectedusers_operation
  Methods:   0.00% ( 0/ 4)   Lines:   0.00% (  0/ 17)
enrol_wallet\editselectedusers_form
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
enrol_wallet\editselectedusers_operation
  Methods:   0.00% ( 0/ 4)   Lines:   0.00% (  0/ 58)
enrol_wallet\event\award_granted
  Methods:  33.33% ( 1/ 3)   Lines:  30.00% (  3/ 10)
enrol_wallet\event\cashback_applied
  Methods:  33.33% ( 1/ 3)   Lines:  30.00% (  3/ 10)
enrol_wallet\event\coupon_used
  Methods:  33.33% ( 1/ 3)   Lines:  37.50% (  3/  8)
enrol_wallet\event\enrolpage_viewed
  Methods:   0.00% ( 0/ 4)   Lines:   0.00% (  0/ 17)
enrol_wallet\event\newuser_gifted
  Methods:  33.33% ( 1/ 3)   Lines:  37.50% (  3/  8)
enrol_wallet\event\transactions_triggered
  Methods:  33.33% ( 1/ 3)   Lines:  17.65% (  3/ 17)
enrol_wallet\form\applycoupon_form
  Methods:   0.00% ( 0/ 3)   Lines:   0.00% (  0/ 92)
enrol_wallet\form\charger_form
  Methods:   0.00% ( 0/ 4)   Lines:   0.00% (  0/106)
enrol_wallet\form\conditional_discount
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/ 45)
enrol_wallet\form\coupons_edit
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/ 76)
enrol_wallet\form\coupons_generator
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/ 93)
enrol_wallet\form\coupons_upload
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/ 28)
enrol_wallet\form\empty_form
  Methods:   0.00% ( 0/ 1)   Lines:   0.00% (  0/  3)
enrol_wallet\form\enrol_form
  Methods:   0.00% ( 0/ 3)   Lines:   0.00% (  0/ 53)
enrol_wallet\form\insuf_form
  Methods:   0.00% ( 0/ 1)   Lines:   0.00% (  0/  3)
enrol_wallet\form\topup_form
  Methods:   0.00% ( 0/ 3)   Lines:   0.00% (  0/ 67)
enrol_wallet\form\transactions_filter
  Methods:   0.00% ( 0/ 1)   Lines:   0.00% (  0/ 54)
enrol_wallet\form\transfer_form
  Methods:   0.00% ( 0/ 3)   Lines:  81.72% ( 76/ 93)
enrol_wallet\notifications
  Methods:   0.00% ( 0/ 1)   Lines:  94.74% ( 36/ 38)
enrol_wallet\observer
  Methods:  33.33% ( 2/ 6)   Lines:  70.97% (110/155)
enrol_wallet\output\payment_info
  Methods:   0.00% ( 0/ 4)   Lines:   0.00% (  0/ 45)
enrol_wallet\output\renderer
  Methods:   0.00% ( 0/ 4)   Lines:   0.00% (  0/ 12)
enrol_wallet\output\wallet_balance
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/ 51)
enrol_wallet\pages
  Methods:   0.00% ( 0/ 4)   Lines:   0.00% (  0/188)
enrol_wallet\payment\service_provider
  Methods:  66.67% ( 2/ 3)   Lines:  93.94% ( 31/ 33)
enrol_wallet\privacy\provider
  Methods:   0.00% ( 0/ 7)   Lines:   0.00% (  0/260)
enrol_wallet\restriction\frontend
  Methods:   0.00% ( 0/ 1)   Lines:   0.00% (  0/ 51)
enrol_wallet\restriction\info
  Methods:   0.00% ( 0/11)   Lines:   0.00% (  0/ 86)
enrol_wallet\restriction\tree
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/ 46)
enrol_wallet\table\transactions
  Methods:   0.00% ( 0/12)   Lines:   0.00% (  0/ 92)
enrol_wallet\task\cleanup_wallet_items
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/ 14)
enrol_wallet\task\migrate_enrollments
  Methods:   0.00% ( 0/ 5)   Lines:   0.00% (  0/109)
enrol_wallet\task\send_expiry_notifications
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/  4)
enrol_wallet\task\sync_enrolments
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/  4)
enrol_wallet\task\turn_non_refundable
  Methods:   0.00% ( 0/ 4)   Lines:  85.71% ( 66/ 77)
enrol_wallet\transactions
  Methods:  25.00% ( 2/ 8)   Lines:  31.48% ( 17/ 54)
enrol_wallet\uploadcoupon\processor
  Methods:   0.00% ( 0/ 7)   Lines:   0.00% (  0/206)
enrol_wallet\uploadcoupon\processor_exception
  Methods:   0.00% ( 0/ 1)   Lines:   0.00% (  0/  2)
enrol_wallet\uploadcoupon\tracker
  Methods:   0.00% ( 0/ 5)   Lines:   0.00% (  0/ 68)
enrol_wallet\util\balance
  Methods:  72.41% (21/29)   Lines:  87.04% (188/216)
enrol_wallet\util\balance_op
  Methods:  47.62% (10/21)   Lines:  75.37% (306/406)
enrol_wallet\util\cm
  Methods:   0.00% ( 0/ 7)   Lines:   0.00% (  0/ 49)
enrol_wallet\util\discount_rules
  Methods:   8.33% ( 1/12)   Lines:  17.86% ( 30/168)
enrol_wallet\util\fake_info
  Methods:   0.00% ( 0/ 5)   Lines:   0.00% (  0/  5)
enrol_wallet\util\instance
  Methods:  52.38% (11/21)   Lines:  68.00% (102/150)
enrol_wallet\util\offers
  Methods:   3.45% ( 1/29)   Lines:   4.54% ( 21/463)
enrol_wallet\util\section
  Methods:   0.00% ( 0/ 7)   Lines:   0.00% (  0/ 48)
enrol_wallet\wordpress
  Methods:   0.00% ( 0/ 8)   Lines:   0.00% (  0/139)
enrol_wallet_external
  Methods:  66.67% ( 4/ 6)   Lines:  91.58% ( 87/ 95)
enrol_wallet_plugin
  Methods:  15.09% ( 8/53)   Lines:  38.55% (352/913)

When adding a coversDefaultClass tag, the warnings are gone. Sample:


/**
 * Tests for balance operations class.
 *
 * @package    enrol_wallet
 * @category   test
 * @copyright  2024 Mohammad Farouk <[email protected]>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @coversDefaultClass \enrol_wallet_plugin
 */
final class balance_op_test extends \advanced_testcase {

css not specific enough.

in your styles.css you define a number of generic styles that could clash with core moodle code or other locations where simliar names are used.

Moodle helpfully adds a number of classes to the body tag based on the path that you can use such as:
eg if you are have a file in mod/assign you would see the following class added to the body tag
path-mod-assign
so if you have an item with the class "filething" on the page you would target it like:

.path-mod-assign .filething {
   color: red;
}

Please make sure your css classes in styles.css are specific enough so they cannot clash with other core code.

table_exists error

vendor/bin/phpunit --colors --no-coverage --testsuite tool_dataprivacy_testsuite

...............................................................  63 / 306 ( 20%)
............................................................... 126 / 306 ( 41%)
............................................................... 189 / 306 ( 61%)
.................E............................................. 252 / 306 ( 82%)
......................................................          306 / 306 (100%)

Time: 00:52.784, Memory: 143.00 MB

There was 1 error:

1) tool_dataprivacy\expired_contexts_test::test_orphaned_records_are_cleared
Unexpected debugging() call detected.
Debugging: Call to undefined method pgsql_native_moodle_database::table_exists()
* line 190 of /payment/classes/privacy/provider.php: call to enrol_wallet\privacy\provider::delete_data_for_all_users_in_context()
* line 8149 of /lib/moodlelib.php: call to core_payment\privacy\provider::delete_data_for_all_users_in_context()
* line 578 of /privacy/classes/manager.php: call to component_class_callback()
* line 611 of /privacy/classes/manager.php: call to core_privacy\manager::component_class_callback()
* line 492 of /privacy/classes/manager.php: call to core_privacy\manager->handled_component_class_callback()
* line 440 of /admin/tool/dataprivacy/classes/expired_contexts_manager.php: call to core_privacy\manager->delete_data_for_all_users_in_context()
* line 388 of /admin/tool/dataprivacy/classes/expired_contexts_manager.php: call to tool_dataprivacy\expired_contexts_manager->delete_expired_context()
* line 2052 of /admin/tool/dataprivacy/tests/expired_contexts_test.php: call to tool_dataprivacy\expired_contexts_manager->process_approved_deletions()
* line 1548 of /vendor/phpunit/phpunit/src/Framework/TestCase.php: call to tool_dataprivacy\expired_contexts_test->test_orphaned_records_are_cleared()
* line 1154 of /vendor/phpunit/phpunit/src/Framework/TestCase.php: call to PHPUnit\Framework\TestCase->runTest()
* line 81 of /lib/phpunit/classes/advanced_testcase.php: call to PHPUnit\Framework\TestCase->runBare()
* line 728 of /vendor/phpunit/phpunit/src/Framework/TestResult.php: call to advanced_testcase->runBare()
* line 904 of /vendor/phpunit/phpunit/src/Framework/TestCase.php: call to PHPUnit\Framework\TestResult->run()
* line 675 of /vendor/phpunit/phpunit/src/Framework/TestSuite.php: call to PHPUnit\Framework\TestCase->run()
* line 675 of /vendor/phpunit/phpunit/src/Framework/TestSuite.php: call to PHPUnit\Framework\TestSuite->run()
* line 675 of /vendor/phpunit/phpunit/src/Framework/TestSuite.php: call to PHPUnit\Framework\TestSuite->run()
* line 653 of /vendor/phpunit/phpunit/src/TextUI/TestRunner.php: call to PHPUnit\Framework\TestSuite->run()
* line 144 of /vendor/phpunit/phpunit/src/TextUI/Command.php: call to PHPUnit\TextUI\TestRunner->run()
* line 97 of /vendor/phpunit/phpunit/src/TextUI/Command.php: call to PHPUnit\TextUI\Command->run()
* line 98 of /vendor/phpunit/phpunit/phpunit: call to PHPUnit\TextUI\Command::main()
* line 123 of /vendor/bin/phpunit: call to include()


lib/phpunit/classes/advanced_testcase.php:89

ERRORS!
Tests: 306, Assertions: 1214, Errors: 1.

$DB->table_exist() function does not exist in Moodle, however one can use

$dbman = $DB->get_manager();
$dbman->table_exists()

Plugin is not GDPR compliant

vendor/bin/phpunit --colors --no-coverage --testsuite core_privacy_testsuite

.............................................................   61 / 1833 (  3%)
.............................................................  122 / 1833 (  6%)
.............................................................  183 / 1833 (  9%)
.............................................................  244 / 1833 ( 13%)
.............................................................  305 / 1833 ( 16%)
.............................................................  366 / 1833 ( 19%)
.............................................................  427 / 1833 ( 23%)
.............................................................  488 / 1833 ( 26%)
.............................................................  549 / 1833 ( 29%)
.............................................................  610 / 1833 ( 33%)
.............................................................  671 / 1833 ( 36%)
.............................................................  732 / 1833 ( 39%)
.............................................................  793 / 1833 ( 43%)
.............................................................  854 / 1833 ( 46%)
.............................................................  915 / 1833 ( 49%)
.............................................................  976 / 1833 ( 53%)
............................................................. 1037 / 1833 ( 56%)
............................................................. 1098 / 1833 ( 59%)
............................................................. 1159 / 1833 ( 63%)
............................................................. 1220 / 1833 ( 66%)
............................................................. 1281 / 1833 ( 69%)
............................................................. 1342 / 1833 ( 73%)
............................................................. 1403 / 1833 ( 76%)
............................................................. 1464 / 1833 ( 79%)
............................................................. 1525 / 1833 ( 83%)
............................................................. 1586 / 1833 ( 86%)
............................................................. 1647 / 1833 ( 89%)
............................................................. 1708 / 1833 ( 93%)
........................F.................................... 1769 / 1833 ( 96%)
............................................................. 1830 / 1833 ( 99%)
...                                                           1833 / 1833 (100%)

Time: 00:55.805, Memory: 159.00 MB

There was 1 failure:

1) core_privacy\privacy\provider_test::test_table_coverage
The following tables with user fields must be covered with metadata providers:
  - enrol_wallet_items (userid)
  - enrol_wallet_awards (userid)
  - enrol_wallet_transactions (userid)
  - enrol_wallet_coupons_usage (userid)
  - enrol_wallet_referral (userid)

privacy/tests/privacy/provider_test.php:328
lib/phpunit/classes/advanced_testcase.php:81

FAILURES!
Tests: 1833, Assertions: 12800, Failures: 1.

See privacy

Idea: Wallet home page

Imagine a Wallet home page where you could see everything important at once: how much money in Wallet you have, what you've bought, requests for money back, and cashback you've earned from referrals. It also has quick buttons for transferring money, adding money, looking at past buys, and even the courses you've bought.

Possible list of features:

  • Current balance
  • Total expenses
  • Refund request
  • Cashback earn
  • Quick links for: Transfer, Top up, Transaction history
  • Bought courses
  • List of previous transactions

I will attempt to build this, but I'm not the best coder around. I'll try my best and let you know how it goes.

PS. Here's an example of what I think:

Screenshot_130

[Idea] Referral "Pre Signup" Page for Guests

Dear Mohammad,

I hope this message finds you well. Once again, I come here with an idea that could possible elevate this plugin's potential even higher.

This time idea is a referral "Pre Signup" page. Try to imagine a Pre Signup page where guests (everyone that clicked referral link) could see 1. who is referring them, 2. what benefit they have if they register (the amount of $ they will earn if they register) and 3. the procedure how to register. It also has a quick button to Moodle registration page including referral code.

I believe this feature could have the following benefits:

  • Increase the number of signups
  • Encourage existing users to promote Moodle
  • Build trust for everyone that clicks referral link

Things to consider:

  • This custom page should be public, even plugin is not built to be public (I guess so?)
  • URL doesn't matter too much, it can remain e.g. /enrol/wallet/referral-link.php, or anything else. But it would be even cooler if it could be like this: /enrol/wallet/referral-link.php?ref=refcode123
  • Would it take too much time? If yes, perhaps it should be postponed for another time

Below is an example/concept of a referral "Pre Signup" page.

I'd love to hear your thoughts about this and does it align with your vision.

Thank you for your time and consideration.

Screenshot_281

Deprecation notice

The boolean $primary is deprecated and replaced by $type, use single_button::BUTTON_PRIMARY or self::BUTTON_SECONDARY instead
line 907 of /lib/outputcomponents.php: call to debugging()
line 120 of /enrol/wallet/extra/topup.php: call to single_button->__construct()

Moodle 4.2.3+
Php: 8.1.26

No default value for profile field mapping

The admin_discount_field has no default value. As a result, the admin bookmarks plugin sometimes does not work: the user is asked to provide a value for discount:

<div class="box py-3 generalbox">The settings shown below were added during your last Moodle upgrade. Make any changes necessary to the defaults and then click the 'Save changes' button at the bottom of this page.</div><form action="upgradesettings.php" method="post" id="adminsettings"><div><input type="hidden" name="sesskey" value="key" /><input type="hidden" name="return" value="" /><fieldset><div class="clearer"><!-- --></div><h2 class="main">New settings - Wallet enrolment</h2><fieldset class="adminsettings">
<div class="clearer"><!-- --></div>
<div class="form-item row" id="admin-discount_field">
    <div class="form-label col-sm-3 text-sm-right">
            <label for="id_s_enrol_wallet_discount_field">
                Profile field mapping
            </label>
        <span class="form-shortname d-block small text-muted">enrol_wallet | discount_field</span>
    </div>
    <div class="form-setting col-sm-9">
        <div class="form-select defaultsnext">
    <select  id="id_s_enrol_wallet_discount_field" name="s_enrol_wallet_discount_field" class="custom-select">
            <option value="0" >Not set</option>
    </select>
</div>
        <div class="form-description mt-3"><p>Select the profile field that stores information about discounts in user profiles.</p>
</div>

maxgrade can be zero.

When running phpunit tests, Division By Zero Errors occur:

vendor/bin/phpunit --testsuite core_testsuite

Php: 8.1.26
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

.............................................................   61 / 4958 (  1%)
.............................................................  122 / 4958 (  2%)
.............................................................  183 / 4958 (  3%)
.............................................................  244 / 4958 (  4%)
.......................................E.........E........E..  305 / 4958 (  6%)
.............................................................  366 / 4958 (  7%)
.............................................................  427 / 4958 (  8%)
.............................................................  488 / 4958 (  9%)
.............................................................  549 / 4958 ( 11%)
.............................................................  610 / 4958 ( 12%)
.............................................................  671 / 4958 ( 13%)
.............................................................  732 / 4958 ( 14%)
...S.........................................................  793 / 4958 ( 15%)
.............................................................  854 / 4958 ( 17%)
.............................................................  915 / 4958 ( 18%)
.............................................................  976 / 4958 ( 19%)
............................................................. 1037 / 4958 ( 20%)
............................................................. 1098 / 4958 ( 22%)
............................................................. 1159 / 4958 ( 23%)
............................................................. 1220 / 4958 ( 24%)
............................................................. 1281 / 4958 ( 25%)
............................................................. 1342 / 4958 ( 27%)
............................................................. 1403 / 4958 ( 28%)
............................................................. 1464 / 4958 ( 29%)
..................................S.......................... 1525 / 4958 ( 30%)
............................................................. 1586 / 4958 ( 31%)
............................................................. 1647 / 4958 ( 33%)
............................................................. 1708 / 4958 ( 34%)
............................................................. 1769 / 4958 ( 35%)
............................................................. 1830 / 4958 ( 36%)
............................................................. 1891 / 4958 ( 38%)
............................................................. 1952 / 4958 ( 39%)
............................................................. 2013 / 4958 ( 40%)
............................................................. 2074 / 4958 ( 41%)
............................................................. 2135 / 4958 ( 43%)
............................................................. 2196 / 4958 ( 44%)
..........................SSSSSSSSSS......................... 2257 / 4958 ( 45%)
............................................................. 2318 / 4958 ( 46%)
............................................................. 2379 / 4958 ( 47%)
............................................................. 2440 / 4958 ( 49%)
............................................................. 2501 / 4958 ( 50%)
............................................................. 2562 / 4958 ( 51%)
............................................................. 2623 / 4958 ( 52%)
............................................................. 2684 / 4958 ( 54%)
............................................................. 2745 / 4958 ( 55%)
............................................................. 2806 / 4958 ( 56%)
............................................................. 2867 / 4958 ( 57%)
.......SSSSSSSSSSS........................................S.. 2928 / 4958 ( 59%)
............................................................. 2989 / 4958 ( 60%)
............................................................. 3050 / 4958 ( 61%)
............................................................. 3111 / 4958 ( 62%)
............................................................. 3172 / 4958 ( 63%)
............................................................. 3233 / 4958 ( 65%)
.............S............................................... 3294 / 4958 ( 66%)
............................................................. 3355 / 4958 ( 67%)
............................................................. 3416 / 4958 ( 68%)
............................................................. 3477 / 4958 ( 70%)
............................................................. 3538 / 4958 ( 71%)
............................................................. 3599 / 4958 ( 72%)
............................................................. 3660 / 4958 ( 73%)
............................................................. 3721 / 4958 ( 75%)
............................................................. 3782 / 4958 ( 76%)
............................................................. 3843 / 4958 ( 77%)
............................................................. 3904 / 4958 ( 78%)
............................................................. 3965 / 4958 ( 79%)
............................................................. 4026 / 4958 ( 81%)
............................................................. 4087 / 4958 ( 82%)
............................................................. 4148 / 4958 ( 83%)
............................................................. 4209 / 4958 ( 84%)
............................................................. 4270 / 4958 ( 86%)
............................................................. 4331 / 4958 ( 87%)
............................................................. 4392 / 4958 ( 88%)
............................................................. 4453 / 4958 ( 89%)
............................................................. 4514 / 4958 ( 91%)
............................................................. 4575 / 4958 ( 92%)
............................................................. 4636 / 4958 ( 93%)
............................................................. 4697 / 4958 ( 94%)
............................................................. 4758 / 4958 ( 95%)
............................................................. 4819 / 4958 ( 97%)
............................................................. 4880 / 4958 ( 98%)
............................................................. 4941 / 4958 ( 99%)
.................                                             4958 / 4958 (100%)

Time: 05:46.122, Memory: 300.00 MB

There were 3 errors:

1) completionlib_test::test_internal_set_data
DivisionByZeroError: Division by zero

enrol/wallet/classes/observer.php:64
lib/classes/event/manager.php:155
lib/classes/event/manager.php:75
lib/classes/event/base.php:795
completion/completion_completion.php:176
lib/completionlib.php:1823
lib/completionlib.php:1327
lib/tests/completionlib_test.php:1101
lib/phpunit/classes/advanced_testcase.php:81

2) completionlib_test::test_course_completed_message
DivisionByZeroError: Division by zero

enrol/wallet/classes/observer.php:64
lib/classes/event/manager.php:155
lib/classes/event/manager.php:75
lib/classes/event/base.php:795
completion/completion_completion.php:176
lib/tests/completionlib_test.php:1537
lib/phpunit/classes/advanced_testcase.php:81

3) completionlib_test::test_aggregate_completions
DivisionByZeroError: Division by zero

enrol/wallet/classes/observer.php:64
lib/classes/event/manager.php:155
lib/classes/event/manager.php:75
lib/classes/event/base.php:795
completion/completion_completion.php:176
lib/completionlib.php:1823
lib/tests/completionlib_test.php:1766
lib/phpunit/classes/advanced_testcase.php:81

ERRORS!
Tests: 4958, Assertions: 58769, Errors: 3, Skipped: 25.

Because maxgrade can be zero, a check should be added before you calculate the percentage ($usergrade / $maxgrade) * 100;

Idea: When inside category, automatically select that category for Offers (wallet block)

When we use Wallet block and we have Offers, students must select category they want to use to top up. What do you think that category is automatically "recognized" and selected?

  1. This is what students see inside a category:

Screenshot_226

  1. And this is how it looks when they select category:

Screenshot_225

I'm afraid not many people will "know" they should select category first, and they'll go ahead and top up without selecting category. But I might be wrong. What do you think about tihs?

incorrect camel case in some strings.

Moodle uses sentence case - please check your lang strings as some use camel case.

for example strings like:
$string['mystring'] = "My String";
should be:
$string['mystring'] = "My string";

Note: this is not a blocker for approval in the plugins db.

Idea: Make Offers responsive

Me again :) I'm sure that you probably plan to do this. Anyway, it would be awesome to make Offers "table" preview responsive, by making it in one row per one offer on smaller screen size

Screenshot_231

PS. This one too

Screenshot_230

Idea: Allow precise discount values in Offers

In Offers, in percentage amount of discount feature, when I try to enter a discount with decimals or dots, like 32,50% or 32.50%, it rounds it to the nearest whole number, turning it into either 32% or 33%. This prevents me from entering precise discount values. What do you think about not rounding it up?

Screenshot_227

Edit: Here is real life scenario with my discounts that I plan to use:

Screenshot_228

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.