Merge branch 'MDL-77640-master-latest' of https://github.com/kevpercy/moodle

This commit is contained in:
Jun Pataleta 2023-08-24 10:23:17 +08:00
commit dfadf21e2f
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
15 changed files with 88 additions and 122 deletions

View File

@ -54,57 +54,55 @@ class gradebook_setup_action_bar extends action_bar {
$generalnavselector = new general_action_bar($this->context,
new moodle_url('/grade/edit/tree/index.php', ['id' => $courseid]), 'settings', 'setup');
$data = $generalnavselector->export_for_template($output);
$actions = [];
$additemurl = new moodle_url('#');
// Add a button to the action bar with a link to the 'add grade item' page.
$addgradeitemlink = new moodle_url('#');
$addgradeitembutton = new \single_button(
$addgradeitemlink,
// Add a button to the action bar dropdown with a link to the 'add grade item' modal.
$actions[] = new \action_menu_link_secondary(
$additemurl,
null,
get_string('additem', 'grades'),
'get',
\single_button::BUTTON_SECONDARY,
[
'data-courseid' => $courseid,
'data-itemid' => -1,
'data-trigger' => 'add-item-form',
'data-gprplugin' => 'tree'
'data-gprplugin' => 'tree',
]
);
$data['addgradeitembutton'] = $addgradeitembutton->export_for_template($output);
// If outcomes are enabled, add a button to the action bar with a link to the 'add outcome item' page.
// If outcomes are enabled, add a button to the action bar dropdown with a link to the 'add outcome item' modal.
if (!empty($CFG->enableoutcomes) && count(\grade_outcome::fetch_all_available($courseid)) > 0) {
// Add a button to the action bar with a link to the 'add outcome item' page.
$addoutcomeitem = new moodle_url('#');
$addoutcomeitembutton = new \single_button(
$addoutcomeitem,
// Add a button to the action bar dropdown with a link to the 'add outcome item' modal.
$actions[] = new \action_menu_link_secondary(
$additemurl,
null,
get_string('addoutcomeitem', 'grades'),
'get',
\single_button::BUTTON_SECONDARY,
[
'class' => 'btn btn-secondary',
'data-courseid' => $courseid,
'data-itemid' => -1,
'data-trigger' => 'add-outcome-form',
'data-gprplugin' => 'tree'
'data-gprplugin' => 'tree',
]
);
$data['addoutcomeitembutton'] = $addoutcomeitembutton->export_for_template($output);
}
// Add a button to the action bar with a link to the 'add category' page.
$addgradecategorybutton = new \single_button(
$addgradeitemlink,
// Add a button to the action bar dropdown with a link to the 'add category' modal.
$actions[] = new \action_menu_link_secondary(
$additemurl,
null,
get_string('addcategory', 'grades'),
'get',
\single_button::BUTTON_SECONDARY,
[
'data-courseid' => $courseid,
'data-category' => -1,
'data-trigger' => 'add-category-form',
'data-gprplugin' => 'tree'
'data-gprplugin' => 'tree',
]
);
$data['addcategorybutton'] = $addgradecategorybutton->export_for_template($output);
$addmenu = new \action_menu($actions);
$addmenu->set_menu_trigger(get_string('add'), 'btn font-weight-bold');
$data['addmenu'] = $addmenu->export_for_template($output);
return $data;
}
}

View File

@ -18,9 +18,7 @@
Context variables required for this template:
* generalnavselector - The data object containing the required properties to render the general navigation selector.
* addgradeitembutton - The data object containing the required properties to render the 'add grade item' button.
* addoutcomeitembutton - The data object containing the required properties to render the 'add outcome item' button.
* addcategorybutton - The data object containing the required properties to render the 'add category' button.
* addmenu - The data object containing the required properties to render the 'Add' action menu.
Example context (json):
{
@ -62,40 +60,18 @@
}
]
},
"addgradeitembutton": {
"id": "single_button12345",
"method" : "get",
"classes": "singlebutton",
"formid": null,
"url" : "#",
"primary" : false,
"tooltip" : null,
"label" : "Add grade item",
"attributes": []
"addmenu": [
{
"classes": "",
"primary": {
"items": [{"rawhtml": "<p>Item in primary menu</p>"}]
},
"addoutcomeitembutton": {
"id": "single_button13245",
"method" : "get",
"classes": "singlebutton",
"formid": null,
"url" : "#",
"primary" : false,
"tooltip" : null,
"label" : "Add outcome item",
"attributes": []
},
"addcategorybutton": {
"id": "single_button14325",
"method" : "get",
"classes": "singlebutton",
"formid": null,
"url" : "#",
"primary" : false,
"tooltip" : null,
"label" : "Add category",
"attributes": []
"secondary": {
"items": [{"rawhtml": "<p>Item in secondary menu</p>"}]
}
}
]
}
}}
<div class="container-fluid tertiary-navigation full-width-bottom-border">
<div class="row">
@ -105,20 +81,12 @@
</div>
<div class="navitem-divider"></div>
{{/generalnavselector}}
{{#addgradeitembutton}}
<div class="navitem-divider ml-auto"></div>
<div class="navitem">
{{>core/single_button}}
{{#addmenu}}
{{>core/action_menu}}
{{/addmenu}}
</div>
{{/addgradeitembutton}}
{{#addoutcomeitembutton}}
<div class="navitem">
{{>core/single_button}}
</div>
{{/addoutcomeitembutton}}
{{#addcategorybutton}}
<div class="navitem">
{{>core/single_button}}
</div>
{{/addcategorybutton}}
<div class="navitem-divider"></div>
</div>
</div>

View File

@ -382,24 +382,24 @@ Feature: We can use calculated grade totals
| Aggregation | Natural |
| Exclude empty grades | 0 |
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add category"
And I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Sub category 3 |
| Aggregation | Natural |
| Drop the lowest | 1 |
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 1 |
| Grade category | Sub category 3 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 2 |
| Grade category | Sub category 3 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 3 |
| Grade category | Sub category 3 |
@ -443,7 +443,7 @@ Feature: We can use calculated grade totals
And I turn editing mode off
And I should see "250.00 (25.25 %)" in the ".course" "css_element"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add category"
And I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Sub sub category 1 |
| Parent category | Sub category 3 |

View File

@ -22,12 +22,12 @@ Feature: Calculated grade items can be used in the gradebook
@javascript
Scenario: The max grade for a category item, with a calculation using Natural aggregation, can be changed
Given I press "Add category"
Given I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Calc cat |
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | grade item 1 |
| Grade category | Calc cat |
@ -50,13 +50,13 @@ Feature: Calculated grade items can be used in the gradebook
@javascript
Scenario: Changing max grade for a category item with a calculation that has existing grades will display the same points with the new max grade values immediately.
Given I press "Add category"
Given I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Calc cat |
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready
And I should not see "Calculated grade" in the "Calc cat" "table_row"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | grade item 1 |
| Grade category | Calc cat |
@ -116,11 +116,11 @@ Feature: Calculated grade items can be used in the gradebook
@javascript
Scenario: Values in calculated grade items are not always out of one hundred
Given I press "Add grade item"
Given I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | grade item 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | calc item |
And I click on "Save" "button" in the "New grade item" "dialogue"

View File

@ -23,12 +23,12 @@ Feature: Gradebook calculations for calculated grade items before the fix 201506
@javascript
Scenario: The max grade for a category item, with a calculation using Natural aggregation, can be changed
Given I press "Add category"
Given I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Calc cat |
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | grade item 1 |
| Grade category | Calc cat |
@ -51,12 +51,12 @@ Feature: Gradebook calculations for calculated grade items before the fix 201506
@javascript
Scenario: Changing max grade for a category item with a calculation that has existing grades will display the same points with the new max grade values immediately.
Given I press "Add category"
Given I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Calc cat |
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | grade item 1 |
| Grade category | Calc cat |
@ -115,11 +115,11 @@ Feature: Gradebook calculations for calculated grade items before the fix 201506
@javascript
Scenario: Values in calculated grade items are not always out of one hundred
Given I press "Add grade item"
Given I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | grade item 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | calc item |
And I click on "Save" "button" in the "New grade item" "dialogue"

View File

@ -40,7 +40,7 @@ Feature: We can understand the gradebook user report
And I set the field "Show contribution to course total" to "Show"
And I press "Save changes"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add category"
And I choose the "Add category" item in the "Add" action menu
And I set the field "Category name" to "Sub category"
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready

View File

@ -20,20 +20,20 @@ Feature: Extra credit contributions are normalised when going out of bounds
And I set the following administration settings values:
| grade_aggregations_visible | Simple weighted mean of grades,Mean of grades (with extra credits),Natural |
And I am on the "Course 1" "grades > gradebook setup" page
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 1 |
| Maximum grade | 150 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 2 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 3 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 4 |
And I click on "Save" "button" in the "New grade item" "dialogue"

View File

@ -20,7 +20,7 @@ Feature: We can change the maximum and minimum number of points for manual items
| student1 | C1 | student |
| student2 | C1 | student |
And I am on the "Course 1" "grades > gradebook setup" page logged in as "teacher1"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 1 |
| Minimum grade | 0 |

View File

@ -27,7 +27,7 @@ Feature: Student and teacher's view of aggregated grade items is consistent when
| assign | C1 | a3 | Test assignment three | Submit something! | Sub category 2 | 100 |
| assign | C1 | a4 | Test assignment four | Submit something! | Sub category 2 | 100 |
And I am on the "Course 1" "grades > gradebook setup" page logged in as "admin"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | calculated |
And I click on "Save" "button" in the "New grade item" "dialogue"

View File

@ -18,12 +18,12 @@ Feature: Hidden grade items should be hidden when grade category is locked, but
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I am on the "Course 1" "grades > gradebook setup" page logged in as "admin"
And I press "Add category"
And I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Test locked category |
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Hidden item |
| Hidden | 1 |
@ -56,12 +56,12 @@ Feature: Hidden grade items should be hidden when grade category is locked, but
Scenario: Hidden grade items in overridden category should show
Given I am on the "Course 1" "grades > gradebook setup" page
And I press "Add category"
And I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Test overridden category B|
And I click on "Save" "button" in the "New category" "dialogue"
And I wait until the page is ready
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Cat b item |
| Grade category | Test overridden category B |

View File

@ -35,7 +35,7 @@ Feature: We carry over data from modal to advanced grade item settings
And I log out
And I am on the "Course 1" course page logged in as teacher1
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
Scenario: Defaults are used when creating a new grade item
Given I click on "Show more..." "link" in the ".modal-dialog" "css_element"
@ -48,7 +48,7 @@ Feature: We carry over data from modal to advanced grade item settings
| Grade category | Course 1 |
And I press "Cancel"
And I wait until the page is ready
And I press "Add category"
And I choose the "Add category" item in the "Add" action menu
And I click on "Show more..." "link" in the ".modal-dialog" "css_element"
And the following fields match these values:
| Category name | |
@ -58,7 +58,7 @@ Feature: We carry over data from modal to advanced grade item settings
| Parent category | Course 1 |
And I press "Cancel"
And I wait until the page is ready
And I press "Add outcome item"
And I choose the "Add outcome item" item in the "Add" action menu
And I click on "Show more..." "link" in the ".modal-dialog" "css_element"
And the following fields match these values:
| Item name | |
@ -84,7 +84,7 @@ Feature: We carry over data from modal to advanced grade item settings
| Grade category | Some cool grade category |
And I press "Cancel"
And I wait until the page is ready
And I press "Add category"
And I choose the "Add category" item in the "Add" action menu
And I set the following fields to these values:
| Category name | Category 1 |
| Aggregation | Mean of grades |
@ -104,7 +104,7 @@ Feature: We carry over data from modal to advanced grade item settings
| Parent category | Some cool grade category |
And I press "Cancel"
And I wait until the page is ready
And I press "Add outcome item"
And I choose the "Add outcome item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Outcome item 1 |
| Outcome | Outcome 2 |

View File

@ -32,7 +32,7 @@ Feature: Grade item validation
| Scale | Disappointing, Good, Very good, Excellent |
And I press "Save changes"
And I am on the "Course 1" "grades > gradebook setup" page
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | MI 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"

View File

@ -26,38 +26,38 @@ Feature: We can use a minimum grade different than zero
And I set the following administration settings values:
| grade_aggregations_visible | Mean of grades,Weighted mean of grades,Simple weighted mean of grades,Mean of grades (with extra credits),Median of grades,Lowest grade,Highest grade,Mode of grades,Natural |
And I am on the "Course 1" "grades > gradebook setup" page
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 1 |
| Minimum grade | -100 |
| Grade category | Course 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 2 |
| Minimum grade | 50 |
| Grade category | Course 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 3 |
| Maximum grade | 50 |
| Minimum grade | -100 |
| Grade category | Sub category 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 4 |
| Minimum grade | -100 |
| Grade category | Sub category 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 5 |
| Minimum grade | 50 |
| Grade category | Sub category 2 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 6 |
| Minimum grade | 50 |

View File

@ -25,27 +25,27 @@ Feature: We can choose what min or max grade to use when aggregating grades.
And I set the following administration settings values:
| grade_minmaxtouse | Min and max grades as specified in grade item settings |
And I am on the "C1" "grades > gradebook setup" page
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | MI 1 |
| Grade category | C1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | MI 2 |
| Grade category | C1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | MI 3 |
| Grade category | CAT1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | MI 4 |
| Grade category | CAT1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I press "Add grade item"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | MI 5 |
| Grade category | C1 |

View File

@ -122,7 +122,7 @@
{{/isgroup}}
{{/options}}
</ul>
<input type="hidden" name="{{name}}" value="{{value}}" id="{{baseid}}-input" />
<input type="hidden" name="{{name}}" value="{{value}}" id="{{baseid}}-input">
</div>
{{#js}}
var label = document.getElementById('{{baseid}}-label');