Skip to content

Commit

Permalink
V5`
Browse files Browse the repository at this point in the history
  • Loading branch information
fmido88 authored Feb 3, 2024
1 parent bc67275 commit 3cdbd04
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion amd/build/balance.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/cdiscount.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions amd/src/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let userInput;
/**
* Get the balance data through ajax call.
*/
function get_data() {
function getData() {
let userid = parseInt(userInput.value);

if (userid && !isNaN(userid)) {
Expand Down Expand Up @@ -63,7 +63,7 @@ export const init = (formid) => {
userInput = form.querySelector("[name=userlist]");

button.onclick = () => {
get_data();
getData();
};
userInput.onchange = () => {
holder.innerHTML = '';
Expand Down
23 changes: 2 additions & 21 deletions amd/src/cdiscount.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ let categoryInput;
let valueAfterInput;
let chargingLabel = '';
let calculateValueHolder;
// let conditions = [];
// let discounts = [];
// let categories = [];
let rules = [];

/**
Expand Down Expand Up @@ -88,7 +85,7 @@ function addListenersChargerForm() {
}

/**
* continue the procedure of the charger form.
* Continue the procedure of the charger form.
*/
function proceedChargerForm() {
calculateValueHolder = form.querySelector("[data-holder=calculated-value]");
Expand Down Expand Up @@ -172,7 +169,7 @@ export const init = (formid, formType) => {
categoryInput = form.querySelector("[name=category]");

for (let i = 1; ; i++) {
let element = form.querySelector("[name=discount_rule_"+ i +"]");
let element = form.querySelector("[name=discount_rule_" + i + "]");
if (!element) {
break;
}
Expand All @@ -183,22 +180,6 @@ export const init = (formid, formType) => {
rules.push(object);
}

// for (let i = 1; ; i++) {
// let element = form.querySelector("[name=condition"+ i +"]");
// if (!element) {
// break;
// }
// conditions.push(parseFloat(element.value));
// }

// for (let i = 1; ; i++) {
// let element = form.querySelector("[name=category"+ i +"]");
// if (!element) {
// break;
// }
// categories.push(parseInt(element.value));
// }

if (formType == 'charge') {
proceedChargerForm();
} else {
Expand Down
18 changes: 16 additions & 2 deletions templates/display.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,21 @@
"norefund": 30,
"policy": "something",
"transfer": "<a href='https://your-moodle.com/enrol/wallet/extra/transfer.php'>transfer</a>",
"referral": "<a href='https://your-moodle.com/enrol/wallet/extra/referral.php'>referral</a>"
"referral": "<a href='https://your-moodle.com/enrol/wallet/extra/referral.php'>referral</a>",
"currentuser": true,
"catdetails": [
{
name: "some category",
refundable: 20,
nonrefundable: 100,
total: 120
},
{
name: "Another one",
refundable: 10,
nonrefundable: 5,
total: 15
}]
}
}}
Expand All @@ -43,7 +57,7 @@
<h3 class="wallet-heading" style="text-align: center;"> {{# str }} mywallet, enrol_wallet {{/ str }} </h3>
{{/ currentuser}}
<p style="text-align: center; direction: ltr;">
<div class="balance-card" style="text-align: center; direction: ltr;">{{#currentuser}}{{# str }} youhavebalance, enrol_wallet {{/ str }}{{/currentuser}}<br>
<div class="balance-card" style="text-align: center; direction: ltr;">{{# currentuser}}{{# str }} youhavebalance, enrol_wallet {{/ str }}{{/ currentuser}}<br>
<strong><span class="wallet-ballance" style="font-size: x-large;">{{balance}} {{currency}}</span></strong><br>
{{#currentuser}}{{# str }} inyourwallet, enrol_wallet {{/ str }} <br>{{/currentuser}}
<span class="wallet-ballance">{{# str }} mainbalance, enrol_wallet {{/ str }} {{main}} {{currency}}</span><br>
Expand Down
2 changes: 1 addition & 1 deletion tests/coupons_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ protected function setUp() :void {
$this->wallet->update_status($instance, ENROL_INSTANCE_ENABLED);
$inst = 'inst' . $i;
$this->$inst = $instance;
if ($i <= 4) {
if ($i <= 3) {
$record = new \stdClass;
$record->section = 1;
$record->course = $this->$var->id;
Expand Down
2 changes: 1 addition & 1 deletion tests/turn_non_refundable_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function test_check_transform_validation(): void {
$this->assertEquals($output2, 200);

// Not transform what already used.
$op->debit(50);
$op->debit(50, $op::OTHER);
$output3 = $task->check_transform_validation($data, $trace);
$this->assertEquals($output3, 150);

Expand Down
2 changes: 1 addition & 1 deletion tests/util/instance_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function test_get_cost_after_discount(): void {
* Testing discounts after first and second repurchase
* @covers ::get_cost_after_discount
*/
public function test_repurchase_discount_and_function() {
public function test_repurchase_discount_and_function():void {
global $DB;
$this->resetAfterTest();
$wallet = new enrol_wallet_plugin;
Expand Down

0 comments on commit 3cdbd04

Please sign in to comment.