diff --git a/class/GroupMgr.php b/class/GroupMgr.php
index b593a6c..c1b5c75 100644
--- a/class/GroupMgr.php
+++ b/class/GroupMgr.php
@@ -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.
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;
}
diff --git a/class/TestMgr.php b/class/TestMgr.php
index 8859baa..28c9b4c 100644
--- a/class/TestMgr.php
+++ b/class/TestMgr.php
@@ -59,7 +59,7 @@ class Test extends AutoStoring
// ---------
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 $nickname; // Associated user's nickname
public string $state; // State of the test (ongoing/concluded)
@@ -142,6 +142,8 @@ class Test extends AutoStoring
$this->startTime = $now;
if ($this->timeLimited) {
$this->endLimitTime = $now + $gp["time_limit"];
+ } else {
+ $this->endLimitTime = -1; // dummy value, not used, since timeLimited is false
}
$this->repeatable = $gp["repeatable"];
@@ -151,7 +153,7 @@ class Test extends AutoStoring
}
// auto-conclude time-constrained test if expired
- if ($this->isOngoing() && ($this->endLimitTime <= time())) {
+ if ($this->timeLimited && $this->isOngoing() && ($this->endLimitTime <= time())) {
$this->concludeTest();
}
}
@@ -261,7 +263,7 @@ class Test extends AutoStoring
return $this->nickname;
}
- public function getGameId(): string
+ public function getGameId(): int
{
return $this->gameId;
}
diff --git a/interface.php b/interface.php
index 5c03e4b..acc2031 100644
--- a/interface.php
+++ b/interface.php
@@ -537,6 +537,15 @@ function generate_detailed_game_stats(ReqHandler &$rh, array $params): array
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("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.");
@@ -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("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("delete_tests", ["ids"], PRIVILEGE_CREATOR, "delete_tests", RESP_PLAIN, "Delete tests.");
// execute processing if user is a creator
if ($privilege === PRIVILEGE_CREATOR) {
diff --git a/js/result_analyzer.js b/js/result_analyzer.js
index 6160123..b526cab 100644
--- a/js/result_analyzer.js
+++ b/js/result_analyzer.js
@@ -110,7 +110,7 @@ function fetch_results() {
});
}
-function generate_report() {
+function get_selected_ids() {
let testids = [];
let game_selectChks = document.getElementsByName("game_select");
game_selectChks.forEach((chk) => {
@@ -118,6 +118,11 @@ function generate_report() {
testids.push(chk.record["_id"]);
}
});
+ return testids;
+}
+
+function generate_report() {
+ let testids = get_selected_ids();
let req = {
action: "generate_detailed_stats",
@@ -196,4 +201,14 @@ function toggle_test_selection() {
game_selectChks.forEach((chk) => {
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
+ });
}
\ No newline at end of file
diff --git a/main.php b/main.php
index 7c84f83..8dfccb9 100644
--- a/main.php
+++ b/main.php
@@ -48,6 +48,7 @@ $privilege = $user_data["privilege"];