Compare commits

...

15 Commits

Author SHA1 Message Date
e2140d8dee - Image patch through Content-Type adjusting added 2024-10-09 21:04:56 +02:00
821f31cd10 - Displaying number of records in result analyzer added 2024-10-08 19:35:19 +02:00
b820afabec - Group game and member management merged into the same function 2024-10-07 21:00:10 +02:00
139c3aa38d - Game to group assignments management added
- Printing of group and game IDs added
- some bugfixes
2024-10-07 20:47:27 +02:00
f3ae982c9c Game genPublicId() namespace fixed 2024-10-07 20:00:45 +02:00
3fda9c8c0a - LaTeX datetime fix 2024-10-01 16:56:57 +02:00
dfd637bdfb - LaTeX datetime fix 2024-10-01 16:47:10 +02:00
b1c1509f9f - Generation time added to LaTeX 2024-10-01 16:45:01 +02:00
8e145df855 - LaTeX comment page bugs fixed 2024-10-01 16:38:55 +02:00
77cf3f267a - pick only best results fixed 2024-10-01 16:33:11 +02:00
5011bd956b - warning text fixed 2024-10-01 16:26:33 +02:00
2e89b7c0d2 - whole report query URL added as comment
- warning page right before comments added
2024-10-01 16:25:35 +02:00
79e2430fb6 - report query params added to LaTeX as a comment 2024-10-01 16:19:42 +02:00
9e209df51f - report filter URI encoding fixed 2024-10-01 16:03:38 +02:00
144c62f9ad - LaTeX template improved: submission count, challenge fill and skip counts added
- "List best results only" option added to each report generation functionality
2024-10-01 15:55:30 +02:00
14 changed files with 358 additions and 129 deletions

View File

@ -31,7 +31,7 @@ class Game extends AutoStoring
// -------
static private function genPublicId(): string
static public function genPublicId(): string
{
return uniqid("p");
}
@ -386,7 +386,7 @@ class GameMgr
"game_file_present" => false,
"properties" => $properties,
"public" => false,
"public_id" => self::genPublicId(),
"public_id" => Game::genPublicId(),
"version" => Game::CURRENT_GAME_VERSION
];
@ -430,5 +430,34 @@ class GameMgr
return $games;
}
// Sanitize games and return game IDs.
function sanitizeGames(array $games) : array {
$sanitized = [];
foreach ($games as $game) {
// explode game identifier
[$name, $id] = explode("#", $game);
// fetch game
if ($id !== null) {
$records = $this->db->findBy([["name", "=", $name], "AND", ["_id", "=", (int)$id]]);
} else {
$records = $this->db->findBy(["name", "=", $name]);
}
// put game ID into sanitized list only if identifier is not ambiguous
if (count($records) === 1) {
$sanitized[] = $records[0]["_id"];
}
}
return $sanitized;
}
// Resolve group IDs to full group identifiers.
function resolveGames(array &$gameIds): void {
$a = $this->db->findBy([["_id", "IN", $gameIds]]); // no caching here...
$gameIds = array_map(fn($r) => $r["name"] . "#" . $r["_id"] ,$a);
}
// -------
}

View File

@ -192,7 +192,7 @@ class Group extends AutoStoring
alter_array_contents($this->games, $gameid, null);
}
foreach ($gameids_remove as $gameid) { // remove games
alter_array_contents($this->members, null, $gameid);
alter_array_contents($this->games, null, $gameid);
}
$this->storeMods(); // store changes

View File

