summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/api.php10
-rw-r--r--http/pkle2018-test.php8
2 files changed, 9 insertions, 9 deletions
diff --git a/http/api.php b/http/api.php
index e83420b..a3f155d 100644
--- a/http/api.php
+++ b/http/api.php
@@ -11,7 +11,7 @@ Parametry:
- ręczna waga (opcjonalny)
- ręczny współczynnik zawodniczy (opcjonalny)
- ręczne progi (opcjonalne)
-
+
{
"type": 2,
"contestants": 20,
@@ -73,7 +73,7 @@ function check_parameters($parameters) {
if (isset($parameters['players'])) {
check_values($parameters, array(
'players' => function($r) { return ctype_digit($r) && intval($r) > 0; }
- ));
+ ));
}
if (!isset($parameters['manual']) || !isset($parameters['manual']['min_points']) || !isset($parameters['manual']['tournament_weight'])) {
ensure_parameters($parameters, array('tournament_rank', 'over39_boards'));
@@ -174,12 +174,12 @@ function calculate_points($parameters) {
(1 + 0.25 * ($parameters['type'] > 2)) * (max(0.15, $parameters['title_sum'] / $parameters['players']) * $parameters['tournament_weight'] + $parameters['players_coefficient'] * $parameters['contestants'] * $parameters['type'])
));
$min_points = 1;
- $result = array("sum" => 0);
+ $result = array("sum" => 0, "points" => array());
for ($place = 1; $place <= $parameters['contestants']; $place++) {
$percentage = get_percentage_from_position($place, $parameters['contestants'], $parameters['points_cutoffs']);
$points = safe_ceil(floatval($max_points) * $percentage);
- $result[$place] = max($min_points, intval($points));
- $result['sum'] += $parameters['type'] * $result[$place];
+ $result['points'][$place] = max($min_points, intval($points));
+ $result['sum'] += $parameters['type'] * $result['points'][$place];
}
return $result;
}
diff --git a/http/pkle2018-test.php b/http/pkle2018-test.php
index 3826d3a..9b056c1 100644
--- a/http/pkle2018-test.php
+++ b/http/pkle2018-test.php
@@ -68,11 +68,11 @@ function display() {
var sqlTeamy = ['UPDATE `addons` SET `mastr` = 0;'];
var pklHTML = ['<tr><td class="t">Miejsce</td><td class="t">&nbsp;&nbsp;&nbsp;PKL&nbsp;&nbsp;&nbsp;</td></tr>'];
for (var place = 1; place <= parseInt(document.getElementsByName('iuc')[0].value); place++) {
- sqlPary.push('UPDATE `dodatki` SET `pkl` = ' + response[place] + ' WHERE `miejsce` = ' + place + ';');
- sqlTeamy.push('UPDATE `addons` SET `mastr` = ' + response[place] + ' WHERE `place` = ' + place + ';');
- pklHTML.push('<tr><td class="t">' + place + '</td><td class="t">' + response[place] + '</td></tr>');
+ sqlPary.push('UPDATE `dodatki` SET `pkl` = ' + response.points[place] + ' WHERE `miejsce` = ' + place + ';');
+ sqlTeamy.push('UPDATE `addons` SET `mastr` = ' + response.points[place] + ' WHERE `place` = ' + place + ';');
+ pklHTML.push('<tr><td class="t">' + place + '</td><td class="t">' + response.points[place] + '</td></tr>');
}
- pklHTML.push('<tr><td class="p">SUMA PKL</td><td class="t">' + response['sum'] + '</td></tr>');
+ pklHTML.push('<tr><td class="p">SUMA PKL</td><td class="t">' + response.sum + '</td></tr>');
document.getElementById('outsql').innerHTML = sqlPary.join("\n");
document.getElementById('outsql2').innerHTML = sqlTeamy.join("\n");
document.getElementById("pkltable").innerHTML = pklHTML.join("");