Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
grade_export Class Reference
Inheritance diagram for grade_export:
grade_export_ods grade_export_txt grade_export_xls grade_export_xml

Public Member Functions

 __construct ($course, $groupid, $formdata)
 Constructor should set up all the private variables ready to be pulled.
 
 display_preview ($require_user_idnumber=false)
 Prints preview of exported grades on screen as a feedback mechanism.
 
 format_column_name ($grade_item, $feedback=false, $gradedisplayname=null)
 Returns the name of column in export.
 
 format_feedback ($feedback, $grade=null)
 Returns formatted grade feedback.
 
 format_grade ($grade, $gradedisplayconst=null)
 Returns string representation of final grade.
 
 get_export_params ()
 Returns array of parameters used by dump.php and export.php.
 
 get_export_url ()
 Generate the export url.
 
 get_grade_publishing_url ()
 Create the html code of the grade publishing feature.
 
 print_continue ()
 Either prints a "Export" box, which will redirect the user to the download page, or prints the URL for the published data.
 
 print_grades ()
 Implemented by child class.
 
 process_form ($formdata)
 Init object based using data from form.
 
 track_exports ()
 Update exported field in grade_grades table.
 

Static Public Member Functions

static convert_flat_displaytypes_to_array ($displaytypes)
 Convert the grade display types parameter into the required array to grade exporting class.
 
static convert_flat_itemids_to_array ($itemids)
 Convert the item ids parameter into the required array to grade exporting class.
 
static export_bulk_export_data ($id, $itemids, $exportfeedback, $onlyactive, $displaytype, $decimalpoints, $updatedgradesonly=null, $separator=null)
 Create a stdClass object from URL parameters to be used by grade_export class.
 

Public Attributes

 $columns
 
 $course
 
 $decimalpoints
 
$displaytype $displaytype
 Grade display type (real, percentages or letter).
 
 $export_feedback
 
 $export_letters
 
 $grade_items
 
 $groupid
 
 $onlyactive
 
 $plugin
 
$previewrows $previewrows
 
 $updatedgradesonly
 
 $usercustomfields
 
 $userkey
 

Protected Member Functions

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

Protected Attributes

int const EXPORT_SELECT_NONE = -1
 Value to state nothing is being exported.
 

Constructor & Destructor Documentation

◆ __construct()

grade_export::__construct ( $course,
$groupid,
$formdata )

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.

Parameters
object$course
int$groupid
stdClass | null$formdata
Note
Exporting as letters will lead to data loss if that exported set it re-imported.

Reimplemented in grade_export_ods, grade_export_txt, and grade_export_xls.

Member Function Documentation

◆ convert_flat_displaytypes_to_array()

static grade_export::convert_flat_displaytypes_to_array ( $displaytypes)
static

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.

Parameters
string$displaytypescan be a single or multiple display type constants comma separated.
Return values
array\$types

◆ convert_flat_itemids_to_array()

static grade_export::convert_flat_itemids_to_array ( $itemids)
static

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.

Parameters
string$itemidscan be a single item id or many item ids comma separated.
Return values
array\$itemscorrectly formatted array.

◆ deprecated_constructor()

grade_export::deprecated_constructor ( $course,
$groupid = 0,
$itemlist = '',
$export_feedback = false,
$updatedgradesonly = false,
$displaytype = GRADE_DISPLAY_TYPE_REAL,
$decimalpoints = 2,
$onlyactive = false,
$usercustomfields = false )
protected

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.

Deprecated
since 2.8 MDL-46548. Instead call the shortened constructor which accepts the data directly from the grade_export_form.

◆ display_preview()

grade_export::display_preview ( $require_user_idnumber = false)

Prints preview of exported grades on screen as a feedback mechanism.

Parameters
bool$require_user_idnumbertrue means skip users without idnumber
Deprecated
since 2.8 MDL-46548. Previews are not useful on export.

◆ export_bulk_export_data()

static grade_export::export_bulk_export_data ( $id,
$itemids,
$exportfeedback,
$onlyactive,
$displaytype,
$decimalpoints,
$updatedgradesonly = null,
$separator = null )
static

Create a stdClass object from URL parameters to be used by grade_export class.

Parameters
int$idcourse id.
string$itemidsgrade items comma separated.
bool$exportfeedbackexport feedback option.
bool$onlyactiveonly enrolled active students.
string$displaytypegrade display type constants comma separated.
int$decimalpointsgrade decimal points.
null$updatedgradesonlyrecently updated grades only (Used by XML exporting only).
null$separatorseparator character: tab, comma, colon and semicolon (Used by TXT exporting only).
Return values
stdClass\$formdata

◆ format_column_name()

grade_export::format_column_name ( $grade_item,
$feedback = false,
$gradedisplayname = null )

Returns the name of column in export.

Parameters
object$grade_item
boolean$feedbackfeedback colum
string$gradedisplaynamegrade display name.
Return values
string

◆ format_feedback()

grade_export::format_feedback ( $feedback,
$grade = null )

Returns formatted grade feedback.

Parameters
object$feedbackobject with properties feedback and feedbackformat
object$gradeGrade object with grade properties
Return values
string

◆ format_grade()

grade_export::format_grade ( $grade,
$gradedisplayconst = null )

Returns string representation of final grade.

Parameters
object$gradeinstance of grade_grade class
integer$gradedisplayconstgrade display type constant.
Return values
string

◆ get_export_params()

grade_export::get_export_params ( )

Returns array of parameters used by dump.php and export.php.

Return values
array

Reimplemented in grade_export_txt.

◆ get_export_url()

grade_export::get_export_url ( )

Generate the export url.

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

Return values
moodle_urlthe url of grade publishing export.

◆ get_grade_publishing_url()

grade_export::get_grade_publishing_url ( )

Create the html code of the grade publishing feature.

Return values
string\$outputhtml code of the grade publishing.

◆ print_continue()

grade_export::print_continue ( )

Either prints a "Export" box, which will redirect the user to the download page, or prints the URL for the published data.

Deprecated
since 2.8 MDL-46548. Call get_export_url and set the action of the grade_export_form instead.
Return values
void

◆ print_grades()

grade_export::print_grades ( )
abstract

Implemented by child class.

Reimplemented in grade_export_ods, grade_export_txt, and grade_export_xls.

◆ process_form()

grade_export::process_form ( $formdata)

Init object based using data from form.

Parameters
object$formdata

Reimplemented in grade_export_xml.

◆ track_exports()

grade_export::track_exports ( )

Update exported field in grade_grades table.

Return values
boolean

Member Data Documentation

◆ $displaytype

$displaytype grade_export::$displaytype

Grade display type (real, percentages or letter).

This attribute is an integer for XML file export. Otherwise is an array for all other formats (ODS, XLS and TXT).

Grade display type constant (1, 2 or 3) or an array of display types where the key is the name and the value is the grade display type constant or 0 for unchecked display types.

◆ $previewrows

$previewrows grade_export::$previewrows
Deprecated
since Moodle 2.8 Number of rows in preview.

The documentation for this class was generated from the following file: