REST Service for POPCORN - ILIAS
alex
4 hours ago b8c5990374e828bea9de4b057709a07d230da6ab
adding  kursLpGet.js
1 files modified
1 files added
28 ■■■■■ changed files
bin/kursLpGet.js 24 ●●●●● patch | view | raw | blame | history
lib/libLp.js 4 ●●●●● patch | view | raw | blame | history
bin/kursLpGet.js
New file
@@ -0,0 +1,24 @@
const db = require("../lib/db")
const yargs = require("yargs")
/////////////////////////////////////////////////////////////////////////
const argv = yargs
   .usage("$0 <ref_id>", "get kurs learning progress using <ref_id>",)
   .option("raw", {
      describe: "print raw learning progress of the sub-objects",
      type: "boolean",
      default: false,
   })
   .strict()
   .parse()
run(argv)
   .then(console.log)
   .catch(console.error)
   .finally(process.exit)
async function run({ref_id, raw}) {
   const {obj_id} = await db.getObjIdFromRefId(ref_id)
   return await db.getKursLp(obj_id, raw)
}
lib/libLp.js
@@ -17,14 +17,11 @@
    const grouped = _.groupBy(data, "usr_id")
    const ret = []
    for (const items of Object.values(grouped)) {
        // console.log(items)
        if (!items.length) continue
        const unterStatusse = items.map(it => it.status)
        const newStatus = auswerten(unterStatusse)
        const status_changed = _.max(items.map(u => u.status_changed))
        console.log({unterStatusse,newStatus,items})
        const {usr_id, login, firstname, lastname,} = items[0]
        const newItem = {
@@ -32,7 +29,6 @@
        }
        ret.push(newItem)
    }
    console.log(ret)
    return ret
}