Mercurial > hg > fapweb
changeset 695:dff9b125f774
Work on results printing and remove "show authors" option as it is rather
useless.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 10 Nov 2014 17:22:12 +0200 |
parents | b4e0501f5588 |
children | cd7ecb33cf75 |
files | dbdefs.inc.php msite.inc.php pages/results.inc.php |
diffstat | 3 files changed, 62 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/dbdefs.inc.php Mon Nov 10 16:56:55 2014 +0200 +++ b/dbdefs.inc.php Mon Nov 10 17:22:12 2014 +0200 @@ -32,7 +32,6 @@ "allowVoting" => array(VT_BOOL, false, "Enable voting (individual compos must be enabled as well)"), "showResults" => array(VT_BOOL, false, "Enable results page"), - "showResAuthors" => array(VT_BOOL, true, "Show entry authors on results page"), "showInfoTextOnAbout" => array(VT_BOOL, false, "Show site info HTML on About page"), @@ -239,6 +238,8 @@ array("visible" , "INT", "DEFAULT 0"), array("voting" , "INT", "DEFAULT 0"), array("show_authors" , "INT", "DEFAULT 0"), + // Show author(s) on compo main screen/voting page for COMPO_NORMAL compos + // For COMPO_POINTS and COMPO_ASSIGN, show on results page or not array("ctype" , "INT", "DEFAULT 0"), array("cpath" , "VARCHAR(".SET_LEN_COMPO_PATH.")"), ),
--- a/msite.inc.php Mon Nov 10 16:56:55 2014 +0200 +++ b/msite.inc.php Mon Nov 10 17:22:12 2014 +0200 @@ -487,13 +487,20 @@ break; case COMPO_POINTS: - case COMPO_ASSIGN: // - // These essentially do the same ... + // Points .. // $sql = "SELECT entries.* FROM entries"; $extra = "ORDER BY entries.evalue DESC"; break; + + case COMPO_ASSIGN: + // + // Ascending + // + $sql = "SELECT entries.* FROM entries"; + $extra = "ORDER BY entries.evalue ASC"; + break; } return $sql." ". @@ -503,7 +510,24 @@ } -function stGetCompoResultsASCIIStr($showAuthors, $html) +function stGetCompoResultLine($html, $entry, $points, $showAuthor) +{ + $name = stStrChopPad($entry["name"], 30); + $author = stStrChopPad($entry["author"], 30); + + $out = sprintf(" %s", $html ? chentities($name) : $name); + + if ($showAuthor) + $out .= sprintf(" by %s", $html ? chentities($author) : $author); + + if ($points != FALSE) + $out .= sprintf(" (%d pts)", $points); + + return $out."\n"; +} + + +function stGetCompoResultsASCIIStr($html) { $sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC"; if (($res = stExecSQL($sql)) === false) @@ -546,23 +570,40 @@ foreach (stExecSQL($sql) as $entry) { - if ($entry["votesum"] !== $prev) + + switch ($compo["ctype"]) { - $index++; - $out .= sprintf("%3d%s.", $index, stGetNumberSuffix($index)); - } - else - $out .= " -''-"; + case COMPO_NORMAL: + if ($entry["votesum"] !== $prev) + { + $index++; + $out .= sprintf("%3d%s.", $index, stGetNumberSuffix($index)); + } + else + $out .= " -''-"; + + $out .= stGetCompoResultLine($html, $entry, $entry["votesum"], TRUE); - $name = stStrChopPad($entry["name"], 30); - $author = stStrChopPad($showAuthors ? $entry["author"] : "-", 30); - - $out .= sprintf(" %s by %s (%d pts)\n", - $html ? chentities($name) : $name, - $html ? chentities($author) : $author, - $entry["votesum"]); + $prev = $entry["votesum"]; + break; + + case COMPO_POINTS: + case COMPO_ASSIGN: + if ($entry["evalue"] !== $prev) + { + $index++; + $out .= sprintf("%3d%s.", $index, stGetNumberSuffix($index)); + } + else + $out .= " -''-"; - $prev = $entry["votesum"]; + $out .= stGetCompoResultLine($html, $entry, + ($compo["ctype"] == COMPO_POINTS) ? $entry["votesum"] : FALSE, + $compo["show_authors"]); + + $prev = $entry["evalue"]; + break; + } } $out .= "\n\n".($html ? "</pre>\n" : ""); }
--- a/pages/results.inc.php Mon Nov 10 16:56:55 2014 +0200 +++ b/pages/results.inc.php Mon Nov 10 17:22:12 2014 +0200 @@ -5,8 +5,6 @@ // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) // $showResults = stGetSetting("showResults"); -$showAuthors = stGetSetting("showResAuthors"); - echo "<h1>Results</h1>\n"; @@ -15,15 +13,13 @@ { if (!$showResults) echo "<p class=\"notice\">Results hidden from normal users.</p>"; - if (!$showAuthors) - echo "<p class=\"notice\">Entry authors hidden from normal users.</p>"; - $showResults = $showAuthors = TRUE; + $showResults = TRUE; } if ($showResults) - echo stGetCompoResultsASCIIStr($showAuthors, TRUE); + echo stGetCompoResultsASCIIStr(TRUE); else { echo "<p>Sorry, no results available! Nothing to see here, move along.</p>";