• Resolved salgas

    (@salgas)


    Hi.

    I managed to put the calculations to work has I need however i found this “issue”.

    The ranking table

    USER PREDICTIONS FULL TOTO GOAL BONUS QUESTIONS POINTS
    P1 6 8 0 4 0 8

    Goal Bonus appearing wrongly and the total points are correct.

    Can you please point me what i am doing wrong?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author AntoineH

    (@antoineh)

    Based on only this information it’s a bit hard to tell what the issue is. What is “appearing wrongly”? The number, the position, something else?

    Thread Starter salgas

    (@salgas)

    Plugin Author AntoineH

    (@antoineh)

    What is the template code that you use for the ranking row? e.g.

    $ranking_template = '<tr class="%css_class%">
    	<td class="user-rank">%rank%.</td>
    	<td class="user-name"><a href="%user_link%">%user_avatar%%user_name%</a></td>
    	<td class="num-predictions">%num_predictions%</td>
    	<td class="score-breakdown full">%breakdown_full_points%</td>
    	<td class="score-breakdown toto">%breakdown_toto_points%</td>
    	<td class="score-breakdown goalbonus">%breakdown_goalbonus_points%</td>
    	<td class="score-breakdown question">%breakdown_question_points%</td>
    	<td class="user-score ranking score">%points%</td>
    	</tr>';

    What settings do you use for the points? e.g.

    full: 2
    toto: 1
    goal bonus: 1
    goal diff: 0

    Thread Starter salgas

    (@salgas)

    the template is the one you post.

    And the settings are
    full: 8
    toto: 5
    goal bonus: 2 (only if user guess one of the goals eg. P1 guess 2-1 and the match ends 2-2 so the player is awarded only 2 points because he guessed the home goals)
    goal diff: 0

    Plugin Author AntoineH

    (@antoineh)

    I did a test myself with the same settings and it shows the correct values for all columns. So my guess is that you’ve changed the calc_score function and made a small mistake there.

    The calc_score function not only updates the points awarded, but also the individual values. In your case you need to check the $goal_bonus var.

    Thread Starter salgas

    (@salgas)

    Hi @antoineh

    what i have to calculate the goal bonus is

    // check for goal bonus
    if ( ($score[‘full’] === 0 and $score[‘toto’] === 0) and $score_vars[‘home’] == $score_vars[‘user_home’] ) {
    $score[‘score’] += $score_vars[‘goal’];
    }
    else
    if ( ($score[‘full’] === 0 and $score[‘toto’] === 0) and $score_vars[‘away’] == $score_vars[‘user_away’] ) {
    $score[‘score’] += $score_vars[‘goal’];
    }`

    Plugin Author AntoineH

    (@antoineh)

    The $score array also holds the amount of different scores per ‘category’, so you need to count if there is a goal bonus, not only increase the total score.

    I’m guessing now, because I do not have the full view of your modifications, but I think it needs to be something like this:

    // check for goal bonus
    if ( ($score['full'] === 0 and $score['toto'] === 0) and $score_vars['home'] == $score_vars['user_home'] ) {
    	$score['score'] += $score_vars['goal'];
    	$score['goal_bonus'] = 1;
    }
    else
    	if ( ($score['full'] === 0 and $score['toto'] === 0) and $score_vars['away'] == $score_vars['user_away'] ) {
    		$score['score'] += $score_vars['goal'];
    		$score['goal_bonus'] = 1;
    	}
Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Ranking Table showing wrong values’ is closed to new replies.