mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-72256 enrol_fee: add payment information to course/info.php
This commit is contained in:
parent
5e5e12e063
commit
b51d8d9a7a
@ -164,7 +164,32 @@ class enrol_fee_plugin extends enrol_plugin {
|
||||
* @return string html text, usually a form in a text box
|
||||
*/
|
||||
public function enrol_page_hook(stdClass $instance) {
|
||||
global $CFG, $USER, $OUTPUT, $PAGE, $DB;
|
||||
return $this->show_payment_info($instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns optional enrolment instance description text.
|
||||
*
|
||||
* This is used in detailed course information.
|
||||
*
|
||||
*
|
||||
* @param object $instance
|
||||
* @return string short html text
|
||||
*/
|
||||
public function get_description_text($instance) {
|
||||
return $this->show_payment_info($instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates payment information to display on enrol/info page.
|
||||
*
|
||||
* @param stdClass $instance
|
||||
* @return false|string
|
||||
* @throws coding_exception
|
||||
* @throws dml_exception
|
||||
*/
|
||||
private function show_payment_info(stdClass $instance) {
|
||||
global $USER, $OUTPUT, $DB;
|
||||
|
||||
ob_start();
|
||||
|
||||
@ -183,19 +208,6 @@ class enrol_fee_plugin extends enrol_plugin {
|
||||
$course = $DB->get_record('course', array('id' => $instance->courseid));
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
$shortname = format_string($course->shortname, true, array('context' => $context));
|
||||
$strloginto = get_string("loginto", "", $shortname);
|
||||
$strcourses = get_string("courses");
|
||||
|
||||
// Pass $view=true to filter hidden caps if the user cannot see them.
|
||||
if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC',
|
||||
'', '', '', '', false, true)) {
|
||||
$users = sort_by_roleassignment_authority($users, $context);
|
||||
$teacher = array_shift($users);
|
||||
} else {
|
||||
$teacher = false;
|
||||
}
|
||||
|
||||
if ( (float) $instance->cost <= 0 ) {
|
||||
$cost = (float) $this->get_config('cost');
|
||||
} else {
|
||||
@ -207,7 +219,7 @@ class enrol_fee_plugin extends enrol_plugin {
|
||||
} else {
|
||||
|
||||
$data = [
|
||||
'isguestuser' => isguestuser(),
|
||||
'isguestuser' => isguestuser() || !isloggedin(),
|
||||
'cost' => \core_payment\helper::get_cost_as_string($cost, $instance->currency),
|
||||
'instanceid' => $instance->id,
|
||||
'description' => get_string('purchasedescription', 'enrol_fee',
|
||||
|
@ -21,11 +21,8 @@ Feature: Signing up for a course with a fee enrolment method
|
||||
And I navigate to "Plugins > Enrolments > Manage enrol plugins" in site administration
|
||||
And I click on "Enable" "link" in the "Enrolment on payment" "table_row"
|
||||
And I log out
|
||||
|
||||
@javascript
|
||||
Scenario: Student can see the payment prompt on the course enrolment page
|
||||
When I log in as "manager1"
|
||||
And I am on the "Course 1" "enrolment methods" page
|
||||
And I log in as "manager1"
|
||||
And I am on the "Course 1" "enrolment methods" page
|
||||
And I select "Enrolment on payment" from the "Add method" singleselect
|
||||
And I set the following fields to these values:
|
||||
| Payment account | Account1 |
|
||||
@ -33,7 +30,10 @@ Feature: Signing up for a course with a fee enrolment method
|
||||
| Currency | Euro |
|
||||
And I press "Add method"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
|
||||
@javascript
|
||||
Scenario: Student can see the payment prompt on the course enrolment page
|
||||
When I log in as "student1"
|
||||
And I am on course index
|
||||
And I follow "Course 1"
|
||||
Then I should see "This course requires a payment for entry."
|
||||
@ -41,3 +41,11 @@ Feature: Signing up for a course with a fee enrolment method
|
||||
And I press "Select payment type"
|
||||
And I should see "PayPal" in the "Select payment type" "dialogue"
|
||||
And I click on "Cancel" "button" in the "Select payment type" "dialogue"
|
||||
|
||||
Scenario: Guest can see the login prompt on the course enrolment page
|
||||
When I log in as "guest"
|
||||
And I am on course index
|
||||
And I follow "Course 1"
|
||||
Then I should see "This course requires a payment for entry."
|
||||
And I should see "123.45"
|
||||
And I should see "Log in to the site"
|
||||
|
Loading…
x
Reference in New Issue
Block a user