mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch '21724-29' of git://github.com/samhemelryk/moodle
This commit is contained in:
commit
8b9bb799f9
@ -40,7 +40,7 @@ Feature: Expand the courses nodes within the navigation block
|
||||
And I click on "Edit settings" "link" in the "Administration" "block"
|
||||
And I set the following fields to these values:
|
||||
| Allow guest access | Yes |
|
||||
And I press "Save changes"
|
||||
And I press "Save and return"
|
||||
And I set the following administration settings values:
|
||||
| Show all courses | 1 |
|
||||
And I log out
|
||||
|
@ -315,7 +315,7 @@ class helper {
|
||||
// Edit.
|
||||
if ($course->can_edit()) {
|
||||
$actions[] = array(
|
||||
'url' => new \moodle_url('/course/edit.php', array('id' => $course->id)),
|
||||
'url' => new \moodle_url('/course/edit.php', array('id' => $course->id, 'returnto' => 'catmanage')),
|
||||
'icon' => new \pix_icon('t/edit', \get_string('edit')),
|
||||
'attributes' => array('class' => 'action-edit')
|
||||
);
|
||||
|
@ -29,6 +29,38 @@ require_once('edit_form.php');
|
||||
$id = optional_param('id', 0, PARAM_INT); // Course id.
|
||||
$categoryid = optional_param('category', 0, PARAM_INT); // Course category - can be changed in edit form.
|
||||
$returnto = optional_param('returnto', 0, PARAM_ALPHANUM); // Generic navigation return page switch.
|
||||
$returnurl = optional_param('returnurl', '', PARAM_LOCALURL); // A return URL. returnto must also be set to 'url'.
|
||||
|
||||
if ($returnto === 'url' && confirm_sesskey() && $returnurl) {
|
||||
// If returnto is 'url' then $returnurl may be used as the destination to return to after saving or cancelling.
|
||||
// Sesskey must be specified, and would be set by the form anyway.
|
||||
$returnurl = new moodle_url($returnurl);
|
||||
} else {
|
||||
switch ($returnto) {
|
||||
case 'category':
|
||||
$returnurl = new moodle_url($CFG->wwwroot.'/course/index.php', array('categoryid' => $categoryid));
|
||||
break;
|
||||
case 'catmanage':
|
||||
$returnurl = new moodle_url($CFG->wwwroot.'/course/management.php', array('categoryid' => $categoryid));
|
||||
break;
|
||||
case 'topcatmanage':
|
||||
$returnurl = new moodle_url($CFG->wwwroot.'/course/management.php');
|
||||
break;
|
||||
case 'topcat':
|
||||
$returnurl = new moodle_url($CFG->wwwroot.'/course/');
|
||||
break;
|
||||
case 'url':
|
||||
// You may be wondering about this, but the url case should be dealt with above.
|
||||
// If we get here than either sesskey was not given or returnurl was not provided.
|
||||
default:
|
||||
if (!empty($course->id)) {
|
||||
$returnurl = new moodle_url($CFG->wwwroot.'/course/view.php', array('id' => $course->id));
|
||||
} else {
|
||||
$returnurl = new moodle_url($CFG->wwwroot.'/course/');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
if ($id) {
|
||||
@ -36,6 +68,12 @@ if ($id) {
|
||||
} else {
|
||||
$pageparams = array('category' => $categoryid);
|
||||
}
|
||||
if ($returnto !== 0) {
|
||||
$pageparams['returnto'] = $returnto;
|
||||
if ($returnto === 'url' && $returnurl) {
|
||||
$pageparams['returnurl'] = $returnurl;
|
||||
}
|
||||
}
|
||||
$PAGE->set_url('/course/edit.php', $pageparams);
|
||||
|
||||
// Basic access control checks.
|
||||
@ -98,31 +136,17 @@ if (!empty($course)) {
|
||||
}
|
||||
|
||||
// First create the form.
|
||||
$editform = new course_edit_form(NULL, array('course'=>$course, 'category'=>$category, 'editoroptions'=>$editoroptions, 'returnto'=>$returnto));
|
||||
$args = array(
|
||||
'course' => $course,
|
||||
'category' => $category,
|
||||
'editoroptions' => $editoroptions,
|
||||
'returnto' => $returnto,
|
||||
'returnurl' => $returnurl
|
||||
);
|
||||
$editform = new course_edit_form(null, $args);
|
||||
if ($editform->is_cancelled()) {
|
||||
switch ($returnto) {
|
||||
case 'category':
|
||||
$url = new moodle_url($CFG->wwwroot.'/course/index.php', array('categoryid' => $categoryid));
|
||||
break;
|
||||
case 'catmanage':
|
||||
$url = new moodle_url($CFG->wwwroot.'/course/management.php', array('categoryid' => $categoryid));
|
||||
break;
|
||||
case 'topcatmanage':
|
||||
$url = new moodle_url($CFG->wwwroot.'/course/management.php');
|
||||
break;
|
||||
case 'topcat':
|
||||
$url = new moodle_url($CFG->wwwroot.'/course/');
|
||||
break;
|
||||
default:
|
||||
if (!empty($course->id)) {
|
||||
$url = new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id));
|
||||
} else {
|
||||
$url = new moodle_url($CFG->wwwroot.'/course/');
|
||||
}
|
||||
break;
|
||||
}
|
||||
redirect($url);
|
||||
|
||||
// The form has been cancelled, take them back to what ever the return to is.
|
||||
redirect($returnurl);
|
||||
} else if ($data = $editform->get_data()) {
|
||||
// Process data if submitted.
|
||||
if (empty($course->id)) {
|
||||
@ -136,14 +160,20 @@ if ($editform->is_cancelled()) {
|
||||
// Deal with course creators - enrol them internally with default role.
|
||||
enrol_try_internal_enrol($course->id, $USER->id, $CFG->creatornewroleid);
|
||||
}
|
||||
if (!is_enrolled($context)) {
|
||||
|
||||
// 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.
|
||||
redirect(new moodle_url('/enrol/users.php', array('id'=>$course->id)));
|
||||
$courseurl = new moodle_url('/enrol/users.php', array('id' => $course->id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,10 +181,17 @@ if ($editform->is_cancelled()) {
|
||||
} else {
|
||||
// Save any changes to the files used in the editor.
|
||||
update_course($data, $editoroptions);
|
||||
// Set the URL to take them too if they choose save and display.
|
||||
$courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
|
||||
}
|
||||
|
||||
// Redirect user to newly created/updated course.
|
||||
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
|
||||
if (isset($data->saveanddisplay)) {
|
||||
// Redirect user to newly created/updated course.
|
||||
redirect($courseurl);
|
||||
} else {
|
||||
// Save and return. Take them back to wherever.
|
||||
redirect($returnurl);
|
||||
}
|
||||
}
|
||||
|
||||
// Print the form.
|
||||
|
@ -27,6 +27,7 @@ class course_edit_form extends moodleform {
|
||||
$category = $this->_customdata['category'];
|
||||
$editoroptions = $this->_customdata['editoroptions'];
|
||||
$returnto = $this->_customdata['returnto'];
|
||||
$returnurl = $this->_customdata['returnurl'];
|
||||
|
||||
$systemcontext = context_system::instance();
|
||||
$categorycontext = context_coursecat::instance($category->id);
|
||||
@ -51,6 +52,10 @@ class course_edit_form extends moodleform {
|
||||
$mform->setType('returnto', PARAM_ALPHANUM);
|
||||
$mform->setConstant('returnto', $returnto);
|
||||
|
||||
$mform->addElement('hidden', 'returnurl', null);
|
||||
$mform->setType('returnurl', PARAM_LOCALURL);
|
||||
$mform->setConstant('returnurl', $returnurl);
|
||||
|
||||
$mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"');
|
||||
$mform->addHelpButton('fullname', 'fullnamecourse');
|
||||
$mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
|
||||
@ -296,7 +301,15 @@ class course_edit_form extends moodleform {
|
||||
}
|
||||
}
|
||||
|
||||
$this->add_action_buttons();
|
||||
// When two elements we need a group.
|
||||
$buttonarray = array();
|
||||
if ($returnto !== 0) {
|
||||
$buttonarray[] = &$mform->createElement('submit', 'saveandreturn', get_string('savechangesandreturn'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('submit', 'saveanddisplay', get_string('savechangesanddisplay'));
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
|
||||
$mform->closeHeaderBefore('buttonar');
|
||||
|
||||
$mform->addElement('hidden', 'id', null);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
@ -25,7 +25,7 @@ Feature: Toggle activities groups mode from the course page
|
||||
And I set the following fields to these values:
|
||||
| Group mode | No groups |
|
||||
| Force group mode | No |
|
||||
When I press "Save changes"
|
||||
When I press "Save and display"
|
||||
Then "No groups (Click to change)" "link" should exist
|
||||
And "//a/child::img[contains(@src, 'groupn')]" "xpath_element" should exist
|
||||
And I click on "No groups (Click to change)" "link" in the "Test forum name" activity
|
||||
|
@ -108,7 +108,7 @@ class behat_course extends behat_base {
|
||||
$steps[] = new Given('I set the following fields to these values:', $table);
|
||||
}
|
||||
|
||||
$steps[] = new Given('I press "' . get_string('savechanges') . '"');
|
||||
$steps[] = new Given('I press "' . get_string('savechangesanddisplay') . '"');
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
@ -29,3 +29,21 @@ Feature: Managers can create courses
|
||||
And I follow "News forum"
|
||||
And "Add a new topic" "button" should not exist
|
||||
And I should see "Forced subscription" in the "Administration" "block"
|
||||
|
||||
Scenario: Create a course from the management interface and return to it
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | idnumber |
|
||||
| Course 1 | Course 1 | C1 |
|
||||
And I log in as "admin"
|
||||
And I go to the courses management page
|
||||
And I should see the "Categories" management page
|
||||
And I click on category "Miscellaneous" in the management interface
|
||||
And I should see the "Course categories and courses" management page
|
||||
And I click on "Create new course" "link" in the "#course-listing" "css_element"
|
||||
When I set the following fields to these values:
|
||||
| Course full name | Course 2 |
|
||||
| Course short name | Course 2 |
|
||||
| Course summary | Course 2 summary |
|
||||
And I press "Save and return"
|
||||
Then I should see the "Course categories and courses" management page
|
||||
And I should see course listing "Course 1" before "Course 2"
|
||||
|
@ -23,9 +23,8 @@ Feature: Test we can both create and delete a course.
|
||||
| Course short name | TCCAC |
|
||||
| Course ID number | TC3401 |
|
||||
| Course summary | This course has been created by automated tests. |
|
||||
And I press "Save changes"
|
||||
And I press "Save and return"
|
||||
# Redirect
|
||||
And I go to the courses management page
|
||||
And I should see the "Course categories and courses" management page
|
||||
And I click on category "Cat 1" in the management interface
|
||||
# Redirect
|
||||
|
@ -22,7 +22,7 @@ Feature: Edit course settings
|
||||
| Course full name | Edited course fullname |
|
||||
| Course short name | Edited course shortname |
|
||||
| Course summary | Edited course summary |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
And I follow "Edited course fullname"
|
||||
Then I should not see "Course 1"
|
||||
And I should not see "C1"
|
||||
@ -34,3 +34,23 @@ Feature: Edit course settings
|
||||
And the field "Course summary" matches value "Edited course summary"
|
||||
And I am on homepage
|
||||
And I should see "Edited course fullname"
|
||||
|
||||
Scenario: Edit course settings and return to the management interface
|
||||
Given the following "categories" exist:
|
||||
| name | category | idnumber |
|
||||
| Cat 1 | 0 | CAT1 |
|
||||
And the following "courses" exist:
|
||||
| category | fullname | shortname | idnumber |
|
||||
| CAT1 | Course 1 | Course 1 | C1 |
|
||||
And I log in as "admin"
|
||||
And I go to the courses management page
|
||||
And I should see the "Categories" management page
|
||||
And I click on category "Cat 1" in the management interface
|
||||
And I should see the "Course categories and courses" management page
|
||||
When I click on "edit" action for "Course 1" in management course listing
|
||||
And I set the following fields to these values:
|
||||
| Course full name | Edited course fullname |
|
||||
| Course short name | Edited course shortname |
|
||||
| Course summary | Edited course summary |
|
||||
And I press "Save and return"
|
||||
Then I should see the "Course categories and courses" management page
|
@ -27,7 +27,7 @@ Feature: Force group mode in a course
|
||||
Given I set the following fields to these values:
|
||||
| Group mode | Separate groups |
|
||||
| Force group mode | Yes |
|
||||
When I press "Save changes"
|
||||
When I press "Save and display"
|
||||
Then "//a/child::img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" should not exist
|
||||
And "//img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" should not exist
|
||||
|
||||
@ -36,7 +36,7 @@ Feature: Force group mode in a course
|
||||
Given I set the following fields to these values:
|
||||
| Group mode | Visible groups |
|
||||
| Force group mode | Yes |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
Then "//a/child::img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" should not exist
|
||||
And "//img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" should not exist
|
||||
|
||||
@ -45,7 +45,7 @@ Feature: Force group mode in a course
|
||||
Given I set the following fields to these values:
|
||||
| Group mode | No groups |
|
||||
| Force group mode | Yes |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
Then "//a/child::img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" should not exist
|
||||
And "//img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" should not exist
|
||||
|
||||
|
@ -36,7 +36,7 @@ Feature: Activities can be moved between sections
|
||||
Given I click on "Edit settings" "link" in the "Administration" "block"
|
||||
And I set the following fields to these values:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
When I move "Test forum name" activity to section "2"
|
||||
Then I should see "Test forum name" in the "#section-2" "css_element"
|
||||
And I should not see "Test forum name" in the "#section-1" "css_element"
|
||||
@ -45,7 +45,7 @@ Feature: Activities can be moved between sections
|
||||
Given I click on "Edit settings" "link" in the "Administration" "block"
|
||||
And I set the following fields to these values:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Second forum name |
|
||||
| Description | Second forum description |
|
||||
|
@ -31,7 +31,7 @@ Feature: Sections can be moved
|
||||
Given I click on "Edit settings" "link" in the "Administration" "block"
|
||||
And I set the following fields to these values:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
@ -44,7 +44,7 @@ Feature: Sections can be moved
|
||||
Given I click on "Edit settings" "link" in the "Administration" "block"
|
||||
And I set the following fields to these values:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
And I add a "Forum" to section "2" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
|
@ -25,7 +25,7 @@ Feature: Rename roles within a course
|
||||
And I set the following fields to these values:
|
||||
| Your word for 'Non-editing teacher' | Tutor |
|
||||
| Your word for 'Student' | Learner |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
And I expand "Switch role to..." node
|
||||
Then I should see "Tutor"
|
||||
And I should see "Learner"
|
||||
@ -37,7 +37,7 @@ Feature: Rename roles within a course
|
||||
And I set the following fields to these values:
|
||||
| Your word for 'Non-editing teacher' | |
|
||||
| Your word for 'Student' | |
|
||||
And I press "Save changes"
|
||||
And I press "Save and display"
|
||||
And I expand "Switch role to..." node
|
||||
And I should see "Teacher"
|
||||
And I should see "Student"
|
||||
|
@ -1566,6 +1566,7 @@ $string['saveandnext'] = 'Save and show next';
|
||||
$string['savedat'] = 'Saved at:';
|
||||
$string['savechanges'] = 'Save changes';
|
||||
$string['savechangesanddisplay'] = 'Save and display';
|
||||
$string['savechangesandreturn'] = 'Save and return';
|
||||
$string['savechangesandreturntocourse'] = 'Save and return to course';
|
||||
$string['savecomment'] = 'Save comment';
|
||||
$string['savepreferences'] = 'Save preferences';
|
||||
|
Loading…
x
Reference in New Issue
Block a user