Participation::evaluate_single( array $aggregate_results, awsmug\Torro_Forms\DB_Objects\Submissions\Submission $submission, awsmug\Torro_Forms\DB_Objects\Forms\Form $form )

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/participation.php

	public function evaluate_single( $aggregate_results, $submission, $form ) {
		if ( ! isset( $aggregate_results['total'] ) ) {
			$aggregate_results['total'] = 1;
		} else {
			$aggregate_results['total']++;
		}

		$year  = (string) $submission->format_datetime( 'Y' );
		$month = (string) $submission->format_datetime( 'm' );

		if ( ! isset( $aggregate_results[ $year ] ) ) {
			$aggregate_results[ $year ] = array();
		}

		if ( ! isset( $aggregate_results[ $year ]['total'] ) ) {
			$aggregate_results[ $year ]['total'] = 1;
		} else {
			$aggregate_results[ $year ]['total']++;
		}

		if ( ! isset( $aggregate_results[ $year ][ $month ] ) ) {
			$aggregate_results[ $year ][ $month ] = 1;
		} else {
			$aggregate_results[ $year ][ $month ]++;
		}

		return $aggregate_results;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.