rank: fix long running scoring error

This commit is contained in:
nemunaire 2018-12-06 21:28:06 +01:00
parent 7edd70c3c0
commit 74550f8907
2 changed files with 9 additions and 9 deletions

View File

@ -28,7 +28,7 @@
<h3>Coût des tentatives</h3> <h3>Coût des tentatives</h3>
<p> <p>
Vous disposez de 9&nbsp;tentatives pour trouver la/les solutions d'un Vous disposez de 10&nbsp;tentatives pour trouver la/les solutions d'un
challenge. Au delà, chaque tentative vous fait perdre une petite quantité challenge. Au delà, chaque tentative vous fait perdre une petite quantité
de points comme suit&nbsp;: de points comme suit&nbsp;:
</p> </p>
@ -41,23 +41,23 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>0 à 9</td> <td>0 à 10</td>
<td>0&nbsp;point</td> <td>0&nbsp;point</td>
</tr> </tr>
<tr> <tr>
<td>10 à 19</td> <td>11 à 20</td>
<td><ng-pluralize count="settings.submissionCostBase" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td> <td><ng-pluralize count="settings.submissionCostBase" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td>
</tr> </tr>
<tr> <tr>
<td>20 à 29</td> <td>21 à 30</td>
<td><ng-pluralize count="settings.submissionCostBase * 2" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td> <td><ng-pluralize count="settings.submissionCostBase * 2" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td>
</tr> </tr>
<tr> <tr>
<td>30 à 39</td> <td>31 à 40</td>
<td><ng-pluralize count="settings.submissionCostBase * 3" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td> <td><ng-pluralize count="settings.submissionCostBase * 3" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td>
</tr> </tr>
<tr> <tr>
<td>40 à 49</td> <td>41 à 50</td>
<td><ng-pluralize count="settings.submissionCostBase * 4" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td> <td><ng-pluralize count="settings.submissionCostBase * 4" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize></td>
</tr> </tr>
<tr> <tr>
@ -74,10 +74,10 @@
Par exemple&nbsp;: Par exemple&nbsp;:
</p> </p>
<ul> <ul>
<li>À&nbsp;10 tentatives, vous aurez perdu <ng-pluralize count="settings.submissionCostBase" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>.</li> <li>À&nbsp;10 tentatives, vous aurez perdu <ng-pluralize count="settings.submissionCostBase * 0" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>.</li>
<li>À&nbsp;15 tentatives, vous aurez perdu en tout <ng-pluralize count="settings.submissionCostBase * 5" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>&nbsp;: <samp>{{ settings.submissionCostBase }} * 5</samp>.</li> <li>À&nbsp;15 tentatives, vous aurez perdu en tout <ng-pluralize count="settings.submissionCostBase * 5" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>&nbsp;: <samp>{{ settings.submissionCostBase }} * 5</samp>.</li>
<li>25 tentatives vous coûteront en tout <ng-pluralize count="settings.submissionCostBase * 20" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>&nbsp;: <samp>{{ settings.submissionCostBase }} * 10 + {{ settings.submissionCostBase * 2}} * 5</samp>.</li> <li>25 tentatives vous coûteront en tout <ng-pluralize count="settings.submissionCostBase * 20" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>&nbsp;: <samp>{{ settings.submissionCostBase }} * 10 + {{ settings.submissionCostBase * 2}} * 5</samp>.</li>
<li>50 tentatives vous coûteront en tout <ng-pluralize count="settings.submissionCostBase * 105" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>&nbsp;: <samp>{{ settings.submissionCostBase }} * 10 + {{ settings.submissionCostBase * 2 }} * 10 + {{ settings.submissionCostBase * 3 }} * 10 + {{ settings.submissionCostBase * 4 }} * 10 + {{ settings.submissionCostBase * 5 }}</samp>.</li> <li>50 tentatives vous coûteront en tout <ng-pluralize count="settings.submissionCostBase * 100" when="{'one': '{}&nbsp;point', 'other': '{}&nbsp;points'}"></ng-pluralize>&nbsp;: <samp>{{ settings.submissionCostBase }} * 10 + {{ settings.submissionCostBase * 2 }} * 10 + {{ settings.submissionCostBase * 3 }} * 10 + {{ settings.submissionCostBase * 4 }} * 10</samp>.</li>
</ul> </ul>
<p> <p>
La dernière tentative (lorsque tous les flags sont bons) est comptabilisée La dernière tentative (lorsque tous les flags sont bons) est comptabilisée

View File

@ -13,7 +13,7 @@ var FirstBlood = 0.12
var SubmissionCostBase = 0.5 var SubmissionCostBase = 0.5
func exoptsQuery(whereExo string) string { func exoptsQuery(whereExo string) string {
return "SELECT S.id_team, S.time, E.gain AS points, coeff FROM (SELECT id_team, id_exercice, MIN(time) AS time, " + fmt.Sprintf("%f", FirstBlood) + " AS coeff FROM exercice_solved GROUP BY id_exercice UNION SELECT id_team, id_exercice, time, coefficient AS coeff FROM exercice_solved) S INNER JOIN exercices E ON S.id_exercice = E.id_exercice " + whereExo + " UNION ALL SELECT id_team, MAX(time) AS time, (FLOOR(COUNT(*)/10 - 1) * (FLOOR(COUNT(*)/10)))/0.2 + (FLOOR(COUNT(*)/10) * (COUNT(*)%10)) AS points, " + fmt.Sprintf("%f", SubmissionCostBase * -1) + " AS coeff FROM exercice_tries S " + whereExo + " GROUP BY id_exercice" return "SELECT S.id_team, S.time, E.gain AS points, coeff FROM (SELECT id_team, id_exercice, MIN(time) AS time, " + fmt.Sprintf("%f", FirstBlood) + " AS coeff FROM exercice_solved GROUP BY id_exercice UNION SELECT id_team, id_exercice, time, coefficient AS coeff FROM exercice_solved) S INNER JOIN exercices E ON S.id_exercice = E.id_exercice " + whereExo + " UNION ALL SELECT id_team, MAX(time) AS time, (FLOOR(COUNT(*)/10 - 1) * (FLOOR(COUNT(*)/10)))/0.2 + (FLOOR(COUNT(*)/10) * (COUNT(*)%10)) AS points, " + fmt.Sprintf("%f", SubmissionCostBase * -1) + " AS coeff FROM exercice_tries S " + whereExo + " GROUP BY id_exercice, id_team"
} }
func rankQuery(whereTeam string) string { func rankQuery(whereTeam string) string {