Moodle  2.2.1
http://www.collinsharper.com
gradingform_instance Class Reference
Inheritance diagram for gradingform_instance:

Public Member Functions

 __construct ($controller, $data)
 copy ($raterid, $itemid)
 get_current_instance ()
 get_controller ()
 get_data ($key)
 get_id ()
 get_status ()
 cancel ()
 update ($elementvalue)
 get_grade ()
 submit_and_get_grade ($elementvalue, $itemid)
 render_grading_element ($page, $gradingformelement)
 validate_grading_element ($elementvalue)
 default_validation_error_message ()

Static Public Member Functions

static create_new ($definitionid, $raterid, $itemid)

Data Fields

const INSTANCE_STATUS_ACTIVE = 1
const INSTANCE_STATUS_NEEDUPDATE = 2
const INSTANCE_STATUS_INCOMPLETE = 0
const INSTANCE_STATUS_ARCHIVE = 3

Protected Member Functions

 make_active ()

Protected Attributes

 $data
 $controller

Detailed Description

Class to manage one grading instance. Stores information and performs actions like update, copy, validate, submit, etc.

Definition at line 625 of file lib.php.


Constructor & Destructor Documentation

__construct ( controller,
data 
)

Creates an instance

Parameters:
gradingform_controller$controller
stdClass$data

Definition at line 642 of file lib.php.


Member Function Documentation

cancel ( )

Deletes this (INCOMPLETE) instance from database. This function is invoked on cancelling the grading form and/or during cron cleanup. Plugins using additional tables must override this method to remove additional data. Note that if the teacher just closes the window or presses 'Back' button of the browser, this function is not invoked.

Reimplemented in gradingform_rubric_instance.

Definition at line 769 of file lib.php.

Here is the call graph for this function:

copy ( raterid,
itemid 
)

Duplicates the instance before editing (optionally substitutes raterid and/or itemid with the specified values) Plugins may want to override this function to copy data from additional tables as well

Parameters:
int$rateridvalue for raterid in the duplicate
int$itemidvalue for itemid in the duplicate
Returns:
int id of the new instance

Reimplemented in gradingform_rubric_instance.

Definition at line 677 of file lib.php.

static create_new ( definitionid,
raterid,
itemid 
) [static]

Creates a new empty instance in DB and mark its status as INCOMPLETE

Parameters:
int$definitionid
int$raterid
int$itemid
Returns:
int id of the created instance

Definition at line 655 of file lib.php.

Returns the error message displayed if validation failed. If plugin wants to display custom message, the empty string should be returned here and the custom message should be output in render_grading_element()

See also:
validate_grading_element()
Returns:
string

Definition at line 879 of file lib.php.

Returns the controller

Returns:
gradingform_controller

Definition at line 707 of file lib.php.

Here is the caller graph for this function:

Returns the current (active or needupdate) instance for the same raterid and itemid as this instance. This function is useful to find the status of the currently modified instance

Returns:
gradingform_instance

Definition at line 695 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_data ( key)

Returns the specified element from object $this->data

Parameters:
string$key
Returns:
mixed

Definition at line 717 of file lib.php.

Here is the caller graph for this function:

get_grade ( ) [abstract]

Calculates the grade to be pushed to the gradebook

Returns:
int the valid grade from $this->get_controller()->get_grade_range()

Reimplemented in gradingform_rubric_instance.

Here is the caller graph for this function:

get_id ( )

Returns instance id

Returns:
int

Definition at line 729 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns instance status

Returns:
int

Definition at line 738 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

make_active ( ) [protected]

Marks the instance as ACTIVE and current active instance (if exists) as ARCHIVE

Definition at line 745 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

render_grading_element ( page,
gradingformelement 
) [abstract]

Returns html for form element of type 'grading'. If there is a form input element it must have the name $gradingformelement->getName(). If there are more than one input elements they MUST be elements of array with name $gradingformelement->getName(). Example: {NAME}[myelement1], {NAME}[myelement2][sub1], {NAME}[myelement2][sub2], etc. ( {NAME} is a shortcut for $gradingformelement->getName() ) After submitting the form the value of $_POST[{NAME}] is passed to the functions validate_grading_element() and submit_and_get_grade()

Plugins may use $gradingformelement->getValue() to get the value passed on previous form submit

When forming html it is a plugin's responsibility to analyze flags $gradingformelement->_flagFrozen and $gradingformelement->_persistantFreeze:

(_flagFrozen == false) => form element is editable

(_flagFrozen == false && _persistantFreeze == true) => form element is not editable but all values are passed as hidden elements

(_flagFrozen == false && _persistantFreeze == false) => form element is not editable and no values are passed as hidden elements

Plugins are welcome to use AJAX in the form element. But it is strongly recommended that the grading only becomes active when teacher presses 'Submit' button (the method submit_and_get_grade() is invoked)

Also client-side JS validation may be implemented here

See also:
MoodleQuickForm_grading in lib/form/grading.php
Parameters:
moodle_page$page
MoodleQuickForm_grading$gradingformelement
Returns:
string

Reimplemented in gradingform_rubric_instance.

submit_and_get_grade ( elementvalue,
itemid 
)

Called when teacher submits the grading form: updates the instance in DB, marks it as ACTIVE and returns the grade to be pushed to the gradebook. $itemid must be specified here (it was not required when the instance was created, because it might not existed in draft)

Parameters:
array$elementvalue
int$itemid
Returns:
int the grade on 0-100 scale

Definition at line 815 of file lib.php.

Here is the call graph for this function:

update ( elementvalue)

Updates the instance with the data received from grading form. This function may be called via AJAX when grading is not yet completed, so it does not change the status of the instance.

Parameters:
array$elementvalue

Reimplemented in gradingform_rubric_instance.

Definition at line 783 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

validate_grading_element ( elementvalue)

Server-side validation of the data received from grading form.

Parameters:
mixed$elementvalueis the scalar or array received in $_POST
Returns:
boolean true if the form data is validated and contains no errors

Reimplemented in gradingform_rubric_instance.

Definition at line 867 of file lib.php.


Field Documentation

$controller [protected]

Definition at line 634 of file lib.php.

$data [protected]

Definition at line 632 of file lib.php.

Definition at line 626 of file lib.php.

Definition at line 629 of file lib.php.

Definition at line 628 of file lib.php.

Definition at line 627 of file lib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations