MDL-72311 core_course: Go to course content when creating a course

This commit is contained in:
Amaia Anabitarte 2021-08-17 18:54:53 +02:00
parent 036800d99d
commit d45058fd21
6 changed files with 27 additions and 27 deletions

View File

@ -173,21 +173,6 @@ if ($editform->is_cancelled()) {
// The URL to take them to if they chose save and display.
$courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
// If they choose to save and display, and they are not enrolled take them to the enrolments page instead.
if (!is_enrolled($context) && isset($data->saveanddisplay)) {
// Redirect to manual enrolment page if possible.
$instances = enrol_get_instances($course->id, true);
foreach($instances as $instance) {
if ($plugin = enrol_get_plugin($instance->enrol)) {
if ($plugin->get_manual_enrol_link($instance)) {
// We know that the ajax enrol UI will have an option to enrol.
$courseurl = new moodle_url('/user/index.php', array('id' => $course->id, 'newcourse' => 1));
break;
}
}
}
}
} else {
// Save any changes to the files used in the editor.
update_course($data, $editoroptions);

View File

@ -91,5 +91,26 @@ Feature: Managers can create courses
| Course short name | myfirstcourse |
And I press "Save and display"
And I follow "Participants"
Then I should see "Kevin the"
And I should see "Teacher"
Then I should see "My first course"
And I should see "Participants"
Scenario: Creators' role in new courses setting behavior
Given the following "users" exist:
| username | firstname | lastname | email |
| kevin | Kevin | the | kevin@example.com |
And the following "system role assigns" exist:
| user | role | contextlevel |
| kevin | coursecreator | System |
And I log in as "admin"
And I set the following administration settings values:
| Creators' role in new courses | Non-editing teacher |
And I log out
And I log in as "kevin"
And I am on site homepage
When I press "Add a new course"
And I set the following fields to these values:
| Course full name | My first course |
| Course short name | myfirstcourse |
And I press "Save and display"
And I click on "Participants" "link"
Then I should see "Non-editing teacher" in the "Kevin the" "table_row"

View File

@ -57,7 +57,6 @@ Feature: Teachers can edit course custom fields
| customfield_f4[year] | 2019 |
| Field 5 | b |
And I press "Save and display"
And I press "Proceed to course content"
And I navigate to "Edit settings" in current page administration
And the following fields match these values:
| Course full name | Course 2 |

View File

@ -156,3 +156,4 @@ enableactivitychooser,core_admin
coursepreferences,core
yourprogress,core_completion
importfrominstructions,core_calendar
proceedtocourse,core_enrol

View File

@ -119,7 +119,6 @@ $string['periodend'] = 'until {$a}';
$string['periodnone'] = 'enrolled {$a}';
$string['periodstart'] = 'from {$a}';
$string['periodstartend'] = 'from {$a->start} until {$a->end}';
$string['proceedtocourse'] = 'Proceed to course content';
$string['recovergrades'] = 'Recover user\'s old grades if possible';
$string['rolefromthiscourse'] = '{$a->role} (Assigned in this course)';
$string['rolefrommetacourse'] = '{$a->role} (Inherited from parent course)';
@ -166,3 +165,6 @@ $string['privacy:metadata:user_enrolments:timemodified'] = 'The time when the us
$string['privacy:metadata:user_enrolments:userid'] = 'The ID of the user';
$string['youenrolledincourse'] = 'You are enrolled in the course.';
$string['youunenrolledfromcourse'] = 'You are unenrolled from the course "{$a}".';
// Deprecated since Moodle 4.0.
$string['proceedtocourse'] = 'Proceed to course content';

View File

@ -308,12 +308,4 @@ echo html_writer::div($enrolbuttonsout, 'd-flex justify-content-end', [
'data-table-uniqueid' => $participanttable->uniqueid,
]);
if ($newcourse == 1) {
$str = get_string('proceedtocourse', 'enrol');
// The margin is to make it line up with the enrol users button when they are both on the same line.
$classes = 'my-1';
$url = course_get_url($course);
echo $OUTPUT->single_button($url, $str, 'GET', array('class' => $classes));
}
echo $OUTPUT->footer();