Merge branch 'MDL-61589-master' of git://github.com/rezaies/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2018-03-21 00:21:24 +01:00
commit 4dca6ab54d
4 changed files with 13 additions and 11 deletions

View File

@ -290,6 +290,7 @@ $string['stoponerror'] = 'Stop on error';
$string['stoponerror_help'] = 'This setting determines whether the import process stops when an error is detected, resulting in no questions being imported, or whether any questions containing errors are ignored and any valid questions are imported.';
$string['tofilecategory'] = 'Write category to file';
$string['tofilecontext'] = 'Write context to file';
$string['topfor'] = 'Top for {$a}';
$string['uninstallbehaviour'] = 'Uninstall this question behaviour.';
$string['uninstallqtype'] = 'Uninstall this question type.';
$string['unknown'] = 'Unknown';

View File

@ -6548,15 +6548,16 @@ function question_add_tops($categories, $pcontexts) {
DEBUG_DEVELOPER);
$topcats = array();
foreach ($pcontexts as $context) {
$topcat = question_get_top_category($context, true);
foreach ($pcontexts as $contextid) {
$topcat = question_get_top_category($contextid, true);
$context = context::instance_by_id($contextid);
$newcat = new stdClass();
$newcat->id = "{$topcat->id},$context";
$newcat->name = get_string('top');
$newcat->id = "{$topcat->id},$contextid";
$newcat->name = get_string('topfor', 'question', $context->get_context_name(false));
$newcat->parent = 0;
$newcat->contextid = $context;
$topcats["{$topcat->id},$context"] = $newcat;
$newcat->contextid = $contextid;
$topcats["{$topcat->id},$contextid"] = $newcat;
}
// Put topcats in at beginning of array - they'll be sorted into different contexts later.
return array_merge($topcats, $categories);

View File

@ -1449,7 +1449,8 @@ function question_fix_top_names($categories) {
foreach ($categories as $id => $category) {
if ($category->parent == 0) {
$categories[$id]->name = get_string('top');
$context = context::instance_by_id($category->contextid);
$categories[$id]->name = get_string('topfor', 'question', $context->get_context_name(false));
}
}

View File

@ -20,13 +20,12 @@ Feature: A teacher can move question categories in the question bank
And I log in as "teacher1"
And I am on "Course 1" course homepage
@javascript
Scenario: A question category can be moved to another context
When I follow "Test quiz"
And I navigate to "Categories" node in "Quiz administration > Question bank"
And I click on "Parent category" "field"
And I click on "//optgroup[@label='Quiz: Test quiz']//option[normalize-space(text())='Top']" "xpath_element"
And I set the field "Name" to "Test category"
And I set the following fields to these values:
| Name | Test category |
| Parent category | Top for Test quiz |
And I press "submitbutton"
And I click on "Share in context for Course: Course 1" "link" in the "Test category" "list_item"
Then I should see "Test category" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' questioncategories ') and contains(concat(' ', normalize-space(@class), ' '), ' contextlevel50 ')]" "xpath_element"