Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

A form for cohort upload.

Copyright: 2014 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 570 lines (23 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: cohort_upload_form  - X-Ref

Cohort upload form class

definition()   X-Ref
Form definition


add_cohort_upload_buttons()   X-Ref
Add buttons to the form ("Upload cohorts", "Preview", "Cancel")


definition_after_data()   X-Ref
Process the uploaded file and allow the submit button only if it doest not have errors.


get_context_options()   X-Ref
Returns the list of contexts where current user can create cohorts.

return: array

validation($data, $files)   X-Ref
No description

get_cohort_file($draftid)   X-Ref
Returns the uploaded file if it is present.

param: int $draftid
return: stored_file|null

get_cohorts_data()   X-Ref
Returns the list of prepared objects to be added as cohorts

return: array of stdClass objects, each can be passed to {@link cohort_add_cohort()}

preview_uploaded_cohorts()   X-Ref
Displays the preview of the uploaded file


get_previewed_rows()   X-Ref
Find up rows to show in preview

Number of previewed rows is limited but rows with errors and warnings have priority.

return: array

display()   X-Ref
No description

process_upload_file($file, $encoding, $delimiter, $defaultcontext)   X-Ref

param: stored_file $file
param: string $encoding
param: string $delimiter
param: context $defaultcontext
return: array

clean_cohort_data(&$hash)   X-Ref
Cleans input data about one cohort.

param: array $hash

resolve_context(&$hash, $defaultcontext)   X-Ref
Determines in which context the particular cohort will be created

param: array $hash
param: context $defaultcontext
return: array array of warning strings