@ -7,7 +7,7 @@ require_once "common_func.php";
class ReportBuilder
{
static public function getStatsByFilters(int $gameid, string $filter, string $groups, string $ordering)
static public function getStatsByFilters(int $gameid, string $filter, string $groups, bool $bestOnly)
{
$groupMgr = new GroupMgr();
$testMgr = new TestMgr();
@ -18,7 +18,7 @@ class ReportBuilder
$groupFilter = ["nickname", "IN", $nicknames];
// get IDs
$tests = $testMgr->getResultsByGameId($gameid, $filter, $ordering, true, $groupFilter);
$tests = $testMgr->getResultsByGameId($gameid, $filter, "", true, $bestOnly, $groupFilter);
$ids = array_map(fn($test) => $test["_id"], $tests);
// generate stats
@ -71,12 +71,25 @@ class Answer
{
return "\\answer" . $this->type . "{" . $this->ratio . "}{" . $this->text . "}\n";
}
// Get answer ratio.
public function getRatio(): float
{
return $this->ratio;
}
}
class Challenge
{
private string $question;
private array $answers;
private int $fillCount;
private int $skipCount;
// Sort answers by ratio.
private function sortAnswers() : void {
usort($this->answers, function($a, $b) {return $a->getRatio() < $b->getRatio();});
}
function __construct(array $data)
{
@ -87,6 +100,10 @@ class Challenge
$type = $answer === $data["correct_answer"] ? Answer::CORRECT : Answer::INCORRECT;
$this->answers[] = new Answer($type, $answer, $ratio);
}
$this->fillCount = array_sum($data["player_answers"]); // get fill count
$this->skipCount = $data["skipped"];
$this->sortAnswers(); // sort answers by fill ratio
}
public function getQuestion(): string
@ -99,10 +116,22 @@ class Challenge
return $this->answers;
}
public function getFillCount(): int {
return $this->fillCount;
}
public function getSkipCount(): int {
return $this->skipCount;
}
public function getSubmissionCount() : int {
return $this->fillCount + $this->skipCount;
}
// Generate TeX representation.
public function genTeX(): string
{
$tex = "\\begin{question}{" . $this->question . "}\n";
$tex = "\\begin{question}{" . $this->question . "}{" . $this->fillCount . "}\n";
foreach ($this->answers as &$answer) {
$tex .= $answer->genTeX();
}
@ -116,6 +145,10 @@ class ReportSection
private string $title;
private array $challenges;
private function getNumberOfSubmissions() : int {
return count($this->challenges) > 0 ? $this->challenges[0]->getSubmissionCount() : 0;
}
function __construct(string $title, array $challenges)
{
$this->title = $title;
@ -135,7 +168,7 @@ class ReportSection
// Generate TeX representation of this report.
function genTeX(): string
{
$tex = "\\begin{quiz}{" . $this->title . "}\n";
$tex = "\\begin{quiz}{" . $this->title . "}{" . $this->getNumberOfSubmissions() . "}\n";
foreach ($this->challenges as $challenge) {
$tex .= $challenge->genTeX();
}
@ -148,11 +181,13 @@ class Report
{
private string $title;
private array $sections;
private array $comments;
function __construct(string $title)
{
$this->title = $title;
$this->sections = [];
$this->comments = [];
}
@ -162,13 +197,28 @@ class Report
$this->sections[] = $section;
}
function addComment(string $comment): void
{
$this->comments[] = $comment;
}
// Generate TeX representation.
function genTeX(): string
{
$tex = "";
// generate content
foreach ($this->sections as $section) {
$tex .= $section->genTeX() . "\n\n";
}
// add comments if any
if ($this->comments != []) {
$tex .= "\\huge\\noindent A következő oldal érzékeny információkat tartalmazhat!\\newline Nem publikálandó!\n\\clearpage\n\n";
$tex .= "\\clearpage\n\small\n\\noindent ";
$tex .= join("\\\\\n", $this->comments);
}
// escape LaTeX control characters
$tex = TeXUtils::processCodeInserts($tex);
$tex = TeXUtils::escape($tex);
return $tex;

View File

@ -406,7 +406,7 @@ class TestMgr
}
// Get test results by game ID.
function getResultsByGameId(string $gameid, string $filter, string $orderby, bool $exclude_challenge_data, array ...$furtherFilters): array
function getResultsByGameId(string $gameid, string $filter, string $orderby, bool $exclude_challenge_data, bool $best_ones_only, array ...$furtherFilters): array
{
$qb = $this->db->createQueryBuilder();
$qb = $qb->where(["gameid", "=", (int)$gameid]);
@ -448,6 +448,34 @@ class TestMgr
}
$test_data_array = $qb->getQuery()->fetch();
// if only the best results should be included, then...
if ($best_ones_only) {
// filter out ongoing ones
$tests = array_filter($test_data_array, fn($test) => $test["state"] === Test::TEST_CONCLUDED);
// sort by result
usort($tests, fn($a, $b) => $a["summary"]["percentage"] > $b["summary"]["percentage"]);
// gather best tests by username here
$best_test_ids = [];
foreach ($tests as $test) {
$nickname = $test["nickname"];
if (!in_array($nickname, $best_test_ids)) {
$best_test_ids[$nickname] = $test["_id"];
}
}
// just keep values, drop the keys (nicknames)
$best_test_ids = array_values($best_test_ids);
// remove non-best results
$test_data_array = array_filter($test_data_array, fn($test) => in_array($test["_id"], $best_test_ids));
// renumber results
$test_data_array = array_values($test_data_array);
}
return $test_data_array;
}
@ -487,6 +515,7 @@ class TestMgr
"correct_answer" => $correct_answer,
"player_answers" => array_fill(0, count($challenge["answers"]), 0),
"answer_count" => count($challenge["answers"]),
"skipped" => 0
];
$aggregated[$challenge_indices[$idhash]] = $challenge_info; // insert challenge info
}
@ -495,9 +524,12 @@ class TestMgr
$challenge_idx = $challenge_indices[$idhash];
// add up player answer
if (trim($challenge["player_answer"]) !== "") {
$player_answer = trim($challenge["player_answer"]);
if (($player_answer !== "") && ($player_answer != -1)) { // player answered
$answer_idx = array_search($challenge["answers"][$challenge["player_answer"]], $aggregated[$challenge_idx]["answers"]); // transform player answer index to report answer index
$aggregated[$challenge_idx]["player_answers"][(int)$answer_idx]++;
} else { // player has not answered or provided an unprocessable answer
$aggregated[$challenge_idx]["skipped"]++;
}
}
}

