Evaluates a specific form submission.
Description
This method is run whenever a submission is completed to update the aggregate calculations. Aggregate calculations are stored so that forms with a very high number of submissions do not need to be calculated live.
See also
Parameters
- $aggregate_results
-
(array) (Required) Aggregate results to update.
- $submission
-
(awsmug\Torro_Forms\DB_Objects\Submissions\Submission) (Required) Submission to evaluate.
- $form
-
(awsmug\Torro_Forms\DB_Objects\Forms\Form) (Required) Form the submission applies to.
Return
(array) Updated aggregate evaluation results.
Source
File: src/modules/evaluators/element-responses.php
public function evaluate_single( $aggregate_results, $submission, $form ) { foreach ( $submission->get_submission_values() as $submission_value ) { if ( ! $this->is_element_evaluatable( $submission_value->element_id ) ) { continue; } if ( ! isset( $aggregate_results[ $submission_value->element_id ] ) ) { $aggregate_results[ $submission_value->element_id ] = array(); } $field = ! empty( $submission_value->field ) ? $submission_value->field : '_main'; if ( ! isset( $aggregate_results[ $submission_value->element_id ][ $field ] ) ) { $aggregate_results[ $submission_value->element_id ][ $field ] = array(); } if ( ! isset( $aggregate_results[ $submission_value->element_id ][ $field ][ $submission_value->value ] ) ) { $aggregate_results[ $submission_value->element_id ][ $field ][ $submission_value->value ] = 1; } else { $aggregate_results[ $submission_value->element_id ][ $field ][ $submission_value->value ]++; } } return $aggregate_results; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |