MDL-48618 grades: Testing calculated items with minmaxtouse
This commit is contained in:
@@ -79,6 +79,60 @@ class behat_grade extends behat_base {
|
||||
return $steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a calculated manual grade item. Needs a table with item name - idnumber relation. The step requires you to be in categories and items page.
|
||||
*
|
||||
* @Given /^I set "(?P<calculation_string>(?:[^"]|\\")*)" calculation for grade item "(?P<grade_item_string>(?:[^"]|\\")*)" with idnumbers:$/
|
||||
* @param string $calculation The calculation.
|
||||
* @param string $gradeitem The grade item name.
|
||||
* @param TableNode $TableNode The grade item name - idnumbers relation.
|
||||
* @return Given[]
|
||||
*/
|
||||
public function i_set_calculation_for_grade_item_with_idnumbers($calculation, $gradeitem, TableNode $data) {
|
||||
|
||||
$steps = array();
|
||||
$gradeitem = $this->getSession()->getSelectorsHandler()->xpathLiteral($gradeitem);
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
$xpath = "//tr[contains(.,$gradeitem)]//*[contains(@class,'moodle-actionmenu')]//a[contains(@class,'toggle-display')]";
|
||||
if ($this->getSession()->getPage()->findAll('xpath', $xpath)) {
|
||||
$steps[] = new Given('I click on "' . $this->escape($xpath) . '" "xpath_element"');
|
||||
}
|
||||
}
|
||||
|
||||
// Going to edit calculation.
|
||||
$savechanges = get_string('savechanges', 'grades');
|
||||
$edit = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string('editcalculation', 'grades'));
|
||||
$linkxpath = "//a[./img[starts-with(@title,$edit) and contains(@title,$gradeitem)]]";
|
||||
$steps[] = new Given('I click on "' . $this->escape($linkxpath) . '" "xpath_element"');
|
||||
|
||||
// After adding id numbers we should wait until the page is reloaded.
|
||||
$steps[] = new Given('I wait until the page is ready');
|
||||
|
||||
// Mapping names to idnumbers.
|
||||
$datahash = $data->getRowsHash();
|
||||
foreach ($datahash as $gradeitem => $idnumber) {
|
||||
// This xpath looks for course, categories and items with the provided name.
|
||||
// Grrr, we can't equal in categoryitem and courseitem because there is a line jump...
|
||||
$inputxpath ="//input[@class='idnumber'][" .
|
||||
"parent::li[@class='item'][text()='" . $gradeitem . "']" .
|
||||
" | " .
|
||||
"parent::li[@class='categoryitem' | @class='courseitem']/parent::ul/parent::li[starts-with(text(),'" . $gradeitem . "')]" .
|
||||
"]";
|
||||
$steps[] = new Given('I set the field with xpath "' . $inputxpath . '" to "' . $idnumber . '"');
|
||||
}
|
||||
|
||||
$steps[] = new Given('I press "' . get_string('addidnumbers', 'grades') . '"');
|
||||
|
||||
// After adding id numbers we should wait until the page is reloaded.
|
||||
$steps[] = new Given('I wait until the page is ready');
|
||||
|
||||
$steps[] = new Given('I set the field "' . get_string('calculation', 'grades') . '" to "' . $calculation . '"');
|
||||
$steps[] = new Given('I press "' . $savechanges . '"');
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the weights for the grade category
|
||||
*
|
||||
|
||||
@@ -49,6 +49,15 @@ Feature: We can choose what min or max grade to use when aggregating grades.
|
||||
| Item name | MI 4 |
|
||||
| Grade category | CAT1 |
|
||||
And I press "Save changes"
|
||||
And I press "Add grade item"
|
||||
And I set the following fields to these values:
|
||||
| Item name | MI 5 |
|
||||
| Grade category | C1 |
|
||||
And I press "Save changes"
|
||||
And I set "=[[mi1]]+[[mi2]]+[[mi3]]" calculation for grade item "MI 5" with idnumbers:
|
||||
| MI 1 | mi1 |
|
||||
| MI 2 | mi2 |
|
||||
| MI 3 | mi3 |
|
||||
And I navigate to "Course grade settings" node in "Grade administration > Setup"
|
||||
And I set the field "Min and max grades used in calculation" to "Default (Min and max grades as specified in grade item settings)"
|
||||
And I set the field "Show weightings" to "Show"
|
||||
@@ -73,21 +82,23 @@ Feature: We can choose what min or max grade to use when aggregating grades.
|
||||
And I select "Student 1" from the "Select all or one user" singleselect
|
||||
And the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 1 | 25.00 % | 75.00 | 0–100 | 75.00 % | 18.75 % |
|
||||
| MI 2 | 25.00 % | 25.00 | 0–100 | 25.00 % | 6.25 % |
|
||||
| MI 3 | 50.00 % | 50.00 | 0–100 | 50.00 % | 12.50 % |
|
||||
| MI 4 | 50.00 % | 100.00 | 0–100 | 100.00 % | 25.00 % |
|
||||
| CAT1 total | 50.00 % | 150.00 | 0–200 | 75.00 % | - |
|
||||
| Course total | - | 250.00 | 0–400 | 62.50 % | - |
|
||||
| MI 1 | 20.00 % | 75.00 | 0–100 | 75.00 % | 15.00 % |
|
||||
| MI 2 | 20.00 % | 25.00 | 0–100 | 25.00 % | 5.00 % |
|
||||
| MI 3 | 50.00 % | 50.00 | 0–100 | 50.00 % | 10.00 % |
|
||||
| MI 4 | 50.00 % | 100.00 | 0–100 | 100.00 % | 20.00 % |
|
||||
| MI 5 | 20.00 % | 100.00 | 0–100 | 100.00 % | 20.00 % |
|
||||
| CAT1 total | 40.00 % | 150.00 | 0–200 | 75.00 % | - |
|
||||
| Course total | - | 350.00 | 0–500 | 70.00 % | - |
|
||||
And I select "Student 2" from the "Select all or one user" singleselect
|
||||
And the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 1 | 50.00 % | 20.00 | 0–100 | 20.00 % | 10.00 % |
|
||||
| MI 1 | 33.33 % | 20.00 | 0–100 | 20.00 % | 6.67 % |
|
||||
| MI 2 | 0.00 % | - | 0–100 | - | 0.00 % |
|
||||
| MI 3 | 100.00 % | 10.00 | 0–100 | 10.00 % | 5.00 % |
|
||||
| MI 3 | 100.00 % | 10.00 | 0–100 | 10.00 % | 3.33 % |
|
||||
| MI 4 | 0.00 % | - | 0–100 | - | 0.00 % |
|
||||
| CAT1 total | 50.00 % | 10.00 | 0–100 | 10.00 % | - |
|
||||
| Course total | - | 30.00 | 0–200 | 15.00 % | - |
|
||||
| MI 5 | 33.33 % | 30.00 | 0–100 | 30.00 % | 10.00 % |
|
||||
| CAT1 total | 33.33 % | 10.00 | 0–100 | 10.00 % | - |
|
||||
| Course total | - | 60.00 | 0–300 | 20.00 % | - |
|
||||
And I navigate to "Categories and items" node in "Grade administration > Setup"
|
||||
And I set the following settings for grade item "MI 1":
|
||||
| Maximum grade | 50.00 |
|
||||
@@ -99,21 +110,37 @@ Feature: We can choose what min or max grade to use when aggregating grades.
|
||||
And I select "Student 1" from the "Select all or one user" singleselect
|
||||
And the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 1 | 16.67 % | 75.00 | 5–50 | 100.00 % | 25.00 % |
|
||||
| MI 2 | 33.33 % | 25.00 | 0–100 | 25.00 % | 8.33 % |
|
||||
| MI 3 | 33.33 % | 50.00 | 5–50 | 100.00 % | 16.67 % |
|
||||
| MI 4 | 66.67 % | 100.00 | 0–100 | 100.00 % | 33.33 % |
|
||||
| CAT1 total | 50.00 % | 150.00 | 0–150 | 100.00 % | - |
|
||||
| Course total | - | 250.00 | 0–300 | 83.33 % | - |
|
||||
| MI 1 | 12.50 % | 75.00 | 5–50 | 100.00 % | 18.75 % |
|
||||
| MI 2 | 25.00 % | 25.00 | 0–100 | 25.00 % | 6.25 % |
|
||||
| MI 3 | 33.33 % | 50.00 | 5–50 | 100.00 % | 12.50 % |
|
||||
| MI 4 | 66.67 % | 100.00 | 0–100 | 100.00 % | 25.00 % |
|
||||
| MI 5 | 25.00 % | 100.00 | 0–100 | 100.00 % | 25.00 % |
|
||||
| CAT1 total | 37.50 % | 150.00 | 0–150 | 100.00 % | - |
|
||||
| Course total | - | 350.00 | 0–400 | 87.50 % | - |
|
||||
And I select "Student 2" from the "Select all or one user" singleselect
|
||||
And the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 1 | 50.00 % | 20.00 | 5–50 | 33.33 % | 20.00 % |
|
||||
| MI 1 | 25.00 % | 20.00 | 5–50 | 33.33 % | 10.00 % |
|
||||
| MI 2 | 0.00 % | - | 0–100 | - | 0.00 % |
|
||||
| MI 3 | 100.00 % | 10.00 | 5–50 | 11.11 % | 10.00 % |
|
||||
| MI 3 | 100.00 % | 10.00 | 5–50 | 11.11 % | 5.00 % |
|
||||
| MI 4 | 0.00 % | - | 0–100 | - | 0.00 % |
|
||||
| CAT1 total | 50.00 % | 10.00 | 0–50 | 20.00 % | - |
|
||||
| Course total | - | 30.00 | 0–100 | 30.00 % | - |
|
||||
| MI 5 | 50.00 % | 30.00 | 0–100 | 30.00 % | 15.00 % |
|
||||
| CAT1 total | 25.00 % | 10.00 | 0–50 | 20.00 % | - |
|
||||
| Course total | - | 60.00 | 0–200 | 30.00 % | - |
|
||||
And I navigate to "Categories and items" node in "Grade administration > Setup"
|
||||
And I set the following settings for grade item "MI 5":
|
||||
| Maximum grade | 200.00 |
|
||||
And I follow "User report"
|
||||
And I select "Student 1" from the "Select all or one user" singleselect
|
||||
And the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 5 | 40.00 % | 150.00 | 0–200 | 75.00 % | 30.00 % |
|
||||
| Course total | - | 400.00 | 0–500 | 80.00 % | - |
|
||||
And I select "Student 2" from the "Select all or one user" singleselect
|
||||
And the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 5 | 66.67 % | 30.00 | 0–200 | 15.00 % | 10.00 % |
|
||||
| Course total | - | 60.00 | 0–300 | 20.00 % | - |
|
||||
And I navigate to "Course grade settings" node in "Grade administration > Setup"
|
||||
When I set the field "Min and max grades used in calculation" to "Initial min and max grades"
|
||||
And I press "Save changes"
|
||||
@@ -121,18 +148,20 @@ Feature: We can choose what min or max grade to use when aggregating grades.
|
||||
And I select "Student 1" from the "Select all or one user" singleselect
|
||||
Then the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 1 | 25.00 % | 75.00 | 0–100 | 75.00 % | 18.75 % |
|
||||
| MI 2 | 25.00 % | 25.00 | 0–100 | 25.00 % | 6.25 % |
|
||||
| MI 3 | 50.00 % | 50.00 | 0–100 | 50.00 % | 12.50 % |
|
||||
| MI 4 | 50.00 % | 100.00 | 0–100 | 100.00 % | 25.00 % |
|
||||
| CAT1 total | 50.00 % | 150.00 | 0–200 | 75.00 % | - |
|
||||
| Course total | - | 250.00 | 0–400 | 62.50 % | - |
|
||||
| MI 1 | 20.00 % | 75.00 | 0–100 | 75.00 % | 15.00 % |
|
||||
| MI 2 | 20.00 % | 25.00 | 0–100 | 25.00 % | 5.00 % |
|
||||
| MI 3 | 50.00 % | 50.00 | 0–100 | 50.00 % | 10.00 % |
|
||||
| MI 4 | 50.00 % | 100.00 | 0–100 | 100.00 % | 20.00 % |
|
||||
| MI 5 | 20.00 % | 150.00 | 0–100 | 100.00 % | 30.00 % |
|
||||
| CAT1 total | 40.00 % | 150.00 | 0–200 | 75.00 % | - |
|
||||
| Course total | - | 400.00 | 0–500 | 80.00 % | - |
|
||||
And I select "Student 2" from the "Select all or one user" singleselect
|
||||
And the following should exist in the "user-grade" table:
|
||||
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
|
||||
| MI 1 | 50.00 % | 20.00 | 0–100 | 20.00 % | 10.00 % |
|
||||
| MI 1 | 33.33 % | 20.00 | 0–100 | 20.00 % | 6.67 % |
|
||||
| MI 2 | 0.00 % | - | 0–100 | - | 0.00 % |
|
||||
| MI 3 | 100.00 % | 10.00 | 0–100 | 10.00 % | 5.00 % |
|
||||
| MI 3 | 100.00 % | 10.00 | 0–100 | 10.00 % | 3.33 % |
|
||||
| MI 4 | 0.00 % | - | 0–100 | - | 0.00 % |
|
||||
| CAT1 total | 50.00 % | 10.00 | 0–100 | 10.00 % | - |
|
||||
| Course total | - | 30.00 | 0–200 | 15.00 % | - |
|
||||
| MI 5 | 33.33 % | 30.00 | 0–100 | 30.00 % | 10.00 % |
|
||||
| CAT1 total | 33.33 % | 10.00 | 0–100 | 10.00 % | - |
|
||||
| Course total | - | 60.00 | 0–300 | 20.00 % | - |
|
||||
|
||||
Reference in New Issue
Block a user