And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager
And I click on "Preview" "button"
Then the following should exist in the "previewuploadedcohorts" table:
- | name | idnumber | description | Context | Status |
- | cohort name 1 | cohortid1 | first description | System | |
- | cohort name 2 | cohortid2 | | System | |
- | cohort name 3 | cohortid3 | | Miscellaneous | |
- | cohort name 4 | cohortid4 | | Cat 1 | |
- | cohort name 5 | cohortid5 | | Cat 2 | |
- | cohort name 6 | cohortid6 | | Cat 3 | |
+ | name | idnumber | description | Context | visible | Status |
+ | cohort name 1 | cohortid1 | first description | System | 1 | |
+ | cohort name 2 | cohortid2 | | System | 1 | |
+ | cohort name 3 | cohortid3 | | Miscellaneous | 0 | |
+ | cohort name 4 | cohortid4 | | Cat 1 | 1 | |
+ | cohort name 5 | cohortid5 | | Cat 2 | 0 | |
+ | cohort name 6 | cohortid6 | | Cat 3 | 1 | |
And I press "Upload cohorts"
And I should see "Uploaded 6 cohorts"
And I press "Continue"
| Cat 1 | cohort name 4 | cohortid4 | | 0 | Created manually |
| Cat 2 | cohort name 5 | cohortid5 | | 0 | Created manually |
| Cat 3 | cohort name 6 | cohortid6 | | 0 | Created manually |
+ And the "class" attribute of "cohort name 1" "table_row" should not contain "dimmed_text"
+ And the "class" attribute of "cohort name 2" "table_row" should not contain "dimmed_text"
+ And the "class" attribute of "cohort name 3" "table_row" should contain "dimmed_text"
+ And the "class" attribute of "cohort name 4" "table_row" should not contain "dimmed_text"
+ And the "class" attribute of "cohort name 5" "table_row" should contain "dimmed_text"
+ And the "class" attribute of "cohort name 6" "table_row" should not contain "dimmed_text"
@javascript
Scenario: Upload cohorts with default category context as admin
-name,idnumber,description,category
-cohort name 1,cohortid1,first description,
-cohort name 2,cohortid2,,
-cohort name 3,cohortid3,,Miscellaneous
-cohort name 4,cohortid4,,CAT1
-cohort name 5,cohortid5,,CAT2
-cohort name 6,cohortid6,,CAT3
+name,idnumber,description,category,visible
+cohort name 1,cohortid1,first description,,
+cohort name 2,cohortid2,,,
+cohort name 3,cohortid3,,Miscellaneous,no
+cohort name 4,cohortid4,,CAT1,yes
+cohort name 5,cohortid5,,CAT2,0
+cohort name 6,cohortid6,,CAT3,1
$columns = $cir->get_columns();
// Check that columns include 'name' and warn about extra columns.
- $allowedcolumns = array('contextid', 'name', 'idnumber', 'description', 'descriptionformat');
+ $allowedcolumns = array('contextid', 'name', 'idnumber', 'description', 'descriptionformat', 'visible');
$additionalcolumns = array('context', 'category', 'category_id', 'category_idnumber', 'category_path');
$displaycolumns = array();
$extracolumns = array();
case 'idnumber': $hash[$key] = core_text::substr(clean_param($value, PARAM_RAW), 0, 254); break;
case 'description': $hash[$key] = clean_param($value, PARAM_RAW); break;
case 'descriptionformat': $hash[$key] = clean_param($value, PARAM_INT); break;
+ case 'visible':
+ $tempstr = trim(core_text::strtolower($value));
+ if ($tempstr === '') {
+ // Empty string is treated as "YES" (the default value for cohort visibility).
+ $hash[$key] = 1;
+ } else {
+ if ($tempstr === core_text::strtolower(get_string('no')) || $tempstr === 'n') {
+ // Special treatment for 'no' string that is not included in clean_param().
+ $value = 0;
+ }
+ $hash[$key] = clean_param($value, PARAM_BOOL) ? 1 : 0;
+ }
+ break;
}
}
}
* Each record is a series of data separated by commas (or other delimiters)
* The first record contains a list of fieldnames defining the format of the rest of the file
* Required fieldname is name
-* Optional fieldnames are idnumber, description, descriptionformat, context, category, category_id, category_idnumber, category_path
+* Optional fieldnames are idnumber, description, descriptionformat, visible, context, category, category_id, category_idnumber, category_path
';
$string['visible'] = 'Visible';
$string['visible_help'] = "Any cohort can be viewed by users who have 'moodle/cohort:view' capability in the cohort context.<br/>