REST Service for POPCORN - ILIAS
alex
2025-07-06 edd25aea7e4c7d317603a09a7081fc26ae70f617
GS-2199
2 files modified
14 ■■■■ changed files
lib/db.js 12 ●●●● patch | view | raw | blame | history
test/testSetStatus.js 2 ●●● patch | view | raw | blame | history
lib/db.js
@@ -1,4 +1,5 @@
const mysql = require("mysql2/promise")
const dayjs = require("dayjs")
const searchLib = require("./search")
const {host, port, user, database, password} = require("./../settings").db
@@ -404,7 +405,7 @@
 * @param userId
 * @param passed
 * @param status
 * @returns {Promise<void>}
 * @returns {Promise<{status: string}>}
 */
async function setStatus (courseId, userId, passed = null, status = null) {
   const pool = await poolP
@@ -424,9 +425,11 @@
COMMIT;
`
   let date = dayjs().format('YYYY-MM-DD HH:mm:ss')
   const q1 = `
       UPDATE ${database}.ut_lp_marks ulm
       SET status = ${status}
       SET status         = ${status},
           status_changed = "${date}"
       WHERE ulm.usr_id = 31793
         AND ulm.obj_id = 32212;
   `
@@ -441,9 +444,7 @@
   const {affectedRows: affectedRows1} = results1
   const {affectedRows: affectedRows2} = results2
   if (affectedRows1 && affectedRows2) {
      return {
         status: "ok",
      }
      return {status: "ok"}
   }
   else {
      throw {
@@ -451,5 +452,4 @@
         reason: {affectedRows1, affectedRows2}
      }
   }
   // return {results1, results2}
}
test/testSetStatus.js
@@ -26,7 +26,7 @@
   })
   it("should set status and passed for a kurs TN", async function () {
      const res = await db.setStatus(kursId, userId, 4, 4)
      const res = await db.setStatus(kursId, userId, passed, status)
      console.dir(res, {depth: null})
      return