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.

Differences Between: [Versions 39 and 402]

(no description)

File Size: 720 lines (28 kb)
Included or required:0 times
Referenced: 4 times
Includes or requires: 0 files

Defines 3 classes

grade_export:: (15 methods):
  __construct()
  deprecated_constructor()
  process_form()
  track_exports()
  format_grade()
  format_column_name()
  format_feedback()
  display_preview()
  get_export_params()
  print_continue()
  get_export_url()
  convert_flat_displaytypes_to_array()
  convert_flat_itemids_to_array()
  get_grade_publishing_url()
  export_bulk_export_data()

grade_export_update_buffer:: (2 methods):
  __construct()
  grade_export_update_buffer()

name:: (4 methods):
  flush()
  track()
  close()
  export_verify_grades()


Class: grade_export  - X-Ref

Base export class

__construct($course, $groupid, $formdata)   X-Ref
Constructor should set up all the private variables ready to be pulled.

This constructor used to accept the individual parameters as separate arguments, in
2.8 this was simplified to just accept the data from the moodle form.

param: object $course
param: int $groupid
param: stdClass|null $formdata

deprecated_constructor($course,$groupid=0,$itemlist='',$export_feedback=false,$updatedgradesonly = false,$displaytype = GRADE_DISPLAY_TYPE_REAL,$decimalpoints = 2,$onlyactive = false,$usercustomfields = false)   X-Ref
Old deprecated constructor.

This deprecated constructor accepts the individual parameters as separate arguments, in
2.8 this was simplified to just accept the data from the moodle form.


process_form($formdata)   X-Ref
Init object based using data from form

param: object $formdata

track_exports()   X-Ref
Update exported field in grade_grades table

return: boolean

format_grade($grade, $gradedisplayconst = null)   X-Ref
Returns string representation of final grade

param: object $grade instance of grade_grade class
param: integer $gradedisplayconst grade display type constant.
return: string

format_column_name($grade_item, $feedback=false, $gradedisplayname = null)   X-Ref
Returns the name of column in export

param: object $grade_item
param: boolean $feedback feedback colum
param: string $gradedisplayname grade display name.
return: string

format_feedback($feedback, $grade = null)   X-Ref
Returns formatted grade feedback

param: object $feedback object with properties feedback and feedbackformat
param: object $grade Grade object with grade properties
return: string

display_preview($require_user_idnumber=false)   X-Ref
Prints preview of exported grades on screen as a feedback mechanism

param: bool $require_user_idnumber true means skip users without idnumber

get_export_params()   X-Ref
Returns array of parameters used by dump.php and export.php.

return: array

print_continue()   X-Ref
Either prints a "Export" box, which will redirect the user to the download page,
or prints the URL for the published data.

return: void

get_export_url()   X-Ref
Generate the export url.

Get submitted form data and create the url to be used on the grade publish feature.

return: moodle_url the url of grade publishing export.

convert_flat_displaytypes_to_array($displaytypes)   X-Ref
Convert the grade display types parameter into the required array to grade exporting class.

In order to export, the array key must be the display type name and the value must be the grade display type
constant.

Note: Added support for combined display types constants like the (GRADE_DISPLAY_TYPE_PERCENTAGE_REAL) as
the $CFG->grade_export_displaytype config is still used on 2.7 in case of missing displaytype url param.
In these cases, the file will be exported with a column for each display type.

param: string $displaytypes can be a single or multiple display type constants comma separated.
return: array $types

convert_flat_itemids_to_array($itemids)   X-Ref
Convert the item ids parameter into the required array to grade exporting class.

In order to export, the array key must be the grade item id and all values must be one.

param: string $itemids can be a single item id or many item ids comma separated.
return: array $items correctly formatted array.

get_grade_publishing_url()   X-Ref
Create the html code of the grade publishing feature.

return: string $output html code of the grade publishing.

export_bulk_export_data($id, $itemids, $exportfeedback, $onlyactive, $displaytype,$decimalpoints, $updatedgradesonly = null, $separator = null)   X-Ref
Create a stdClass object from URL parameters to be used by grade_export class.

param: int $id course id.
param: string $itemids grade items comma separated.
param: bool $exportfeedback export feedback option.
param: bool $onlyactive only enrolled active students.
param: string $displaytype grade display type constants comma separated.
param: int $decimalpoints grade decimal points.
param: null $updatedgradesonly recently updated grades only (Used by XML exporting only).
param: null $separator separator character: tab, comma, colon and semicolon (Used by TXT exporting only).
return: stdClass $formdata

Class: grade_export_update_buffer  - X-Ref

This class is used to update the exported field in grade_grades.
It does internal buffering to speedup the db operations.

__construct()   X-Ref
Constructor - creates the buffer and initialises the time stamp


grade_export_update_buffer()   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

flush($buffersize)   X-Ref
No description

track($grade_grade)   X-Ref
Track grade export status

param: object $grade_grade
return: string $status (unknow, new, regrade, nochange)

close()   X-Ref
Flush and close the buffer.


export_verify_grades($courseid)   X-Ref
Verify that there is a valid set of grades to export.

param: $courseid int The course being exported