Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gradeimport_csv_load_data Class Reference

A class for loading and preparing grade data from import. More...

Public Member Functions

 get_error ()
 Returns the error parameter for this class. More...
 
 get_gradebookerrors ()
 Returns the gradebookerrors parameter for this class. More...
 
 get_headers ()
 Returns the headers parameter for this class. More...
 
 get_iid ()
 Returns the iid parameter for this class. More...
 
 get_previewdata ()
 Returns the preview_data parameter for this class. More...
 
 load_csv_content ($text, $encoding, $separator, $previewrows)
 Load CSV content for previewing. More...
 
 prepare_import_grade_data ($header, $formdata, $csvimport, $courseid, $separatemode, $currentgroup, $verbosescales)
 Checks and prepares grade data for inserting into the gradebook. More...
 

Static Public Member Functions

static fetch_grade_items ($courseid)
 Gets all of the grade items in this course. More...
 

Protected Member Functions

 check_user_exists ($value, $userfields)
 Check that the user is in the system. More...
 
 cleanup_import ($notification)
 Clean up failed CSV grade import. More...
 
 create_feedback ($courseid, $itemid, $value)
 Check to see if the feedback matches a grade item. More...
 
 import_new_grade_item ($header, $key, $value)
 Insert the new grade into the grade item buffer table. More...
 
 insert_grade_record ($record, $studentid)
 Inserts a record into the grade_import_values table. More...
 
 map_user_data_with_value ($mappingidentifier, $value, $header, $map, $key, $courseid, $feedbackgradeid, $verbosescales)
 Check user mapping. More...
 
 raise_limits ()
 Raises the php execution time and memory limits for importing the CSV file.
 
 trim_headers ()
 Cleans the column headers from the CSV file.
 
 update_grade_item ($courseid, $map, $key, $verbosescales, $value)
 This updates existing grade items. More...
 

Protected Attributes

string $error
 $error csv import error.
 
array $gradebookerrors
 $gradebookerrors An array of errors from trying to import into the gradebook.
 
array $headers
 $headers Column names for the data.
 
int $iid
 $iid Unique identifier for these csv records.
 
int $importcode
 $importcode The code for this batch insert.
 
array $newfeedbacks
 $newfeedbacks Feedback to be inserted into the gradebook.
 
array $newgradeitems
 $newgradeitems An array of new grade items to be inserted into the gradebook.
 
array $newgrades
 $newgrades Grades to be inserted into the gradebook.
 
array $previewdata
 $previewdata A subsection of the csv imported data.
 
bool $status
 $status The current status of the import. More...
 
int $studentid
 $studentid Student ID
 

Detailed Description

A class for loading and preparing grade data from import.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ check_user_exists()

gradeimport_csv_load_data::check_user_exists (   $value,
  $userfields 
)
protected

Check that the user is in the system.

Parameters
string$valueThe value, from the csv file, being mapped to identify the user.
array$userfieldsContains the field and label being mapped from.
Return values
intReturns the user ID if it exists, otherwise null.

◆ cleanup_import()

gradeimport_csv_load_data::cleanup_import (   $notification)
protected

Clean up failed CSV grade import.

Clears the temp table for inserting grades.

Parameters
string$notificationThe error message to display from the unsuccessful grade import.

◆ create_feedback()

gradeimport_csv_load_data::create_feedback (   $courseid,
  $itemid,
  $value 
)
protected

Check to see if the feedback matches a grade item.

Parameters
int$courseidThe course ID.
int$itemidThe ID of the grade item that the feedback relates to.
string$valueThe actual feedback being imported.
Return values
objectCreates a feedback object with the item ID and the feedback value.

◆ fetch_grade_items()

static gradeimport_csv_load_data::fetch_grade_items (   $courseid)
static

Gets all of the grade items in this course.

Parameters
int$courseidCourse id;
Return values
arrayAn array of grade items for the course.

