Function __global->cns_calculate_answer_voting_power

Definitions

sources/cns_polls_action2.php

  • Calculate how much voting power a particular poll answer has in total, and cache it (this also does the same for all votes).
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: float

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$answer_id AUTO_LINK No No required parameter N/A N/A The poll answer ID
$recalculate boolean No No False N/A N/A Recalculate even if a cached voting power already exists
$row ?array No No Null N/A N/A The database row for the poll answer if it was already queried elsewhere (null: query for it)

Returns

  • The total voting power for the specified poll answer
  • Type: float
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Calculate how much voting power a particular poll answer has in total, and cache it (this also does the same for all votes).
 *
 * @param  AUTO_LINK $answer_id The poll answer ID
 * @param  boolean $recalculate Recalculate even if a cached voting power already exists
 * @param  ?array $row The database row for the poll answer if it was already queried elsewhere (null: query for it)
 * @return float The total voting power for the specified poll answer
 */

function cns_calculate_answer_voting_power(int $answer_id, bool $recalculate = false, ?array $row = null) : float