mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
Merge branch 'MDL-43472-master' of git://github.com/danpoltawski/moodle
This commit is contained in:
commit
79eefed3c8
4 changed files with 87 additions and 6 deletions
|
@ -804,8 +804,7 @@ class helper {
|
|||
}
|
||||
|
||||
list($where, $params) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
|
||||
$params['categoryid'] = $moveto->id;
|
||||
$sql = "SELECT c.id, c.category FROM {course} c WHERE c.id {$where} AND c.category <> :categoryid";
|
||||
$sql = "SELECT c.id, c.category FROM {course} c WHERE c.id {$where}";
|
||||
$courses = $DB->get_records_sql($sql, $params);
|
||||
$checks = array();
|
||||
foreach ($courseids as $id) {
|
||||
|
|
|
@ -786,6 +786,31 @@ class core_course_management_renderer extends plugin_renderer_base {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderers bulk actions that can be performed on courses in search returns
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function course_search_bulk_actions() {
|
||||
$html = html_writer::start_div('course-bulk-actions bulk-actions');
|
||||
$html .= html_writer::div(get_string('coursebulkaction'), 'accesshide', array('tabindex' => '0'));
|
||||
$options = coursecat::make_categories_list('moodle/category:manage');
|
||||
$select = html_writer::select(
|
||||
$options,
|
||||
'movecoursesto',
|
||||
'',
|
||||
array('' => 'choosedots'),
|
||||
array('aria-labelledby' => 'moveselectedcoursesto')
|
||||
);
|
||||
$submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move'));
|
||||
$html .= $this->detail_pair(
|
||||
html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')),
|
||||
$select . html_writer::empty_tag('input', $submit)
|
||||
);
|
||||
$html .= html_writer::end_div();
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderers detailed course information.
|
||||
*
|
||||
|
@ -1085,6 +1110,7 @@ class core_course_management_renderer extends plugin_renderer_base {
|
|||
}
|
||||
$html .= html_writer::end_tag('ul');
|
||||
$html .= $this->search_pagination($totalcourses, $page, $perpage, true, $search);
|
||||
$html .= $this->course_search_bulk_actions();
|
||||
$html .= html_writer::end_div();
|
||||
return $html;
|
||||
}
|
||||
|
@ -1173,15 +1199,26 @@ class core_course_management_renderer extends plugin_renderer_base {
|
|||
'data-selected' => ($selectedcourse == $course->id) ? '1' : '0',
|
||||
'data-visible' => $course->visible ? '1' : '0'
|
||||
);
|
||||
|
||||
$bulkcourseinput = array('type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox');
|
||||
$bulkcourseinput = '';
|
||||
if (coursecat::get($course->category)->can_move_courses_out_of()) {
|
||||
$bulkcourseinput = array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'bc[]',
|
||||
'value' => $course->id,
|
||||
'class' => 'bulk-action-checkbox',
|
||||
'aria-label' => get_string('bulkactionselect', 'moodle', $text),
|
||||
'data-action' => 'select'
|
||||
);
|
||||
}
|
||||
$viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id));
|
||||
$categoryname = coursecat::get($course->category)->get_formatted_name();
|
||||
|
||||
$html = html_writer::start_tag('li', $attributes);
|
||||
$html .= html_writer::start_div('clearfix');
|
||||
$html .= html_writer::start_div('float-left');
|
||||
$html .= html_writer::empty_tag('input', $bulkcourseinput).' ';
|
||||
if ($bulkcourseinput) {
|
||||
$html .= html_writer::empty_tag('input', $bulkcourseinput).' ';
|
||||
}
|
||||
$html .= html_writer::end_div();
|
||||
$html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename'));
|
||||
$html .= html_writer::tag('span', $categoryname, array('class' => 'float-left categoryname'));
|
||||
|
|
|
@ -290,7 +290,7 @@ if ($action !== false && confirm_sesskey()) {
|
|||
$moveto = coursecat::get($movetoid);
|
||||
try {
|
||||
// If this fails we want to catch the exception and report it.
|
||||
$redirectback = \core_course\management\helper::action_category_move_courses_into($category, $moveto,
|
||||
$redirectback = \core_course\management\helper::move_courses_into_category($moveto,
|
||||
$courseids);
|
||||
if ($redirectback) {
|
||||
$a = new stdClass;
|
||||
|
|
45
course/tests/behat/course_search.feature
Normal file
45
course/tests/behat/course_search.feature
Normal file
|
@ -0,0 +1,45 @@
|
|||
@core @core_course
|
||||
Feature: Courses can be searched for and moved in bulk.
|
||||
In order to manage a large number of courses
|
||||
As a Moodle Administrator
|
||||
I need to be able to search courses in bulk and move them around
|
||||
|
||||
Background:
|
||||
Given the following "categories" exist:
|
||||
| name | category | idnumber |
|
||||
| Science | 0 | SCI |
|
||||
| English | 0 | ENG |
|
||||
| Miscellaneous | 0 | MISC |
|
||||
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Biology Y1 | BIO1 | MISC |
|
||||
| Biology Y2 | BIO2 | MISC |
|
||||
| English Y1 | ENG1 | ENG |
|
||||
| English Y2 | ENG2 | MISC |
|
||||
|
||||
Scenario: Search courses finds correct results
|
||||
Given I log in as "admin"
|
||||
And I go to the courses management page
|
||||
When I set the field "Search courses:" to "Biology"
|
||||
And I press "Go"
|
||||
Then I should see "Biology Y1"
|
||||
And I should see "Biology Y2"
|
||||
And I should not see "English Y1"
|
||||
And I should not see "English Y2"
|
||||
|
||||
@javascript
|
||||
Scenario: Search courses and move results in bulk
|
||||
Given I log in as "admin"
|
||||
And I go to the courses management page
|
||||
And I set the field "Search courses:" to "Biology"
|
||||
And I press "Go"
|
||||
When I select course "Biology Y1" in the management interface
|
||||
And I select course "Biology Y2" in the management interface
|
||||
And I set the field "menumovecoursesto" to "Science"
|
||||
And I press "Move"
|
||||
Then I should see "Successfully moved 2 courses into Science"
|
||||
And I wait to be redirected
|
||||
And I click on category "Science" in the management interface
|
||||
And I should see "Biology Y1"
|
||||
And I should see "Biology Y2"
|
Loading…
Add table
Add a link
Reference in a new issue