◆ get_error()

gradeimport_csv_load_data::get_error ( )

Returns the error parameter for this class.

Return values
stringreturns error parameter for this class.

◆ get_gradebookerrors()

gradeimport_csv_load_data::get_gradebookerrors ( )

Returns the gradebookerrors parameter for this class.

Return values
arrayreturns gradebookerrors parameter for this class.

◆ get_headers()

gradeimport_csv_load_data::get_headers ( )

Returns the headers parameter for this class.

Return values
arrayreturns headers parameter for this class.

◆ get_iid()

gradeimport_csv_load_data::get_iid ( )

Returns the iid parameter for this class.

Return values
intreturns iid parameter for this class.

◆ get_previewdata()

gradeimport_csv_load_data::get_previewdata ( )

Returns the preview_data parameter for this class.

Return values
arrayreturns previewdata parameter for this class.

◆ import_new_grade_item()

gradeimport_csv_load_data::import_new_grade_item (   $header,
  $key,
  $value 
)
protected

Insert the new grade into the grade item buffer table.

Parameters
array$headerThe column headers from the CSV file.
int$keyCurrent row identifier.
string$valueThe value for this row (final grade).
Return values
stdClassnew grade that is ready for commiting to the gradebook.

◆ insert_grade_record()

gradeimport_csv_load_data::insert_grade_record (   $record,
  $studentid 
)
protected

Inserts a record into the grade_import_values table.

This also adds common record information.

Parameters
object$recordThe grade record being inserted into the database.
int$studentidThe student ID.
Return values
bool|inttrue or insert id on success. Null if the grade value is too high.

◆ load_csv_content()

gradeimport_csv_load_data::load_csv_content (   $text,
  $encoding,
  $separator,
  $previewrows 
)

Load CSV content for previewing.

Parameters
string$textThe grade data being imported.
string$encodingThe type of encoding the file uses.
string$separatorThe separator being used to define each field.
int$previewrowsHow many rows are being previewed.

◆ map_user_data_with_value()

gradeimport_csv_load_data::map_user_data_with_value (   $mappingidentifier,
  $value,
  $header,
  $map,
  $key,
  $courseid,
  $feedbackgradeid,
  $verbosescales 
)
protected

Check user mapping.

Parameters
string$mappingidentifierThe user field that we are matching together.
string$valueThe value we are checking / importing.
array$headerThe column headers of the csv file.
array$mapMapping information provided by the user.
int$keyCurrent row identifier.
int$courseidThe course ID.
int$feedbackgradeidThe ID of the grade item that the feedback relates to.
bool$verbosescalesForm setting for grading with scales.

◆ prepare_import_grade_data()

gradeimport_csv_load_data::prepare_import_grade_data (   $header,
  $formdata,
  $csvimport,
  $courseid,
  $separatemode,
  $currentgroup,
  $verbosescales 
)

Checks and prepares grade data for inserting into the gradebook.

Parameters
array$headerColumn headers of the CSV file.
object$formdataMapping information from the preview page.
object$csvimportcsv import reader object for iterating over the imported CSV file.
int$courseidThe course ID.
bool$separatemodeIf we have groups are they separate?
mixed$currentgroupcurrent group information.
bool$verbosescalesForm setting for grading with scales.
Return values
boolTrue if the status for importing is okay, false if there are errors.

◆ update_grade_item()

gradeimport_csv_load_data::update_grade_item (   $courseid,
  $map,
  $key,
  $verbosescales,
  $value 
)
protected

This updates existing grade items.

Parameters
int$courseidThe course ID.
array$mapMapping information provided by the user.
int$keyThe line that we are currently working on.
bool$verbosescalesForm setting for grading with scales.
string$valueThe grade value.
Return values
arraygrades to be updated.

Member Data Documentation

◆ $status

bool gradeimport_csv_load_data::$status
protected

$status The current status of the import.

True = okay, False = errors.


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