Evidence::getDiag PHP Method

getDiag() public method

public getDiag ( $this_evidence, $active_project )
    public function getDiag($this_evidence, $active_project)
    {
        // Get the diagnosticity. Both variables are objects.
        global $active_user;
        $total_diag = 0;
        for ($j = 0; $j < count($active_project->hypotheses); $j++) {
            $this_hypothesis = new Hypothesis();
            $this_hypothesis->populateFromId($active_project->hypotheses[$j]);
            $results = mysql_fast("SELECT * FROM ratings WHERE evidence_id='{$this_evidence->id}' AND hypothesis_id='{$this_hypothesis->id}' AND user_id='{$active_user->id}'");
            for ($i = 0; $i < count($results); $i++) {
                $total_diag += getHypoRatingScore($results[$i]['rating']);
            }
        }
        return $total_diag * -1;
        //multiple by -1 so that most diagnostic evidence appears at top upon sort
    }

Usage Example

 public function getDiags()
 {
     // Load up diags for the evidence array.
     for ($i = 0; $i < count($this->evidence); $i++) {
         $this_evidence = new Evidence();
         $this_evidence->populateFromId($this->evidence[$i]);
         $this_evidence->diag = Evidence::getDiag($this_evidence, $this);
         //$this_evidence->update();
     }
 }