View File

@ -3,6 +3,7 @@
"rakibtg/sleekdb": "2.15",
"ext-http": "*",
"ext-mbstring" : "*",
"ext-zip": "*"
"ext-zip": "*",
"ext-fileinfo": "*"
}
}

View File

@ -146,7 +146,10 @@ if (!get_autologin_state() || (($user_data["privilege"] !== PRIVILEGE_CREATOR) &
<select id="report_output_type">
<option value="pdf">PDF</option>
<option value="tex">TeX</option>
</select>
</select><br>
<input type="checkbox" id="best_only"><label for="best_only" style="font-size: 12px">Csak legjobb eredmények felhasználónként</label>
<br>
<br>
<input type="button" value="Előállítás" onclick="generate_game_report_by_groups()">
<input type="button" value="Bezárás" onclick="hide('report_generator')">
</section>

View File

@ -67,13 +67,23 @@ if (!get_autologin_state() || ($user_data["privilege"] !== PRIVILEGE_QUIZMASTER)
<tr>
<td>
<label for="group_members">Tagok:</label><br>
<input type="button" value="+" onclick="open_member_change_window('add')">
<input type="button" value="-" onclick="open_member_change_window('remove')">
<input type="button" value="+" onclick="open_element_change_window('add', 'member')">
<input type="button" value="-" onclick="open_element_change_window('remove', 'member')">
</td>
<td>
<textarea id="group_members" readonly></textarea>
</td>
</tr>
<tr>
<td>
<label for="group_games">Játékok:</label><br>
<input type="button" value="+" onclick="open_element_change_window('add', 'game')">
<input type="button" value="-" onclick="open_element_change_window('remove', 'game')">
</td>
<td>
<textarea id="group_games" readonly></textarea>
</td>
</tr>
</table>
<section style="display: block; text-align: right">
<input type="button" value="" id="group_editor_submit_btn">
@ -82,13 +92,13 @@ if (!get_autologin_state() || ($user_data["privilege"] !== PRIVILEGE_QUIZMASTER)
</section>
</section>
<section class="window" shown="false" id="member_manager_window">
<section class="window" shown="false" id="element_manager_window">
<section class="window-inner">
<section id="member_manager_window_title">
<section id="element_manager_window_title">
</section>
<textarea id="add_remove_member_area"></textarea><br>
<input type="button" value="OK" onclick="change_group_members()">
<input type="button" value="Mégse" onclick="hide('member_manager_window')">
<textarea id="add_remove_element_area"></textarea><br>
<input type="button" value="OK" onclick="change_group_elements()">
<input type="button" value="Mégse" onclick="hide('element_manager_window')">
</section>
</section>

View File

@ -286,9 +286,12 @@ function patch_through_image(string $gameid, string $img_url)
$image_fetch_url = $game_dir . DIRECTORY_SEPARATOR . $img_url;
$img_fp = fopen($image_fetch_url, "r");
$content_type = mime_content_type($image_fetch_url);
if ($img_fp === false) {
$img_fp = fopen(MISSING_IMAGE_PLACEHOLDER, "r");
$content_type = mime_content_type(MISSING_IMAGE_PLACEHOLDER);
}
header("Content-Type: $content_type");
fpassthru($img_fp);
fclose($img_fp);
}
@ -485,6 +488,7 @@ function get_results_by_gameid(ReqHandler &$rh, array $params): array
$filter = trim($params["filter"] ?? "");
$ordering = trim($params["orderby"] ?? "");
$groups = explode_list(trim($params["groups"] ?? ""));
$best_only = trim($params["best_only"] ?? "false") === "true";
$game = $gameMgr->getGame($gameid);
@ -516,9 +520,9 @@ function get_results_by_gameid(ReqHandler &$rh, array $params): array
// execute filtering
$game_results = null;
if ($group_filter !== []) {
$game_results = $testMgr->getResultsByGameId($gameid, $filter, $ordering, true, $group_filter);
$game_results = $testMgr->getResultsByGameId($gameid, $filter, $ordering, true, $best_only, $group_filter);
} else {
$game_results = $testMgr->getResultsByGameId($gameid, $filter, $ordering, true);
$game_results = $testMgr->getResultsByGameId($gameid, $filter, $ordering, true, $best_only);
}
$result = $game_results;
}
@ -534,6 +538,7 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
$gameid = trim($params["gameid"]);
$filter = trim($params["filter"] ?? "");
$groups = explode_list(trim($params["groups"]));
$best_only = trim($params["best_only"] ?? "false") === "true";
$outtype = trim($params["outtype"] ?? "pdf");
// only PDF and TEX are valid
@ -565,11 +570,20 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
// assemble report
$report = new Report($game->getName());
foreach ($groups as $groupname) {
$stats = ReportBuilder::getStatsByFilters($gameid, $filter, $groupname, "");
$stats = ReportBuilder::getStatsByFilters($gameid, $filter, $groupname, $best_only);
$section = new ReportSection($groupname, $stats);
$report->addSection($section);
}
// add comments
$report->addComment("gameid: ${gameid}");
$groupsJoined = join(", ", $groups);
$report->addComment("groups: ${groupsJoined}");
$report->addComment("filter: ${filter}");
$report->addComment("best_only: ${params["best_only"]}");
$requestURL = $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
$report->addComment("\\scriptsize \\path{" . $requestURL . "}");
// generate latex
$report->saveTeX($buildDir);
@ -594,8 +608,8 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
foreach ($files as $file) {
$zip->addFile($file, basename($file));
}
$zip->addFromString("request.txt", "gameid: ${gameid}\ngroups: " . join(", ", $groups) . "\nfilter: ${filter}\nouttype: ${outtype}\n");
$zip->addFromString("request.url", $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]);
$zip->addFromString("request.txt", "gameid: ${gameid}\ngroups: " . $groupsJoined . "\nfilter: ${filter}\nouttype: ${outtype}\nbest_only: ${params["best_only"]}");
$zip->addFromString("request.url", $requestURL);
$zip->close();
$contentType = "application/zip";
}
@ -710,10 +724,14 @@ function delete_groups(ReqHandler &$rh, array $params): string
function get_all_groups(ReqHandler &$rh, array $params): array
{
global $groupMgr;
global $gameMgr;
$groups = $groupMgr->getAllGroups();
$a = [];
foreach ($groups as $g) {
$a[] = $g->toArray();
$r = $g->toArray();
$gameMgr->resolveGames($r["games"]);
$a[] = $r;
}
return $a;
}
@ -806,20 +824,29 @@ function get_game_groups(ReqHandler &$rh, array $params): array
return $groups;
}
function change_group_members(ReqHandler &$rh, array $params): string
function change_group_members_or_games(ReqHandler &$rh, array $params): string
{
global $groupMgr;
global $user;
global $userMgr;
$group = $groupMgr->getGroup($params["groupid"]);
if ($group !== null) {
if ($group->isUserContributor($user->getNickname())) {
if ($group->isUserContributor($user->getNickname()) || $user->hasQuizmasterPrivilege()) {
$add = explode_list(trim($params["add"]));
$add = $userMgr->sanitizeNicknames($add);
$remove = explode_list(trim($params["remove"]));
$remove = $userMgr->sanitizeNicknames($remove);
$group->changeMembers($add, $remove);
$action = $params["action"];
if ($action === "change_group_members") {
global $userMgr;
$add = $userMgr->sanitizeNicknames($add);
$remove = $userMgr->sanitizeNicknames($remove);
$group->changeMembers($add, $remove);
} else if ($action === "change_group_games") {
global $gameMgr;
$add = $gameMgr->sanitizeGames($add);
$remove = $gameMgr->sanitizeGames($remove);
$group->changeGames($add, $remove);
}
return "OK";
}
}
@ -840,7 +867,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("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("change_group_members", ["groupid", "add", "remove"], PRIVILEGE_QUIZMASTER, "change_group_members", RESP_PLAIN, "Change group members.");
$rh->add(["change_group_members", "change_group_games"], ["groupid", "add", "remove"], PRIVILEGE_QUIZMASTER, "change_group_members_or_games", RESP_PLAIN, "Change group members or games.");
$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.");

View File

@ -26,7 +26,7 @@ function list_all_games() {
let tdChkBox = document.createElement("td");
tdChkBox.appendChild(chkbox);
tdChkBox.classList.add("checkbox");
let tdGameName = create_table_cell(g["name"]);
let tdGameName = create_table_cell(g["name"] + "<span style='color:gray'>#" + g["_id"] + "</span>");
let tdGameDescription = create_table_cell(g["description"]);
let tdOwner = create_table_cell(g["owner"]);
row.append(tdChkBox, tdGameName, tdGameDescription, tdOwner);
@ -373,12 +373,13 @@ function list_results_by_game(game) {
function generate_game_report_by_groups() {
let gameid = EDITED_GAME["_id"];
let filter = document.getElementById("report_filter").value.trim()
let groups = document.getElementById("report_groups").value.trim()
let filter = encodeURIComponent(document.getElementById("report_filter").value.trim());
let groups = encodeURIComponent(document.getElementById("report_groups").value.trim());
let best_only = document.getElementById("best_only").checked ? "true" : "false";
let outtype = document.getElementById("report_output_type").value;
let report_url = `interface.php?action=generate_report_by_groups&gameid=${gameid}&groups=${groups}&filter=${filter}&outtype=${outtype}`;
report_url = report_url.replace("#", "%23");
let report_url = `interface.php?action=generate_report_by_groups&gameid=${gameid}&groups=${groups}&filter=${filter}&outtype=${outtype}&best_only=${best_only}`;
//report_url = report_url.replaceAll("#", "%23");
window.open(report_url, "_blank");
}

View File

@ -44,6 +44,7 @@ function create_edit_group(group = null) {
let group_ownerF = document.getElementById("group_owner");
let group_editorsF = document.getElementById("group_editors");
let group_membersF = document.getElementById("group_members");
let group_gamesF = document.getElementById("group_games");
if (!update) { // create a new group
groupnameF.value = "";
@ -53,6 +54,7 @@ function create_edit_group(group = null) {
group_ownerF.readOnly = true;
group_editorsF.value = "";
group_membersF.value = "";
group_gamesF.value = "";
hide("group_editor_additional_fields");
} else { // update and existing one
groupnameF.value = group["groupname"];
@ -62,6 +64,7 @@ function create_edit_group(group = null) {
group_ownerF.readOnly = false;
group_editorsF.value = group["editors"].join(", ");
group_membersF.value = group["users"].join(", ");
group_gamesF.value = group["games"].join(", ");
show("group_editor_additional_fields");
}
@ -123,47 +126,48 @@ function delete_groups() {
function print_group_name(group_data) {
let record = group_data["groupname"];
if (!group_data["unique"]) {
record += "#" + group_data["_id"];
}
let seqNumStyle = (group_data["unique"]) ? "style='color:lightgray'" : "";
record += `<span ${seqNumStyle}>#` + group_data["_id"] + `</span>`;
return record;
}
let MEMBER_ACTION = "";
let ACTION = "";
let TYPE = ""
function open_member_change_window(action) {
MEMBER_ACTION = action;
let winCap = document.getElementById("member_manager_window_title");
function open_element_change_window(action, type) {
ACTION = action;
TYPE = type;
let winCap = document.getElementById("element_manager_window_title");
let typeStr = (type === "member") ? "Tagok" : "Játékok";
let opStr = (action === "add") ? "hozzáadása" : "eltávolítása";
// print window title
if (action === "add") {
winCap.innerText = "Tagok hozzáadása";
} else if (action === "remove") {
winCap.innerText = "Tagok eltávolítása";
}
winCap.innerText = typeStr + " " + opStr;
show("member_manager_window");
show("element_manager_window");
}
function change_group_members() {
let userListTA = document.getElementById("add_remove_member_area");
function change_group_elements() {
let elementListTA = document.getElementById("add_remove_element_area");
let req = {
action: "change_group_members",
action: `change_group_${TYPE}s`,
groupid: EDITED_GROUP["_id"],
add: [],
remove: []
};
if (MEMBER_ACTION === "add") {
req["add"] = userListTA.value;
} else if (MEMBER_ACTION === "remove") {
req["remove"] = userListTA.value;
if (ACTION === "add") {
req["add"] = elementListTA.value;
} else if (ACTION === "remove") {
req["remove"] = elementListTA.value;
}
request(req).then(resp => {
userListTA.value = "";
hide("member_manager_window");
elementListTA.value = "";
hide("element_manager_window");
hide("group_editor_window");
list_all_groups();
});

View File

@ -31,11 +31,24 @@ function autoconvert_datetime(str) {
return filter;
}
function count_selected() {
let n = 0;
document.getElementsByName("game_select").forEach((chk) => {
if (chk.checked) {
n++;
}
});
document.getElementById("selected_n").innerText = n.toString();
}
function fetch_results() {
let filterF = document.getElementById("filter");
let orderbyF = document.getElementById("orderby");
let groupsF = document.getElementById("groups");
let best_onlyChk = document.getElementById("best_only");
let records_nS = document.getElementById("records_n");
let filter = autoconvert_datetime(filterF.value.trim());
@ -46,7 +59,8 @@ function fetch_results() {
gameid: GAMEID,
filter: filter.trim(),
orderby: orderbyF.value.trim(),
groups: groupsF.value.trim()
groups: groupsF.value.trim(),
best_only: best_onlyChk.checked ? "true" : "false"
};
request(req).then(resp => {
@ -59,7 +73,7 @@ function fetch_results() {
return;
}
// let n = results.length;
records_nS.innerText = results.length;
results.forEach((record) => {
let row = document.createElement("tr");
@ -87,6 +101,9 @@ function fetch_results() {
selectChk.type = "checkbox";
selectChk.name = "game_select";
selectChk.record = record;
selectChk.addEventListener("input", () => {
count_selected();
});
let selection_cell = create_cell();
selection_cell.append(selectChk);
@ -209,6 +226,7 @@ function toggle_test_selection() {
game_selectChks.forEach((chk) => {
chk.checked = !chk.checked;
});
count_selected();
}
function delete_tests() {

View File

@ -1,12 +1,19 @@
% !TeX spellcheck = hu_HU
% !TeX encoding = UTF-8
% !TeX program = xelatex
\documentclass[10pt]{article}
%% Importing packages
% General things
\usepackage[magyar]{babel}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[a4paper,margin=10mm,footskip=5mm]{geometry}
\usepackage{fontspec}
\usepackage[fontsize=7pt]{fontsize}
\usepackage{titlesec}
\usepackage{url}
\usepackage{datetime2}
% For frame layout and content
\usepackage{xcolor}
@ -28,6 +35,10 @@
\definecolor{colpbb}{HTML}{A0A0A0} % Progressbar background
\definecolor{colanc}{HTML}{176767} % Correct answer background
\definecolor{colani}{HTML}{D3E5E5} % Incorrect answer background
\definecolor{colsbg}{HTML}{AA8A7D} % Group title background
\definecolor{colsfg}{HTML}{EFEFEF} % Group title text color
\definecolor{colqsb}{HTML}{176767} % Quiz sequence number background
\definecolor{colqsf}{HTML}{EFEFEF} % Quiz sequence number text color
% Setting up outer frames
\mdfsetup{
@ -52,16 +63,16 @@
% Replacing ToC text
\addto\captionsmagyar{%
\renewcommand{\contentsname}%
{\huge Kurzusok}%
\renewcommand{\contentsname}%
{\huge Csoportok}%
}
% Add dotfill to ToC
\makeatletter
\patchcmd{\l@section}{\hfil}{%
\leaders\hbox{$\m@th
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
mu$}\hfill}{}{}
mu$}\hfill}{}{}
\makeatother
@ -83,39 +94,76 @@
\newcommand{\unnumsec}[1]{\section*{#1}%
\addcontentsline{toc}{section}{#1}}
% Set section title style
\titleformat{\unnumsec}{\Large\bfseries}{\thesection}{1em}{}
% Macros for answers
\newcommand{\answerCorrect}[2]{\progressbar{#1} & \begin{minipage}{0.8\columnwidth}\begin{mdframed}[backgroundcolor=colanc]\color{coltxl}{#2}\end{mdframed}\end{minipage}\\}
\newcommand{\answerIncorrect}[2]{\progressbar[filledcolor=colpbs]{#1} & \begin{minipage}{0.8\columnwidth}\begin{mdframed}[backgroundcolor=colani]\color{coltxd}{#2}\end{mdframed}\end{minipage}\\}
% Macros for questions.
\newmdenv[backgroundcolor=colqsb,align=left,innerleftmargin=0.2em,innerrightmargin=0.2em]{qsn} % Question sequence number
% Environment for questions. The parameter is the question itself, the contents of the environment should consist of \answer*{}{} macros and nothing else
\newenvironment{question}[1]{
\begin{center}
\begin{mdframed}
{\color{coltit}\large #1\par}\medskip
\begin{tabular}{c c}
}{
\end{tabular}
\end{mdframed}
\end{center}
\newenvironment{question}[2]{
\begin{center}
\begin{mdframed}
\raisebox{0.05em} {
\begin{minipage}{0.6cm}
\begin{qsn}[userdefinedwidth=0.5cm]
\begin{flushright}
\color{colqsf}\arabic{qc}.
\end{flushright}
\end{qsn}
\end{minipage}
}
%
{\color{coltit}\large #1\par}\medskip
%
{\hspace{1em}\small #2~kitöltő}\vspace{0.6em}\par
\stepcounter{qc}
\begin{tabular}{c c}
}{
\end{tabular}
\end{mdframed}
\end{center}
}
% An environment to create a quiz containing questions. The parameter is either the title of the quiz, or the name of the course
\newenvironment{quiz}[1]{
\unnumsec{#1}
}{
\newenvironment{quiz}[2]{
% Create highlighted group title
\begin{mdframed}[backgroundcolor=colsbg]
{
\color{colsfg}
\unnumsec{#1}
{\small #2~kitöltő}
\vspace{0.4em}
}
\end{mdframed}
% Reset question counter
\setcounter{qc}{1}
}{
\clearpage
}
\begin{document}
\begin{center}
\Huge \IfFileExists{stats/title.tex}{\input{title.tex}}{Kvíz eredmények}
\end{center}
\begin{center}
\Huge \IfFileExists{title.tex}{\input{title.tex}}{Kvíz eredmények}\\
\normal \DTMnow
\end{center}
\Large
\tableofcontents
\normalsize
\clearpage
\Large
\tableofcontents
\normalsize
\clearpage
\inputIfFileExists{content.tex}
% Create question counter
\newcounter{qc}
\inputIfFileExists{content.tex}
\end{document}

View File

@ -52,50 +52,52 @@ if (!$gameMgr->getGame($game_id)->isUserContributorOrOwner($user_data["nickname"
<input type="text" placeholder="Rendezés" id="orderby" style="font-family: 'Monaco', monospace; width: 30em;">
<input type="button" value="Szűrés" onclick="fetch_results()">
<input type="button" value="Jelentés előállítása" onclick="generate_report()">
<input type="button" value="Kijelöltek törlése" onclick="delete_tests()">
<input type="button" value="Kijelöltek törlése" onclick="delete_tests()"><br>
<input type="checkbox" id="best_only"><label for="best_only" style="font-size: 12px">Csak legjobb eredmények felhasználónként</label>
</section>
<section>
<section id="table_section">
<table class="management">
<thead>
<tr>
<th>
<input type="checkbox" onclick="toggle_test_selection()">
</th>
<th>#<br>
<code>
[_id]
</code>
</th>
<th></th>
<th>
Felhasználónév<br>
<code>
[nickname]
</code>
</th>
<th>Eredmény<br>
<code>
[summary.percentage]
</code>
</th>
<th>Kezdés ideje<br>
<code>
[start_time]
</code>
</th>
<th>Befejezés ideje<br>
<code>
[end_time]
</code>
</th>
<section id="table_section">
<table class="management">
<thead>
<tr>
<th>
<input type="checkbox" onclick="toggle_test_selection()">
</th>
<th>#<br>
<code>
[_id]
</code>
</th>
<th></th>
<th>
Felhasználónév<br>
<code>
[nickname]
</code>
</th>
<th>Eredmény<br>
<code>
[summary.percentage]
</code>
</th>
<th>Kezdés ideje<br>
<code>
[start_time]
</code>
</th>
<th>Befejezés ideje<br>
<code>
[end_time]
</code>
</th>
</tr>
</thead>
<tbody id="results_display">
</tbody>
</table>
</section>
</tr>
</thead>
<tbody id="results_display">
</tbody>
</table>
</section>
<section id="summary_section">
<span id="records_n">0</span>&nbsp;találat, <span id="selected_n">0</span>&nbsp;kijelölve
</section>
<script>
let GAMEID = <?="$game_id"?>;

View File

@ -1,9 +1,13 @@
section#table_section {
position: sticky;
height: calc(100vh - 4em);
height: calc(100vh - 6em);
overflow-y: auto;
}
section#summary_section {
margin-top: 0.5em;
}
table.management {
width: 100%;
border-collapse: collapse;