REST Service for POPCORN - ILIAS
alex
2025-06-22 56c4f060543542692accdbfab7cb1fff82a7f40f
GS-2156
1 files added
2 files modified
49 ■■■■■ changed files
bin/getUser.js 21 ●●●●● patch | view | raw | blame | history
lib/libIlias.js 14 ●●●●● patch | view | raw | blame | history
php/globus-ilias-rest/api.php 14 ●●●●● patch | view | raw | blame | history
bin/getUser.js
New file
@@ -0,0 +1,21 @@
const iliasLib = require("../lib/libIlias")
const db = require("../lib/db")
const yargs = require("yargs")
/////////////////////////////////////////////////////////////////////////
const argv = yargs
   .usage("$0 <usr_id>", "get user from ILIAS (php) using <usr_id>",)
   .strict()
   .parse()
run(argv)
   .then(console.log)
   .catch(console.error)
   .finally(process.exit)
async function run({usr_id}) {
   return await iliasLib.getUser(usr_id)
}
lib/libIlias.js
@@ -9,7 +9,10 @@
/////////////////////////////////////////////////////////////////////////
module.exports = {
   getUser,
   importIliasUser,
   deleteUser,
   deleteAllUsers,
@@ -18,6 +21,17 @@
/////////////////////////////////////////////////////////////////////////
/////// GET USER ////////////////////////////////////////////////////////////////
async function getUser (usr_id) {
   const sp = new URLSearchParams({
      command: "getUser",
      usr_id,
      token: iliastoken,
   })
   let url2 = `${url}?${sp.toString()}`
   const res = await fetch(url2, {method: "GET"})
   return await res.json() //
}
/////// USER IMPORT ////////////////////////////////////////////////////////////////
php/globus-ilias-rest/api.php
@@ -50,6 +50,15 @@
                    $res["status"] = "ok";
                    break;
                }
            case "getUser":
                if($method == "GET") {
                    $usr_id = (int) $_GET["usr_id"];
                    $res["usr_id"] = $usr_id;
                    $usr = getUser($usr_id);
                    $res["data"] = $usr;
                    $res["status"] = "ok";
                    break;
                }
            case "importUser":
                if ($method == "POST") {
                    $body = file_get_contents('php://input');
@@ -93,6 +102,11 @@
###############################
function getUser($usr_id) {
    $usr = ilObjectFactory::getInstanceByObjId($usr_id);
    return $usr;
}
function importUser($data) {
    $user = new ilObjUser();
    $user->assignData($data);