From 594de40ac39ac32d6d526c8c4875dc6665b2d8dc Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Thu, 23 Oct 2025 09:01:21 +0000
Subject: [PATCH] GS-2375
---
lib/db.js | 34 ++++++++++++++++-
app.js | 1
test/testKursLp.js | 43 +++++++++++++++++++++
3 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/app.js b/app.js
index e8a2f5b..5a2a88d 100644
--- a/app.js
+++ b/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"}
diff --git a/lib/db.js b/lib/db.js
index 6f9922c..d02f06c 100644
--- a/lib/db.js
+++ b/lib/db.js
@@ -43,6 +43,9 @@
getSingleKursTeilnehmer,
getKursTeilnehmerCount,
+ getKursLp,
+ getKursUnterobjektLp,
+
getKursOffline,
setKursOffline,
@@ -402,10 +405,37 @@
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
- FROM ${database}.object_data
+ const q = `SELECT offline
+ FROM ${database}.object_data
WHERE obj_id = ${obj_id}
`
const [results] = await pool.query(q)
diff --git a/test/testKursLp.js b/test/testKursLp.js
new file mode 100644
index 0000000..7bcf6a2
--- /dev/null
+++ b/test/testKursLp.js
@@ -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")
+ }
+ })
+ })
+
+
+
+})
+
+/////////////////////////////////////////////////////////////////////////
+
--
Gitblit v1.8.0