- report generation first deploy
This commit is contained in:
parent
ada4c5c496
commit
13743a5681
@ -7,7 +7,7 @@ require_once "common_func.php";
|
|||||||
|
|
||||||
class ReportBuilder
|
class ReportBuilder
|
||||||
{
|
{
|
||||||
static private function getStatsByFilters(int $gameid, string $filter, string $groups, string $ordering)
|
static public function getStatsByFilters(int $gameid, string $filter, string $groups, string $ordering)
|
||||||
{
|
{
|
||||||
$groupMgr = new GroupMgr();
|
$groupMgr = new GroupMgr();
|
||||||
$testMgr = new TestMgr();
|
$testMgr = new TestMgr();
|
||||||
@ -122,7 +122,7 @@ class Report
|
|||||||
{
|
{
|
||||||
$this->sections[] = $section;
|
$this->sections[] = $section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate TeX representation.
|
// Generate TeX representation.
|
||||||
function genTeX() :string
|
function genTeX() :string
|
||||||
{
|
{
|
||||||
@ -133,9 +133,13 @@ class Report
|
|||||||
return $tex;
|
return $tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save TeX representation
|
const CONTENT_FILE = "content.tex";
|
||||||
function saveTeX(string $fileName) : void {
|
const TITLE_FILE = "title.tex";
|
||||||
file_put_contents($fileName, $this->genTeX()); // TODO: cím!!!
|
|
||||||
|
// Save TeX representation.
|
||||||
|
function saveTeX(string $dir) : void {
|
||||||
|
file_put_contents($dir . DIRECTORY_SEPARATOR . self::CONTENT_FILE, $this->genTeX());
|
||||||
|
file_put_contents($dir . DIRECTORY_SEPARATOR . self::TITLE_FILE, $this->title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
require_once "class/TestMgr.php";
|
require_once "class/TestMgr.php";
|
||||||
|
|
||||||
$longopts = [
|
const longopts = [
|
||||||
"action:", // execute some CLI action
|
"action:", // execute some CLI action
|
||||||
"tick" // tick timed objects (e.g. timed tests)
|
"tick" // tick timed objects (e.g. timed tests)
|
||||||
];
|
];
|
||||||
|
|
||||||
$options = getopt("", $longopts);
|
$options = getopt("", longopts);
|
||||||
|
|
||||||
// CLI actions
|
// CLI actions
|
||||||
if (isset($options["action"])) {
|
if (isset($options["action"])) {
|
||||||
|
@ -233,7 +233,8 @@ function access_test_data(string $testid): Test|null
|
|||||||
return $test;
|
return $test;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exclude_correct_answers(array &$challenges) : void {
|
function exclude_correct_answers(array &$challenges): void
|
||||||
|
{
|
||||||
foreach ($challenges as &$challenge) {
|
foreach ($challenges as &$challenge) {
|
||||||
$challenge["correct_answer"] = -1;
|
$challenge["correct_answer"] = -1;
|
||||||
}
|
}
|
||||||
@ -518,8 +519,35 @@ function get_results_by_gameid(ReqHandler &$rh, array $params): array
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_report(ReqHandler &$rh, array $params): string {
|
function generate_report_by_groups(ReqHandler &$rh, array $params): string
|
||||||
|
{
|
||||||
|
global $gameMgr;
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$gameid = trim($params["gameid"]);
|
||||||
|
$filter = trim($params["filter"]);
|
||||||
|
$ordering = trim($params["orderby"]);
|
||||||
|
$groups = explode_list(trim($params["groups"])); // TODO: lehessen több csoportra is
|
||||||
|
|
||||||
|
$game = $gameMgr->getGame($gameid);
|
||||||
|
|
||||||
|
// verify game and access
|
||||||
|
if (($game === null) || (!$game->isUserContributorOrOwner($user->getNickname()) || $user->hasQuizmasterPrivilege())) {
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
|
||||||
|
// assemble report
|
||||||
|
$report = new Report($game->getName());
|
||||||
|
foreach ($groups as $groupname) {
|
||||||
|
$stats = ReportBuilder::getStatsByFilters($gameid, $filter, $groupname, $ordering);
|
||||||
|
$section = new ReportSection($groupname, $stats);
|
||||||
|
$report->addSection($section);
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate latex
|
||||||
|
$report->saveTeX("report/");
|
||||||
|
|
||||||
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_detailed_game_stats(ReqHandler &$rh, array $params): array
|
function generate_detailed_game_stats(ReqHandler &$rh, array $params): array
|
||||||
@ -532,7 +560,8 @@ function generate_detailed_game_stats(ReqHandler &$rh, array $params): array
|
|||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_tests(ReqHandler &$rh, array $params): string {
|
function delete_tests(ReqHandler &$rh, array $params): string
|
||||||
|
{
|
||||||
global $testMgr;
|
global $testMgr;
|
||||||
$ids = explode_list(trim($params["ids"]));
|
$ids = explode_list(trim($params["ids"]));
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
@ -695,21 +724,24 @@ function get_all_users(ReqHandler &$rh, array $params): array
|
|||||||
return $user_data_filtered;
|
return $user_data_filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_user_groups(ReqHandler &$rh, array $params): array {
|
function get_user_groups(ReqHandler &$rh, array $params): array
|
||||||
|
{
|
||||||
global $groupMgr;
|
global $groupMgr;
|
||||||
$groups = $groupMgr->getUserGroupIDs($params["nickname"]);
|
$groups = $groupMgr->getUserGroupIDs($params["nickname"]);
|
||||||
$groupMgr->resolveGroupIds($groups);
|
$groupMgr->resolveGroupIds($groups);
|
||||||
return $groups;
|
return $groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_game_groups(ReqHandler &$rh, array $params): array {
|
function get_game_groups(ReqHandler &$rh, array $params): array
|
||||||
|
{
|
||||||
global $groupMgr;
|
global $groupMgr;
|
||||||
$groups = $groupMgr->getGameGroupIDs($params["gameid"]);
|
$groups = $groupMgr->getGameGroupIDs($params["gameid"]);
|
||||||
$groupMgr->resolveGroupIds($groups);
|
$groupMgr->resolveGroupIds($groups);
|
||||||
return $groups;
|
return $groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_group_members(ReqHandler &$rh, array $params): string {
|
function change_group_members(ReqHandler &$rh, array $params): string
|
||||||
|
{
|
||||||
global $groupMgr;
|
global $groupMgr;
|
||||||
global $user;
|
global $user;
|
||||||
global $userMgr;
|
global $userMgr;
|
||||||
@ -742,7 +774,7 @@ $rh->add("update_group", ["groupname", "description", "owner", "editors", "id"],
|
|||||||
$rh->add("delete_groups", ["ids"], PRIVILEGE_QUIZMASTER, "delete_groups", RESP_PLAIN, "Delete group.");
|
$rh->add("delete_groups", ["ids"], PRIVILEGE_QUIZMASTER, "delete_groups", RESP_PLAIN, "Delete group.");
|
||||||
$rh->add("get_all_groups", [], PRIVILEGE_QUIZMASTER, "get_all_groups", RESP_JSON, "Get all player groups.");
|
$rh->add("get_all_groups", [], PRIVILEGE_QUIZMASTER, "get_all_groups", RESP_JSON, "Get all player groups.");
|
||||||
$rh->add("search_groups", ["needle"], PRIVILEGE_QUIZMASTER, "search_groups", RESP_JSON, "Serach and fetch player groups.");
|
$rh->add("search_groups", ["needle"], PRIVILEGE_QUIZMASTER, "search_groups", RESP_JSON, "Serach and fetch player groups.");
|
||||||
$rh->add("change_group_members", ["groupid", "add", "remove"], PRIVILEGE_QUIZMASTER,"change_group_members", RESP_PLAIN, "Change group members.");
|
$rh->add("change_group_members", ["groupid", "add", "remove"], PRIVILEGE_QUIZMASTER, "change_group_members", RESP_PLAIN, "Change group members.");
|
||||||
|
|
||||||
$rh->add(["create_user", "update_user"], ["nickname", "password", "realname", "privilege"], PRIVILEGE_QUIZMASTER, "create_update_user", RESP_PLAIN, "Create or update user.");
|
$rh->add(["create_user", "update_user"], ["nickname", "password", "realname", "privilege"], PRIVILEGE_QUIZMASTER, "create_update_user", RESP_PLAIN, "Create or update user.");
|
||||||
$rh->add("delete_users", ["users"], PRIVILEGE_QUIZMASTER, "delete_users", RESP_PLAIN, "Delete users.");
|
$rh->add("delete_users", ["users"], PRIVILEGE_QUIZMASTER, "delete_users", RESP_PLAIN, "Delete users.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user