1 files added
4 files modified
| | |
| | | |
| | | importIliasUser, |
| | | |
| | | createKurs, |
| | | |
| | | anmelden, |
| | | abmelden, |
| | | |
| | |
| | | // } |
| | | // } |
| | | |
| | | /////// KURS //////////////////////////////////////////////////////////////// |
| | | |
| | | async function createKurs(kurs) { |
| | | const sp = new URLSearchParams({ |
| | | command: "createKurs", |
| | | token: iliastoken, |
| | | }) |
| | | let url2 = `${url}?${sp.toString()}` |
| | | const res = await fetch(url2, { |
| | | method: "POST", |
| | | body: JSON.stringify(kurs), |
| | | }) |
| | | return await res.json() |
| | | } |
| | | |
| | | |
| | | /////// Anmelden / Abmelden //////////////////////////////////////////////////////////////// |
| | | |
| | | async function anmelden (usr_id, course_id) { |
| | |
| | | $res["status"] = "ok"; |
| | | break; |
| | | } |
| | | /////// Kurs //////////////////////////////////////////////////////////////// |
| | | case "createKurs": |
| | | if ($method == "POST") { |
| | | $body = file_get_contents('php://input'); |
| | | $data = json_decode($body, true); |
| | | $res["ref_id"] = createKurs($data); |
| | | $res["status"] = "ok"; |
| | | $res["msg"] = "User Import OK"; |
| | | break; |
| | | } |
| | | //// Anmelden / Abmelden ////////////////////////////////////////////////////////// |
| | | case "anmelden": // params: usr_id, course_id, role |
| | | if ($method == "POST") { |
| | |
| | | return $usr_id; |
| | | } |
| | | |
| | | function createKurs($data) { |
| | | // TODO ätzend kompliziert |
| | | // ilSoapCourseAdministration->addCourse() |
| | | // beispile wie Kurs erstellt wird in : ilECSCourseCreationHandler->createParallelCourse |
| | | // $course = new ilObjCourse(); |
| | | // $course->create(); |
| | | throw new Exception("not implemented"); |
| | | } |
| | | |
| | | // ACHTUNG course_id muss obj_id sein! |
| | | // die Rolle muss aus dem Kurs gelesen werden |
| | | function anmelden($usr_id, $course_id) { |
| | |
| | | $course = ilObjectFactory::getInstanceByObjId($course_id); |
| | | $membersObject = $course->getMembersObject(); |
| | | return $membersObject->delete($usr_id); |
| | | // TODO auch aus Rolle löschen - wird eigentlich gemacht in ilCourseParticipants->delete() |
| | | } |
| | | |
| | | function deleteUser($obj_id, $dry) |
| | |
| | | }, |
| | | } |
| | | |
| | | const kurs = { |
| | | "title": "Globus-ILIAS-Rest Testkurs", |
| | | "description": "ein Kurs zum Testen", |
| | | "online": false, |
| | | "public": false, |
| | | "maxTn": 20, |
| | | "registerNo": true |
| | | } |
| | | |
| | | module.exports = { |
| | | user, |
| | | kurs, |
| | | } |
| | | |
| | |
| | | const kurs = testData.kurs // TODO |
| | | const user = testData.user |
| | | |
| | | let kursId = 31938 |
| | | let userId = 31954 |
| | | let kursId = null |
| | | let userId = null |
| | | |
| | | beforeEach(async function () { |
| | | // TODO add kurs |
| | | // const res = await libIlias.importIliasUser(user) |
| | | // userId = res.usr_id |
| | | // const {usr_id:userId} = await libIlias.importIliasUser(user) |
| | | const userRes = await libIlias.importIliasUser(user) |
| | | const kursRes = await libIlias. |
| | | console.log(data) |
| | | }) |
| | | |
| | | afterEach(async function () { |
| | |
| | | }) |
| | | |
| | | it("should import a new user to ILIAS", async function () { |
| | | console.log("!111") |
| | | console.error("finish test") |
| | | return |
| | | |
| | | console.log("++abmelden", userId, kursId) |
| | | const res = await libIlias.abmelden(userId, kursId) |
| | | console.dir(res, {depth: null}) |
| New file |
| | |
| | | const expect = require("chai").expect |
| | | |
| | | const settings = require("../settings") |
| | | const libIlias = require("../lib/libIlias") |
| | | const db = require("../lib/db") |
| | | const testData = require("./data") |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | describe("the function anmelden", function () { |
| | | |
| | | const kurs = testData.kurs // TODO |
| | | let kursId = 31938 |
| | | |
| | | beforeEach(async function () { |
| | | }) |
| | | |
| | | afterEach(async function () { |
| | | }) |
| | | |
| | | it("should create a new Kurs in ILIAS", async function () { |
| | | console.log("++createKurs", kurs) |
| | | const res = await libIlias.createKurs(kurs) |
| | | console.dir(res, {depth: null}) |
| | | // expect(res).to.have.property("status").and.to.equal("ok") |
| | | // expect(res.command).to.equal("anmelden") |
| | | // expect(res.method).to.equal("POST") |
| | | }) |
| | | |
| | | }) |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |