REST Service for POPCORN - ILIAS
alex
2025-12-08 82f18bd37dae283be0940416f3ab7684ad56044c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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 functions for Course Admins", function () {
 
   beforeEach(async function () {
   })
 
   afterEach(async function () {
   })
 
 
   describe("the function getCourseAdminRoles()", function () {
      it("should return all admin roles for all courses", async function () {
         const res = await db.getCourseAdminRoles()
         // console.table(res)
         // console.log(res)
         expect(res).to.be.a("array")
         for (const item of res) {
            expect(item).to.have.property("crs_obj_id").and.to.be.a("number")
            expect(item).to.have.property("crs_ref_id").and.to.be.a("number")
            expect(item).to.have.property("crs_title").and.to.be.a("string")
            expect(item).to.have.property("rol_id").and.to.be.a("number")
            expect(item).to.have.property("role").and.to.be.a("string")
         }
      })
   })
 
   describe("the function getCoursesWithoutAdminRoles()", function () {
      it("should return all admin roles for all courses", async function () {
         const res = await db.getCourseWithoutAdminRoles()
         // console.table(res)
         console.log(res)
         expect(res).to.be.a("array")
         for (const item of res) {
            expect(item).to.have.property("crs_obj_id").and.to.be.a("number")
            expect(item).to.have.property("crs_ref_id").and.to.be.a("number")
            expect(item).to.have.property("crs_title").and.to.be.a("string")
            expect(item).to.have.property("rol_id").and.to.be.a("number")
            expect(item).to.have.property("role").and.to.be.a("string")
         }
      })
   })
 
   // wird nicht gebraucht - Admin Erkennung in ILIAS läuft anders ab
   // describe("the function getCourseAdmins()", function () {
   //    it("should get the Admins of all courses", async function () {
   //       const res = await db.getCourseAdmins()
   //       console.table(res)
   //       expect(res).to.be.a("array")
   //       for (const item of res) {
   //          expect(item).to.have.property("kurs_obj_id").and.to.be.a("number")
   //          expect(item).to.have.property("kurs_ref_id").and.to.be.a("number")
   //          expect(item).to.have.property("usr_id").and.to.be.a("number")
   //          expect(item).to.have.property("login").and.to.be.a("string")
   //          expect(item).to.have.property("firstname").and.to.be.a("string")
   //          expect(item).to.have.property("lastname").and.to.be.a("string")
   //          expect(item).to.have.property("title").and.to.be.a("string")
   //       }
   //    })
   // })
   //
   // describe("the function getCoursesWithNoAdmins()", function () {
   //    it("should return all courses without a single admin member", async function () {
   //       const res = await db.getCoursesWithNoAdmins()
   //       console.table(res)
   //       expect(res).to.be.a("array")
   //       for (const item of res) {
   //          expect(item).to.have.property("obj_id").and.to.be.a("number")
   //          expect(item).to.have.property("ref_id").and.to.be.a("number")
   //          expect(item).to.have.property("numTn").and.to.be.a("number")
   //          expect(item).to.have.property("title").and.to.be.a("string")
   //       }
   //    })
   // })
 
})
 
/////////////////////////////////////////////////////////////////////////