# HG changeset patch # User viric@mandarina # Date 1230505948 0 # Node ID 971cc599446719d7b70744c9d80ef2b48af44697 # Parent c7ff1a59ed84d293920a8a3801f2f9e68d0a936c Fixing the calculation of values. diff -r c7ff1a59ed84 -r 971cc5994467 config/config.php --- a/config/config.php Sun Dec 28 21:15:17 2008 +0000 +++ b/config/config.php Sun Dec 28 23:12:28 2008 +0000 @@ -11,7 +11,7 @@ | http://example.com/ | */ -$config['base_url'] = "http://mandarina/~viric/ci/"; +$config['base_url'] = "/~viric/ci/"; /* |-------------------------------------------------------------------------- diff -r c7ff1a59ed84 -r 971cc5994467 models/opiniarbo_model.php --- a/models/opiniarbo_model.php Sun Dec 28 21:15:17 2008 +0000 +++ b/models/opiniarbo_model.php Sun Dec 28 23:12:28 2008 +0000 @@ -249,27 +249,31 @@ $this->db->select('asertoj.id,values.id as vid,values.value,values.influence'); $this->db->from('values'); $this->db->join('asertoj','values.assertion = asertoj.id'); + $this->db->where('values.user', $user); $this->db->where('asertoj.parent',$parent); - $this->db->where('values.user', $user); $query = $this->db->get(); $val = NULL; - if ($parent != NULL) + if ($query->num_rows() > 0) { - if ($query->num_rows() > 0) - { - $qresult = $query->result_array(); + $qresult = $query->result_array(); - $sum_influence = 0; + $sum_influence = 0.; - foreach($qresult as $row) - { - $sum_influence += abs($row['influence']); - } + foreach($qresult as $row) + { + $sum_influence += abs($row['influence']); + } - // Calculate the calc_value - $val = 0; - foreach($qresult as $row) + // Calculate the calc_value + $val = 0; + + foreach($qresult as $row) + { + // for $parent == NULL we only need the recursive call. + // the $row['influence'] will have no meaning in a head assertion, + // so we avoid the division_by_zero error writting a special case. + if ($parent != NULL) { if ($row['influence'] >= 0) $val += $row['influence'] * $this->get_user_calc_value($user, @@ -278,8 +282,13 @@ $val += $row['influence'] * ($this->get_user_calc_value($user, $row['id'], $row['value']) - 1) / $sum_influence; } + else + $this->get_user_calc_value($user, $row['id'], $row['value']); } + } + if ($parent != NULL) + { // Set the NULL calc_value to those without subassertions, // and the proper value to those with subassertions. $query2 = $this->db->where('assertion', $parent); diff -r c7ff1a59ed84 -r 971cc5994467 views/context.php --- a/views/context.php Sun Dec 28 21:15:17 2008 +0000 +++ b/views/context.php Sun Dec 28 23:12:28 2008 +0000 @@ -1,2 +1,2 @@

-
+