- report generation first deploy
This commit is contained in:
parent
ada4c5c496
commit
13743a5681
@ -7,7 +7,7 @@ require_once "common_func.php";
|
||||
|
||||
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();
|
||||
$testMgr = new TestMgr();
|
||||
@ -133,9 +133,13 @@ class Report
|
||||
return $tex;
|
||||
}
|
||||
|
||||
// Save TeX representation
|
||||
function saveTeX(string $fileName) : void {
|
||||
file_put_contents($fileName, $this->genTeX()); // TODO: cím!!!
|
||||
const CONTENT_FILE = "content.tex";
|
||||
const TITLE_FILE = "title.tex";
|
||||
|
||||
// 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";
|
||||
|
||||
$longopts = [
|
||||
const longopts = [
|
||||
"action:", // execute some CLI action
|
||||
"tick" // tick timed objects (e.g. timed tests)
|
||||
];
|
||||
|
||||
$options = getopt("", $longopts);
|
||||
$options = getopt("", longopts);
|
||||
|
||||
// CLI actions
|
||||
if (isset($options["action"])) {
|
||||
|
@ -233,7 +233,8 @@ function access_test_data(string $testid): Test|null
|
||||
return $test;
|
||||
}
|
||||
|
||||
function exclude_correct_answers(array &$challenges) : void {
|
||||
function exclude_correct_answers(array &$challenges): void
|
||||
{
|
||||
foreach ($challenges as &$challenge) {
|
||||
$challenge["correct_answer"] = -1;
|
||||
}
|
||||
@ -518,8 +519,35 @@ function get_results_by_gameid(ReqHandler &$rh, array $params): array
|
||||
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
|
||||
@ -532,7 +560,8 @@ function generate_detailed_game_stats(ReqHandler &$rh, array $params): array
|
||||
return $stats;
|
||||
}
|
||||
|
||||
function delete_tests(ReqHandler &$rh, array $params): string {
|
||||
function delete_tests(ReqHandler &$rh, array $params): string
|
||||
{
|
||||
global $testMgr;
|
||||
$ids = explode_list(trim($params["ids"]));
|
||||
foreach ($ids as $id) {
|
||||
@ -695,21 +724,24 @@ function get_all_users(ReqHandler &$rh, array $params): array
|
||||
return $user_data_filtered;
|
||||
}
|
||||
|
||||
function get_user_groups(ReqHandler &$rh, array $params): array {
|
||||
function get_user_groups(ReqHandler &$rh, array $params): array
|
||||
{
|
||||
global $groupMgr;
|
||||
$groups = $groupMgr->getUserGroupIDs($params["nickname"]);
|
||||
$groupMgr->resolveGroupIds($groups);
|
||||
return $groups;
|
||||
}
|
||||
|
||||
function get_game_groups(ReqHandler &$rh, array $params): array {
|
||||
function get_game_groups(ReqHandler &$rh, array $params): array
|
||||
{
|
||||
global $groupMgr;
|
||||
$groups = $groupMgr->getGameGroupIDs($params["gameid"]);
|
||||
$groupMgr->resolveGroupIds($groups);
|
||||
return $groups;
|
||||
}
|
||||
|
||||
function change_group_members(ReqHandler &$rh, array $params): string {
|
||||
function change_group_members(ReqHandler &$rh, array $params): string
|
||||
{
|
||||
global $groupMgr;
|
||||
global $user;
|
||||
global $userMgr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user