From b7bca5c6c1cd51bc691eedbaa47be789bbef2731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiesner=20Andr=C3=A1s?= Date: Fri, 8 Mar 2024 18:14:53 +0100 Subject: [PATCH] - batch user import basics --- interface.php | 9 ++++++++- js/quizmaster_common.js | 12 ++++++++---- js/usermgr.js | 5 +++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/interface.php b/interface.php index 0a14ad4..a5b87d2 100644 --- a/interface.php +++ b/interface.php @@ -116,7 +116,7 @@ if ((($testid = trim($_REQUEST["testid"] ?: "")) !== "") && ($test_data["nickname"] === $nickname)) { // update the test if timed - update_timed_tests([ $test_data ]); + update_timed_tests([$test_data]); switch ($action) { case "get_test": @@ -372,6 +372,13 @@ switch ($action) { $result = json_encode($user_data_filtered); } break; + case "import_users_from_csv": + { + if (!isset($_FILES["users_table"])) { + goto print_result; + } + } + break; } // ---------- diff --git a/js/quizmaster_common.js b/js/quizmaster_common.js index c844b41..1aefc03 100644 --- a/js/quizmaster_common.js +++ b/js/quizmaster_common.js @@ -10,8 +10,12 @@ function create_table_cell(content, styleClass = "") { return td; } -function highlight_row(nickname) { - let hl_on = document.getElementById("user_chk_" + nickname).checked; - let row = document.getElementById("row_" + nickname); - row.setAttribute("highlight", hl_on ? "true" : "false"); +function highlight_row(rowid) { + let hl_on = document.getElementById("chk_" + rowid).checked; + let row = document.getElementById("row_" + rowid); + if (hl_on) { + row.setAttribute("highlight", "true"); + } else { + row.removeAttribute("highlight"); + } } \ No newline at end of file diff --git a/js/usermgr.js b/js/usermgr.js index 6988268..5d91850 100644 --- a/js/usermgr.js +++ b/js/usermgr.js @@ -7,10 +7,15 @@ function list_all_users() { for (let i = 0; i < users.length; i++) { let u = users[i]; let row = document.createElement("tr"); + row.id = "row_" + u["nickname"]; let chkbox = document.createElement("input"); chkbox.type = "checkbox"; chkbox.name = "user_chkbox"; chkbox.user = u; + chkbox.id = "chk_" + u["nickname"]; + chkbox.addEventListener("input", () => { + highlight_row(u["nickname"]); + }); let tdChkBox = document.createElement("td"); tdChkBox.appendChild(chkbox); tdChkBox.classList.add("checkbox");