- gameid type inconsistency in Test fixed
- delete_tests action added
This commit is contained in:
parent
bd7079bded
commit
4ea8aca8c2
@ -371,7 +371,7 @@ class GroupMgr
|
|||||||
|
|
||||||
// Check if a user has access to a game, i.e. there's at least a single group that contains both the user and the game.
|
// Check if a user has access to a game, i.e. there's at least a single group that contains both the user and the game.
|
||||||
function doesUserAccessGame(string $gameid, string $nickname): bool {
|
function doesUserAccessGame(string $gameid, string $nickname): bool {
|
||||||
$intersection = $this->db->findOneBy([["games", "CONTAINS", $gameid], "AND", ["users", "CONTAINS", $nickname]]);
|
$intersection = $this->db->findOneBy([["games", "CONTAINS", (int)$gameid], "AND", ["users", "CONTAINS", $nickname]]);
|
||||||
return $intersection !== null;
|
return $intersection !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class Test extends AutoStoring
|
|||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
public int $id; // ID
|
public int $id; // ID
|
||||||
public string $gameId; // ID of associated game
|
public int $gameId; // ID of associated game
|
||||||
public string $gameName; // Name of the associated game
|
public string $gameName; // Name of the associated game
|
||||||
public string $nickname; // Associated user's nickname
|
public string $nickname; // Associated user's nickname
|
||||||
public string $state; // State of the test (ongoing/concluded)
|
public string $state; // State of the test (ongoing/concluded)
|
||||||
@ -142,6 +142,8 @@ class Test extends AutoStoring
|
|||||||
$this->startTime = $now;
|
$this->startTime = $now;
|
||||||
if ($this->timeLimited) {
|
if ($this->timeLimited) {
|
||||||
$this->endLimitTime = $now + $gp["time_limit"];
|
$this->endLimitTime = $now + $gp["time_limit"];
|
||||||
|
} else {
|
||||||
|
$this->endLimitTime = -1; // dummy value, not used, since timeLimited is false
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->repeatable = $gp["repeatable"];
|
$this->repeatable = $gp["repeatable"];
|
||||||
@ -151,7 +153,7 @@ class Test extends AutoStoring
|
|||||||
}
|
}
|
||||||
|
|
||||||
// auto-conclude time-constrained test if expired
|
// auto-conclude time-constrained test if expired
|
||||||
if ($this->isOngoing() && ($this->endLimitTime <= time())) {
|
if ($this->timeLimited && $this->isOngoing() && ($this->endLimitTime <= time())) {
|
||||||
$this->concludeTest();
|
$this->concludeTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,7 +263,7 @@ class Test extends AutoStoring
|
|||||||
return $this->nickname;
|
return $this->nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGameId(): string
|
public function getGameId(): int
|
||||||
{
|
{
|
||||||
return $this->gameId;
|
return $this->gameId;
|
||||||
}
|
}
|
||||||
|
@ -537,6 +537,15 @@ function generate_detailed_game_stats(ReqHandler &$rh, array $params): array
|
|||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delete_tests(ReqHandler &$rh, array $params): string {
|
||||||
|
global $testMgr;
|
||||||
|
$ids = explode_list(trim($params["ids"]));
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
$testMgr->deleteTest($id);
|
||||||
|
}
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
$rh->add(["create_game", "update_game"], ["data"], PRIVILEGE_CREATOR, "create_update_game", RESP_JSON, "Create or update game.");
|
$rh->add(["create_game", "update_game"], ["data"], PRIVILEGE_CREATOR, "create_update_game", RESP_JSON, "Create or update game.");
|
||||||
$rh->add("get_all_game_headers", [], PRIVILEGE_CREATOR, "get_all_game_headers", RESP_JSON, "Get all game headers.");
|
$rh->add("get_all_game_headers", [], PRIVILEGE_CREATOR, "get_all_game_headers", RESP_JSON, "Get all game headers.");
|
||||||
$rh->add("get_challenges", [], PRIVILEGE_CREATOR, "get_challenges", RESP_PLAIN, "Get game challenges.");
|
$rh->add("get_challenges", [], PRIVILEGE_CREATOR, "get_challenges", RESP_PLAIN, "Get game challenges.");
|
||||||
@ -544,6 +553,7 @@ $rh->add("delete_games", ["ids"], PRIVILEGE_CREATOR, "delete_games", RESP_PLAIN,
|
|||||||
$rh->add("export_game_file_csv", ["gameid"], PRIVILEGE_CREATOR, "export_game_file_csv", RESP_NONE, "Export game CSV file.");
|
$rh->add("export_game_file_csv", ["gameid"], PRIVILEGE_CREATOR, "export_game_file_csv", RESP_NONE, "Export game CSV file.");
|
||||||
$rh->add("get_results_by_gameid", ["gameid"], PRIVILEGE_CREATOR, "get_player_results_by_gameid", RESP_JSON, "Get game results.");
|
$rh->add("get_results_by_gameid", ["gameid"], PRIVILEGE_CREATOR, "get_player_results_by_gameid", RESP_JSON, "Get game results.");
|
||||||
$rh->add("generate_detailed_stats", ["gameid", "testids"], PRIVILEGE_CREATOR, "generate_detailed_game_stats", RESP_JSON, "Generate detailed game stats.");
|
$rh->add("generate_detailed_stats", ["gameid", "testids"], PRIVILEGE_CREATOR, "generate_detailed_game_stats", RESP_JSON, "Generate detailed game stats.");
|
||||||
|
$rh->add("delete_tests", ["ids"], PRIVILEGE_CREATOR, "delete_tests", RESP_PLAIN, "Delete tests.");
|
||||||
|
|
||||||
// execute processing if user is a creator
|
// execute processing if user is a creator
|
||||||
if ($privilege === PRIVILEGE_CREATOR) {
|
if ($privilege === PRIVILEGE_CREATOR) {
|
||||||
|
@ -110,7 +110,7 @@ function fetch_results() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_report() {
|
function get_selected_ids() {
|
||||||
let testids = [];
|
let testids = [];
|
||||||
let game_selectChks = document.getElementsByName("game_select");
|
let game_selectChks = document.getElementsByName("game_select");
|
||||||
game_selectChks.forEach((chk) => {
|
game_selectChks.forEach((chk) => {
|
||||||
@ -118,6 +118,11 @@ function generate_report() {
|
|||||||
testids.push(chk.record["_id"]);
|
testids.push(chk.record["_id"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return testids;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_report() {
|
||||||
|
let testids = get_selected_ids();
|
||||||
|
|
||||||
let req = {
|
let req = {
|
||||||
action: "generate_detailed_stats",
|
action: "generate_detailed_stats",
|
||||||
@ -196,4 +201,14 @@ function toggle_test_selection() {
|
|||||||
game_selectChks.forEach((chk) => {
|
game_selectChks.forEach((chk) => {
|
||||||
chk.checked = !chk.checked;
|
chk.checked = !chk.checked;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_tests() {
|
||||||
|
let req = {
|
||||||
|
action: "delete_tests",
|
||||||
|
ids: get_selected_ids().join(",")
|
||||||
|
};
|
||||||
|
request(req).then(resp => {
|
||||||
|
fetch_results(); // refresh results
|
||||||
|
});
|
||||||
}
|
}
|
1
main.php
1
main.php
@ -48,6 +48,7 @@ $privilege = $user_data["privilege"];
|
|||||||
<?php if ($privilege != PRIVILEGE_PLAYER) { ?>
|
<?php if ($privilege != PRIVILEGE_PLAYER) { ?>
|
||||||
<section id="action_panel" class="info-pane-element">
|
<section id="action_panel" class="info-pane-element">
|
||||||
<?php if (($privilege === PRIVILEGE_CREATOR) || ($privilege === PRIVILEGE_QUIZMASTER)) { ?>
|
<?php if (($privilege === PRIVILEGE_CREATOR) || ($privilege === PRIVILEGE_QUIZMASTER)) { ?>
|
||||||
|
<input type="button" value="Nyitólap" onclick="open_in_content_frame('default_frame.php')">
|
||||||
<input type="button" value="Tartalmak kezelése" onclick="open_in_content_frame('game_manager_frame.php')">
|
<input type="button" value="Tartalmak kezelése" onclick="open_in_content_frame('game_manager_frame.php')">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($privilege === PRIVILEGE_QUIZMASTER) { ?>
|
<?php if ($privilege === PRIVILEGE_QUIZMASTER) { ?>
|
||||||
|
@ -49,6 +49,7 @@ if (!is_user_contributor_to_game($game_id, $user_data["nickname"]) && ($user_dat
|
|||||||
<input type="text" placeholder="Rendezés" id="orderby" style="font-family: 'Monaco', monospace; width: 50em;">
|
<input type="text" placeholder="Rendezés" id="orderby" style="font-family: 'Monaco', monospace; width: 50em;">
|
||||||
<input type="button" value="Szűrés" onclick="fetch_results()">
|
<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="Jelentés előállítása" onclick="generate_report()">
|
||||||
|
<input type="button" value="Kijelöltek törlése" onclick="delete_tests()">
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<section id="table_section">
|
<section id="table_section">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user