Collection of themes/skins for the Fossil SCM

⌈⌋ ⎇ branch:  Fossil Skins Extra


Artifact [c6238f4a12]

Artifact c6238f4a1213d9d6fadaa29b562a5e9d16a5cfad:

  • Executable file extroot/survey_sum — part of check-in [7573908dd3] at 2021-10-24 06:20:10 on branch trunk — standardize PMD type: further (user: mario size: 1459)

#!/usr/bin/php-cgi -dcgi.force_redirect=0
<?php
# encoding: utf-8
# api: cgi
# type: output
# category: database
# title: Survey summarize
# description: Only collects numeric entries for approximate stats
# version: 0.2
# state: alpha
# config: -
# access: public
#
# Requires a link like  "/ext/survey_sum/SAMPLE",
# and counts the numeric fields (checkboxes yes/no).
# It's just meant for a quick result list, and
# outputs approximate points 🞓


include("./fossil_common.php");


#-- insert
function show($tbl) {
    $r = [];
    foreach (db("SELECT fields FROM `survey_$tbl`") as $j) {
        if ($j = json_decode($j["fields"])) {
            foreach ($j as $k=>$v) {
                if (is_numeric($v)) {
                     @$r[$k] += $v;
                }
            }
        }
    }
ini_set("display_errors", 1);
    if ($r) {
         print("| question | score |\n|-------|-------|\n");
         $max = max($r) + 1;
         foreach ($r as $k=>$v) {
             $k = htmlspecialchars($k, ENT_QUOTES); # though already MD
             $n = ($v / $max) * 20.1;
             $n = str_repeat("🞓", (int)$n);
             print("| $k | $n |\n");
         }
    }
}

#-- run
if ($tbl = preg_replace("/\W+/", "", basename($_SERVER["PATH_INFO"]))) {
    header("Content-Type: text/x-markdown");
    print("\n##### survey $tbl\n##### Survey '*$tbl*' (approx. results)\n\n");
    show($tbl);
}
else {
    die("No table name given /survey/NAME");
}