- batch user import basics

This commit is contained in:
Wiesner András 2024-03-08 18:14:53 +01:00
parent a2c6ddabb3
commit b7bca5c6c1
3 changed files with 21 additions and 5 deletions

View File

@ -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;
}
// ----------

View File

@ -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");
}
}

View File

@ -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");