REST Service for POPCORN - ILIAS
alex
2025-10-23 594de40ac39ac32d6d526c8c4875dc6665b2d8dc
GS-2375
1 files added
2 files modified
74 ■■■■■ changed files
app.js 1 ●●●● patch | view | raw | blame | history
lib/db.js 30 ●●●●● patch | view | raw | blame | history
test/testKursLp.js 43 ●●●●● patch | view | raw | blame | history
app.js
@@ -275,6 +275,7 @@
        }
    })
    // abmelden
    .delete("/api/kurs/:refId/teilnehmer/:usrId", async function (req, res) {
        const {refId, usrId} = req.params
        if (!refId || !usrId) throw {status: "error", msg: "refId and usrId requried"}
lib/db.js
@@ -43,6 +43,9 @@
    getSingleKursTeilnehmer,
    getKursTeilnehmerCount,
    getKursLp,
    getKursUnterobjektLp,
    getKursOffline,
    setKursOffline,
@@ -402,6 +405,33 @@
    return results
}
async function getKursLp(obj_id) {
}
async function getKursUnterobjektLp(obj_id) {
    const pool = await poolP
    const q = `SELECT ulc.obj_id,
                      ulc.item_id,
                      ulc.lpmode,
                      t.obj_id as item_obj_id,
                      ulm.usr_id,
                      ulm.status,
                      ulm.status_changed,
                      ulm.percentage,
                      ulm.completed
               FROM ${database}.ut_lp_collections ulc
                        INNER JOIN ${database}.object_reference t ON t.ref_id = ulc.item_id
                        INNER JOIN ${database}.ut_lp_marks ulm ON ulm.obj_id = t.obj_id
               WHERE ulc.obj_id = ${obj_id} # obj_id Kurs
                    AND ulc.active = 1
                    AND ulc.lpmode = 5  # nur mode 5
    `
    const [results] = await pool.query(q)
    return results
}
async function getKursOffline(obj_id) {
    const pool = await poolP
    const q = `SELECT offline 
test/testKursLp.js
New file
@@ -0,0 +1,43 @@
const expect = require("chai").expect
const settings = require("../settings")
const libIlias = require("../lib/libIlias")
const db = require("../lib/db")
const testData = require("./data")
/////////////////////////////////////////////////////////////////////////
describe("regarding the Kurs LP", function () {
   const kurs = testData.kurs // TODO real test
   let kursId = 32212
   beforeEach(async function () {
   })
   afterEach(async function () {
   })
    describe("the function getKursUnterobjektLp", function () {
        it("should deliver the LP for the Kurs Unterobjekte", async function () {
            const res = await db.getKursUnterobjektLp(kursId)
            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("item_id").and.to.be.a("number")
                expect(item).to.have.property("lpmode").and.to.be.a("number")
                expect(item).to.have.property("item_obj_id").and.to.be.a("number")
                expect(item).to.have.property("usr_id").and.to.be.a("number")
                expect(item).to.have.property("status").and.to.be.a("number")
                expect(item).to.have.property("status_changed").and.to.be.a("date")
            }
        })
    })
})
/////////////////////////////////////////////////////////////////////////