![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/keeview_app/html/ |
Upload File : |
pluginModule = function () { var retval = {}; var module = retval; // node: hrplugins.keeview.e_learning var v35 = (function (module) { return function () { var retval = {}; // function: hrplugins.keeview.e_learning.changeQuesion var v41 = function(module, me) { return function (message) { return new Promise(function(rs){ ModalElement.showWindow({ index: 1, title: "Chú ý", noPadding: true, bodycontent: absol._({ tag: "span", child: {text: message} }), buttonlist: [ { text: "Có", onclick: function(){ rs("save"); ModalElement.close(1); } }, { text: "Không", onclick: function(){ rs("dont"); ModalElement.close(1); } }, { text: "Hủy", onclick: function(){ rs("cancel"); ModalElement.close(1); } } ] }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.deleteConfirm var v40 = function(module, me) { return function (title, message) { return new Promise(function(rs){ ModalElement.showWindow({ index: 1, title: title, noPadding: true, bodycontent: absol._({ tag: "span", child: {text: message} }), buttonlist: [ { text: "OK", onclick: function(){ rs(); ModalElement.close(1); } }, { text: "Hủy", onclick: function(){ ModalElement.close(1); } } ] }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseEdit var v51 = function(module, me) { return function (hrapi, content, div_element, onsave, onabort) { if (content.name) div_element.name = content.name; hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); return; } hrapi.table.select("topics", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu bài học"}); return; } hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } var topics = []; var dict = {}; var indexList = []; value.forEach((item, i) => { if (item.content){ if (item.content.lesson == content.lesson) { item.content.key = item.key; topics.push(item.content); item.content.childrenIndex = []; dict[item.key] = item.content; } } }); topics.forEach(function(elt, idx){ if (elt.parent == "root") { indexList.push(idx); } if (dict[elt.parent] !== undefined) { dict[elt.parent].childrenIndex.push(idx); } }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onabort(); } }); var checkDuplicate = function(content){ var questions = []; content.forEach((item, i) => { questions = questions.concat(item.questions); }); var dict = {}; questions.forEach((item, i) => { if (!dict[item.content]) dict[item.content] = [i + 1]; else dict[item.content].push(i + 1); }); var keys = Object.keys(dict); var rs = []; keys.forEach((item, i) => { if (dict[item].length > 1) rs.push(dict[item]); }); return rs; }; var saveFunc = function() { ModalElement.show_loading(); var exerciseData = mPoserEditor.getData(); absol.$.replaceFileInObject(exerciseData, function(value, key, subObject){ return me.uploadFle(value).then(function(result){ return window.domainFilesNew + result; }); }).then(function(retData){ var duplicate = checkDuplicate(retData); if (duplicate.length > 0) { var message = "Các câu hỏi bị trùng: "; duplicate.forEach((item, i) => { if (i > 0) message += ", "; message += "[" + item.toString() + "]"; }); ModalElement.alert({message: message}); ModalElement.close(-1); return; } var value = { name: name.value.trim(), lesson: content.lesson, topic: topic.value, comment: comment.value.trim(), active: active.checked, content: retData } if (value.name == "") { ModalElement.alert({ message: "Chưa nhập tên", func: function(){ name.focus(); } }); return; } var key; if (!content.key) { key = (new Date()).getTime(); value.creator = currentEmp.firstid; value.createdtime = new Date(); value.click = 0; } else { key = content.key; value.lastmodified = currentEmp.firstid; value.lastmodifiedtime = new Date(); value.creator = content.creator; value.createdtime = content.createdtime; value.click = content.click === undefined ? content.click : 0; } hrapi.table.update("exercise", key, value, function(s, r){ ModalElement.close(-1); if (s) { value.key = key; content.key = value.key; onsave(value); } else onabort(r); }); }); }; var saveBtn = me.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var addQuestionBtn = me.noneIconButton({ text: "Thêm câu hỏi", onclick: function(){ mPoserEditor.addNewQuestion({data: {content: "New Question"}}); } }); var questionSortBtn = me.noneIconButton({ text: "Sắp xếp câu hỏi", onclick: function(){ ModalElement.showWindow({ title: "Tree Editor", noPadding: true, bodycontent: DOMElement.div({ attrs: { style: { border: "1px solid #d6d6d6", padding: "10px" } }, children: [treeEditorView] }), buttonlist: [ { text: "Đóng", onclick: function(){ ModalElement.close(1); } } ] }); } }); var name = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.name ? content.name : "" } }); var topicItems = me.getTopicItems(topics, content.lesson); var topic = absol._({ tag: "selecttreemenu", props: { enableSearch: true, items: topicItems, value: content.topic ? content.topic : topicItems[0].value } }); // var lessonItems = lessonList.map(function(elt){ // return {value: elt.key, text: elt.content.name}; // }); // var lesson = absol._({ // tag: "selectmenu", // props: { // items: lessonItems, // value: content.lesson ? content.lesson : lessonItems[0].value // } // }); var comment = absol._({ tag: "textarea", class: "cardSimpleTextarea", style: { width: "400px" }, props: { value: content.comment ? content.comment : "" } }); // var createduser = absol._({ // child: {text: currentEmp.fullname} // }); // var createdtime = absol._({ // child: {text: content.createdtime ? me.getDateTimeView(content.createdtime) : me.getDateTimeView(new Date())} // }); // var active = absol._({ // tag: "switch", // style: { // font: "var(--switch-fontsize)", // margin: "auto" // }, // props: { // checked: content.active !== undefined ? content.active : true // } // }); var active = absol._({ tag: "checkbox", props: { checked: content.active !== undefined ? content.active : true } }); var rightChild = []; rightChild.push(absol.buildDom({ attr: { "data-sectionid": "exercise" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Bài tập" }, } ] }), { style: { paddingLeft: "10px" }, child: DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {paddingLeft: "10px"}}, children: [name] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Topic"}, { attrs: {style: {paddingLeft: "10px"}}, children: [topic] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Mô tả"}, { attrs: {style: {paddingLeft: "10px"}}, children: [comment] } ], // [{attrs: {style: {paddingTop: "10px"}}}], // [ // // {text: "Người tạo"}, // { // attrs: {style: {paddingLeft: "10px"}}, // children: [createduser] // } // ], // [{attrs: {style: {paddingTop: "10px"}}}], // [ // // {text: "Thời gian tạo"}, // { // attrs: {style: {paddingLeft: "10px"}}, // children: [createdtime] // } // ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {paddingLeft: "10px"}}, children: [active] } ] ] }) } ] })); var PoserEditor = absol.poser.PoserEditor; var mPoserEditor = new PoserEditor({ hasScroller: false,//không cuộn hasTool: false,//không có cây, mình lấy ra để riêng hoặc không dùng tới hasSection: false, // không có section questionTypes: ['multiple_choice', 'checkboxes'] }); var mPoserEditorView = mPoserEditor.getView(); if (content.content) mPoserEditor.setData(content.content); else mPoserEditor.setData([]); var treeEditorView = mPoserEditor.treeEditor.getView(); treeEditorView.addStyle("width", "600px"); rightChild.push(absol.buildDom({ attr: { "data-sectionid": "question" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Câu hỏi" }, } ] }), { style: { paddingLeft: "10px" }, child: mPoserEditorView } ] })); var nav = absol.buildDom({ tag:'mknavigator', style: { display:'inline-block'// or 'block' }, props: { items: [ {text: "Bài tập", value: "exercise"}, {text: "Câu hỏi", value: "question"}, ], value: "exercise" }, on:{ press: function(event){ rightCtn.off('scroll', scrollRightFunc);// prevent loop if (sectionList[this.value]) sectionList[this.value].scrollIntoView(); setTimeout(function(){ rightCtn.on('scroll', scrollRightFunc ); }, 10); } } }); var scrollRightFunc = function(){ var elt; var bound = rightCtn.getBoundingClientRect(); var eltBound; var nearestEltId; var nearestDistance = 100000000; var distance; for (var i in sectionList){ elt = sectionList[i]; eltBound = elt.getBoundingClientRect(); distance = 1000000; if (eltBound.top <= bound.top){ if (eltBound.bottom >= bound.bottom){ distance = -1e6; } else if (bound.top - eltBound.top < 30){ distance = eltBound.top - bound.bottom;//negative } else if (eltBound.bottom > bound.top){ distance = bound.top - eltBound.top; } } else if (eltBound.top < bound.bottom){ distance = eltBound.top - bound.bottom;//negative } else { distance = Math.abs(bound.top - eltBound.top) } if (nearestDistance > distance){ nearestDistance = distance; nearestEltId = i; } } nav.value = nearestEltId; }; var rightCtn = absol.buildDom({ class: 'mk-main-right', style: { paddingBottom: "var(--footer-margin)" }, child: rightChild, on: { scroll: scrollRightFunc } }); var data_ctn = absol._({ class: 'mk-main', style: { height: '100%' }, child: [ { class: 'mk-main-left-ctn', child: [nav] }, rightCtn ] }); var sectionList = {}; absol.$("div", rightCtn, function(elt){ var id = elt.getAttribute("data-sectionid"); if (!id) return; sectionList[id] = elt; }); var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn }, { class: "single-button-header", child: addQuestionBtn }, { class: "single-button-header", child: questionSortBtn } ] } }, data_ctn ] }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } frameList.addChild(singlePage); singlePage.requestActive(); }); }); }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseMobileSuccess var v67 = function(module, me) { return function (hrapi, content, div_element, doagain, onclose) { var score = 0 var correct = 0; var incorrect = 0; var unmake = 0; var sum = 0; content.sections[0].questions.forEach((item, i) => { sum += item.score; if (!content.result[item.ident]) { unmake++; } else if (!content.result[item.ident].value) { unmake++; } else { if (item.type == "checkboxes") { item.correct_answer.sort(function(a, b){ return a - b; }); var t_value = content.result[item.ident].value.map(function(elt){ return elt.idx; }); t_value.sort(function(a, b){ return a - b; }); if (EncodingClass.string.compare(item.correct_answer, t_value) == 0) { correct++; score += item.score; } else incorrect++; } else { if (item.correct_answer == content.result[item.ident].value.idx) { correct++; score += item.score; } else incorrect++; } } }); var t = { total: content.sections[0].questions.length, arcs: [ { name: correct + " Trả lời đúng", value: correct, color: "#629c44"}, { name: incorrect + " Trả lòi sai", value: incorrect, color: "#e61610"}, { name: unmake + " Không trả lời", value: unmake, color: "#f4eb49"} ] }; var chart = absol._({ tag: 'tinycirclechart', style: { width: '250px', height: '100px' }, props: t }); var commands = [ { icon: DOMElement.i({ attrs: { className: "mdi mdi-undo" } }), cmd: function(){ frameList.removeLast(); doagain(); } } ]; console.log(content.name); var header = absol.buildDom({ tag: 'mheaderbar', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: content.name, commands: commands }, on: { action: function(){ frameList.removeLast(); onclose(); }, command: function(event){ event.commandItem.cmd(); } } }); var PoserEvaluation = absol.poser.PoserEvaluation; var viewer = new PoserEvaluation( { hasScroller: false, hasSection: false, readOnly: true } ); var mPoserView = viewer.getView(); if (content) viewer.setData(content); else viewer.setData({}); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: 'tabframe', child:[ header, absol.buildDom({ class: "card-mobile-content", child: [ { style: { borderRadius: "5px", border: "var(--control-border)", boxShadow: "2px 2px 6px 0px #7f7f7f", display: "inline-block", paddingTop: "var(--control-verticle-distance-2)", paddingBottom: "var(--control-verticle-distance-2)", paddingLeft: "20px", paddingRight: "20px" }, child: [ { style: { fontWeight: "bold", display: "inline-block", verticalAlign: "middle" }, child: {text: "Kết quả: " + score + " / " + sum} }, { style: { paddingLeft: "20px", display: "inline-block", verticalAlign: "middle" }, child: chart } ] }, { style: { paddingTop: "20px" }, child: mPoserView } ] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseMobileTable var v65 = function(module, me) { return function (hrapi, div_element, onclose) { var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); ModalElement.show_loading(); var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("lesson", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("topics", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise_publishment_information", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }) ]; Promise.all(createDB).then(function(){ var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("lesson", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.table.select("topics", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.table.select("exercise", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.table.select("exercise_publishment_information", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }) ]; Promise.all(loadDB).then(function(rs){ ModalElement.close(-1); var database = { lesson: rs[0], topics: rs[1], exercise: rs[2], isAdmin: rs[3], currentEmp: rs[4], exercise_publishment_information: rs[5] }; var lessonItems = database.lesson.map(function(elt){ return { value: elt.key, text: elt.content.name }; }); lessonItems.unshift({value: "all", text: "Tất cả"}); var lessonCbb = absol._({ tag: "selectmenu", style: { width: "100%" }, props: { enableSearch: true, items: lessonItems }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); var dict = { lesson: {}, topics: {}, exercise_publishment_information: {} }; database.lesson.forEach((item, i) => { dict.lesson[item.key] = item.content; }); database.topics.forEach((item, i) => { if (item.content) dict.topics[item.key] = item.content; }); database.exercise_publishment_information.forEach((item, i) => { if (!dict.exercise_publishment_information[item.content.exerciseKey]) dict.exercise_publishment_information[item.content.exerciseKey] = {}; dict.exercise_publishment_information[item.content.exerciseKey][item.content.employeeid] = item; }); div_element.dict = dict; var generateData = function(){ var data = []; database.exercise.forEach(function(elt){ if (lessonCbb.value != "all" && elt.content.lesson != lessonCbb.value) return; if (!dict.lesson[elt.content.lesson]) return; if (!dict.topics[elt.content.topic]) return; var publishInfor = dict.exercise_publishment_information[elt.key]; var click = 0; var success = false; if (publishInfor) { click = Object.keys(publishInfor).length; if (publishInfor[database.currentEmp.id]) success = true; } var doExercise = function(exerciseContent){ return function(){ var onclose = function(value){ for (var i = 0; i < database.exercise.length; i++){ if (database.exercise[i].key == value.key){ database.exercise[i].content = value; } } container.clearChild(); container.addChild(generateData()); }; exerciseContent.content.key = exerciseContent.key; exerciseContent.content.currentEmpId = database.currentEmp.id; me.exerciseMobileView(hrapi, exerciseContent.content, div_element, onclose); } }(elt); var cells = [ { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild( absol._({ tag: "span", class: ["as-dt-row-index", 'hr-table-cell-link'], on: { click: function(){ doExercise(); } } }) ); } }, { innerText: elt.content.name, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: elt.content.name}, on: { click: function(){ doExercise(); } } })); } }, { style: {width: "40px"}, render: function(tdElt){ var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_horiz" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { getMenuProps: function(){ var quickMenuItems = []; quickMenuItems.push({ text: "Làm bài tập", extendClasses: "bsc-quickmenu", icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "visibility" }), cmd: function(){ doExercise(); } }); return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } } ]; data.push({ lesson: elt.content.lesson, topic: elt.content.topic, cells: cells }); }); data.sort(function(a, b){ if (a.lesson > b.lesson) return 1; if (a.lesson < b.lesson) return -1; if (a.topic > b.topic) return 1; if (a.topic < b.topic) return -1; return 0; }); var tableView = absol.buildDom({ tag: "dynamictable", props: { adapter: { data: { head: { rows: [] }, body: { rows: data } } } } }); tableView.attachSearchInput(inputsearchbox); return tableView; }; var filterFunc = function(){ theme.modalFormMobile({ title: LanguageModule.text("txt_filter"), bodycontent: DOMElement.div({ children: [ DOMElement.div({ attrs: { className: "card-mobile-label-form-edit-first" }, text: LanguageModule.text("txt_lesson") }), lessonCbb ] }) }); }; var commands = []; commands.push({ icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "filter_alt" }), cmd: function(){ filterFunc(); } }); commands.push({ icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "search" }), cmd: function(){ header.searchMode(true); } }); var inputsearchbox = absol.buildDom({ tag: 'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: LanguageModule.text("txt_search") } }); var header = absol.buildDom({ tag: 'headerbarwithsearch', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: LanguageModule.text("txt_exercise"), commands: commands }, data:{ searchInput: inputsearchbox }, on: { action: function(){ onclose(); }, command: function(event){ event.commandItem.cmd(); } } }); var container = absol._({ child: generateData() }); var singlePage = absol.buildDom({ tag: 'tabframe', child:[ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [container] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) }, function(err){console.log(err);}); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseMobileView var v66 = function(module, me) { return function (hrapi, content, div_element, onclose) { var commands = [{ icon: DOMElement.i({ attrs: { className: "mdi mdi-check-circle-outline" } }), cmd: function(){ var publishInfor; var drawSuccess = function(){ var doagain = function() { if (t_content) viewer.setData(t_content); else viewer.setData([]); } var closeSuccess = function(){ frameList.removeLast(); onclose(content); } me.exerciseSuccess(hrapi, {sections: content.content, result: viewer.getResult()}, div_element, doagain, closeSuccess); } if (div_element.dict.exercise_publishment_information[content.key]) { publishInfor = div_element.dict.exercise_publishment_information[content.key][content.currentEmpId]; //drawSuccess(); } if (!publishInfor) { var score = 0 var correct = 0; var incorrect = 0; var unmake = 0; var sum = 0; var rs = {sections: content.content, result: viewer.getResult()}; rs.sections[0].questions.forEach((item, i) => { sum += item.score; if (!rs.result[item.ident]) { unmake++; } else if (!rs.result[item.ident].value) { unmake++; } else { if (item.type == "checkboxes") { item.correct_answer.sort(function(a, b){ return a - b; }); var t_value = rs.result[item.ident].value.map(function(elt){ return elt.idx; }); t_value.sort(function(a, b){ return a - b; }); if (EncodingClass.string.compare(item.correct_answer, t_value) == 0) { correct++; score += item.score; } else incorrect++; } else { if (item.correct_answer == rs.result[item.ident].value.idx) { correct++; score += item.score; } else incorrect++; } } }); if (score == sum) { if (!div_element.dict.exercise_publishment_information[content.key]) { div_element.dict.exercise_publishment_information[content.key] = {}; } var t_key = (new Date()).getTime(); var rs1 = { exerciseKey: content.key, employeeid: content.currentEmpId }; div_element.dict.exercise_publishment_information[content.key][content.currentEmpId] = { key: t_key, content: rs1 }; hrapi.table.update("exercise_publishment_information", t_key, rs1, (s, r) => { if (!s){ console.log(s, r); return; } drawSuccess(); }); } else { drawSuccess(); } } else { drawSuccess(); } } }]; var header = absol.buildDom({ tag: 'mheaderbar', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: content.name, commands: commands }, on: { action: function(){ frameList.removeLast(); onclose(content); }, command: function(event){ event.commandItem.cmd(); } } }); var PoserViewer = absol.poser.PoserViewer; var viewer = new PoserViewer( { hasScroller: false, hasSection: false } ); var mPoserView = viewer.getView(); var t_content; if (content.content) { t_content = EncodingClass.string.duplicate(content.content); t_content[0].questions.forEach((item, i) => { delete item.correct_answer; }); viewer.setData(t_content); } else viewer.setData([]); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: 'tabframe', child:[ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [ absol.buildDom({ style: { fontWeight: "bold", paddingBottom: "10px" }, child: {text: content.name} }), mPoserView ] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseReport var v193 = function(module, me) { return function (hrapi, div_element, onclose) { ModalElement.show_loading(); var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("lesson", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("topics", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise_publishment_information", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }) ]; Promise.all(createDB).then(function(){ var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("lesson", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.table.select("topics", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.table.select("exercise", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.table.select("exercise_publishment_information", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.firstid] = orgContent; orgContent.employees.forEach((item, i) => { item.orgName = orgContent.name; employees.push(item); }); // employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); rs({ orgs: retval, employees: employees, orgDict: orgDict }); }); }); }), ]; Promise.all(loadDB).then(function(rs){ ModalElement.close(-1); var database = { lesson: rs[0], topics: rs[1], exercise: rs[2], isAdmin: rs[3], currentEmp: rs[4], exercise_publishment_information: rs[5], orgs: rs[6].orgs, employees: rs[6].employees, orgDict: rs[6].orgDict }; var lessonItems = database.lesson.map(function(elt){ return { value: elt.key, text: elt.content.name }; }); lessonItems.unshift({value: "all", text: "Tất cả"}); var lessonCbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: lessonItems }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); var t_data = {}; var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var cur = { value: -item.firstid, text: item.name }; var items = []; if (item.children) items = items.concat(getEmployeeItems(item.children)); if (item.employees) item.employees.forEach((item2) => { t_data[item2.firstid] = {}; // if (item2.available) items.push({ items.push({ value: item2.firstid, text: item2.fullname, isLeaf: true }); }); cur.items = items; data.push(cur); }); return data; }; var empItems = getEmployeeItems(database.orgs); var empSelect = absol._({ tag: "multichecktreemenu", props: { items: empItems, values: [], enableSearch: true }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); var dict = { lesson: {}, topics: {}, exercise_publishment_information: {}, employees: {} }; database.employees.forEach((item, i) => { dict.employees[item.firstid] = item; }); var empByLesson = {}; database.lesson.forEach((item, i) => { if (!empByLesson[item.key]) empByLesson[item.key] = []; var getEmpView = function(orgs){ orgs.employees.forEach((item2, i2) => { t_data[item2.firstid][item.key] = {count: 0, success: 0}; empByLesson[item.key].push(item2.firstid); }); orgs.children.forEach((item2, i2) => { getEmpView(item2); }); }; item.content.viewPriv.forEach((item2, i2) => { if (item2 > 0) { t_data[item2][item.key] = {count: 0, success: 0}; empByLesson[item.key].push(item2); } else { getEmpView(database.orgDict[-item2]); } }); dict.lesson[item.key] = item.content; }); database.topics.forEach((item, i) => { if (item.content) dict.topics[item.key] = item.content; }); database.exercise_publishment_information.forEach((item, i) => { if (!dict.exercise_publishment_information[item.content.exerciseKey]) dict.exercise_publishment_information[item.content.exerciseKey] = {}; dict.exercise_publishment_information[item.content.exerciseKey][item.content.employeeid] = item; }); database.exercise.forEach(function(elt){ if (lessonCbb.value != "all" && elt.content.lesson != lessonCbb.value) return; if (!dict.lesson[elt.content.lesson]) return; if (!dict.topics[elt.content.topic]) return; var publishInfor = dict.exercise_publishment_information[elt.key]; empByLesson[elt.content.lesson].forEach((item, i) => { t_data[item][elt.content.lesson].count++; if (publishInfor) { if (publishInfor[item]) t_data[item][elt.content.lesson].success++; } }); }); div_element.dict = dict; var generateData = function(){ var getEmpView = function(orgs){ orgs.employees.forEach((item2, i2) => { empList.push(item2.firstid); }); orgs.children.forEach((item2, i2) => { getEmpView(item2); }); }; var empList = []; empSelect.values.forEach((item2, i2) => { if (item2 > 0) { empList.push(item2); } else { getEmpView(database.orgDict[-item2]); } }); var lesson = lessonCbb.value; data = []; var keys = Object.keys(t_data); keys.forEach((item, i) => { if (empList.indexOf(parseInt(item, 10)) != -1) { var keys2 = Object.keys(t_data[item]); keys2.forEach((item2, i2) => { if (lesson == item2 || lesson== "all"){ var cells = [ { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: dict.employees[item].fullname} })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: dict.employees[item].orgName} })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: dict.lesson[item2].name}, })); } }, { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: t_data[item][item2].success + ""} })); } }, { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: t_data[item][item2].count + ""} })); } }, { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: t_data[item][item2].count > 0 ? (t_data[item][item2].success * 100 / t_data[item][item2].count).toFixed(2) + "%" : "---"} })); } } ]; data.push({ employeeName: absol.string.nonAccentVietnamese(dict.employees[item].fullname).toLowerCase(), lessonName: absol.string.nonAccentVietnamese(dict.lesson[item2].name).toLowerCase(), cells: cells }); } }); } }); data.sort(function(a, b){ if (a.employeeName > b.employeeName) return 1; if (a.employeeName < b.employeeName) return -1; if (a.lessonName > b.lessonName) return 1; if (a.lessonName < b.lessonName) return -1; return 0; }); var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: [ { child: {text: "Nhân viên"} }, { child: {text: "Bộ phận"} }, { child: {text: "Tên giáo trình"} }, { child: {text: "Đã thực hiện"} }, { child: {text: "Tổng bài tập"} }, { child: {text: "Tỷ lệ"} } ] } ] }, body: { rows: data } } } } }); tableView.attachSearchInput(inputsearchbox); return tableView; }; var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: "Tìm kiếm..." } }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); div_element.addChild(frameList); var container = absol._({ child: generateData() }); var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: empSelect }, { class: "single-button-header", child: lessonCbb }, { class: "single-button-header", child: inputsearchbox } ] } }, container ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) }, function(err){console.log(err);}); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseSuccess var v52 = function(module, me) { return function (hrapi, content, div_element, doagain, onclose) { var score = 0 var correct = 0; var incorrect = 0; var unmake = 0; var sum = 0; content.sections[0].questions.forEach((item, i) => { sum += item.score; if (!content.result[item.ident]) { unmake++; } else if (!content.result[item.ident].value) { unmake++; } else { if (item.type == "checkboxes") { item.correct_answer.sort(function(a, b){ return a - b; }); var t_value = content.result[item.ident].value.map(function(elt){ return elt.idx; }); t_value.sort(function(a, b){ return a - b; }); if (EncodingClass.string.compare(item.correct_answer, t_value) == 0) { correct++; score += item.score; } else incorrect++; } else { if (item.correct_answer == content.result[item.ident].value.idx) { correct++; score += item.score; } else incorrect++; } } }); var t = { total: content.sections[0].questions.length, arcs: [ { name: correct + " Trả lời đúng", value: correct, color: "#629c44"}, { name: incorrect + " Trả lòi sai", value: incorrect, color: "#e61610"}, { name: unmake + " Không trả lời", value: unmake, color: "#f4eb49"} ] }; var chart = absol._({ tag: 'tinycirclechart', style: { width: '250px', height: '100px' }, props: t }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); var doAgainBtn = me.noneIconButton({ text: "Làm lại", onclick: function(){ frameList.removeLast(); doagain(); } }); var PoserEvaluation = absol.poser.PoserEvaluation; var viewer = new PoserEvaluation( { hasScroller: false, hasSection: false, readOnly: true } ); var mPoserView = viewer.getView(); if (content) viewer.setData(content); else viewer.setData({}); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: doAgainBtn } ] } }, { style: { paddingLeft: "10px", userSelect: "none" }, child: [ { style: { borderRadius: "5px", border: "var(--control-border)", boxShadow: "2px 2px 6px 0px #7f7f7f", display: "inline-block", paddingTop: "var(--control-verticle-distance-2)", paddingBottom: "var(--control-verticle-distance-2)", paddingLeft: "20px", paddingRight: "20px" }, child: [ { style: { fontWeight: "bold", display: "inline-block", verticalAlign: "middle" }, child: {text: "Kết quả: " + score + " / " + sum} }, { style: { paddingLeft: "20px", display: "inline-block", verticalAlign: "middle" }, child: chart } ] }, { style: { paddingTop: "20px" }, child: mPoserView } ] } ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseTable var v36 = function(module, me) { return function (hrapi, div_element, onclose) { var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("lesson", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("topics", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise_publishment_information", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(r) return; } rs() }); }) ]; Promise.all(createDB).then(function(){ var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("lesson", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.table.select("topics", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.table.select("exercise", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.table.select("exercise_publishment_information", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }) ]; Promise.all(loadDB).then(function(rs){ var database = { lesson: rs[0], topics: rs[1], exercise: rs[2], isAdmin: rs[3], currentEmp: rs[4], exercise_publishment_information: rs[5] }; var lessonItems = database.lesson.map(function(elt){ return { value: elt.key, text: elt.content.name }; }); lessonItems.unshift({value: "all", text: "Tất cả"}); var lessonCbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: lessonItems }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); var dict = { lesson: {}, topics: {}, exercise_publishment_information: {} }; database.lesson.forEach((item, i) => { dict.lesson[item.key] = item.content; }); database.topics.forEach((item, i) => { if (item.content) dict.topics[item.key] = item.content; }); database.exercise_publishment_information.forEach((item, i) => { if (!dict.exercise_publishment_information[item.content.exerciseKey]) dict.exercise_publishment_information[item.content.exerciseKey] = {}; dict.exercise_publishment_information[item.content.exerciseKey][item.content.employeeid] = item; }); div_element.dict = dict; var generateData = function(){ var data = []; database.exercise.forEach(function(elt){ if (lessonCbb.value != "all" && elt.content.lesson != lessonCbb.value) return; if (!dict.lesson[elt.content.lesson]) return; if (!dict.topics[elt.content.topic]) return; var publishInfor = dict.exercise_publishment_information[elt.key]; var click = 0; var success = false; if (publishInfor) { click = Object.keys(publishInfor).length; if (publishInfor[database.currentEmp.firstid]) success = true; } var doExercise = function(exerciseContent){ return function(){ var onclose = function(value){ for (var i = 0; i < database.exercise.length; i++){ if (database.exercise[i].key == value.key){ database.exercise[i].content = value; } } div_element.name = "Bài tập"; container.clearChild(); container.addChild(generateData()); }; exerciseContent.content.key = exerciseContent.key; exerciseContent.content.currentEmpId = database.currentEmp.firstid; me.exerciseView(hrapi, exerciseContent.content, div_element, onclose); } }(elt); var cells = [ { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild( absol._({ tag: "span", class: ["as-dt-row-index", 'hr-table-cell-link'], on: { click: function(){ doExercise(); } } }) ); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: elt.content.name}, on: { click: function(){ doExercise(); } } })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: dict.lesson[elt.content.lesson].name}, on: { click: function(){ doExercise(); } } })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: dict.topics[elt.content.topic].name}, on: { click: function(){ doExercise(); } } })); } }, { style: {textAlign: "center"}, render: function(elt){ return function(tdElt){ tdElt.addChild(absol._({ tag: "switch", style: { fontSize: "var(--switch-fontsize)" }, props: { disabled: true, checked: success } })); } }(elt) }, { style: {textAlign: "center"}, render: function(elt){ return function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: click} })); } }(elt) }, { style: {width: "40px"}, render: function(tdElt){ var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_vert" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { getMenuProps: function(){ var quickMenuItems = []; quickMenuItems.push({ text: "Làm bài tập", extendClasses: "bsc-quickmenu", icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "visibility" }), cmd: function(){ doExercise(); } }); quickMenuItems.push({ text: "Sửa", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "edit" }), cmd: function(exerciseContent){ return function(){ var onsave = function(value){ for (var i = 0; i < database.exercise.length; i++){ if (database.exercise[i].key == value.key){ database.exercise[i].content = value; } } container.clearChild(); container.addChild(generateData()); }; var onabort = function(rs){ div_element.name = "Bài tập"; console.log(rs); }; exerciseContent.content.key = exerciseContent.key; me.exerciseEdit(hrapi, exerciseContent.content, div_element, onsave, onabort); } }(elt) }); return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } } ]; data.push({ lesson: elt.content.lesson, topic: elt.content.topic, cells: cells }); }); data.sort(function(a, b){ if (a.lesson > b.lesson) return 1; if (a.lesson < b.lesson) return -1; if (a.topic > b.topic) return 1; if (a.topic < b.topic) return -1; return 0; }); var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Bài học"} }, { child: {text: "Topic"} }, { child: {text: "Đã thực hiện"} }, { child: {text: "Số lần thực hiện"} }, {} ] } ] }, body: { rows: data } } } } }); tableView.attachSearchInput(inputsearchbox); return tableView; }; var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: "Tìm kiếm..." } }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); div_element.addChild(frameList); var container = absol._({ child: generateData() }); var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: lessonCbb }, { class: "single-button-header", child: inputsearchbox } ] } }, container ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) }, function(err){console.log(err);}); } } (module, retval); // function: hrplugins.keeview.e_learning.exerciseView var v53 = function(module, me) { return function (hrapi, content, div_element, onclose) { div_element.name = content.name; var closeBtn = me.noneIconButton({ text: "Quay lại", onclick: function(){ frameList.removeLast(); onclose(content); } }); var doAgainBtn = me.noneIconButton({ text: "Hoàn thành", onclick: function(){ var publishInfor; var drawSuccess = function(){ var doagain = function() { if (t_content) viewer.setData(t_content); else viewer.setData([]); } var closeSuccess = function(){ frameList.removeLast(); onclose(content); } me.exerciseSuccess(hrapi, {sections: content.content, result: viewer.getResult()}, div_element, doagain, closeSuccess); } if (div_element.dict.exercise_publishment_information[content.key]) { publishInfor = div_element.dict.exercise_publishment_information[content.key][content.currentEmpId]; //drawSuccess(); } if (!publishInfor) { var score = 0 var correct = 0; var incorrect = 0; var unmake = 0; var sum = 0; var rs = {sections: content.content, result: viewer.getResult()}; rs.sections[0].questions.forEach((item, i) => { sum += item.score; if (!rs.result[item.ident]) { unmake++; } else if (!rs.result[item.ident].value) { unmake++; } else { if (item.type == "checkboxes") { item.correct_answer.sort(function(a, b){ return a - b; }); var t_value = rs.result[item.ident].value.map(function(elt){ return elt.idx; }); t_value.sort(function(a, b){ return a - b; }); if (EncodingClass.string.compare(item.correct_answer, t_value) == 0) { correct++; score += item.score; } else incorrect++; } else { if (item.correct_answer == rs.result[item.ident].value.idx) { correct++; score += item.score; } else incorrect++; } } }); if (score == sum) { if (!div_element.dict.exercise_publishment_information[content.key]) { div_element.dict.exercise_publishment_information[content.key] = {}; } var t_key = (new Date()).getTime(); var rs1 = { exerciseKey: content.key, employeeid: content.currentEmpId }; div_element.dict.exercise_publishment_information[content.key][content.currentEmpId] = { key: t_key, content: rs1 }; hrapi.table.update("exercise_publishment_information", t_key, rs1, (s, r) => { if (!s){ console.log(s, r); return; } drawSuccess(); }); } else { drawSuccess(); } } else { drawSuccess(); } } }); var PoserViewer = absol.poser.PoserViewer; var viewer = new PoserViewer( { hasScroller: false, hasSection: false } ); var mPoserView = viewer.getView(); var t_content; if (content.content) { t_content = EncodingClass.string.duplicate(content.content); t_content[0].questions.forEach((item, i) => { delete item.correct_answer; }); viewer.setData(t_content); } else viewer.setData([]); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: doAgainBtn } ] } }, { style: { paddingLeft: "10px", userSelect: "none" }, child: [ { style: { fontWeight: "bold", paddingBottom: "10px" }, child: {text: content.name} }, mPoserView ] } ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.e_learning.exportLessonData var v171 = function(module, me) { return function (hrapi, content) { ModalElement.show_loading(); var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("lesson", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(); } else { var items = []; for (var i = 0; i < value.length; i++){ if (value[i].key == content.key) { value[i].content.editPriv = []; value[i].content.viewPriv = []; value[i].content.group = "general_group"; delete value[i].content.lastmodified; delete value[i].content.lastmodifiedtime; items.push(value[i]); break; } } rs(items); } }) }), new Promise(function(rs, rj){ hrapi.table.select("topics", (s, value) => { if (s) { var items = []; for (var i = 0; i < value.length; i++){ if (value[i].content.lesson == content.key) { value[i].content.success = []; value[i].content.click = 0; delete value[i].content.lastmodified; delete value[i].content.lastmodifiedtime; items.push(value[i]); } } rs(items); } else rj(); }); }), new Promise(function(rs, rj){ hrapi.table.select("exercise", (s, value) => { if (s) { var items = []; for (var i = 0; i < value.length; i++){ if (value[i].content.lesson == content.key) { value[i].content.success = []; value[i].content.click = 0; delete value[i].content.lastmodified; delete value[i].content.lastmodifiedtime; delete value[i].content.currentEmpId; items.push(value[i]); } } rs(items); } else rj(); }); }) ]; Promise.all(loadDB).then(function(retval){ ModalElement.close(-1); var data = { lesson: retval[0], topics: retval[1], exercise: retval[2] }; console.log(data); let dataStr = JSON.stringify(data); let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr); let exportFileDefaultName = 'data.json'; let linkElement = document.createElement('a'); linkElement.setAttribute('href', dataUri); linkElement.setAttribute('download', exportFileDefaultName); linkElement.click(); },function(err){console.log(err)}) } } (module, retval); // function: hrplugins.keeview.e_learning.getDateTimeView var v43 = function(module, me) { return function (timesend) { if (!timesend) return ""; var res = ""; var month, day, year, hour, minute; month = timesend.getMonth() + 1; day = timesend.getDate(); year = timesend.getFullYear(); hour = timesend.getHours(); minute = timesend.getMinutes(); if (month < 10) { month = "0" + month; } if (day < 10) { day = "0" + day; } if (hour < 10) { hour = "0" + hour; } if (minute < 10) { minute = "0" + minute; } res += day + "/"; res += month + "/"; res += year; res += " " + hour + ":"; res += minute; return res; } } (module, retval); // function: hrplugins.keeview.e_learning.getDateTimeView2 var v139 = function(module, me) { return function (timesend) { if (!timesend) return ""; var res = ""; var month, day, year, hour, minute; month = timesend.getMonth() + 1; day = timesend.getDate(); year = timesend.getFullYear(); hour = timesend.getHours(); minute = timesend.getMinutes(); if (month < 10) { month = "0" + month; } if (day < 10) { day = "0" + day; } if (hour < 10) { hour = "0" + hour; } if (minute < 10) { minute = "0" + minute; } res += hour + ":"; res += minute; res += " " + day + "/"; res += month + "/"; res += year; return res; } } (module, retval); // function: hrplugins.keeview.e_learning.getTimeViewFromDateTime var v138 = function(module, me) { return function (timesend) { if (!timesend) return ""; var res = ""; var hour, minute; hour = timesend.getHours(); minute = timesend.getMinutes(); if (hour < 10) { hour = "0" + hour; } if (minute < 10) { minute = "0" + minute; } res += hour + ":"; res += minute; return res; } } (module, retval); // function: hrplugins.keeview.e_learning.getTopicItems var v62 = function(module, me) { return function (topics, lesson) { var getNode = function(index){ var items = [], ni; for (var i = 0; i < topics[index].childrenIndex.length; i++){ ni = topics[index].childrenIndex[i]; if (lesson) { if (topics[ni].key == lesson) continue; } items.push(getNode(ni)); } items.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); items.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); return { text: topics[index].name, value: topics[index].key, items: items, tIndex: index, idx: topics[index].idx }; }; var treeNodes = []; for (var i = 0; i < topics.length; i++){ if (lesson) { if (topics[i].key == lesson) continue; } if (topics[i].parent != "root") continue; treeNodes.push(getNode(i)); } treeNodes.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); treeNodes.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); return treeNodes; } } (module, retval); // function: hrplugins.keeview.e_learning.groupCategory var v44 = function(module, me) { return function (hrapi, div_element, onsuccess) { hrapi.table.create("lesson_category", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } hrapi.table.select("lesson_category", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); console.log(value); return; } var holderForSort = value.map(function(item){ item.content.key = item.key; return { item: item.content, val: absol.string.nonAccentVietnamese(item.content.name.toLowerCase()) } }); holderForSort.sort(function(a, b){ if (a.val < b.val) return -1; if (a.val > b.val) return 1; return 0; }); var lesson_category = holderForSort.map(function(holder){ return holder.item; }); lesson_category.unshift({ key: "general_group", name: "Nhóm chung", comment: "", active: true }); var redrawTableFunc = function(){ var data = []; var makeRow = function(elt){ var cells = [{ style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(DOMElement.span({attrs: {className: "as-dt-row-index"}})); } }]; cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: elt.name} })); } }); cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: elt.comment} })); } }); cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: elt.active, disabled: elt.key == "general_group" } })); } }); if (elt.key != "general_group"){ cells.push({ style: {width: "40px"}, render: function(tdElt){ var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_vert" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { getMenuProps: function(){ var quickMenuItems = []; quickMenuItems.push({ text: "Xem", extendClasses: "bsc-quickmenu", icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "visibility" }), cmd: function(content){ return function(){ tDiv.emit("onEdit", content); } }(elt) }); quickMenuItems.push({ text: "Xóa", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "delete" }), cmd: function(key){ return function(){ me.deleteConfirm() hrapi.table.delete("lesson_category", key, function(){ var x = tableView.rowOf(row) x.remove(); }); }; }(elt.key) }); return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } }); } else cells.push({}); var row = { cells: cells } return row; } var row; for (var i = 0; i < lesson_category.length; i++) { row = makeRow(lesson_category[i]); data.push(row); } var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Mô tả"} }, { child: {text: "Hoạt động"} }, {} ] } ] }, body: { rows: data } } } } }); var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: "Tìm kiếm..." } }); tableView.attachSearchInput(inputsearchbox); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ tDiv.emit("onClose"); } }); var addBtn = me.noneIconButton({ text: "Thêm", onclick: function(){ tDiv.emit("onAdd"); } }); var tDiv = absol._({ child: [ { class: "absol-single-page-header", child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: addBtn } ] } }, tableView ] }); absol.OOP.extends(tDiv, absol.EventEmitter.prototype); absol.EventEmitter.call(tDiv); tDiv.defineEvent('onClose'); tDiv.defineEvent('onAdd'); tDiv.defineEvent('onEdit'); div_element.lessonGroupContent = tDiv; div_element.appendChild(tDiv); onsuccess(); }; redrawTableFunc(); }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.groupCategoryEdit var v45 = function(module, me) { return function (hrapi, content, div_element, onsave, onabort) { var name = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.name ? content.name : "" } }); var comment = absol._({ tag: "textarea", class: "cardSimpleTextarea", style: { width: "400px" }, props: { value: content.comment ? content.comment : "" } }); var active = absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: content.active !== undefined ? content.active : true } }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ // div_element.clearChild(); onabort("close"); } }); var saveFunc = function() { var value = { name: name.value.trim(), comment: comment.value.trim(), active: active.checked } if (value.name == "") { ModalElement.alert({ message: "Chưa nhập tên", func: function(){ name.focus(); } }) return; } var key; if (content.key) key = content.key; else key = (new Date()).getTime(); ModalElement.show_loading(); hrapi.table.update("lesson_category", key, value, (s,r) => { ModalElement.close(-1); if (s) onsave(r); else onabort(r); }); }; var saveBtn = me.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var tDiv = absol._({ child: [ { class: "absol-single-page-header", child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn } ] } }, DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {paddingLeft: "10px"}}, children: [name] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Mô tả"}, { attrs: {style: {paddingLeft: "10px"}}, children: [comment] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {paddingLeft: "10px"}}, children: [active] } ] ] }) ] }); div_element.addChild(tDiv); } } (module, retval); // function: hrplugins.keeview.e_learning.importLessonData var v172 = function(module, me) { return function (hrapi) { return new Promise(function(resolve, reject){ var importFunc = function(content){ ModalElement.show_loading(); console.log(content); // return; var firstid; var run6 = function(elt){ return new Promise(function(rs, rj){ elt.content.creator = firstid; elt.content.createdtime = new Date(elt.content.createdtime); hrapi.table.update("exercise", elt.key, elt.content, function(s, r){ if (s) { rs(); } else rj(["exercise", r]); }); }); } var run5 = function(idx){ if (idx < content.exercise.length) { run6(content.exercise[idx]).then(function(){ run5(idx+1); }, function(err){ content.exercise.forEach(function(elt){ hrapi.table.delete("exercise", elt.key, function(s, r){ }); }); reject(err); }) } else { ModalElement.close(-1); var data = content.lesson[0].content; data.key = content.lesson[0].key; ModalElement.alert({message: "success", func: function(){resolve(data)}}); } } var run4 = function(elt){ return new Promise(function(rs, rj){ elt.content.author = firstid; elt.content.creator = firstid; elt.content.editor = firstid; elt.content.createdtime = new Date(elt.content.createdtime); hrapi.table.update("topics", elt.key, elt.content, function(s, r){ if (s) { rs(); } else rj(["topics", r]); }); }); } var run3 = function(idx){ if (idx < content.topics.length) { run4(content.topics[idx]).then(function(){ run3(idx+1); }, function(err){ content.topics.forEach(function(elt){ hrapi.table.delete("topics", elt.key, function(s, r){ }); }); reject(err); }) } else { run5(0); } } var run2 = function(elt){ return new Promise(function(rs, rj){ elt.content.creator = firstid; elt.content.createdtime = new Date(elt.content.createdtime); hrapi.table.update("lesson", elt.key, elt.content, function(s, r){ if (s) rs() else rj(["lesson", r]); }); }); } var run = function(idx){ if (idx < content.lesson.length) { run2(content.lesson[idx]).then(function(){ run(idx+1); }, function(err){ content.lesson.forEach(function(elt){ hrapi.table.delete("lesson", elt.key, function(s, r){ }); }); reject(err); }) } else run3(0); } // run(0); hrapi.table.create("lesson", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); reject(r); return; } hrapi.table.create("topics", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); reject(r); return; } hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); reject(r); return; } hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); reject(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); reject(currentEmp); return; } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); reject(currentEmp); return; } firstid = currentEmp.firstid; run(0); }); }); }) }) }) }; var selector = absol._({ tag: "input", props: {type: "file", accept: ".json"}, on: { change: function(event){ var file = event.target.files[0]; const reader = new FileReader(); reader.addEventListener('load', (event) => { var content = event.target.result; var intern = JSON.parse(content); importFunc(intern); }); reader.readAsText(file); } } }); selector.click(); }) } } (module, retval); // function: hrplugins.keeview.e_learning.lessonConfig var v54 = function(module, me) { return function (hrapi, content, div_element, onsave, onabort) { var generateData = function(orgs, currentEmp, lesson_category) { var nav = absol.buildDom({ tag:'mknavigator', style: { display:'inline-block'// or 'block' }, props: { items: [ {text: "Thông tin chung", value: "general_information"}, {text: "Phân quyền", value: "privilege"}, {text: "Tùy chọn", value: "option"} ], value: "general_information" }, on:{ press: function(event){ rightCtn.off('scroll',scrollRightFunc);// prevent loop if (sectionList[this.value]) sectionList[this.value].scrollIntoView(); setTimeout(function(){ rightCtn.on('scroll',scrollRightFunc ); }, 10); } } }); var scrollRightFunc = function(){ var elt; var bound = rightCtn.getBoundingClientRect(); var eltBound; var nearestEltId; var nearestDistance = 100000000; var distance; for (var i in sectionList){ elt = sectionList[i]; eltBound = elt.getBoundingClientRect(); distance = 1000000; if (eltBound.top <= bound.top){ if (eltBound.bottom >= bound.bottom){ distance = -1e6; } else if (bound.top - eltBound.top < 30){ distance = eltBound.top - bound.bottom;//negative } else if (eltBound.bottom > bound.top){ distance = bound.top - eltBound.top; } } else if (eltBound.top < bound.bottom){ distance = eltBound.top - bound.bottom;//negative } else { distance = Math.abs(bound.top - eltBound.top) } if (nearestDistance > distance){ nearestDistance = distance; nearestEltId = i; } } nav.value = nearestEltId; }; var rightChild = []; var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); if(onabort) onabort(); } }); var saveFunc = function() { var value = { name: name.value.trim(), comment: comment.value.trim(), group: group.value, active: active.checked, editPriv: editPriv.values, viewPriv: viewPriv.values, topicConfig: { display_creator: displayCreator.checked, display_createdtime: displayCreatedTime.checked, display_modifieder: displayModifieder.checked, display_modifiedtime: displayModifiedTime.checked, display_click: displayClick.checked }, exerciseConfig: { display_creator: e_displayCreator.checked, display_createdtime: e_displayCreatedTime.checked, display_modifieder: e_displayModifieder.checked, display_modifiedtime: e_displayModifiedTime.checked, display_click: e_displayClick.checked } }; if (value.name == "") { ModalElement.alert({ message: "Chưa nhập tên", func: function(){ name.focus(); } }); return; } var key; if (!content.key) { key = (new Date()).getTime(); value.creator = currentEmp.firstid; value.createdtime = new Date(); value.count = 0; content.key = key; } else { key = content.key; value.lastmodified = currentEmp.firstid; value.lastmodifiedtime = new Date(); value.creator = content.creator; value.createdtime = content.createdtime; value.count = content.count === undefined ? content.count : 0; } ModalElement.show_loading(); hrapi.table.update("lesson", key, value, function(s, r){ ModalElement.close(-1); if (s) if(onsave) { value.key = key; onsave(value); } else if(onabort) onabort(r); }); }; var saveBtn = me.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc() } }); var name = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.name ? content.name : "" } }); var groupItems = lesson_category.map(function(elt){ return {value: elt.key, text: elt.content.name}; }); var group = absol._({ tag: "selectmenu", props: { items: groupItems, value: content.groupKey ? content.groupKey : "general_group" } }) var comment = absol._({ tag: "textarea", class: "cardSimpleTextarea", style: { width: "400px" }, props: { value: content.comment ? content.comment : "" } }); var active = absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: content.active !== undefined ? content.active : true } }); rightChild.push({ attr: { "data-sectionid": "general_information" }, child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Thông tin chung" }, } ] }, { style: { paddingLeft: "10px" }, child: DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {paddingLeft: "10px"}}, children: [name] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Nhóm"}, { attrs: {style: {paddingLeft: "10px"}}, children: [group] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Mô tả"}, { attrs: {style: {paddingLeft: "10px"}}, children: [comment] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {paddingLeft: "10px"}}, children: [active] } ] ] }) } ] }); var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var cur = { value: -item.firstid, text: item.name }; var items = []; if (item.children) items = items.concat(getEmployeeItems(item.children)); if (item.employees) item.employees.forEach((item2) => { // if (item2.available) items.push({ items.push({ value: item2.firstid, text: item2.fullname, isLeaf: true }); }); cur.items = items; data.push(cur); }); return data; }; var empItems = getEmployeeItems(orgs); var editPriv = absol._({ tag: "multichecktreeleafmenu", props: { items: empItems, values: content.editPriv ? content.editPriv : [], enableSearch: true } }); var viewPriv = absol._({ tag: "multichecktreemenu", props: { items: empItems, values: content.viewPriv ? content.viewPriv : [], enableSearch: true } }); rightChild.push({ attr: { "data-sectionid": "privilege" }, child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Phân quyền" }, } ] }, { style: { paddingLeft: "10px" }, child: [ { style: { fontWeight: "bold" }, child: {text: "Nhân viên nào được xem bài học này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: viewPriv } ] }, { style: { paddingTop: "10px", fontWeight: "bold" }, child: {text: "Nhân viên nào được sửa bài học này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: editPriv } ] } ] } ] }); var displayCreator = absol._({ tag: "checkbox", props: { checked: content.topicConfig !== undefined ? content.topicConfig.display_creator !== undefined ? content.topicConfig.display_creator == 1 : true : true } }); var displayCreatedTime = absol._({ tag: "checkbox", props: { checked: content.topicConfig !== undefined ? content.topicConfig.display_createdtime == 1 : false } }); var displayModifieder = absol._({ tag: "checkbox", props: { checked: content.topicConfig !== undefined ? content.topicConfig.display_modifieder == 1 : false } }); var displayModifiedTime = absol._({ tag: "checkbox", props: { checked: content.topicConfig !== undefined ? content.topicConfig.display_modifiedtime == 1 : false } }); var displayClick = absol._({ tag: "checkbox", props: { checked: content.topicConfig !== undefined ? content.topicConfig.display_click !== undefined ? content.topicConfig.display_click == 1 : true : true } }); var e_displayCreator = absol._({ tag: "checkbox", props: { checked: content.exerciseConfig !== undefined ? content.exerciseConfig.display_creator !== undefined ? content.exerciseConfig.display_creator == 1 : true : true } }); var e_displayCreatedTime = absol._({ tag: "checkbox", props: { checked: content.exerciseConfig !== undefined ? content.exerciseConfig.display_createdtime == 1 : false } }); var e_displayModifieder = absol._({ tag: "checkbox", props: { checked: content.exerciseConfig !== undefined ? content.exerciseConfig.display_modifieder == 1 : false } }); var e_displayModifiedTime = absol._({ tag: "checkbox", props: { checked: content.exerciseConfig !== undefined ? content.exerciseConfig.display_modifiedtime == 1 : false } }); var e_displayClick = absol._({ tag: "checkbox", props: { checked: content.exerciseConfig !== undefined ? content.exerciseConfig.display_click !== undefined ? content.exerciseConfig.display_click == 1 : true : true } }); rightChild.push({ attr: { "data-sectionid": "option" }, child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Tùy chọn" }, } ] }, { style: { paddingLeft: "10px" }, child: [ { child: [ { style: { fontWeight: "bold" }, child: {text: "Các tùy chọn của Topic"} }, { style: { paddingTop: "10px", paddingLeft: "10px" }, child: DOMElement.table({ data: [ [ {text: "Hiển thị người tạo"}, { attrs: {style: {paddingLeft: "10px"}}, children: [displayCreator] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị thời gian tạo"}, { attrs: {style: {paddingLeft: "10px"}}, children: [displayCreatedTime] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị người sửa lần cuối"}, { attrs: {style: {paddingLeft: "10px"}}, children: [displayModifieder] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị thời gian sửa lần cuối"}, { attrs: {style: {paddingLeft: "10px"}}, children: [displayModifiedTime] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị số lần click"}, { attrs: {style: {paddingLeft: "10px"}}, children: [displayClick] } ] ] }) } ] }, { style: { paddingTop: "10px" }, child: [ { style: { fontWeight: "bold" }, child: {text: "Các tùy chọn của Bài tập"} }, { style: { paddingTop: "10px", paddingLeft: "10px" }, child: DOMElement.table({ data: [ [ {text: "Hiển thị người tạo"}, { attrs: {style: {paddingLeft: "10px"}}, children: [e_displayCreator] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị thời gian tạo"}, { attrs: {style: {paddingLeft: "10px"}}, children: [e_displayCreatedTime] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị người sửa lần cuối"}, { attrs: {style: {paddingLeft: "10px"}}, children: [e_displayModifieder] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị thời gian sửa lần cuối"}, { attrs: {style: {paddingLeft: "10px"}}, children: [e_displayModifiedTime] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị số lần click"}, { attrs: {style: {paddingLeft: "10px"}}, children: [e_displayClick] } ] ] }) } ] } ] } ] }); var rightCtn = absol.buildDom({ class: 'mk-main-right', style: { paddingBottom: "var(--footer-margin)" }, child: rightChild, on: { scroll: scrollRightFunc } }); var data_ctn = absol._({ class: 'mk-main', style: { height: '100%' }, child: [ { class: 'mk-main-left-ctn', child: [nav] }, rightCtn ] }); var sectionList = {}; absol.$("div", rightCtn, function(elt){ var id = elt.getAttribute("data-sectionid"); if (!id) return; sectionList[id] = elt; }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn } ] } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); } hrapi.table.select("lesson_category", function(result, lesson_category){ if (!result) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); return; } hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); return; } if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); Promise.all(loadOrgs).then(function(retval){ lesson_category.unshift({key: "general_group", content: { name: "Nhóm chính", comment: "", active: true }}); generateData(retval, currentEmp, lesson_category); }, function(err){console.log(err);}); }); }); }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonContentMobileView var v71 = function(module, me) { return function (hrapi, params, div_element) { setTimeout(function(currentKey){ return function(){ if (currentKey != params.currentKey) return; params.topicDict[params.currentKey].click++; if (!params.topicDict[params.currentKey]) { ModalElement.alert({message: "Lỗi dữ liệu"}); return; }; hrapi.table.update("topics", params.currentKey, params.topicDict[params.currentKey], (s, r) => { if (s){ var topicInfor = ""; if (params.config.topicConfig) { if (params.config.topicConfig.display_click) { topicInfor += "Số lần click: " + content.click; } if (params.config.topicConfig.display_creator) { topicInfor += ",\tTác giả: " + getEmployeeName(content.creator); } if (params.config.topicConfig.display_createdtime) { topicInfor += ",\tNgày tạo: " + me.getDateTimeView(content.createdtime); } if (params.config.topicConfig.display_modifieder) { topicInfor += ",\tĐược sửa bởi: " + getEmployeeName(content.lastmodified); } if (params.config.topicConfig.display_modifiedtime) { topicInfor += ",\tNgày sửa: " + me.getDateTimeView(content.lastmodifiedtime); } } publishInfor.innerHTML = topicInfor; } else { console.log(s, r); } }); } }(params.currentKey), 5000); var content = params.topicDict[params.currentKey] !== undefined ? params.topicDict[params.currentKey] : {}; var tDiv = absol._({}); var topicInfor = ""; var getEmployeeName = function(id){ for (var i = 0; i < params.employees.length; i++) { if (params.employees[i].id == id) return params.employees[i].fullname; } return ""; }; if (params.config.topicConfig) { if (params.config.topicConfig.display_click) { topicInfor += "Số lần click: " + content.click; } if (params.config.topicConfig.display_creator) { topicInfor += ",\tTác giả: " + getEmployeeName(content.creator); } if (params.config.topicConfig.display_createdtime) { topicInfor += ",\tNgày tạo: " + me.getDateTimeView(content.createdtime); } if (params.config.topicConfig.display_modifieder) { topicInfor += ",\tĐược sửa bởi: " + getEmployeeName(content.lastmodified); } if (params.config.topicConfig.display_modifiedtime) { topicInfor += ",\tNgày sửa: " + me.getDateTimeView(content.lastmodifiedtime); } } var success = absol._({ tag: "checkbox", class: "right", props: { checked: content.success ? content.success.indexOf(params.currentEmpId) != -1 : false, text: "Hoàn thành" }, on: { change: function() { if (this.checked) { params.topicDict[params.currentKey].success.push(params.currentEmpId); } else { params.topicDict[params.currentKey].success = params.topicDict[params.currentKey].success.filter(function(elt){ return elt != params.currentEmpId; }); } if (!params.topicDict[params.currentKey]) { ModalElement.alert({message: "Lỗi dữ liệu"}); return; }; hrapi.table.update("topics", params.currentKey, params.topicDict[params.currentKey], (s, r) => { if (s){ params.dynamicLinks = {}; var t = params.getTreeList(params.topics, params.dynamicLinks); params.tree_list.nodes = t; params.tree_list.openAllNodeRecursive(2); } else { console.log(s, r); } }); } } }); var publishInfor = absol._({ style: { paddingTop: "var(--control-verticle-distance-2)" }, props: { innerHTML: topicInfor } }); tDiv.addChild(absol._({ child: [ success, publishInfor ] })); content.content[content.content.length - 1].data = me.repareViewDynamicLink(content.content[content.content.length - 1].data, params.dynamicLinks); var topicContent = absol._({ style: { fontSize: "16px" }, props: { innerHTML: content.content[content.content.length - 1].data } }); absol.$$("a.as-ck-widget-dynamic-link", topicContent).forEach((item, i) => { item.on("click", function(event){ event.preventDefault(); var key = item.attr("data-link-id"); params.currentKey = key; params.tree_list.activeNode(key); frameList.removeLast(); me.lessonContentMobileView(hrapi, params, div_element); }); }); tDiv.addChild(absol.buildDom({ child: [ { class: 'm-mk-section-header', child: [ { class: 'm-mk-section-header-name', child: { text: "Nội dung" }, } ] }, { child: topicContent } ] })); var eltList = []; var makeExerciseRow = function(item){ var t_name = absol._({ child: {text: params.exerciseDict[item].name} }); var row = absol._({ child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: { tag: "a", style: { color: "#1464f6", cursor: "pointer" }, child: t_name, on: { click: function(){ var onclose = function(){ // params.div_element.name = params.lessonContent.name; // params.rightCtn.clearChild(); // params.rightCtn.addChild(tDiv); }; params.exerciseDict[item].currentEmpId = params.currentEmpId; me.exerciseMobileView(hrapi, params.exerciseDict[item], div_element, onclose); } } } } ] }); return row; } if (params.exerciseOfTopic[content.key]) { params.exerciseOfTopic[content.key].forEach((item, i) => { var row = makeExerciseRow(item); eltList.push(row); }); } if (eltList.length > 0) { var data_ctn = absol._({ child: eltList }); tDiv.addChild(absol.buildDom({ child: [ { class: 'm-mk-section-header', child: [ { class: 'm-mk-section-header-name', child: { text: "Bài tập" } } ] }, { child: data_ctn } ] })); } var count = 0; var sum = 0; var thisRate; params.topicrate.forEach((item, i) => { if (item.content.topic == params.currentKey) { count++; sum += item.content.rate; if (item.content.employeeid == params.currentEmpId) { thisRate = item; } } }); var makeRate = function(rate){ var child = []; var classname; var color; var i = 1; while (i <= 5) { if (i <= rate) { classname = 'mdi-star'; color = "#0c59cf"; } else { classname = 'mdi-star-outline'; color = "#c0c0c0"; } child.push({ style: { fontSize: "var(--icon-fontsize)", color: color }, tag: "span", class:['mdi', classname], on: { click: function(rate){ return function(){ var isNew; if (thisRate) thisRate.content.rate = rate; else { isNew = true; thisRate = { key: (new Date()).getTime(), content: { topic: params.currentKey, employeeid: params.currentEmpId, rate: rate } } } hrapi.table.update("topicrate", thisRate.key, thisRate.content, (s, r) => { if (isNew) { params.topicrate.push(thisRate); } rateDiv.clearChild(); rateDiv.addChild(makeRate(thisRate.content.rate)); countDiv.clearChild(); averageDiv.clearChild(); var count = 0; var sum = 0; params.topicrate.forEach((item, i) => { if (item.content.topic == params.currentKey) { count++; sum += item.content.rate; } }); countDiv.addChild(absol._({child: {text: count}})); averageDiv.addChild(absol._({child: {text: (sum/count).toFixed(1)}})); }); } }(i) } }); i++; } var st = absol._({ child: child }); return st; } var rateDiv = absol._({ child: makeRate(thisRate ? thisRate.content.rate : 0) }); var countDiv = absol._({ child: {text: count} }); var averageDiv = absol._({ child: {text: count > 0 ? (sum/count).toFixed(1) : 0} }); tDiv.addChild(absol.buildDom({ child: [ { class: 'm-mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'm-mk-section-header-name', child: { text: "Đánh giá" } } ] }, { child: [ DOMElement.table({ data: [ [ { text: "Đánh giá nội dung bài học" }, { attrs: { style: { paddingLeft: "10px" } }, children: [rateDiv] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Số người đánh giá: " }, { attrs: { style: { paddingLeft: "10px" } }, children: [countDiv] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Điểm trung bình: " }, { attrs: { style: { paddingLeft: "10px" } }, children: [averageDiv] } ] ] }) ] } ] })); var makeBigTopicElt = function(topicid){ var st = absol._({ tag: "button", style: { minWidth: "120px", maxWidth: "300px", height: "70px", cursor: "pointer", backgroundColor: "#dfedd6", borderRadius: "5px", marginRight: "20px", marginBottom: "20px", border: "1px solid #d6d6d6", fontSize: "16px", verticalAlign: "middle" }, child: {text: params.topicDict[topicid].name}, on: { click: function(){ params.currentKey = topicid; params.tree_list.activeNode(topicid); frameList.removeLast(); me.lessonContentMobileView(hrapi, params, div_element); } } }); return st; } var t_child = []; params.topics.forEach((item, i) => { if (item.parent == "root"){ var elt = makeBigTopicElt(item.key); elt.idx = item.idx; t_child.push(elt); } }); t_child.sort(function(a, b){ return a.idx - b.idx; }); tDiv.addChild(absol.buildDom({ child: [ { class: 'm-mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'm-mk-section-header-name', child: { text: "Chuyên mục" } } ] }, { child: t_child } ] })); var showQuickMenu = function(){ var inputsearchboxM = absol.buildDom({ tag: 'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: LanguageModule.text("txt_search") } }); var tree_list = absol.buildDom({ tag: "toclist", style: { width: "100%", overflowY: 'auto' }, props: { nodes: params.tree_list.nodes, searchInput: inputsearchboxM }, on: { pressnode: function (event) { params.currentKey = event.nodeData.ident; params.tree_list.activeNode(event.nodeData.ident); frameList.removeLast(); frameList.removeLast(); me.lessonContentMobileView(hrapi, params, div_element); } } }); tree_list.activeNode(params.currentKey); tree_list.openAllNodeRecursive(2); var headerM = absol.buildDom({ tag: 'headerbarwithsearch', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: params.lessonContent.name, commands: [{ icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "search" }), cmd: function(){ headerM.searchMode(true); } }] }, data: { searchInput: inputsearchboxM }, on: { action: function(){ frameList.removeLast(); }, command: function(event){ event.commandItem.cmd(); } } }); var singlePageM = absol.buildDom({ tag: 'tabframe', child: [ headerM, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [ tree_list ] }) ] }); frameList.addChild(singlePageM); singlePageM.requestActive(); }; var commands = [{ icon: DOMElement.i({ attrs: { className: "mdi mdi-menu" } }), cmd: function(){ showQuickMenu(); } }]; var header = absol.buildDom({ tag: 'mheaderbar', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: content.name, commands: commands }, on: { action: function(){ frameList.removeLast(); }, command: function(event){ event.commandItem.cmd(); } } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: 'tabframe', child: [ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [ tDiv ] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonEdit var v50 = function(module, me) { return function (hrapi, content, div_element, onsave, onabort) { ModalElement.show_loading(); div_element.name = content.name; var lesson = content.key ? content.key : ""; var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs(); }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise_publishment_information", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs(); }); }) ]; Promise.all(createDB).then(function(rs){ var loadDB = [ new Promise(function(rs, rj){ hrapi.users.isAdmin(function(s, isAdmin){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else rs(isAdmin); }) }), new Promise(function(rs, rj){ hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else { hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); return; } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(); return; } rs(currentEmp); }) } }) }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); rj(); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); Promise.all(loadOrgs).then(function(retval){ rs(retval); }, function(err){console.log(err);}); }) }) ]; var onLoading = function(exercise, exerciseDict, retval) { ModalElement.close(-1); var leftCtn = absol.buildDom({ class: 'mk-main-left-ctn', style:{ display:'flex', 'flex-direction': 'column' } }); var rightCtn = absol.buildDom({ class: 'mk-main-right', style: { paddingBottom: "var(--footer-margin)" } }); var data_ctn = absol._({ class: 'mk-main', style: { height: "100%" }, child: [ leftCtn, rightCtn ] }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ div_element.name = "Bài học"; frameList.removeLast(); } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn } ] } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); var exerciseOfTopic = {}; exercise.forEach(function(elt){ if (!exerciseOfTopic[elt.topic]) exerciseOfTopic[elt.topic] = []; exerciseOfTopic[elt.topic].push(elt.key); }); var params = { lessonContent: content, orgs: retval[2], lesson: lesson, leftCtn: leftCtn, rightCtn: rightCtn, currentEmpId: retval[1].id, currentEmp: retval[1], exercise: exercise, exerciseDict: exerciseDict, frameList: frameList, div_element: div_element, exerciseOfTopic: exerciseOfTopic, isAdmin: retval[0] }; me.lessonLeftContentEdit(hrapi, params); } if (lesson != "") { loadDB.push(new Promise(function(rs, rj){ hrapi.table.select("exercise", (s, value) => { if (s) rs(value); else rj(); }); })), loadDB.push(new Promise(function(rs, rj){ hrapi.table.select("exercise_publishment_information", (s, value) => { if (s) rs(value); else rj(); }); })); Promise.all(loadDB).then(function(retval){ var t = []; var dict = {}; retval[3].forEach((item, i) => { if (item.content.lesson == lesson) { item.content.key = item.key; t.push(item.content); dict[item.key] = item.content; } }); exercise = t; div_element.dict = { exercise_publishment_information: {} }; retval[4].forEach((item, i) => { if (!div_element.dict.exercise_publishment_information[item.content.exerciseKey]) div_element.dict.exercise_publishment_information[item.content.exerciseKey] = {}; div_element.dict.exercise_publishment_information[item.content.exerciseKey][item.content.employeeid] = item; }); onLoading(exercise, dict, retval); }); } else { Promise.all(loadDB).then(function(retval){ var exercise = []; onLoading(exercise, {}, retval); }); } }) } } (module, retval); // function: hrplugins.keeview.e_learning.lessonLeftContentEdit var v49 = function(module, me) { return function (hrapi, params) { params.dynamicLinks = {}; var getTreeList = function(topics, dynamicLinks){ var getNode = function(index){ var items = [], ni; for (var i = 0; i < topics[index].childrenIndex.length; i++){ ni = topics[index].childrenIndex[i]; items.push(getNode(ni)); } items.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); items.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); dynamicLinks[topics[index].key] = { href: "#", text: topics[index].name }; return { name: topics[index].name, ident: topics[index].key, idx: topics[index].idx, checked: (topics[index].success) ? topics[index].success.indexOf(params.currentEmpId) != -1 : false, children: items, tIndex: index }; }; var treeNodes = []; for (var i = 0; i < topics.length; i++){ if (topics[i].parent != "root") continue; // topics[i].idx = idx++; if (!params.firstKey) params.firstKey = topics[i].key; treeNodes.push(getNode(i)); } treeNodes.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); treeNodes.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); return treeNodes; }; params.getTreeList = getTreeList; hrapi.table.create("topics", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } hrapi.table.select("topics", function(s, value){ var topics = []; var dict = {}; value.forEach((item, i) => { if (item.content){ if (item.content.lesson == params.lesson) { item.content.key = item.key; topics.push(item.content); item.content.childrenIndex = []; dict[item.key] = item.content; } } }); params.topicDict = dict; params.topics = topics; params.getTopicIndex = function(key){ for (var i = 0; i < params.topics.length; i++){ if (params.topics[i].key == key){ return i; } } return -1; } topics.forEach(function(elt, idx){ if (dict[elt.parent] !== undefined) dict[elt.parent].childrenIndex.push(idx); }); var tree_list = absol.buildDom({ tag: "toclist", style: { width: "400px", 'flex-grow': 1, overflowY: 'auto' }, props: { nodes: getTreeList(params.topics, params.dynamicLinks) }, on: { pressnode: function (event) { params.currentKey = event.nodeData.ident; params.tree_list.activeNode(event.nodeData.ident); me.lessonRightContentEdit(hrapi, params); }, pressnodequickmmenu: function (event) { var nodeController = event.controller; event.showMenu({ items: [ { text: 'Thêm bài viết', icon: 'span.mdi.mdi-add', value: "add"}, { text: 'Sửa bài viết', icon: 'span.mdi.mdi-edit', value: "edit"}, { text: "Xoá bài viết", icon: 'span.mdi.mdi-remove', value: "delete"}, { text: "Sao chép Topic", icon: 'span.mdi.mdi-remove', value: "copy"} ] }, function (item) { switch (item.value) { case "add": params.currentKey = ""; params.parent = event.nodeData.ident; var onsave = function(value){ params.currentKey = value.key; params.tree_list.activeNode(value.key); me.lessonRightContentEdit(hrapi, params); }; var onabort = function(rs){ console.log(rs); }; params.content = { parent: params.parent }; me.topicEdit(hrapi, params, onsave, onabort); break; case "edit": params.currentKey = event.nodeData.ident; params.tree_list.activeNode(event.nodeData.ident); var onsave = function(value){ me.lessonRightContentEdit(hrapi, params); }; var onabort = function(rs){ me.lessonRightContentEdit(hrapi, params); }; params.content = params.topicDict[params.currentKey]; me.topicEdit(hrapi, params, onsave, onabort); break; case "copy": var onsave = function(value){ params.currentKey = value.key; params.tree_list.activeNode(value.key); me.lessonRightContentEdit(hrapi, params); }; var onabort = function(rs){ console.log(rs); }; params.content = params.topicDict[event.nodeData.ident]; me.topicCopy(hrapi, params, onsave, onabort); break; case "delete": me.deleteConfirm("Xóa topic", "Toàn bộ dữ liệu của topic này và topic con sẽ bị xóa, bạn có muôn tiếp tục ?").then(function(){ var getRemoveList = function(content, list){ removeList.push(content.key); content.childrenIndex.forEach((item, i) => { getRemoveList(params.topics[item], list); }); }; var removeList = []; getRemoveList(params.topicDict[event.nodeData.ident], removeList); var promiseArray = []; removeList.forEach((item, i) => { promiseArray.push( new Promise(function(rs, rj){ hrapi.table.delete("topics", item, (s, r) => { params.topics = params.topics.filter(function(elt){ return elt.key != item; }); delete params.topicDict[item]; rs(); }); }) ); if (params.exerciseOfTopic[item]) { params.exerciseOfTopic[item].forEach(function(cur){ promiseArray.push( new Promise(function(rs, rj){ hrapi.table.delete("exercise", cur, (s, r) => { params.exercise = params.exercise.filter(function(elt){ return elt.key != cur; }); delete params.exerciseDict[cur]; rs(); }); }) ); }); delete params.exerciseOfTopic[item]; } }); Promise.all(promiseArray).then(function(){ params.topics.forEach(function(elt, idx){ elt.childrenIndex = []; }); params.topics.forEach(function(elt, idx){ if (params.topicDict[elt.parent] !== undefined) params.topicDict[elt.parent].childrenIndex.push(idx); }); params.dynamicLinks = {}; var t = getTreeList(params.topics, params.dynamicLinks); tree_list.nodes = t; tree_list.openAllNodeRecursive(2); if (event.nodeData.ident == params.currentKey) { params.rightCtn.clearChild(); } }); }); break; } }) } } }); params.tree_list = tree_list; tree_list.openAllNodeRecursive(2); var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "360px", display: "inline-block", verticalAlign: "middle" }, props:{ placeholder: "Tìm kiếm..." } }); var add_icon = DOMElement.div({ attrs: { className: "bsc-icon-cover", style: { marginLeft: "10px", display: "inline-block", verticalAlign: "middle" }, onclick: function(){ params.currentKey = ""; params.parent = "root"; var onsave = function(value){ params.currentKey = value.key; params.tree_list.activeNode(value.key); me.lessonRightContentEdit(hrapi, params); }; var onabort = function(rs){ console.log(rs); }; params.content = { parent: params.parent }; me.topicEdit(hrapi, params, onsave, onabort); } }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "add" })] }); DOMElement.removeAllChildren(params.leftCtn); params.leftCtn.appendChild(DOMElement.div({ attrs: { style: { paddingBottom: "10px" } }, children: [ inputsearchbox, add_icon ] })); params.leftCtn.appendChild(tree_list); if (params.firstKey) { params.currentKey = params.firstKey; params.tree_list.activeNode(params.firstKey); me.lessonRightContentEdit(hrapi, params); } }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonLeftContentView var v56 = function(module, me) { return function (hrapi, params) { params.dynamicLinks = {}; var getTreeList = function(topics, dynamicLinks){ var getNode = function(index){ var items = [], ni; for (var i = 0; i < topics[index].childrenIndex.length; i++){ ni = topics[index].childrenIndex[i]; items.push(getNode(ni)); } items.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); items.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); dynamicLinks[topics[index].key] = { href: "#", text: topics[index].name }; return { name: topics[index].name, ident: topics[index].key, idx: topics[index].idx, checked: (topics[index].success) ? topics[index].success.indexOf(params.currentEmpId) != -1 : false, children: items, tIndex: index, hasQuickMenu: false }; }; var treeNodes = []; for (var i = 0; i < topics.length; i++){ if (topics[i].parent != "root") continue; if (!params.firstKey) params.firstKey = topics[i].key; treeNodes.push(getNode(i)); } treeNodes.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); treeNodes.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); return treeNodes; }; params.getTreeList = getTreeList; hrapi.table.create("topics", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } hrapi.table.select("topics", function(s, value){ console.log((new Date().getTime())); ModalElement.close(-1); var topics = []; var dict = []; value.forEach((item, i) => { if (item.content) { if (item.content.lesson == params.lesson) { item.content.key = item.key; topics.push(item.content); item.content.childrenIndex = []; dict[item.key] = item.content; } } }); params.topicDict = dict; params.topics = topics; topics.forEach(function(elt, idx){ if (dict[elt.parent] !== undefined) dict[elt.parent].childrenIndex.push(idx); }); var tree_list = absol.buildDom({ tag: "toclist", style: { width: "400px", 'flex-grow': 1, overflowY: 'auto' }, props: { nodes: getTreeList(params.topics, params.dynamicLinks) }, on: { pressnode: function (event) { params.currentKey = event.nodeData.ident; params.tree_list.activeNode(event.nodeData.ident); me.lessonRightContentView(hrapi, params); } } }); params.tree_list = tree_list; // tree_list.openAllNodeRecursive(2); var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "380px", display: "inline-block", verticalAlign: "middle" }, props:{ placeholder: "Tìm kiếm..." } }); DOMElement.removeAllChildren(params.leftCtn); params.leftCtn.appendChild(DOMElement.div({ attrs: { style: { paddingBottom: "10px" } }, children: [ inputsearchbox ] })); params.leftCtn.appendChild(tree_list); if (params.topicid) params.firstKey = params.topicid; if (params.firstKey) { params.currentKey = params.firstKey; params.tree_list.activeNode(params.firstKey); me.lessonRightContentView(hrapi, params); } }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonListContentMobileView var v70 = function(module, me) { return function (hrapi, params, div_element, onclose) { params.dynamicLinks = {}; var getTreeList = function(topics, dynamicLinks){ var getNode = function(index){ var items = [], ni; for (var i = 0; i < topics[index].childrenIndex.length; i++){ ni = topics[index].childrenIndex[i]; items.push(getNode(ni)); } items.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); items.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); dynamicLinks[topics[index].key] = { href: "#", text: topics[index].name }; return { name: topics[index].name, ident: topics[index].key, idx: topics[index].idx, checked: (topics[index].success) ? topics[index].success.indexOf(params.currentEmpId) != -1 : false, children: items, tIndex: index, hasQuickMenu: false }; }; var treeNodes = []; for (var i = 0; i < topics.length; i++){ if (topics[i].parent != "root") continue; if (!params.firstKey) params.firstKey = topics[i].key; treeNodes.push(getNode(i)); } treeNodes.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); treeNodes.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); return treeNodes; }; params.getTreeList = getTreeList; hrapi.table.create("topics", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } hrapi.table.select("topics", function(s, value){ ModalElement.close(-1); var topics = []; var dict = []; value.forEach((item, i) => { if (item.content) { if (item.content.lesson == params.lesson) { item.content.key = item.key; topics.push(item.content); item.content.childrenIndex = []; dict[item.key] = item.content; } } }); params.topicDict = dict; params.topics = topics; topics.forEach(function(elt, idx){ if (dict[elt.parent] !== undefined) dict[elt.parent].childrenIndex.push(idx); }); var inputsearchbox = absol.buildDom({ tag: 'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: LanguageModule.text("txt_search") } }); var tree_list = absol.buildDom({ tag: "toclist", style: { width: "400px", 'flex-grow': 1, overflowY: 'auto' }, props: { nodes: getTreeList(params.topics, params.dynamicLinks) }, on: { pressnode: function (event) { params.currentKey = event.nodeData.ident; params.tree_list.activeNode(event.nodeData.ident); me.lessonContentMobileView(hrapi, params, div_element); } } }); // tree_list.openAllNodeRecursive(2); params.tree_list = tree_list; var commands = []; commands.push({ icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "search" }), cmd: function(){ header.searchMode(true); } }); var header = absol.buildDom({ tag: 'headerbarwithsearch', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: params.lessonContent.name, commands: commands }, data:{ searchInput: inputsearchbox }, on: { action: function(){ frameList.removeLast(); onclose(); }, command: function(event){ event.commandItem.cmd(); } } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: 'tabframe', child: [ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [ tree_list ] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonMobileTable var v68 = function(module, me) { return function (hrapi, div_element, onclose) { var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); ModalElement.show_loading(); var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("lesson", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo dữ liệu"}); rj(); } else rs(); }) }), new Promise(function(rs, rj){ hrapi.table.create("lesson_category", (s, r) => { if (!s) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); rj(); } else rs(); }) }) ]; Promise.all(createDB).then(function(){ var run = function(retval) { ModalElement.close(-1); var isAdmin = retval[2]; var currentEmp = retval[3]; var lesson_category = retval[0]; var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.firstid] = orgContent; employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; retval[4].forEach((item, i) => { getEmployeesFunc(item); }); var holderForSort = retval[1].map(function(item){ item.content.key = item.key; return { item: item.content, val: absol.string.nonAccentVietnamese(item.content.name.toLowerCase()) } }); holderForSort.sort(function(a, b){ if (a.val < b.val) return -1; if (a.val > b.val) return 1; return 0; }); var groupDict = {}; lesson_category.forEach(function(elt) { groupDict[elt.key] = elt.content; }); var lesson = holderForSort.map(function(holder){ return holder.item; }); var commands = []; commands.push({ icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "search" }), cmd: function(){ header.searchMode(true); } }); var inputsearchbox = absol.buildDom({ tag: 'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: LanguageModule.text("txt_search") } }); var header = absol.buildDom({ tag: 'headerbarwithsearch', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: LanguageModule.text("txt_lesson"), commands: commands }, data:{ searchInput: inputsearchbox }, on: { action: function(){ onclose(); }, command: function(event){ event.commandItem.cmd(); } } }); div_element.addChild(frameList); var container = absol._({}); var singlePage = absol.buildDom({ tag: 'tabframe', child:[ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [container] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); div_element.currentEmp = currentEmp; div_element.isAdmin = isAdmin; var viewFunc = function(content){ var onclose = function(rs){}; me.lessonMobileView(hrapi, content, div_element, onclose); }; var redrawTableFunc = function(){ var data = []; var makeRow = function(elt){ var cells = []; cells.push({ innerText: elt.name, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: elt.name}, on: { click: function(content){ return function(){ viewFunc(content) } }(elt) } })); } }); cells.push({ style: {width: "40px"}, render: function(tdElt){ tdElt.addChild(DOMElement.div({ attrs: { className: "card-icon-cover", onclick: function(content){ return function(){ viewFunc(content) } }(elt) }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "visibility" })] })); } }); var row = { cells: cells } return row; } for (var i = 0; i < lesson.length; i++) { var row = makeRow(lesson[i]); data.push(row); } var tableView = absol.buildDom({ tag: "dynamictable", props: { adapter: { data: { head: { rows: [] }, body: { rows: data } } } } }); tableView.attachSearchInput(inputsearchbox); container.clearChild(); container.addChild(tableView); }; redrawTableFunc(); }; var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("lesson_category", function(s, lesson_category){ if (!s) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); rj(); } else { lesson_category.unshift({key: "general_group", content: { name: "Nhóm chính", comment: "", active: true }}); rs(lesson_category); } }) }), new Promise(function(rs, rj){ hrapi.table.select("lesson", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(); } else rs(value); }) }), new Promise(function(rs, rj){ hrapi.users.isAdmin(function(s, isAdmin){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else rs(isAdmin); }) }), new Promise(function(rs, rj){ hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else { hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); return; } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(); return; } rs(currentEmp); }) } }) }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); rj(); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); Promise.all(loadOrgs).then(function(retval){ rs(retval); }, function(err){console.log(err);}); }) }) ]; Promise.all(loadDB).then(function(retval){ run(retval); }) }) } } (module, retval); // function: hrplugins.keeview.e_learning.lessonMobileView var v69 = function(module, me) { return function (hrapi, content, div_element, onclose) { ModalElement.show_loading(); var lesson = content.key ? content.key : ""; var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("topicrate", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs(); }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise_publishment_information", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs(); }); }) ]; Promise.all(createDB).then(function(rs){ var employees = []; var getEmployeesFunc = function(orgContent){ employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; var onLoading = function(exercise, exerciseDict, retval) { retval[3].forEach((item, i) => { getEmployeesFunc(item); }); var exerciseOfTopic = {}; exercise.forEach(function(elt){ if (!exerciseOfTopic[elt.topic]) exerciseOfTopic[elt.topic] = []; exerciseOfTopic[elt.topic].push(elt.key); }); var params = { lessonContent: content, orgs: retval[3], lesson: lesson, currentEmpId: retval[2].id, currentEmp: retval[2], exercise: exercise, exerciseDict: exerciseDict, exerciseOfTopic: exerciseOfTopic, isAdmin: retval[1], topicid: content.topicid, config: { topicConfig: content.topicConfig, exerciseConfig: content.exerciseConfig }, employees: employees, topicrate: retval[0] }; me.lessonListContentMobileView(hrapi, params, div_element, onclose); } var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("topicrate", function(s, topicrate){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu đánh giá"}); rj(); } else rs(topicrate); }) }), new Promise(function(rs, rj){ hrapi.users.isAdmin(function(s, isAdmin){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else rs(isAdmin); }) }), new Promise(function(rs, rj){ hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else { hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); return; } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(); return; } rs(currentEmp); }) } }) }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); rj(); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); Promise.all(loadOrgs).then(function(retval){ rs(retval); }, function(err){console.log(err);}); }) }) ]; if (lesson != "") { loadDB.push(new Promise(function(rs, rj){ hrapi.table.select("exercise", (s, value) => { if (s) rs(value); else rj(); }); })), loadDB.push(new Promise(function(rs, rj){ hrapi.table.select("exercise_publishment_information", (s, value) => { if (s) rs(value); else rj(); }); })); Promise.all(loadDB).then(function(retval){ var t = []; var dict = {}; retval[4].forEach((item, i) => { if (item.content.lesson == lesson) { item.content.key = item.key; t.push(item.content); dict[item.key] = item.content; } }); exercise = t; div_element.dict = { exercise_publishment_information: {} }; retval[5].forEach((item, i) => { if (!div_element.dict.exercise_publishment_information[item.content.exerciseKey]) div_element.dict.exercise_publishment_information[item.content.exerciseKey] = {}; div_element.dict.exercise_publishment_information[item.content.exerciseKey][item.content.employeeid] = item; }); onLoading(exercise, dict, retval); }); } else { Promise.all(loadDB).then(function(retval){ var exercise = []; onLoading(exercise, {}, retval); }); } // var onLoading = function(exercise, exerciseDict) { // hrapi.table.select("topicrate", function(s, topicrate){ // if (!s) { // ModalElement.alert({message: "Lỗi tải dữ liệu đánh giá"}); // return; // } // hrapi.users.isAdmin(function(s, isAdmin){ // if (!s) { // ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); // return; // } // hrapi.users.getCurrentId(function(s, userid){ // if (!s) { // ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); // return; // } // hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { // if (!currentEmp){ // ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); // return; // } // if (!s1) { // ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); // return; // } // hrapi.orgs.getCompaniesList(function(s, companies){ // if (!s) { // ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); // return; // } // var loadOrgs = []; // companies.forEach((item, i) => { // loadOrgs.push(new Promise(function(rs, rj){ // hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ // if (r) rs(s); // else rj(s); // }); // })); // }); // var employees = []; // var getEmployeesFunc = function(orgContent){ // employees = employees.concat(orgContent.employees); // orgContent.children.forEach((item, i) => { // getEmployeesFunc(item); // }); // }; // Promise.all(loadOrgs).then(function(retval){ // retval.forEach((item, i) => { // getEmployeesFunc(item); // }); // var exerciseOfTopic = {}; // exercise.forEach(function(elt){ // if (!exerciseOfTopic[elt.topic]) exerciseOfTopic[elt.topic] = []; // exerciseOfTopic[elt.topic].push(elt.key); // }); // var params = { // lessonContent: content, // orgs: retval, // lesson: lesson, // currentEmpId: currentEmp.id, // currentEmp: currentEmp, // exercise: exercise, // exerciseDict: exerciseDict, // exerciseOfTopic: exerciseOfTopic, // isAdmin: isAdmin, // topicid: content.topicid, // config: { // topicConfig: content.topicConfig, // exerciseConfig: content.exerciseConfig // }, // employees: employees, // topicrate: topicrate // }; // me.lessonListContentMobileView(hrapi, params, div_element, onclose); // }, function(err){console.log(err);}); // }); // }); // }); // }); // }); // } // if (lesson != "") { // hrapi.table.select("exercise", (s, value) => { // var t = []; // var dict = {}; // value.forEach((item, i) => { // if (item.content.lesson == lesson) { // item.content.key = item.key; // t.push(item.content); // dict[item.key] = item.content; // } // }); // exercise = t; // onLoading(exercise, dict); // }); // } // else { // var exercise = []; // onLoading(exercise, {}); // } }); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonRightContentEdit var v48 = function(module, me) { return function (hrapi, params) { var content = params.topicDict[params.currentKey] !== undefined ? params.topicDict[params.currentKey] : {}; var tDiv = absol._({}); content.content[content.content.length - 1].data = me.repareViewDynamicLink(content.content[content.content.length - 1].data, params.dynamicLinks); tDiv.addChild(absol.buildDom({ child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Nội dung" }, }, { class: 'mk-section-header-right', child: [ { child: {text: "Sửa"}, on: { click: function(){ var onsave = function(value){ me.lessonRightContentEdit(hrapi, params); }; var onabort = function(rs){ console.log(rs); }; params.content = params.topicDict[params.currentKey]; me.topicEdit(hrapi, params, onsave, onabort); } } } ] } ] }, { style: { paddingLeft: "10px" }, child: DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {paddingLeft: "10px"}}, text: content.name } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Version"}, { attrs: {style: {paddingLeft: "10px"}}, text: content.content[content.content.length - 1].name } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "ID"}, { attrs: {style: {paddingLeft: "10px"}}, text: content.key } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {paddingLeft: "10px"}}, children: [absol._({ tag: "checkbox", props: { disabled: true, checked: content.active } })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ { attrs: { colSpan: 2 }, children: [absol._({ class: "cke_contents_ltr", style: content.content[content.content.length - 1].data != "" ? { borderTop: "1px solid #d0d1d3", fontSize: "16px" } : {fontSize: "16px"}, props: { innerHTML: content.content[content.content.length - 1].data } })] } ] ] }) } ] })); var eltList = []; var makeExerciseRow = function(item){ var t_name = absol._({ child: {text: params.exerciseDict[item].name} }); var row = absol._({ child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: { tag: "a", style: { color: "#1464f6", cursor: "pointer" }, child: t_name, on: { click: function(){ var onclose = function(){ params.div_element.name = params.lessonContent.name; params.rightCtn.clearChild(); params.rightCtn.addChild(tDiv); }; params.exerciseDict[item].currentEmpId = params.currentEmpId; me.exerciseView(hrapi, params.exerciseDict[item], params.div_element, onclose); } } } }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "20px" }, child: [ { tag: "i", class: ["material-icons", "bsc-icon-hover-black"], child: {text: "edit"}, on: { click: function(){ var onsave = function(value){ for (var i = 0; i < params.exercise.length; i++) { if (params.exercise[i].key == value.key){ params.exercise[i] == value; break; } } params.exerciseDict[item] = value; if (value.topic != content.key) { if (!params.exerciseOfTopic[value.topic]) params.exerciseOfTopic[value.topic] = []; params.exerciseOfTopic[value.topic].push(value.key); params.exerciseOfTopic[content.key] = params.exerciseOfTopic[content.key].filter(function(elt){ return elt != value.key; }); data_ctn.removeChild(row); } else { t_name.clearChild(); t_name.addChild(absol._({text: params.exerciseDict[item].name})); } }; var onabort = function(rs){ params.div_element.name = params.lessonContent.name; console.log(rs); }; me.exerciseEdit(hrapi, params.exerciseDict[item], params.div_element, onsave, onabort); } } }, { tag: "i", class: ["material-icons", "bsc-icon-hover-black"], style: { paddingLeft: "10px" }, child: {text: "delete"}, on: { click: function(){ me.deleteConfirm("Xóa bài tập", "Bài tập \"" + params.exerciseDict[item].name + "\" sẽ bị xóa, bạn có muốn tiếp tục ?").then(function(){ hrapi.table.delete("exercise", item, (s, r) => { data_ctn.removeChild(row); var t_key = params.exerciseDict[item].topic; delete params.exerciseDict[item]; params.exercise = params.exercise.filter(function(elt){ return elt.key != item; }); params.exerciseOfTopic[t_key] = params.exerciseOfTopic[t_key].filter(function(elt){ return elt != item; }); });params.exerciseDict[item] }); } } } ] } ] }); return row; } if (params.exerciseOfTopic[content.key]) { params.exerciseOfTopic[content.key].forEach((item, i) => { var row = makeExerciseRow(item); eltList.push(row); }); } var data_ctn = absol._({ child: eltList }); tDiv.addChild(absol.buildDom({ child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Bài tập" } }, { class: 'mk-section-header-right', child: [ { child: {text: "Thêm"}, on: { click: function(){ var t_data = {}; var onsave = function(value){ if (!t_data.key) { t_data.key = value.key; params.exerciseDict[value.key] = value; params.exercise.push(value); if (!params.exerciseOfTopic[value.topic]) params.exerciseOfTopic[value.topic] = []; params.exerciseOfTopic[value.topic].push(value.key); var row = makeExerciseRow(value.key); data_ctn.addChild(row); } else { params.exerciseDict[value.key] = value; for (var i = 0; i < params.exercise.length; i++){ if (params.exercise[i].key == value.key){ params.exercise[i] = value; break; } } } }; var onabort = function(rs){ params.div_element.name = params.lessonContent.name; console.log(rs); }; me.exerciseEdit(hrapi, {lesson: content.lesson, topic: content.key}, params.div_element, onsave, onabort); } } } ] } ] }, { style: { paddingLeft: "10px" }, child: data_ctn } ] })); params.rightCtn.clearChild(); params.rightCtn.addChild(tDiv); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonRightContentView var v57 = function(module, me) { return function (hrapi, params) { setTimeout(function(currentKey){ return function(){ if (currentKey != params.currentKey) return; params.topicDict[params.currentKey].click++; if (!params.topicDict[params.currentKey]) { ModalElement.alert({message: "Lỗi dữ liệu"}); return; }; hrapi.table.update("topics", params.currentKey, params.topicDict[params.currentKey], (s, r) => { if (s){ var topicInfor = ""; if (params.config.topicConfig) { if (params.config.topicConfig.display_click) { topicInfor += "Số lần click: " + content.click; } if (params.config.topicConfig.display_creator) { topicInfor += ",\tTác giả: " + getEmployeeName(content.creator); } if (params.config.topicConfig.display_createdtime) { topicInfor += ",\tNgày tạo: " + me.getDateTimeView(content.createdtime); } if (params.config.topicConfig.display_modifieder) { topicInfor += ",\tĐược sửa bởi: " + getEmployeeName(content.lastmodified); } if (params.config.topicConfig.display_modifiedtime) { topicInfor += ",\tNgày sửa: " + me.getDateTimeView(content.lastmodifiedtime); } } publishInfor.innerHTML = topicInfor; } else { console.log(s, r); } }); } }(params.currentKey), 5000); var content = params.topicDict[params.currentKey] !== undefined ? params.topicDict[params.currentKey] : {}; var newUrl = "lesson_view/" + params.currentKey; params.div_element.changeUrl(newUrl); var tDiv = absol._({}); var topicInfor = ""; var getEmployeeName = function(id){ for (var i = 0; i < params.employees.length; i++) { if (params.employees[i].id == id) return params.employees[i].fullname; } return ""; }; if (params.config.topicConfig) { if (params.config.topicConfig.display_click) { topicInfor += "Số lần click: " + content.click; } if (params.config.topicConfig.display_creator) { topicInfor += ",\tTác giả: " + getEmployeeName(content.creator); } if (params.config.topicConfig.display_createdtime) { topicInfor += ",\tNgày tạo: " + me.getDateTimeView(content.createdtime); } if (params.config.topicConfig.display_modifieder) { topicInfor += ",\tĐược sửa bởi: " + getEmployeeName(content.lastmodified); } if (params.config.topicConfig.display_modifiedtime) { topicInfor += ",\tNgày sửa: " + me.getDateTimeView(content.lastmodifiedtime); } } var success = absol._({ tag: "checkbox", props: { checked: content.success ? content.success.indexOf(params.currentEmpId) != -1 : false }, on: { change: function() { if (this.checked) { params.topicDict[params.currentKey].success.push(params.currentEmpId); } else { params.topicDict[params.currentKey].success = params.topicDict[params.currentKey].success.filter(function(elt){ return elt != params.currentEmpId; }); } if (!params.topicDict[params.currentKey]) { ModalElement.alert({message: "Lỗi dữ liệu"}); return; }; hrapi.table.update("topics", params.currentKey, params.topicDict[params.currentKey], (s, r) => { if (s){ params.dynamicLinks = {}; var t = params.getTreeList(params.topics, params.dynamicLinks); params.tree_list.nodes = t; params.tree_list.openAllNodeRecursive(2); } else { console.log(s, r); } }); } } }); var publishInfor = absol._({ props: { innerHTML: topicInfor } }); tDiv.addChild(absol._({ child: [DOMElement.table({ data: [ [ {text: "Hoàn thành"}, { attrs: {style: {paddingLeft: "10px"}}, children: [success] }, { attrs: {style: {paddingLeft: "50px"}}, children: publishInfor } ] ] })] })); content.content[content.content.length - 1].data = me.repareViewDynamicLink(content.content[content.content.length - 1].data, params.dynamicLinks); var topicContent = absol._({ class: "cke_contents_ltr", style: { fontSize: "16px" }, props: { innerHTML: content.content[content.content.length - 1].data } }); absol.$$("a.as-ck-widget-dynamic-link", topicContent).forEach((item, i) => { item.on("click", function(event){ event.preventDefault(); var key = item.attr("data-link-id"); params.currentKey = key; params.tree_list.activeNode(key); me.lessonRightContentView(hrapi, params); }); }); tDiv.addChild(absol.buildDom({ child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Nội dung" }, } ] }, { style: { paddingLeft: "10px" }, child: topicContent } ] })); var eltList = []; var makeExerciseRow = function(item){ var t_name = absol._({ child: {text: params.exerciseDict[item].name} }); var row = absol._({ child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: { tag: "a", style: { color: "#1464f6", cursor: "pointer" }, child: t_name, on: { click: function(){ var onclose = function(){ params.div_element.name = params.lessonContent.name; params.rightCtn.clearChild(); params.rightCtn.addChild(tDiv); }; params.exerciseDict[item].currentEmpId = params.currentEmpId; me.exerciseView(hrapi, params.exerciseDict[item], params.div_element, onclose); } } } } ] }); return row; } if (params.exerciseOfTopic[content.key]) { params.exerciseOfTopic[content.key].forEach((item, i) => { var row = makeExerciseRow(item); eltList.push(row); }); } if (eltList.length > 0) { var data_ctn = absol._({ child: eltList }); tDiv.addChild(absol.buildDom({ child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Bài tập" } } ] }, { style: { paddingLeft: "10px" }, child: data_ctn } ] })); } var count = 0; var sum = 0; var thisRate; params.topicrate.forEach((item, i) => { if (item.content.topic == params.currentKey) { count++; sum += item.content.rate; if (item.content.employeeid == params.currentEmpId) { thisRate = item; } } }); var makeRate = function(rate){ var child = []; var classname; var color; var i = 1; while (i <= 5) { if (i <= rate) { classname = 'mdi-star'; color = "#0c59cf"; } else { classname = 'mdi-star-outline'; color = "#c0c0c0"; } child.push({ style: { fontSize: "var(--icon-fontsize)", color: color }, tag: "span", class:['mdi', classname], on: { click: function(rate){ return function(){ var isNew; if (thisRate) thisRate.content.rate = rate; else { isNew = true; thisRate = { key: (new Date()).getTime(), content: { topic: params.currentKey, employeeid: params.currentEmpId, rate: rate } } } hrapi.table.update("topicrate", thisRate.key, thisRate.content, (s, r) => { if (isNew) { params.topicrate.push(thisRate); } rateDiv.clearChild(); rateDiv.addChild(makeRate(thisRate.content.rate)); countDiv.clearChild(); averageDiv.clearChild(); var count = 0; var sum = 0; params.topicrate.forEach((item, i) => { if (item.content.topic == params.currentKey) { count++; sum += item.content.rate; } }); countDiv.addChild(absol._({child: {text: count}})); averageDiv.addChild(absol._({child: {text: (sum/count).toFixed(1)}})); }); } }(i) } }); i++; } var st = absol._({ child: child }); return st; } var rateDiv = absol._({ child: makeRate(thisRate ? thisRate.content.rate : 0) }); var countDiv = absol._({ child: {text: count} }); var averageDiv = absol._({ child: {text: count > 0 ? (sum/count).toFixed(1) : 0} }); tDiv.addChild(absol.buildDom({ child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Đánh giá" } } ] }, { style: { paddingLeft: "10px" }, child: [ DOMElement.table({ data: [ [ { text: "Đánh giá nội dung bài học" }, { attrs: { style: { paddingLeft: "10px" } }, children: [rateDiv] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Số người đánh giá: " }, { attrs: { style: { paddingLeft: "10px" } }, children: [countDiv] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Điểm trung bình: " }, { attrs: { style: { paddingLeft: "10px" } }, children: [averageDiv] } ] ] }) ] } ] })); var makeBigTopicElt = function(topicid){ var st = absol._({ tag: "button", style: { minWidth: "120px", maxWidth: "300px", height: "70px", cursor: "pointer", backgroundColor: "#dfedd6", borderRadius: "5px", marginRight: "20px", marginBottom: "20px", border: "1px solid #d6d6d6", fontSize: "16px", verticalAlign: "middle" }, child: {text: params.topicDict[topicid].name}, on: { click: function(){ params.currentKey = topicid; params.tree_list.activeNode(topicid); me.lessonRightContentView(hrapi, params); } } }); return st; } var t_child = []; params.topics.forEach((item, i) => { if (item.parent == "root"){ var elt = makeBigTopicElt(item.key); elt.idx = item.idx; t_child.push(elt); } }); t_child.sort(function(a, b){ return a.idx - b.idx; }); tDiv.addChild(absol.buildDom({ child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Chuyên mục" } } ] }, { style: { paddingLeft: "10px" }, child: t_child } ] })); params.rightCtn.clearChild(); params.rightCtn.addChild(tDiv); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonTable var v46 = function(module, me) { return function (hrapi, div_element, onclose) { ModalElement.show_loading(); var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("lesson", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo dữ liệu"}); rj(); } else rs(); }) }), new Promise(function(rs, rj){ hrapi.table.create("lesson_category", (s, r) => { if (!s) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); rj(); } else rs(); }) }) ]; Promise.all(createDB).then(function(){ var run = function(retval) { ModalElement.close(-1); var isAdmin = retval[2]; var currentEmp = retval[3]; var lesson_category = retval[0]; var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.firstid] = orgContent; employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; retval[4].forEach((item, i) => { getEmployeesFunc(item); }); var holderForSort = retval[1].map(function(item){ item.content.key = item.key; return { item: item.content, val: absol.string.nonAccentVietnamese(item.content.name.toLowerCase()) } }); holderForSort.sort(function(a, b){ if (a.val < b.val) return -1; if (a.val > b.val) return 1; return 0; }); var groupDict = {}; lesson_category.forEach(function(elt) { groupDict[elt.key] = elt.content; }); var lesson = holderForSort.map(function(holder){ return holder.item; }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); var addFunc = function(){ var t_data = {}; var onsave = function(content) { if (!t_data.key) { t_data.key = content.key; lesson.push(content); } else { for (var i = 0; i < lesson.length; i++) { if (lesson[i].key == content.key) { lesson[i] = content; break; } } } redrawTableFunc(); }; var onabort = function(rs){ console.log(rs); }; me.lessonConfig(hrapi, {}, div_element, onsave, onabort); } var addBtn = me.noneIconButton({ text: "Thêm", onclick: function(){ addFunc(); } }); var importFunc = function(){ me.importLessonData(hrapi).then(function(retval){ lesson.push(retval); redrawTableFunc(); }, function(err){console.log(err)}); } var importBtn = module.e_learning.noneIconButton({ text: "Import", onclick: function(){ importFunc(); } }); div_element.addChild(frameList); var container = absol._({}); var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", style: {display: isAdmin ? "" : "none"}, child: addBtn }, { class: "single-button-header", style: {display: isAdmin ? "" : "none"}, child: importBtn } ] } }, container ] }); frameList.addChild(singlePage); singlePage.requestActive(); div_element.currentEmp = currentEmp; div_element.isAdmin = isAdmin; var viewFunc = function(content){ var onclose = function(rs){ // host.frameList.removeLast(); }; me.lessonView(hrapi, content, div_element, onclose); }; var exFunc = function(content){ me.exportLessonData(hrapi, content); }; var redrawTableFunc = function(){ var data = []; var makeRow = function(elt){ var cells = [{ style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(DOMElement.span({attrs: {className: "as-dt-row-index"}})); } }]; cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ class: "hr-table-cell-link", tag: "span", child: {text: elt.name}, on: { click: function(content){ return function(){ viewFunc(content) } }(elt) } })); } }); cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ class: "hr-table-cell-link", tag: "span", child: {text: groupDict[elt.group].name}, on: { click: function(content){ return function(){ viewFunc(content) } }(elt) } })); } }); cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: elt.comment} })); } }); cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: elt.active } })); } }); cells.push({ style: {width: "40px"}, render: function(tdElt){ var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_vert" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { getMenuProps: function(){ var quickMenuItems = []; var getEmpView = function(orgs, data){ orgs.employees.forEach((item, i) => { data.push(item.id); }); orgs.children.forEach((item, i) => { getEmpView(item, data); }); }; var empList = []; elt.viewPriv.forEach((item, i) => { if (item > 0) empList.push(item); else { getEmpView(orgDict[-item], empList); } }); if (isAdmin || elt.editPriv.indexOf(currentEmp.firstid) != -1 || empList.indexOf(currentEmp.firstid) != -1 || elt.creator == currentEmp.firstid) quickMenuItems.push({ text: "Xem", extendClasses: "bsc-quickmenu", icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "visibility" }), cmd: function(content){ return function(){ viewFunc(content); } }(elt) }); var editFunc = function(content) { var onsave = function(content){ }; var onabort = function(rs){ console.log(rs); }; me.lessonEdit(hrapi, content, div_element, onsave, onabort); } if (isAdmin || elt.editPriv.indexOf(currentEmp.firstid) != -1 || elt.creator == currentEmp.firstid) { quickMenuItems.push({ text: "Sửa", extendClasses: "bsc-quickmenu", icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "edit" }), cmd: function(content){ return function(){ editFunc(content); } }(elt) }); quickMenuItems.push({ text: "Export", extendClasses: ["bsc-quickmenu"], icon: absol._({ class: ["mdi", "mdi-export"] }), cmd: function(){ exFunc(elt); } }); } var configFunc = function(t_data) { var onsave = function(content) { for (var i = 0; i < lesson.length; i++) { if (lesson[i].key == content.key) { lesson[i] = content; break; } } redrawTableFunc(); }; var onabort = function(rs){ console.log(rs); }; me.lessonConfig(hrapi, t_data, div_element, onsave, onabort); } if (isAdmin || elt.editPriv.indexOf(currentEmp.firstid) != -1 || elt.creator == currentEmp.firstid) quickMenuItems.push({ text: "Thiết lập", extendClasses: "bsc-quickmenu", icon: absol._({ tag: "span", class: ['mdi', 'mdi-cog'] }), cmd: function(content){ return function(){ configFunc(content); } }(elt) }); var publishedInformation = function(content){ var onClose = function(){ } me.publishedInformation(hrapi, content.key, div_element, onClose); }; if (isAdmin || elt.editPriv.indexOf(currentEmp.firstid) != -1 || elt.creator == currentEmp.firstid) quickMenuItems.push({ text: "Thông tin xuất bản", extendClasses: "bsc-quickmenu", icon: absol._({ tag: "span", class: ['mdi', 'mdi-alpha-i'] }), cmd: function(content){ return function(){ publishedInformation(content); } }(elt) }); if (isAdmin || elt.editPriv.indexOf(currentEmp.firstid) != -1 || elt.creator == currentEmp.firstid) quickMenuItems.push({ text: "Xóa", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "delete" }), cmd: function(elt){ return function(){ me.deleteConfirm("Xóa bài học", "Bài học \"" + elt.name + "\" sẽ bị xóa, bạn có muốn tiếp tục ?").then(function(){ hrapi.table.delete("lesson", elt.key, function(){ var x = tableView.rowOf(row) x.remove(); }); hrapi.table.select("topics", function(s, topics){ topics.forEach((item, i) => { if (item.lesson == elt.key) hrapi.table.delete("topics", item.key, function(){}); }); }); }); }; }(elt) }); return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } }); var row = { cells: cells } return row; } for (var i = 0; i < lesson.length; i++) { var row = makeRow(lesson[i]); data.push(row); } var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Nhóm"} }, { child: {text: "Mô tả"} }, { child: {text: "Hoạt động"} }, {} ] } ] }, body: { rows: data } } } } }); var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: "Tìm kiếm..." } }); tableView.attachSearchInput(inputsearchbox); container.clearChild(); container.addChild(tableView); }; redrawTableFunc(); }; var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("lesson_category", function(s, lesson_category){ if (!s) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); rj(); } else { lesson_category.unshift({key: "general_group", content: { name: "Nhóm chính", comment: "", active: true }}); rs(lesson_category); } }) }), new Promise(function(rs, rj){ hrapi.table.select("lesson", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(); } else rs(value); }) }), new Promise(function(rs, rj){ hrapi.users.isAdmin(function(s, isAdmin){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else rs(isAdmin); }) }), new Promise(function(rs, rj){ hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else { hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); return; } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(); return; } rs(currentEmp); }) } }) }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); rj(); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); Promise.all(loadOrgs).then(function(retval){ rs(retval); }, function(err){console.log(err);}); }) }) ]; Promise.all(loadDB).then(function(retval){ run(retval); }) }); } } (module, retval); // function: hrplugins.keeview.e_learning.lessonView var v55 = function(module, me) { return function (hrapi, content, div_element, onclose) { ModalElement.show_loading(); div_element.name = content.name; var lesson = content.key ? content.key : ""; var createDB = [ new Promise(function(rs, rj){ hrapi.table.create("topicrate", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs() }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs(); }); }), new Promise(function(rs, rj){ hrapi.table.create("exercise_publishment_information", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); rj(); } else rs(); }); }) ]; Promise.all(createDB).then(function(rs){ var employees = []; var getEmployeesFunc = function(orgContent){ employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; var onLoading = function(exercise, exerciseDict, retval) { retval[3].forEach((item, i) => { getEmployeesFunc(item); }); var leftCtn = absol.buildDom({ class: 'mk-main-left-ctn', style:{ display:'flex', 'flex-direction': 'column' } }); var rightCtn = absol.buildDom({ class: 'mk-main-right', style: { paddingBottom: "var(--footer-margin)", userSelect: "none" } }); var data_ctn = absol._({ class: 'mk-main', style: { height: "100%" }, child: [ leftCtn, rightCtn ] }); var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ div_element.name = "Bài học"; div_element.changeUrl("lesson"); frameList.removeLast(); onclose(); } }); var editBtn = me.noneIconButton({ text: "Sửa", onclick: function(){ div_element.name = "Bài học"; div_element.changeUrl("lesson"); frameList.removeLast(); var editFunc = function(content) { var onsave = function(content){ }; var onabort = function(rs){ console.log(rs); }; me.lessonEdit(hrapi, content, div_element, onsave, onabort); } editFunc(content); } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var buttonList = [ { class: "single-button-header", child: closeBtn } ]; if (div_element.isAdmin || content.editPriv.indexOf(div_element.currentEmp.firstid) != -1 || content.creator == div_element.currentEmp.firstid){ buttonList.push({ class: "single-button-header", child: editBtn }); } var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: buttonList } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); var exerciseOfTopic = {}; exercise.forEach(function(elt){ if (!exerciseOfTopic[elt.topic]) exerciseOfTopic[elt.topic] = []; exerciseOfTopic[elt.topic].push(elt.key); }); var params = { lessonContent: content, orgs: retval[3], lesson: lesson, leftCtn: leftCtn, rightCtn: rightCtn, currentEmpId: retval[2].id, currentEmp: retval[2], exercise: exercise, exerciseDict: exerciseDict, frameList: frameList, div_element: div_element, exerciseOfTopic: exerciseOfTopic, isAdmin: retval[1], topicid: content.topicid, config: { topicConfig: content.topicConfig, exerciseConfig: content.exerciseConfig }, employees: employees, topicrate: retval[0] }; me.lessonLeftContentView(hrapi, params); } var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("topicrate", function(s, topicrate){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu đánh giá"}); rj(); } else rs(topicrate); }) }), new Promise(function(rs, rj){ hrapi.users.isAdmin(function(s, isAdmin){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else rs(isAdmin); }) }), new Promise(function(rs, rj){ hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); } else { hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(); return; } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(); return; } rs(currentEmp); }) } }) }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); rj(); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); Promise.all(loadOrgs).then(function(retval){ rs(retval); }, function(err){console.log(err);}); }) }) ]; if (lesson != "") { loadDB.push(new Promise(function(rs, rj){ hrapi.table.select("exercise", (s, value) => { if (s) rs(value); else rj(); }); })), loadDB.push(new Promise(function(rs, rj){ hrapi.table.select("exercise_publishment_information", (s, value) => { if (s) rs(value); else rj(); }); })); Promise.all(loadDB).then(function(retval){ var t = []; var dict = {}; var isAdmin = retval[1]; var currentEmp = retval[2]; div_element.currentEmp = currentEmp; div_element.isAdmin = isAdmin; retval[4].forEach((item, i) => { if (item.content.lesson == lesson) { item.content.key = item.key; t.push(item.content); dict[item.key] = item.content; } }); exercise = t; div_element.dict = { exercise_publishment_information: {} }; retval[5].forEach((item, i) => { if (!div_element.dict.exercise_publishment_information[item.content.exerciseKey]) div_element.dict.exercise_publishment_information[item.content.exerciseKey] = {}; div_element.dict.exercise_publishment_information[item.content.exerciseKey][item.content.employeeid] = item; }); onLoading(exercise, dict, retval); }); } else { Promise.all(loadDB).then(function(retval){ var exercise = []; onLoading(exercise, {}, retval); }); } }) } } (module, retval); // function: hrplugins.keeview.e_learning.linkDirectionPage var v38 = function(module, me) { return function (topics, topicDict, values, callBackFunc) { var indexList = []; topics.forEach(function(elt, idx){ if (elt.parent == "root") { indexList.push(idx); } }); var selectedList = []; var getTopicItems = function(topics){ var getNode = function(index){ var items = [], ni; for (var i = 0; i < topics[index].childrenIndex.length; i++){ ni = topics[index].childrenIndex[i]; items.push(getNode(ni)); } items.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); items.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); return { cells: [ { children: topics[index].name }, { attrs: { align: "center" }, children: absol._({ tag: "checkbox", props: { checked: false }, on: { change: function(key){ return function(){ if (this.checked) { selectedList.push(key); } else { selectedList = selectedList.filter(function(elt){ return elt != key; }); } } }(topics[index].key) } }) } ], children: items, tIndex: index, idx: topics[index].idx } }; var treeNodes = []; for (var i = 0; i < topics.length; i++){ if (topics[i].parent != "root") continue; treeNodes.push(getNode(i)); } treeNodes.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); treeNodes.forEach((item, i) => { topics[item.tIndex].idx = i; item.idx = i; }); return treeNodes; }; ModalElement.showWindow({ title: "Link", noPadding: true, bodycontent: DOMElement.div({ attrs: { className: "cardsimpletableclass", }, children: DOMElement.treetable({ attrs: { style: { width: "100%" } }, header: [ {text: "Topic"}, {attrs: {style: {width: "40px"}}} ], data: getTopicItems(topics) }) }), buttonlist: [ { text: "Insert", onclick: function(){ callBackFunc(selectedList); ModalElement.close(); } }, { text: "Hủy", onclick: function(event,me) { ModalElement.close(); } } ] }); } } (module, retval); // function: hrplugins.keeview.e_learning.noneIconButton var v42 = function(module, me) { return function (params) { return absol.buildDom({ tag: "flexiconbutton", style: { minWidth: "var(--button-min-width)", height: "var(--button-height)", fontSize: "var(--button-title-font-size)", fontWeight: "var(--button-title-font-weight)" }, on: { click: params.onclick }, props:{ text: params.text } }); } } (module, retval); // function: hrplugins.keeview.e_learning.openTopicByLink var v37 = function(module, me) { return function (hrapi, topicid, div_element, onClose) { hrapi.table.select("lesson", function(s, lesson){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); return; } var dict = {}; lesson.forEach((item, i) => { item.content.key = item.key; dict[item.key] = item.content; }); hrapi.table.select("topics", function(s, topics){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); return; } var t = false; for (var i = 0; i < topics.length; i++){ if (topics[i].key == topicid) { var content = dict[topics[i].content.lesson]; content.topicid = topicid; var openTable = function(){ div_element.clearChild(); me.lessonTable(hrapi, div_element, onClose); } me.lessonView(hrapi, content, div_element, openTable); t = true; break; } } if (!t) me.lessonTable(hrapi, div_element, onClose); }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.publishedInformation var v59 = function(module, me) { return function (hrapi, lesson, div_element, onClose) { hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var getEmployeesFunc = function(orgContent){ employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); hrapi.table.select("topicrate", function(s, topicrate){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu đánh giá"}); return; } var rateDict = {}; topicrate.forEach((item, i) => { if (!rateDict[item.content.topic]) rateDict[item.content.topic] = { count: 0, sum: 0 }; rateDict[item.content.topic].count++; rateDict[item.content.topic].sum += item.content.rate; }); hrapi.table.select("topics", function(s, value){ var topics = []; var topicDict = {}; var indexList = []; value.forEach((item, i) => { if (item.content) { if (item.content.lesson == lesson) { item.content.key = item.key; if (item.content.parent == "root") indexList.push(topics.length); topics.push(item.content); item.content.childrenIndex = []; topicDict[item.key] = item.content; } } }); topics.forEach(function(elt, idx){ if (topicDict[elt.parent] !== undefined) topicDict[elt.parent].childrenIndex.push(idx); }); var getEmployeeName = function(id){ for (var i = 0; i < employees.length; i++) { if (employees[i].id == id) return employees[i].fullname; } return ""; }; var generateData = function(indexList, k){ var data = []; indexList.forEach((item, i) => { data.push([ { attrs: {style: {paddingLeft: (30 * k) + "px"}}, text: topics[item].name }, { text: getEmployeeName(topics[item].creator) }, { text: me.getDateTimeView(topics[item].createdtime) }, { text: getEmployeeName(topics[item].lastmodified) }, { text: me.getDateTimeView(topics[item].lastmodifiedtime) }, { text: topics[item].click }, { text: rateDict[topics[item].key] ? (rateDict[topics[item].key].sum / rateDict[topics[item].key].count).toFixed(1) : 0 } ]); if (topics[item].childrenIndex.length > 0) { data = data.concat(generateData(topics[item].childrenIndex, k + 1)); } }); return data; } var data = generateData(indexList, 1); var table = DOMElement.table({ header: [ {text: "Topic"}, {text: "Tác giả"}, {text: "Thời gian tạo"}, {text: "Người sửa lần cuối"}, {text: "Thời gian sửa lần cuối"}, {text: "Số lần click"}, {text: "Đánh giá"} ], data: data }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var closeBtn = me.noneIconButton({ text: "Đóng", onclick: function(){ div_element.changeUrl("lesson"); frameList.removeLast(); onclose(); } }); var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn } ] } }, { class: "cardsimpletableclass", child: table } ] }); frameList.addChild(singlePage); singlePage.requestActive(); }); }); }, function(err){console.log(err);}); }); } } (module, retval); // function: hrplugins.keeview.e_learning.repareViewDynamicLink var v61 = function(module, me) { return function (html, dynamicLinks) { var div = absol._({}); div.innerHTML = html; absol.$$('.as-ck-widget-dynamic-link', div).forEach(function(elt){ var currentId = elt.attr("data-link-id"); if (!dynamicLinks[currentId]) { elt.style.color = "red"; return; } elt.attr("href", dynamicLinks[currentId].href); elt.clearChild().addChild(absol._({text: dynamicLinks[currentId].text})); }); return div.innerHTML; } } (module, retval); // function: hrplugins.keeview.e_learning.replaceDynamicLink var v60 = function(module, me) { return function (html, dynamicLinks, replacements) { var div = absol._({}); div.innerHTML = html; absol.$$('.as-ck-widget-dynamic-link', div).forEach(function(elt){ var currentId = elt.attr("data-link-id"); var newId = replacements[currentId]; if (!newId) return; elt.attr("data-link-id", newId); elt.attr("href", dynamicLinks[newId].href); elt.clearChild().addChild(absol._({text: dynamicLinks[newId].text})); }); return div.innerHTML; } } (module, retval); // function: hrplugins.keeview.e_learning.topicCopy var v58 = function(module, me) { return function (hrapi, params, onsave, onabort) { hrapi.table.select("lesson", function(s, lesson){ if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); return; } hrapi.table.select("topics", function(s, topics){ if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); return; } var topicDict = {}; var lessonItems = lesson.map(function(elt){ topicDict[elt.key] = { items: [], dict: {}, indexList: [] }; return { value: elt.key, text: elt.content.name, sortText: absol.string.nonAccentVietnamese(elt.content.name.toLowerCase()) }; }); lessonItems.sort(function(a, b){ if (a.sortText > b.sortText) return 1; if (a.sortText < b.sortText) return -1; return 0; }); topics.forEach((item, i) => { if (!topicDict[item.content.lesson]) return; item.content.key = item.key; item.content.childrenIndex = []; if (item.content.parent == "root") { topicDict[item.content.lesson].indexList.push(topicDict[item.content.lesson].items.length); } topicDict[item.content.lesson].items.push(item.content); topicDict[item.content.lesson].dict[item.key] = item.content; }); Object.keys(topicDict).forEach(function(item){ topicDict[item].items.forEach(function(elt, idx){ if (topicDict[item].dict[elt.parent] !== undefined) topicDict[item].dict[elt.parent].childrenIndex.push(idx); }); }); var lessonCbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: lessonItems }, on: { change: function(){ topicCbb.items = [ { value: 'root', text: "Root", items: me.getTopicItems(topicDict[this.value].items, params.content.key) } ] topicCbb.value = undefined; } } }); var topicCbb = absol._({ tag: "selecttreemenu", props: { enableSearch: true, items: [ { value: 'root', text: "Root", items: me.getTopicItems(topicDict[lessonCbb.value].items, params.content.key) } ] } }); ModalElement.showWindow({ title: "Sao chép Topic", noPadding: true, bodycontent: DOMElement.table({ data: [ [ { text: "Bài học" }, { attrs: { style: { paddingLeft: "10px" } }, children: [lessonCbb] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Parent" }, { attrs: { style: { paddingLeft: "10px" } }, children: [topicCbb] } ] ] }), buttonlist: [ { text: "OK", onclick: function(){ ModalElement.show_loading(); var saveFunc = function(topicContent, parent, lesson){ return new Promise(function(rs, rj){ var content = EncodingClass.string.duplicate(topicContent); var oldKey = content.key; var promiseArray = []; if (params.exerciseOfTopic[content.key]) { params.exerciseOfTopic[content.key].forEach(function(elt){ promiseArray.push(function(lesson, topic){ return new Promise(function(y, n){ var exContent = EncodingClass.string.duplicate(params.exerciseDict[elt]); exContent.lesson = lesson; exContent.topic = topic; exContent.creator = params.currentEmpId; exContent.createdtime = new Date(); exContent.click = 0; delete exContent.lastmodified; delete exContent.lastmodifiedtime; var key = (new Date()).getTime(); hrapi.table.update("exercise", key, exContent, (s, r) => { if (s){ exContent.key = key; y(exContent); } else n(); }); }); }); }); } content.creator = params.currentEmpId; content.createdtime = new Date(); content.count = 0; content.success = []; content.parent = parent; content.lesson = lesson; if (parent == 'root') { content.idx = Object.keys(topicDict[lesson].dict).length; } else content.idx = topicDict[lesson].dict[parent].childrenIndex.length; if (content.lesson == params.lesson) { // content.name += " Copy"; // content.alias += "-copy"; } content.oldKey = oldKey; delete content.key; delete content.lastmodified; delete content.lastmodifiedtime; var key = (new Date()).getTime(); if (!content) { ModalElement.alert({message: "Lỗi dữ liệu"}); rj(); return; }; hrapi.table.update("topics", key, content, (s, r) => { if (s) { if (promiseArray.length > 0){ var ex = []; var run = function(index, max){ promiseArray[index](lesson, key).then(function(retval){ ex.push(retval); if (index < max - 1) run(index + 1, max); else { content.key = key; content.childrenIndex = []; topicDict[lesson].dict[key] = EncodingClass.string.duplicate(content); if(parent != 'root') topicDict[lesson].dict[parent].childrenIndex.push(topicDict[lesson].items.length); topicDict[lesson].items.push(topicDict[lesson].dict[key]); if (lesson == params.lesson) { content.key = key; if (params.topicDict[content.parent]) params.topicDict[content.parent].childrenIndex.push(params.topics.length); params.topics.push(content); params.topicDict[key] = content; params.exerciseOfTopic[key] = []; ex.forEach((item, i) => { params.exercise.push(item); params.exerciseDict[item.key] = item; params.exerciseOfTopic[key].push(item.key); }); rs(content); // onsave(content); } else rs(content); } }, function(err){console.log(err);rj(err)}); } if (promiseArray.length > 0) run(0, promiseArray.length); } else { content.key = key; content.childrenIndex = []; topicDict[lesson].dict[key] = EncodingClass.string.duplicate(content); if(parent != 'root') topicDict[lesson].dict[parent].childrenIndex.push(topicDict[lesson].items.length); topicDict[lesson].items.push(topicDict[lesson].dict[key]); if (lesson == params.lesson) { content.key = key; if (params.topicDict[content.parent]) params.topicDict[content.parent].childrenIndex.push(params.topics.length); params.topics.push(content); params.topicDict[key] = content; params.exerciseOfTopic[key] = []; rs(content); // onsave(content); } else rs(content); } // else onsave(); } else rj(); // else onabort(); }); }); }; var lessonValue = lessonCbb.value; var topicNew = []; var replacements = {}; var dynamicLinks = {}; var initialFunc = function(content, parent){ return new Promise(function(rs, rj){ var promiseArray = []; content.forEach(function(elt){ promiseArray.push(function(){ return saveFunc(elt, parent, lessonValue); }); }); var run = function(index, max){ promiseArray[index]().then(function(retval){ topicNew.push(retval); replacements[retval.oldKey] = retval.key; dynamicLinks[retval.key] = {href: "#", text: retval.name}; initialFunc(content[index].childrenIndex.map(function(elt){ return params.topics[elt]; }), retval.key).then(function(){ if (index < max - 1) run(index + 1, max); else { rs(); } }); }, function(err){console.log(err);rj(err)}); } if (promiseArray.length > 0) run(0, promiseArray.length); else rs(); }); } initialFunc([params.content], topicCbb.value).then(function(){ var promiseArray = []; topicNew.forEach(function(elt){ promiseArray.push(function(){ var newKey = elt.key; delete elt.oldKey; elt.content.forEach((item, i) => { item.data = me.replaceDynamicLink(item.data, dynamicLinks, replacements); }); return new Promise(function(y, n){ hrapi.table.update("topics", newKey, elt, (s, r) => { if (s) y(); else n(); }); }); }); }); var end = function(){ params.dynamicLinks = {}; var t = params.getTreeList(params.topics, params.dynamicLinks); params.tree_list.nodes = t; params.tree_list.openAllNodeRecursive(2); ModalElement.closeAll(); // ModalElement.close(); } var run = function(index, max){ promiseArray[index]().then(function(retval){ if (index < max - 1) run(index + 1, max); else { end(); } }, function(err){console.log(err);rj(err)}); } if (promiseArray.length > 0) run(0, promiseArray.length); else end(); }, function(err){console.log(err);}); } }, { text: "Hủy", onclick: function(){ ModalElement.close(); onabort(); } } ] }); }); }); } } (module, retval); // function: hrplugins.keeview.e_learning.topicEdit var v47 = function(module, me) { return function (hrapi, params, onsave, onabort) { var content = params.topicDict[params.currentKey] !== undefined ? params.topicDict[params.currentKey] : { parent: params.parent }; var closeFunc = function(){ var value = { name: name.value.trim(), parent: parent.value, active: active.checked, author: author.value, time_of_write: time_of_write.value, click: click.value.trim() }; value.click = parseInt(value.click, 10); value.content = EncodingClass.string.duplicate(content.content); if (value.content) { if (EncodingClass.string.compare(value.content[value.content.length - 1].data, content_input.data) != 0) { var k = value.content[value.content.length - 1].name.indexOf("-"); var number = parseInt(value.content[value.content.length - 1].name.substr(8, k), 10); value.content.push({ name: "Version " + (number + 1) + " - " + params.currentEmp.fullname + " - " + me.getDateTimeView(new Date()), data: content_input.data }); while (value.content.length > 5) {value.content.splice(0, 1);} } } else { value.content = [{ name: "Version 1" + " - " + params.currentEmp.fullname + " - " + me.getDateTimeView(new Date()), data: content_input.data }]; } var afterValue = after.value; var topicIdx = EncodingClass.string.duplicate(afterItems); topicIdx.splice(0, 1); if (afterValue == "first") { value.idx = 0; } else { for (var i = 0; i < topicIdx.length; i++) { if (topicIdx[i].value == afterValue) { value.idx = i + 1; break; } } } var checkChange = function(){ var keys = Object.keys(value); for (var i = 0; i < keys.length; i++){ if (EncodingClass.string.compare(value[keys[i]], content[keys[i]]) != 0) return true; } return false; } if (checkChange()) { me.changeQuesion("Dữ liệu chưa được lưu, bạn có muốn lưu lại trước khi tiếp tục hay không?").then(function(rs){ if (rs == "save") { saveFunc(); params.frameList.removeLast(); } else if (rs == "dont"){ params.frameList.removeLast(); onabort(); } }); } else { params.frameList.removeLast(); onabort(); } } var closeBtn = me.noneIconButton({ text: "Quay lại", onclick: function(){ closeFunc(); } }); var saveFunc = function() { var value = { name: name.value.trim(), parent: parent.value, lesson: params.lesson, active: active.checked, author: author.value, time_of_write: time_of_write.value, editor: editor.value, time_of_edit: time_of_edit.value, click: click.value.trim() }; value.click = parseInt(value.click, 10); if (content.content) { if (EncodingClass.string.compare(content.content[content.content.length - 1].data, content_input.data) != 0) { var k = content.content[content.content.length - 1].name.indexOf("-"); var number = parseInt(content.content[content.content.length - 1].name.substr(8, k), 10); content.content.push({ name: "Version " + (number + 1) + " - " + params.currentEmp.fullname + " - " + me.getDateTimeView(new Date()), data: content_input.data }); while (content.content.length > 5) {content.content.splice(0, 1);} } } else { content.content = [{ name: "Version 1" + " - " + params.currentEmp.fullname + " - " + me.getDateTimeView(new Date()), data: content_input.data }]; } if (content.exercise) value.exercise = content.exercise; else value.exercise = []; if (content.success) value.success = content.success; else value.success = []; value.content = content.content; if (value.name == "") { ModalElement.alert({ message: "Chưa nhập tên", func: function(){ name.focus(); } }); return; } var key; if (!content.key) { key = (new Date()).getTime(); value.creator = params.currentEmpId; value.createdtime = new Date(); value.count = 0; } else { key = content.key; value.lastmodified = params.currentEmpId; value.lastmodifiedtime = new Date(); value.creator = content.creator; value.createdtime = content.createdtime; value.count = content.count === undefined ? content.count : 0; } var afterValue = after.value; var topicIdx = EncodingClass.string.duplicate(afterItems); topicIdx.splice(0, 1); if (afterValue == "first") { topicIdx.unshift({value: key}); value.idx = 0; } else { for (var i = 0; i < topicIdx.length; i++) { if (topicIdx[i].value == afterValue) { topicIdx.splice(i + 1, 0, {value: key}); value.idx = i + 1; break; } } } ModalElement.show_loading(); if (!value) { ModalElement.alert({message: "Lỗi dữ liệu"}); return; }; hrapi.table.update("topics", key, value, (s, r) => { if (s) { var t_content = value; t_content.key = key; if (!content.key) { if (params.topicDict[t_content.parent]) params.topicDict[t_content.parent].childrenIndex.push(params.topics.length); t_content.childrenIndex = []; params.topics.push(t_content); } else { var idx = params.getTopicIndex(content.key); if (idx == -1) { ModalElement.alert({message: "Có lỗi xảy ra"}); return; } t_content.childrenIndex = params.topics[idx].childrenIndex; params.topics[idx] = t_content; if (content.parent != t_content.parent){ if (t_content.parent != "root") { params.topics[params.getTopicIndex(t_content.parent)].childrenIndex.push(idx); params.topicDict[t_content.parent].childrenIndex = params.topics[params.getTopicIndex(t_content.parent)].childrenIndex; } if (content.parent != "root") { params.topics[params.getTopicIndex(content.parent)].childrenIndex = params.topics[params.getTopicIndex(content.parent)].childrenIndex.filter(function(elt){ return elt != idx; }); params.topicDict[content.parent].childrenIndex = params.topics[params.getTopicIndex(content.parent)].childrenIndex; } } } params.topicDict[key] = t_content; content = t_content; makeVersionData(t_content); var promiseArray = []; topicIdx.forEach((item, i) => { if (item.value == key) return; var t_content = EncodingClass.string.duplicate(params.topicDict[item.value]); t_content.idx = i; delete t_content.key; promiseArray.push(new Promise(function(rs, rj){ if (!t_content) { ModalElement.alert({message: "Lỗi dữ liệu"}); rj("Lỗi dữ liệu"); return; }; hrapi.table.update("topics", item.value, t_content, (s, r) => { if (s) { t_content.key = item.value; params.topics[params.getTopicIndex(t_content.key)] = t_content; params.topicDict[item.value] = t_content; rs(); } else rj(r); }); })) }); Promise.all(promiseArray).then(function(rs){ params.dynamicLinks = {}; var t = params.getTreeList(params.topics, params.dynamicLinks); params.tree_list.nodes = t; params.tree_list.openAllNodeRecursive(2); onsave(t_content); ModalElement.close(-1); }, function(err){ ModalElement.close(-1); onabort(err); }); } else { console.log(s, r); } }); }; var saveBtn = me.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var name = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.name ? content.name : "" } }); var makeTopicItems = function(indexList){ var data = []; indexList.forEach((item, i) => { if (params.topics[item].key == params.currentKey) return; var t = { value: params.topics[item].key, text: params.topics[item].name, idx: params.topics[item].idx, items: makeTopicItems(params.topics[item].childrenIndex) }; data.push(t); }); data.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); return data; }; var indexList = []; params.topics.forEach((item, i) => { if (item.parent == "root") indexList.push(i); }); var topicItems = [{ value: "root", text: "Root", items: makeTopicItems(indexList) }]; var parent = absol._({ tag: "selecttreemenu", props: { items: topicItems, enableSearch: true, value: content.parent ? content.parent : "root" }, on: { change: function() { afterItems = getAfterItems(); after.items = afterItems; if (this.value == content.parent) { after.value = params.currentKey == "" ? afterItems[afterItems.length - 1].value : afterItems[params.topicDict[params.currentKey].idx] ? afterItems[params.topicDict[params.currentKey].idx].value : afterItems[afterItems.length - 1].value; } else { after.value = afterItems[afterItems.length - 1].value; } } } }); var getAfterItems = function(){ var items = [{value: "first", text: "Đưa lên đầu"}]; var key = parent.value; if (key == "root") { indexList.forEach(function(elt){ if (params.topics[elt].key == params.currentKey) return; items.push({value: params.topics[elt].key, text: params.topics[elt].name, idx: params.topics[elt].idx}); }); } else { params.topicDict[key].childrenIndex.forEach(function(elt){ if (params.topics[elt].key == params.currentKey) return; items.push({value: params.topics[elt].key, text: params.topics[elt].name, idx: params.topics[elt].idx}); }); } items.sort(function(a, b){ if (a.idx > b.idx) return 1; if (a.idx < b.idx) return -1; return 0; }); return items; } var afterItems = getAfterItems(); var after = absol._({ tag: "selectmenu", props: { items: afterItems, enableSearch: true, value: params.currentKey == "" ? afterItems[afterItems.length - 1].value : afterItems[params.topicDict[params.currentKey].idx] ? afterItems[params.topicDict[params.currentKey].idx].value : afterItems[afterItems.length - 1].value } }); var version = absol._({ tag: "selectmenu", props: { }, on: { change: function(){ content.content[version.value].data = me.repareViewDynamicLink(content.content[version.value].data, params.dynamicLinks); content_input.data = content.content[version.value].data; } } }); var makeVersionData = function(content){ if (content.key) { var versionItem = content.content.map((item, i) => { return { value: i, text: item.name }; }); version.items = versionItem; version.value = content.content.length - 1; } }; makeVersionData(content); var active = absol._({ tag: "checkbox", props: { checked: content.active !== undefined ? content.active : true } }); var rightChild = []; rightChild.push(absol.buildDom({ attr: { "data-sectionid": "general_information" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Thông tin chung" }, } ] }), { style: { paddingLeft: "10px" }, child: DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {paddingLeft: "10px"}}, children: [name] } ], // [{attrs: {style: {paddingTop: "10px"}}}], // [ // // {text: "Alias"}, // { // attrs: {style: {paddingLeft: "10px"}}, // children: [alias] // } // ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Parent"}, { attrs: {style: {paddingLeft: "10px"}}, children: [parent] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "After"}, { attrs: {style: {paddingLeft: "10px"}}, children: [after] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Version"}, { attrs: {style: {paddingLeft: "10px"}}, children: [version] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {paddingLeft: "10px"}}, children: [active] } ] ] }) } ] })); var pages = {}; params.topics.forEach((item, i) => { pages[item.key] = {text: item.name, href: "#"}; }); if (content.content)content.content[content.content.length - 1].data = me.repareViewDynamicLink(content.content[content.content.length - 1].data, params.dynamicLinks); var content_input = absol.buildDom({ tag: 'ckplaceholder', class: "container-bot", props: { data: content.content ? content.content[content.content.length - 1].data : "", extensions: ["dynamic_link"], dynamicLinks: pages }, on:{ command: function(event){ var self = this; if (event.command == "insert_dynamic_link") { var values = []; me.linkDirectionPage(params.topics, params.topicDict, values, function(values){ var htmlCode = values.map(function (value){ var key = value; var text; var info = (self.dynamicLinks && self.dynamicLinks[key]) || {href:'.', text: 'undefined'}; if (!text){ text = info.text; } return '<a class="as-ck-widget-dynamic-link" data-link-id="'+key+'" href = "#">' + text + '</a>'; }).join(' '); self.editor.insertHtml(htmlCode); }); } }, editorready: function(event){ params.editorContent = this.editor; } } }); rightChild.push(absol.buildDom({ attr: { "data-sectionid": "content" }, child: [ { class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Nội dung" }, } ] }, { style: { paddingLeft: "10px" }, child: content_input } ] })); var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var cur = { value: -item.id, text: item.name }; var items = []; if (item.children) items = items.concat(getEmployeeItems(item.children)); if (item.employees) item.employees.forEach((item2) => { items.push({ value: item2.id, text: item2.fullname, isLeaf: true }); }); cur.items = items; data.push(cur); }); return data; }; var empItems = getEmployeeItems(params.orgs); var author = absol._({ tag: "selecttreeleafmenu", props: { items: empItems, enableSearch: true } }); if (content.author) author.value = content.author; else author.value = params.currentEmpId; var editor = absol._({ tag: "selecttreeleafmenu", props: { disabled: true, items: empItems, enableSearch: true } }); if (content.lastmodified) editor.value = content.lastmodified; else editor.value = null; var time_of_write = absol._({ tag: "dateinput", props: { value: content.time_of_write ? content.time_of_write : new Date() } }); var time_of_edit = absol._({ tag: "dateinput", props: { disabled: true, value: content.lastmodifiedtime ? content.lastmodifiedtime : null } }); var click = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.click ? content.click.toString() : "0" } }); rightChild.push(absol.buildDom({ attr: { "data-sectionid": "publication_information" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Thông tin xuất bản" }, } ] }), { style: { paddingLeft: "10px" }, child: DOMElement.table({ data: [ [ {text: "Tác giả"}, { attrs: {style: {paddingLeft: "10px"}}, children: [author] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thời gian tạo"}, { attrs: {style: {paddingLeft: "10px"}}, children: [time_of_write] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Người sửa lần cuối"}, { attrs: {style: {paddingLeft: "10px"}}, children: [editor] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thời gian sửa lần cuối"}, { attrs: {style: {paddingLeft: "10px"}}, children: [time_of_edit] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Số lần click"}, { attrs: {style: {paddingLeft: "10px"}}, children: [click] } ] ] }) } ] })); var nav = absol.buildDom({ tag:'mknavigator', style: { display:'inline-block'// or 'block' }, props: { items: [ {text: "Thông tin chung", value: "general_information"}, {text: "Nội dung", value: "content"}, {text: "Thông tin xuất bản", value: "publication_information"} ], value: "general_information" }, on:{ press: function(event){ rightCtn.off('scroll', scrollRightFunc);// prevent loop if (sectionList[this.value]) sectionList[this.value].scrollIntoView(); setTimeout(function(){ rightCtn.on('scroll', scrollRightFunc ); }, 10); } } }); var scrollRightFunc = function(){ var elt; var bound = rightCtn.getBoundingClientRect(); var eltBound; var nearestEltId; var nearestDistance = 100000000; var distance; for (var i in sectionList){ elt = sectionList[i]; eltBound = elt.getBoundingClientRect(); distance = 1000000; if (eltBound.top <= bound.top){ if (eltBound.bottom >= bound.bottom){ distance = -1e6; } else if (bound.top - eltBound.top < 30){ distance = eltBound.top - bound.bottom;//negative } else if (eltBound.bottom > bound.top){ distance = bound.top - eltBound.top; } } else if (eltBound.top < bound.bottom){ distance = eltBound.top - bound.bottom;//negative } else { distance = Math.abs(bound.top - eltBound.top) } if (nearestDistance > distance){ nearestDistance = distance; nearestEltId = i; } } nav.value = nearestEltId; }; var rightCtn = absol.buildDom({ class: 'mk-main-right', style: { paddingBottom: "var(--footer-margin)" }, child: rightChild, on: { scroll: scrollRightFunc } }); var data_ctn = absol._({ class: 'mk-main', style: { height: '100%' }, child: [ { class: 'mk-main-left-ctn', child: [nav] }, rightCtn ] }); var sectionList = {}; absol.$("div", rightCtn, function(elt){ var id = elt.getAttribute("data-sectionid"); if (!id) return; sectionList[id] = elt; }); var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn } ] } }, data_ctn ] }); params.frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.e_learning.uploadFle var v39 = function(module, me) { return function (value) { return new Promise(function(rs, rj){ var saveFile = function(){ var name = (new Date()).getTime() + "_" + value.name + ".upload"; systemconfig.connectorFile.upload({ index: 0, path: ["hr", "files"], filehandle: value, filename: name, onsuccess: function (content){ rs(name); }, onfailed: function (content){ rj(content); } }); }; systemconfig.loadFolderFunc().then(function(value){ if (value) saveFile(); else { systemconfig.reconnectFile().then(function(){ saveFile(); }); } }); }) } } (module, retval); retval.changeQuesion = v41; retval.deleteConfirm = v40; retval.exerciseEdit = v51; retval.exerciseMobileSuccess = v67; retval.exerciseMobileTable = v65; retval.exerciseMobileView = v66; retval.exerciseReport = v193; retval.exerciseSuccess = v52; retval.exerciseTable = v36; retval.exerciseView = v53; retval.exportLessonData = v171; retval.getDateTimeView = v43; retval.getDateTimeView2 = v139; retval.getTimeViewFromDateTime = v138; retval.getTopicItems = v62; retval.groupCategory = v44; retval.groupCategoryEdit = v45; retval.importLessonData = v172; retval.lessonConfig = v54; retval.lessonContentMobileView = v71; retval.lessonEdit = v50; retval.lessonLeftContentEdit = v49; retval.lessonLeftContentView = v56; retval.lessonListContentMobileView = v70; retval.lessonMobileTable = v68; retval.lessonMobileView = v69; retval.lessonRightContentEdit = v48; retval.lessonRightContentView = v57; retval.lessonTable = v46; retval.lessonView = v55; retval.linkDirectionPage = v38; retval.noneIconButton = v42; retval.openTopicByLink = v37; retval.publishedInformation = v59; retval.repareViewDynamicLink = v61; retval.replaceDynamicLink = v60; retval.topicCopy = v58; retval.topicEdit = v47; retval.uploadFle = v39; return retval; } } (module)) (); // node: hrplugins.keeview.examination var v63 = (function (module) { return function () { var retval = {}; // function: hrplugins.keeview.examination.configSendMail var v99 = function(module, me) { return function (hrapi, content, div_element, onsave, onclose) { Promise.all([ new Promise(function(rs, rj){ hrapi.templates.getGroupsList(function(r, s){ if (r) rs(s); else rj(s); }) }), new Promise(function(rs, rj){ hrapi.templates.getEmails(function(r, s){ if (r) rs(s); else rj(s); }) }) ]).then(function(value){ var host = { database: {}, dict: { groups: {}, emails: {} } }; me.makeDatabaseContent(host, {groups: value[0], emails: value[1]}); var t = {}; host.database.emails.items.forEach((item, i) => { if (!t[item.groupid]) t[item.groupid] = []; t[item.groupid].push({value: item.id, text: item.name, isLeaf: true}); }); var emailItems = [{value: "select", text: "Chọn email template", isLeaf: true}]; host.database.groups.items.forEach((item, i) => { var cur = {value: item.id, text: item.name}; if (t[item.id]) cur.items = t[item.id]; emailItems.push(cur); }); if (!content.content.emailConfig) content.content.emailConfig = { questionnaireDesigns: "select", questionnaireOpen: "select", questionnaireGrading: "select", questionnaireGraded: "select", questionnaireCancel: "select" }; var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); var saveFunc = function() { var value = { questionnaireDesigns: questionnaireDesigns.value, questionnaireOpen: questionnaireOpen.value, questionnaireGrading: questionnaireGrading.value, questionnaireGraded: questionnaireGraded.value, questionnaireCancel: questionnaireCancel.value } if (value.questionnaireDesigns == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo xây dựng câu hỏi"}); return; } if (value.questionnaireOpen == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo thực hiện kiểm tra"}); return; } if (value.questionnaireGrading == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo chấm điểm"}); return; } if (value.questionnaireGraded == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo hoàn thành chấm điểm"}); return; } if (value.questionnaireCancel == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo hủy bỏ bài kiểm tra"}); return; } content.content.emailConfig = value; hrapi.table.update("examination", content.key, content.content, function(s, r){ frameList.removeLast(); if (s) onsave(); else onclose(s, r); }); }; var saveBtn = module.e_learning.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var questionnaireDesigns = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: content.content.emailConfig.questionnaireDesigns } }); var questionnaireOpen = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: content.content.emailConfig.questionnaireOpen } }); var questionnaireGrading = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: content.content.emailConfig.questionnaireGrading } }); var questionnaireGraded = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: content.content.emailConfig.questionnaireGraded } }); var questionnaireCancel = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: content.content.emailConfig.questionnaireCancel } }); var data_ctn = absol._({ child: DOMElement.table({ data: [ [ {text: "Thông báo xây dựng câu hỏi"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireDesigns] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo thực hiện kiểm tra"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireOpen] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo chấm điểm"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireGrading] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo hoàn thành chấm điểm"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireGraded] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo hủy bỏ"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireCancel] } ] ] }) }) var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn } ] } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) } } (module, retval); // function: hrplugins.keeview.examination.doExamination var v82 = function(module, me) { return function (hrapi, content, examData, div_element, onclose, onsuccess) { div_element.changeUrl("do_examination/" + content.key); FormClass.api_call({ url: "database_load.php", params: [{name: "task", value: "current_time"}], func: function(success, message){ if (success) { if (message.substr(0, 2) == "ok"){ var currentTime = EncodingClass.string.toVariable(message.substr(2)); var r_time = currentTime.getTime(); var r_end_time = content.content.startTime.getTime() + content.content.duration * 60 * 1000; var finish = false; var outOfTimeFunc = function(){ if (finish) return; r_time = r_time + 60 * 1000; if (r_time < r_end_time) { setTimeout(function(){ outOfTimeFunc(); }, 60 * 1000); } else successFunc(); } var closeBtn = module.e_learning.noneIconButton({ text: "Quay lại", onclick: function(){ frameList.removeLast(); onclose("close"); } }); var saveFunc = function(ident, result){ hrapi.table.update("examination_details_" + content.key, "student_result_" + div_element.currentEmp.firstid + "_" + ident, result, function(s, r){ if (s) { // onsuccess(content); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(s, r); // onclose(r); } }); } var successFunc = function(){ ModalElement.show_loading(); var data = viewer.getResult(); var keys = Object.keys(data); var exc2 = function(ident, vla){ return new Promise(function(rs, rj){ if (vla.value === null || vla.value.length == 0) { rs(); } else { hrapi.table.update("examination_details_" + content.key, "student_result_" + div_element.currentEmp.firstid + "_" + ident, vla.value, function(s, r){ if (s) { rs(); } else { rj([s, r]); } }); } }); } var exc = function(idx){ exc2(keys[idx], data[keys[idx]]).then(function(){ if (idx < keys.length - 1) exc(idx + 1); else { hrapi.table.update("examination_details_" + content.key, "student_success_" + div_element.currentEmp.firstid, true, function(s, r){ if (s) { hrapi.table.update("examination_details_" + content.key, "student_completed_time_" + div_element.currentEmp.firstid, new Date(), function(s1, r1){ if (s1) { ModalElement.close(); finish = true; frameList.removeLast(); onsuccess(content); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(s1, r1); } }) } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(s, r); } }); } },function(err){ ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(err); }); } exc(0); } var successBtn = module.e_learning.noneIconButton({ text: "Hoàn thành", onclick: function(){ var title = "Hoàn thành"; var message = "Bạn có chắc chắn đã hoàn thành bài kiểm tra"; module.e_learning.deleteConfirm(title, message).then(function(){ successFunc(); }); } }); var container = absol._({ class: "as-pseudo-align-child-center", style: { height: "100%" } }); var resultInfo = absol._({ style: { display: "inline-block", verticalAlign: "middle" } }); var timeInfo = absol._({ style: { display: "inline-block", verticalAlign: "middle" } }); var singlePage = absol.buildDom({ tag: "singlepage", class: "as-viewport-full", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: successBtn }, { class: "single-button-header", child: absol._({ style: { fontWeight: "bold" }, child: [resultInfo, timeInfo] }) } ] } }, { style: { paddingLeft: "10px", userSelect: "none", height: "100%" }, child: container } ] }); var viewer; var makeQuesion = function(){ container.removeClass("as-pseudo-align-child-center"); singlePage.removeClass("as-viewport-full"); closeBtn.style.display = "none"; var PoserViewer = absol.poser.PoserViewer; viewer = new PoserViewer( { hasScroller: false, hasSection: false } ); var saveTimeout = -1; viewer.on("resultchange", function(event){ var data = viewer.getResult(); answerCount = 0; t_content.forEach((item, i) => { item.questions.forEach((item2, i) => { if (data[item2.ident].value){ if (item2.type == "checkboxes" || item2.type == "paragraph" || item2.type == "short_answer") { if (data[item2.ident].value.length > 0) answerCount++; } else answerCount++; } }); }); resultInfo.clearChild(); resultInfo.addChild(absol._({text: "Câu hỏi đã làm: " + answerCount + "/" + count + "- Thời gian còn lại: "})); if (saveTimeout > 0) clearTimeout(saveTimeout); saveTimeout = setTimeout(function(){ saveTimeout = -1; console.log(event); saveFunc(event.questionIdent, event.questionResult); }, 500); }); var mPoserView = viewer.getView(); var count = 0; var answerCount = 0; var result = {}; if (examData.student[div_element.currentEmp.firstid] && examData.student[div_element.currentEmp.firstid].result) { result = EncodingClass.string.duplicate(examData.student[div_element.currentEmp.firstid].result); } var t_content = []; if (examData.questions) { t_content = EncodingClass.string.duplicate(examData.questions.content); t_content.forEach((item, i) => { item.questions.forEach((item2, i) => { count++; if (result[item2.ident] && result[item2.ident].value !== null){ if (item2.type == "checkboxes" || item2.type == "paragraph" || item2.type == "short_answer") { if (result[item2.ident].value.length > 0) answerCount++; } else answerCount++; } delete item2.correct_answer; }); }); viewer.setData(t_content); viewer.setResult(result); } else viewer.setData([]); var t_time = EncodingClass.string.duplicate(content.content.startTime); t_time.setMinutes(t_time.getMinutes() + content.content.duration); var clock = absol._({ tag: 'countdowntext', props: { finishTime: t_time, format: "standard", fps: 3 }, on: { } }); resultInfo.addChild(absol._({text: "Câu hỏi đã làm: " + answerCount + "/" + count + "- Thời gian còn lại: "})); timeInfo.addChild(clock); container.clearChild(); container.addChild(mPoserView); } if (currentTime < content.content.startTime) { successBtn.style.display = "none"; var clock = absol._({ tag: 'countdowntext', props: { finishTime: content.content.startTime, format: "standard", fps: 3 }, on: { finish: function(){ successBtn.style.display = ""; makeQuesion(); var run = function(){ hrapi.table.update("examination_details_" + content.key, "student_success_" + div_element.currentEmp.firstid, false, function(s, r){ if (s) { hrapi.table.update("examination_details_" + content.key, "student_start_time_" + div_element.currentEmp.firstid, new Date(), function(s1, r1){ if (s1) { } else { run(); } }); } else { run(); } }); } run(); outOfTimeFunc(); } } }); container.addChild(absol._({ style: { fontSize: "18px" }, child: [ { style: { fontWeight: "bold" }, child: {text: "Bạn chuẩn bị làm bài kiểm tra \"" + content.content.name + "\""} }, { style: { paddingTop: "20px" }, child: {text: "Thời gian bắt đầu: " + module.e_learning.getDateTimeView(content.content.startTime)} }, { style: { fontWeight: "bold", paddingTop: "20px" }, child: clock } ] })) } else { if ( currentTime.getTime() > (content.content.startTime.getTime()) + content.content.delay * 60 * 1000 && examData.student[div_element.currentEmp.firstid] === undefined ) { container.addChild(absol._({style: {fontSize: "18px", fontWeight: "bold"}, child: {text: "Bạn vào muộn hơn thời gian quy định, không thể thực hiện bài kiểm tra"}})); successBtn.style.display = "none"; } else if (currentTime.getTime() < (content.content.startTime.getTime()) + content.content.duration * 60 * 1000) { makeQuesion(); var run = function(){ hrapi.table.update("examination_details_" + content.key, "student_success_" + div_element.currentEmp.firstid, false, function(s, r){ if (s) { hrapi.table.update("examination_details_" + content.key, "student_start_time_" + div_element.currentEmp.firstid, new Date(), function(s1, r1){ if (s1) { } else { run(); } }); } else { run() } }); } run(); outOfTimeFunc(); } else { container.addChild(absol._({style: {fontSize: "18px", fontWeight: "bold"}, child: {text: "Đã kết thúc thời gian làm bài"}})); successBtn.style.display = "none"; } } var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } frameList.addChild(singlePage); singlePage.requestActive(); } else { console.log(message); } } else { console.log(message); } } }) } } (module, retval); // function: hrplugins.keeview.examination.doExaminationMobile var v176 = function(module, me) { return function (hrapi, content, examData, div_element, onclose, onsuccess) { FormClass.api_call({ url: "database_load.php", params: [{name: "task", value: "current_time"}], func: function(success, message){ if (success) { if (message.substr(0, 2) == "ok"){ var currentTime = EncodingClass.string.toVariable(message.substr(2)); var r_time = currentTime.getTime(); var r_end_time = content.content.startTime.getTime() + content.content.duration * 60 * 1000; var finish = false; var outOfTimeFunc = function(){ if (finish) return; r_time = r_time + 60 * 1000; if (r_time < r_end_time) { setTimeout(function(){ outOfTimeFunc(); }, 60 * 1000); } else successFunc(); } var saveFunc = function(ident, result){ hrapi.table.update("examination_details_" + content.key, "student_result_" + div_element.currentEmp.firstid + "_" + ident, result, function(s, r){ if (s) { // onsuccess(content); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(s, r); // onclose(r); } }); } var successFunc = function(){ ModalElement.show_loading(); var data = viewer.getResult(); var keys = Object.keys(data); var exc2 = function(ident, vla){ return new Promise(function(rs, rj){ if (vla.value === null || vla.value.length == 0) { rs(); } else { hrapi.table.update("examination_details_" + content.key, "student_result_" + div_element.currentEmp.firstid + "_" + ident, vla.value, function(s, r){ if (s) { rs(); } else { rj([s, r]); } }); } }); } var exc = function(idx){ exc2(keys[idx], data[keys[idx]]).then(function(){ if (idx < keys.length - 1) exc(idx + 1); else { hrapi.table.update("examination_details_" + content.key, "student_success_" + div_element.currentEmp.firstid, true, function(s, r){ if (s) { hrapi.table.update("examination_details_" + content.key, "student_completed_time_" + div_element.currentEmp.firstid, new Date(), function(s1, r1){ if (s1) { ModalElement.close(); finish = true; frameList.removeLast(); onsuccess(content); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(s1, r1); } }) } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(s, r); } }); } },function(err){ ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(err); }); } exc(0); } var container = absol._({ class: "as-pseudo-align-child-center", style: { height: "100%" } }); var resultInfo = absol._({ style: { display: "inline-block", verticalAlign: "middle" } }); var timeInfo = absol._({ style: { display: "inline-block", verticalAlign: "middle" } }); var icon = DOMElement.i({ attrs: { className: "mdi mdi-check-circle-outline" } }); var commands = [{ icon: icon, cmd: function(){ var title = "Hoàn thành"; var message = "Bạn có chắc chắn đã hoàn thành bài kiểm tra"; module.e_learning.deleteConfirm(title, message).then(function(){ successFunc(); }); } }]; var header = absol.buildDom({ tag: 'mheaderbar', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: content.content.name, commands: commands }, on: { action: function(){ if (!c) frameList.removeLast(); onclose(content); }, command: function(event){ event.commandItem.cmd(); } } }); var singlePage = absol.buildDom({ tag: 'tabframe', child:[ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [container] }) ] }); var viewer; var c = false; var makeQuesion = function(){ c = true; container.removeClass("as-pseudo-align-child-center"); singlePage.removeClass("as-viewport-full"); icon.style.display = ""; var PoserViewer = absol.poser.PoserViewer; viewer = new PoserViewer( { hasScroller: false, hasSection: false } ); var saveTimeout = -1; viewer.on("resultchange", function(event){ var data = viewer.getResult(); answerCount = 0; t_content.forEach((item, i) => { item.questions.forEach((item2, i) => { if (data[item2.ident].value){ if (item2.type == "checkboxes" || item2.type == "paragraph" || item2.type == "short_answer") { if (data[item2.ident].value.length > 0) answerCount++; } else answerCount++; } }); }); resultInfo.clearChild(); resultInfo.addChild(absol._({text: "Câu hỏi đã làm: " + answerCount + "/" + count + "- Thời gian còn lại: "})); if (saveTimeout > 0) clearTimeout(saveTimeout); saveTimeout = setTimeout(function(){ saveTimeout = -1; console.log(event); saveFunc(event.questionIdent, event.questionResult); }, 500); }); var mPoserView = viewer.getView(); var count = 0; var answerCount = 0; var result = {}; if (examData.student[div_element.currentEmp.firstid] && examData.student[div_element.currentEmp.firstid].result) { result = EncodingClass.string.duplicate(examData.student[div_element.currentEmp.firstid].result); } var t_content = []; if (examData.questions) { t_content = EncodingClass.string.duplicate(examData.questions.content); t_content.forEach((item, i) => { item.questions.forEach((item2, i) => { count++; if (result[item2.ident] && result[item2.ident].value !== null){ if (item2.type == "checkboxes" || item2.type == "paragraph" || item2.type == "short_answer") { if (result[item2.ident].value.length > 0) answerCount++; } else answerCount++; } delete item2.correct_answer; }); }); viewer.setData(t_content); viewer.setResult(result); } else viewer.setData([]); var t_time = EncodingClass.string.duplicate(content.content.startTime); t_time.setMinutes(t_time.getMinutes() + content.content.duration); var clock = absol._({ tag: 'countdowntext', props: { finishTime: t_time, format: "standard", fps: 3 }, on: { } }); resultInfo.addChild(absol._({text: "Câu hỏi đã làm: " + answerCount + "/" + count + "- Thời gian còn lại: "})); timeInfo.addChild(clock); container.clearChild(); container.addChild(mPoserView); } if (currentTime < content.content.startTime) { icon.style.display = "none"; var clock = absol._({ tag: 'countdowntext', props: { finishTime: content.content.startTime, format: "standard", fps: 3 }, on: { finish: function(){ icon.style.display = ""; makeQuesion(); var run = function(){ hrapi.table.update("examination_details_" + content.key, "student_success_" + div_element.currentEmp.firstid, false, function(s, r){ if (s) { hrapi.table.update("examination_details_" + content.key, "student_start_time_" + div_element.currentEmp.firstid, new Date(), function(s1, r1){ if (s1) { } else { run(); } }); } else { run(); } }); } run(); outOfTimeFunc(); } } }); container.addChild(absol._({ style: { fontSize: "18px" }, child: [ { style: { fontWeight: "bold" }, child: {text: "Bạn chuẩn bị làm bài kiểm tra \"" + content.content.name + "\""} }, { style: { paddingTop: "20px" }, child: {text: "Thời gian bắt đầu: " + module.e_learning.getDateTimeView(content.content.startTime)} }, { style: { fontWeight: "bold", paddingTop: "20px" }, child: clock } ] })) } else { if ( currentTime.getTime() > (content.content.startTime.getTime()) + content.content.delay * 60 * 1000 && examData.student[div_element.currentEmp.firstid] === undefined ) { container.addChild(absol._({style: {fontSize: "18px", fontWeight: "bold"}, child: {text: "Bạn vào muộn hơn thời gian quy định, không thể thực hiện bài kiểm tra"}})); icon.style.display = "none"; } else if (currentTime.getTime() < (content.content.startTime.getTime()) + content.content.duration * 60 * 1000) { makeQuesion(); var run = function(){ hrapi.table.update("examination_details_" + content.key, "student_success_" + div_element.currentEmp.firstid, false, function(s, r){ if (s) { hrapi.table.update("examination_details_" + content.key, "student_start_time_" + div_element.currentEmp.firstid, new Date(), function(s1, r1){ if (s1) { } else { run(); } }); } else { run() } }); } run(); outOfTimeFunc(); } else { container.addChild(absol._({style: {fontSize: "18px", fontWeight: "bold"}, child: {text: "Đã kết thúc thời gian làm bài"}})); icon.style.display = "none"; } } var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } frameList.addChild(singlePage); singlePage.requestActive(); } else { console.log(message); } } else { console.log(message); } } }) } } (module, retval); // function: hrplugins.keeview.examination.evaluatingExamination var v83 = function(module, me) { return function (hrapi, content, examData, div_element, onclose, onsuccess) { var makeRatingText = function(percent){ var ratingText = ""; var ratingScale = content.content.ratingScale; for (var i = 0; i < ratingScale.length; i++) { if (i == 0) { if (percent >= ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } else if (i == ratingScale.length - 1) { if (percent > ratingScale[i].min) { ratingText = ratingScale[i].text; break; } } else { if (percent > ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } } return ratingText; }; var closeBtn = module.e_learning.noneIconButton({ text: "Quay lại", onclick: function(){ frameList.removeLast(); onclose(); } }); var successBtn = module.e_learning.noneIconButton({ text: "Hoàn thành chấm điểm", onclick: function(){ frameList.removeLast(); onsuccess(); } }); var scoreTotal = 0; examData.questions.content.forEach((item, i) => { item.questions.forEach((item2, i) => { scoreTotal += item2.score; }); }); if (!content.content.student) content.content.student = []; var data = []; var getEmployeeItems = function(orgs, data, path){ orgs.forEach((item, i) => { if (item.employees) item.employees.forEach((item2) => { if (content.content.student.indexOf(item2.firstid) != -1) { var successElt = absol._({ tag: "switch", style: { fontSize: "var(--switch-fontsize)" }, props: { checked: examData.student[item2.firstid] && examData.student[item2.firstid].evaluated, disabled: true } }); var sumScore = 0; var ratingText = ""; if (examData.student[item2.firstid]) { if (examData.student[item2.firstid].score) { var keys = Object.keys(examData.student[item2.firstid].score); keys.forEach((item, i) => { sumScore += examData.student[item2.firstid].score[item].score; }); } var percent = parseInt((sumScore / scoreTotal * 100), 10); ratingText = makeRatingText(percent); } else sumScore = "Không làm bài"; var scoreElt = absol._({ style: { textAlign: "center" }, child: {text: sumScore.toString()} }); var ratingElt = absol._({ style: { textAlign: "center" }, child: {text: ratingText} }); var cells = [ { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(DOMElement.span({attrs: {className: "as-dt-row-index"}})); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: item2.fullname} })); } }, { style: { textAlign: "center" }, render: function(tdElt){ tdElt.addChild(successElt); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: path + "\\ " + item.name} })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: scoreElt })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: ratingElt })); } }, { render: function(tdElt) { tdElt.addChild(absol._({ tag: "span", style: { cursor: "pointer", color: "var(--a-color)", display: examData.student[item2.firstid] ? "" : "none" }, child: {text: "Chấm điểm"}, on: { click: function(){ var onclose = function(){ }; var onsuccess = function(s){ examData.student[item2.firstid] = s; successElt.checked = s.evaluated; scoreElt.clearChild(); var sumScore = 0; var keys = Object.keys(s.score); keys.forEach((item, i) => { sumScore += s.score[item].score; }); scoreElt.addChild(absol._({text: sumScore.toString()})); var percent = parseInt((sumScore / scoreTotal * 100), 10); ratingText = makeRatingText(percent); ratingElt.clearChild(); ratingElt.addChild(absol._({text: ratingText})); // this.style.display = "none"; div_element.makeStudent(content.content.student); }; me.evaluatingExaminationDetail(hrapi, content, examData, item2.firstid, div_element, onclose, onsuccess) } } })); } } ]; var row = { cells: cells }; row.id = item2.firstid; data.push(row); } }); if (item.children) getEmployeeItems(item.children, data, path != "" ? path + "\\ " + item.name : item.name); // cur.items = items; // data.push(cur); }); }; getEmployeeItems(div_element.database.orgs.items, data, "", []); var header = [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Đã chấm điểm"} }, { child: {text: "Bộ phận"} }, { child: {text: "Điểm"} }, { child: {text: "Xếp loại"} }, {} ]; var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: header } ] }, body: { rows: data } } } } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: successBtn } ] } }, { style: { paddingLeft: "10px", userSelect: "none" }, child: tableView } ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.examination.evaluatingExaminationDetail var v84 = function(module, me) { return function (hrapi, content, examData, empid, div_element, onclose, onsuccess) { var closeBtn = module.e_learning.noneIconButton({ text: "Quay lại", onclick: function(){ frameList.removeLast(); onclose(); } }); var successBtn = module.e_learning.noneIconButton({ text: "Hoàn thành", onclick: function(){ ModalElement.show_loading(); examData.student[empid].score = viewer.getEvaluation(); examData.student[empid].evaluated = true; hrapi.table.update("examination_details_" + content.key, "student_score_" + empid, examData.student[empid].score, function(s, r){ ModalElement.close(-1); if (s){ hrapi.table.update("examination_details_" + content.key, "student_evaluated_" + empid, examData.student[empid].evaluated, function(s, r){ ModalElement.close(-1); if (s){ frameList.removeLast(); onsuccess(examData.student[empid]); } else { ModalElement.alert({message: "update error"}); console.log(s, r); } }) } else { ModalElement.alert({message: "update error"}); console.log(s, r); } }) } }); var PoserEvaluation = absol.poser.PoserEvaluation; var viewer = new PoserEvaluation( { hasScroller: false, hasSection: true } ); viewer.on("evaluationchange", function(event){ var score = viewer.getEvaluation(); chartDiv.clearChild(); chartDiv.addChild(me.makeResultChart(examData.questions.content, { result: examData.student[empid].result, score: score, startTime: examData.student[empid].startTime, completedTime: examData.student[empid].completedTime, }, content.content.ratingScale, div_element.employeeDict[empid])); }); var mPoserView = viewer.getView(); var studentData = { sections: examData.questions.content, result: examData.student[empid].result }; if (!studentData.result) { ModalElement.alert({message: "Thí sinh này chưa thực hiện bài kiểm tra"}); return; } viewer.setData(studentData); if (examData.student[empid].score) viewer.setEvaluation(examData.student[empid].score); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var score = viewer.getEvaluation(); var chartDiv = absol._({ style: { textAlign: "center" }, child: me.makeResultChart(examData.questions.content, { result: examData.student[empid].result, score: score, startTime: examData.student[empid].startTime, completedTime: examData.student[empid].completedTime, }, content.content.ratingScale, div_element.employeeDict[empid]) }); var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: successBtn } ] } }, chartDiv, { style: { paddingTop: "20px", paddingLeft: "10px", userSelect: "none" }, child: mPoserView } ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.examination.examinationAddNew var v75 = function(module, me) { return function (hrapi, content, onsave, onabort) { hrapi.table.select("examination_config_mail", function(s, value){ var emailConfig; if (!s || value.length == 0) { emailConfig = { questionnaireDesigns: "select", questionnaireOpen: "select", questionnaireGrading: "select", questionnaireGraded: "select", questionnaireCancel: "select" }; } else { emailConfig = value[0].content } hrapi.table.select("examination_category", function(s, value){ if (!s) { ModalElement.alert({message: value}); return; } hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); return; } if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } value.unshift({key: "general_group", content: { name: "Nhóm chung", comment: "", active: true }}); var groupItems = value.map(function(elt){ return { value: elt.key, text: elt.content.name }; }); // groupItems.unshift({value: "all", text: "Chọn nhóm bài kiểm tra"}); var stageItems = [ {value: "plan", text: "Kế hoạch"}, {value: "question", text: "Xây dựng câu hỏi"}, {value: "question_success", text: "Hoàn thành câu hỏi"}, {value: "ongoing", text: "Thực hiện kiểm tra"}, {value: "evaluating", text: "Thực hiện chấm điểm"}, {value: "evaluated", text: "Chấm điểm xong"}, {value: "finish", text: "Kết thúc"}, {value: "cancel", text: "Hủy"} ]; var name = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.name ? content.name : "" } }); var group = absol._({ tag: "selectmenu", props: { items: groupItems, value: content.category } }); var stage = absol._({ tag: "selectmenu", props: { items: stageItems, value: content.stage } }); var comment = absol._({ tag: "textarea", class: "cardSimpleTextarea", style: { width: "400px" }, props: { value: content.comment ? content.comment : "" } }); var feedbackDisplay = absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: content.feedbackDisplay } }); var orderRandom = absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: content.orderRandom } }); var evaluationTime = absol._({ tag: "numberinput", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.evaluationTime ? content.evaluationTime : 96 } }); var startTime = absol._({ tag: "datetimeinput", props: { value: content.startTime } }); var duration = absol._({ tag: "numberinput", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.duration ? content.duration : 0 } }); var delay = absol._({ tag: "numberinput", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.delay ? content.delay : 0 } }); var ratingContent = me.ratingData(content.ratingScale) var active = absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: content.active !== undefined ? content.active : true } }); ModalElement.showWindow({ title: content.key ? "Sửa bài kiểm tra" : "Thêm bài kiểm tra", noPadding: true, bodycontent: DOMElement.table({ data: [ [ { text: "Tên" }, { attrs: { style: { paddingLeft: "10px" } }, children: [name] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Nhóm" }, { attrs: { style: { paddingLeft: "10px" } }, children: [group] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Giai đoạn" }, { attrs: { style: { paddingLeft: "10px" } }, children: [stage] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Mô tả" }, { attrs: { style: { paddingLeft: "10px" } }, children: [comment] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Hiển thị nhận xét trả lời" }, { attrs: { style: { paddingLeft: "10px" } }, children: [feedbackDisplay] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Thứ tự câu hỏi ngẫu nhiên" }, { attrs: { style: { paddingLeft: "10px" } }, children: [orderRandom] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Thời gian chấm điểm (giờ)" }, { attrs: { style: { paddingLeft: "10px" } }, children: [evaluationTime] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Thời gian kiểm tra bắt đầu" }, { attrs: { style: { paddingLeft: "10px" } }, children: [startTime] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Thời lượng (phút)" }, { attrs: { style: { paddingLeft: "10px" } }, children: [duration] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Được phép bắt đầu trế (phút)" }, { attrs: { style: { paddingLeft: "10px" } }, children: [delay] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Xếp loại (%)" }, { attrs: { style: { paddingLeft: "10px" } }, children: [ratingContent] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Hoạt động" }, { attrs: { style: { paddingLeft: "10px" } }, children: [active] } ] ] }), buttonlist: [ { text: "Lưu", onclick: function(){ var value = { name: name.value.trim(), category: group.value, stage: stage.value, comment: comment.value.trim(), feedbackDisplay: feedbackDisplay.checked, orderRandom: orderRandom.checked, evaluationTime: evaluationTime.value, startTime: startTime.value, duration: duration.value, delay: delay.value, ratingScale: ratingContent.getValue(), active: active.checked }; if (value.name == "") { ModalElement.alert({ message: "Chưa nhập tên", func: function(){ name.focus(); } }); return; } if (value.category == "all") { ModalElement.alert({ message: "Chưa chọn nhóm" }); return; } if (value.stage == "all") { ModalElement.alert({ message: "Chưa chọn giai đoạn" }); return; } if (value.evaluationTime <= 0) { ModalElement.alert({ message: "Thời gian chấm điểm không hợp lệ", func: function(){ evaluationTime.focus(); } }); return; } if (value.duration <= 0) { ModalElement.alert({ message: "Thời lượng không hợp lệ", func: function(){ duration.focus(); } }); return; } if (value.delay < 0) { ModalElement.alert({ message: "Được phép bắt đầu trễ không hợp lệ", func: function(){ delay.focus(); } }); return; } if (!content) content = {}; var t_content = {}; var keys = Object.keys(value); keys.forEach((item, i) => { if (item == "creator") return; if (item == "createdtime") return; if (item == "lastmodified") return; if (item == "lastmodifiedtime") return; if (item == "key") return; content[item] = value[item]; }); var key; if (!content.key) { key = (new Date()).getTime(); content.creator = currentEmp.firstid; content.createdtime = new Date(); content.emailConfig = emailConfig; ModalElement.show_loading(); hrapi.table.update("examination", key, content, function(s, r){ ModalElement.closeAll(); if (s) { hrapi.table.create("examination_details_" + key, (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); onabort(r); return; } if(onsave) { content.key = key; onsave(content); } }) } else if(onabort) onabort(r); }); } else { key = content.key; content.lastmodified = currentEmp.firstid; content.lastmodifiedtime = new Date(); ModalElement.show_loading(); hrapi.table.update("examination", key, content, function(s, r){ ModalElement.closeAll(); if (s) { if(onsave) { content.key = key; onsave(content); } } else if(onabort) onabort(r); }); } } }, { text: "Hủy", onclick: function(){ ModalElement.closeAll(); onabort(); } } ] }); }); }); }); }); } } (module, retval); // function: hrplugins.keeview.examination.examinationConfigMail var v100 = function(module, me) { return function (hrapi, div_element, onclose) { hrapi.table.create("examination_config_mail", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } Promise.all([ new Promise(function(rs, rj){ hrapi.templates.getGroupsList(function(r, s){ if (r) rs(s); else rj(s); }) }), new Promise(function(rs, rj){ hrapi.templates.getEmails(function(r, s){ if (r) rs(s); else rj(s); }) }), new Promise(function(rs, rj){ hrapi.table.select("examination_config_mail", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }) ]).then(function(value){ var host = { database: {}, dict: { groups: {}, emails: {} } }; var config = value[2]; me.makeDatabaseContent(host, {groups: value[0], emails: value[1]}); var t = {}; host.database.emails.items.forEach((item, i) => { if (!t[item.groupid]) t[item.groupid] = []; t[item.groupid].push({value: item.id, text: item.name, isLeaf: true}); }); var emailItems = [{value: "select", text: "Chọn email template", isLeaf: true}]; host.database.groups.items.forEach((item, i) => { var cur = {value: item.id, text: item.name}; if (t[item.id]) cur.items = t[item.id]; emailItems.push(cur); }); var emailConfig; if (config.length == 0) emailConfig = { questionnaireDesigns: "select", questionnaireOpen: "select", questionnaireGrading: "select", questionnaireGraded: "select", questionnaireCancel: "select" }; else emailConfig = config[0].content; var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); var saveFunc = function() { var value = { questionnaireDesigns: questionnaireDesigns.value, questionnaireOpen: questionnaireOpen.value, questionnaireGrading: questionnaireGrading.value, questionnaireGraded: questionnaireGraded.value, questionnaireCancel: questionnaireCancel.value } if (value.questionnaireDesigns == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo xây dựng câu hỏi"}); return; } if (value.questionnaireOpen == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo thực hiện kiểm tra"}); return; } if (value.questionnaireGrading == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo chấm điểm"}); return; } if (value.questionnaireGraded == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo hoàn thành chấm điểm"}); return; } if (value.questionnaireCancel == "select"){ ModalElement.alert({message: "Chưa chọn template cho Thông báo hủy bỏ bài kiểm tra"}); return; } hrapi.table.update("examination_config_mail", "config_mail", value, function(s, r){ }); }; var saveBtn = module.e_learning.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var questionnaireDesigns = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: emailConfig.questionnaireDesigns } }); var questionnaireOpen = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: emailConfig.questionnaireOpen } }); var questionnaireGrading = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: emailConfig.questionnaireGrading } }); var questionnaireGraded = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: emailConfig.questionnaireGraded } }); var questionnaireCancel = absol._({ tag: "selecttreeleafmenu", props: { enableSearch: true, items: emailItems, value: emailConfig.questionnaireCancel } }); var data_ctn = absol._({ child: DOMElement.table({ data: [ [ {text: "Thông báo xây dựng câu hỏi"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireDesigns] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo thực hiện kiểm tra"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireOpen] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo chấm điểm"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireGrading] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo hoàn thành chấm điểm"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireGraded] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thông báo hủy bỏ"}, { attrs: {style: {paddingLeft: "10px"}}, children: [questionnaireCancel] } ] ] }) }) var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn } ] } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) }) } } (module, retval); // function: hrplugins.keeview.examination.examinationEdit var v77 = function(module, me) { return function (hrapi, content, div_element, onsave, onabort) { var examInfo = content; if (examInfo.content.student) examInfo.content.student = examInfo.content.student.filter(function(elt, idx){return examInfo.content.student.indexOf(elt) == idx}); var saveFunc = function(content, field, value) { return new Promise(function(rs, rj) { ModalElement.show_loading(); examInfo.content.lastmodified = div_element.currentEmp.firstid; examInfo.content.lastmodifiedtime = new Date(); examInfo.content[field] = value; hrapi.table.update("examination", examInfo.key, examInfo.content, function(s, r){ if (s){ ModalElement.close(-1); rs() } else { ModalElement.alert({message: "update error"}); rj(); } }); }) } var run = function(){ hrapi.table.select("examination_details_" + examInfo.key, function(r, s){ if (r){ run2(s); } else { onabort(s); } }) } var run2 = function(content) { var teacher = []; if (examInfo.content.teacher) { teacher = examInfo.content.teacher; } var student = []; if (examInfo.content.student) { var student = examInfo.content.student; } var examData = { questions: {}, student: {}, teacher: {} }; student.forEach((item, i) => { examData.student[item] = {}; }); content.forEach((item, i) => { if (item.key == "questions") examData.questions = item.content; else if (item.key.startsWith("student_success_")) { if (!examData.student[item.key.substr(16)]) return; examData.student[item.key.substr(16)].success = item.content; } else if (item.key.startsWith("student_evaluated_")) { if (!examData.student[item.key.substr(18)]) return; examData.student[item.key.substr(18)].evaluated = item.content; } else if (item.key.startsWith("student_result_")) { var str = item.key.substr(15); var k = str.indexOf("_"); var studentid = str.substr(0, k); var qIdent = str.substr(k + 1); if (!examData.student[studentid]) return; if (!examData.student[studentid].result) examData.student[studentid].result = {}; examData.student[studentid].result[qIdent] = {ident: qIdent, value: item.content}; } else if (item.key.startsWith("student_score_")) { if (!examData.student[item.key.substr(14)]) return; examData.student[item.key.substr(14)].score = item.content; } else if (item.key.startsWith("student_start_time_")) { if (!examData.student[item.key.substr(19)]) return; examData.student[item.key.substr(19)].startTime = item.content; } else if (item.key.startsWith("student_completed_time_")) { if (!examData.student[item.key.substr(23)]) return; examData.student[item.key.substr(23)].completedTime = item.content; } }); if (!examData.questions.content) examData.questions.content = []; var editPriv = []; if (examInfo.content.editPriv) { examInfo.content.editPriv.forEach(function(elt){ if (elt > 0) editPriv.push(elt); else { editPriv = editPriv.concat(div_element.orgDict[-elt].all_employees); } }) // editPriv = examInfo.content.editPriv; } var viewPriv = []; if (examInfo.content.viewPriv) { examInfo.content.viewPriv.forEach(function(elt){ if (elt > 0) viewPriv.push(elt); else { viewPriv = viewPriv.concat(div_element.orgDict[-elt].all_employees); } }) // viewPriv = examInfo.content.viewPriv; } var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onabort("close"); } }); var buttonlist = [ { class: "single-button-header", child: closeBtn } ]; var questionBtn = module.e_learning.noneIconButton({ text: "Xây dựng câu hỏi", onclick: function(){ if (!examInfo.content.teacher || examInfo.content.teacher.length == 0) { ModalElement.alert({message: "Chưa thêm giáo viên"}); return; } if (!examInfo.content.student || examInfo.content.student.length == 0) { ModalElement.alert({message: "Chưa thêm thí sinh"}); return; } changeStageToQuestion(); } }); var exportBtn = module.e_learning.noneIconButton({ text: "Export", onclick: function(){ me.exportData(hrapi, examInfo); } }); var changeStageToQuestion = function(linkElt){ var message = "Bạn muốn chuyển trạng thái bài kiểm tra sang giai đoạn \"Xây dựng câu hỏi\" phải không?" module.e_learning.deleteConfirm("Chuyển trạng thái", message).then(function(){ saveFunc(examInfo, "stage", "question").then(function(){ frameList.removeLast(); me.examinationEdit(hrapi, examInfo, div_element, onsave, onabort); }) }); }; var onGoingBtn = module.e_learning.noneIconButton({ text: "Thực hiện kiểm tra", onclick: function(){ changeStageToOnGoing(); } }); var changeStageToOnGoing = function(linkElt){ var message = "Bạn muốn chuyển trạng thái bài kiểm tra sang giai đoạn \"Thực hiện kiểm tra\" phải không?" module.e_learning.deleteConfirm("Chuyển trạng thái", message).then(function(){ saveFunc(examInfo, "stage", "ongoing").then(function(){ frameList.removeLast(); me.examinationEdit(hrapi, examInfo, div_element, onsave, onabort); }) }); }; var evaluatingBtn = module.e_learning.noneIconButton({ text: "Đang chấm điểm", onclick: function(){ changeStageToEvaluating(); } }); var mockExamination = function(){ var onclose = function(r){ } var onsuccess = function(){ } me.mockExamination(hrapi, examInfo, examData, div_element, onclose, onsuccess); }; var mockExaminationBtn = module.e_learning.noneIconButton({ text: "Làm thử bài kiểm tra", onclick: function(){ mockExamination(); } }); var changeStageToEvaluating = function(linkElt){ var message = "Bạn muốn chuyển trạng thái bài kiểm tra sang giai đoạn \"Đang chấm điểm\" phải không?" module.e_learning.deleteConfirm("Chuyển trạng thái", message).then(function(){ saveFunc(examInfo, "stage", "evaluating").then(function(){ frameList.removeLast(); me.examinationEdit(hrapi, examInfo, div_element, onsave, onabort); }) }); } var sendMailItems = [ { text: "Thông báo xây dựng câu hỏi", templateid: examInfo.content.emailConfig.questionnaireDesigns, mailTo: "teacher" }, { text: "Thông báo thực hiện kiểm tra", templateid: examInfo.content.emailConfig.questionnaireOpen, mailTo: "student" }, { text: "Thông báo chấm điểm", templateid: examInfo.content.emailConfig.questionnaireGrading, mailTo: "teacher" }, { text: "Thông báo hoàn thành chấm điểm", templateid: examInfo.content.emailConfig.questionnaireGraded, mailTo: "student" }, { text: "Thông báo hủy bỏ", templateid: examInfo.content.emailConfig.questionnaireCancel, mailTo: "all" } ]; var sendMailBtn = me.ribbonButton({ text: "Gửi mail", items: sendMailItems, select: function(event){ sendMailFunc(event.item); } }); var sendMailFunc = function(item){ var template, tIndex, mailTo; mailTo = item.mailTo; tIndex = div_element.database.email_templates.getIndex(item.templateid); if (tIndex === undefined) return; if (!examInfo.content.student) examInfo.content.student = []; if (!examInfo.content.teacher) examInfo.content.teacher = []; var student = []; examInfo.content.student.forEach(function(elt){ if(div_element.employeeDict[elt]) student.push(div_element.employeeDict[elt].id); }); var teacher = []; examInfo.content.teacher.forEach(function(elt){ if(div_element.employeeDict[elt]) teacher.push(div_element.employeeDict[elt].id); }); var employees; if (mailTo == "teacher") employees = teacher; else if (mailTo == "student") employees = student; else employees = teacher.concat(student); template = div_element.database.email_templates.items[tIndex].content; var examinationPluginVariable = { originVariable: { name_of_examination: examInfo.content.name, description_of_examination: examInfo.content.comment, stage_of_examination: examInfo.content.stage, duration_of_examination_scoring: examInfo.content.evaluationTime, start_time_of_examination: examInfo.content.startTime, duration_of_examination: examInfo.content.duration, late_start_duration_of_examination: examInfo.content.delay }, variableToString: { name_of_examination: examInfo.content.name, description_of_examination: examInfo.content.comment, stage_of_examination: examInfo.content.stage, duration_of_examination_scoring: examInfo.content.evaluationTime, start_time_of_examination: examInfo.content.startTime, duration_of_examination: examInfo.content.duration, late_start_duration_of_examination: examInfo.content.delay } }; examinationPluginVariable.originVariable.start_time_of_examination.hasTime = true; examinationPluginVariable.variableToString.start_time_of_examination.hasTime = true; hr.email_templates.parseTemplate(template, employees, examinationPluginVariable); } var changeStageToFinish = function(linkElt){ var message = "Bạn muốn chuyển trạng thái bài kiểm tra sang giai đoạn \"Chấm điểm xong\" phải không?" module.e_learning.deleteConfirm("Chuyển trạng thái", message).then(function(){ saveFunc(examInfo, "stage", "evaluated").then(function(){ frameList.removeLast(); me.examinationEdit(hrapi, examInfo, div_element, onsave, onabort); }) }); } var questionSuccessBtn = module.e_learning.noneIconButton({ text: "Hoàn thành câu hỏi", onclick: function(){ changeStageToQuestionSuccess(); } }); var changeStageToQuestionSuccess = function(linkElt){ var message = "Bạn muốn chuyển trạng thái bài kiểm tra sang giai đoạn \"Hoàn thành câu hỏi\" phải không?" module.e_learning.deleteConfirm("Chuyển trạng thái", message).then(function(){ saveFunc(examInfo, "stage", "question_success").then(function(){ frameList.removeLast(); me.examinationEdit(hrapi, examInfo, div_element, onsave, onabort); }) }); } var evaluatingSuccessBtn = module.e_learning.noneIconButton({ text: "Chấm điểm xong", onclick: function(){ changeStageToFinish(); } }); var doExamination = function(){ var onclose = function(r){ console.log(r); } var onsuccess = function(){ doExaminationBtn.style.display = "none"; questionDiv.addChild(absol._({ style: { color: "red" }, child: {text: "Đã thực hiện xong bài kiểm tra. Chờ kết quả chấm điểm"} })); doExaminationLink.style.display = "none"; // if (linkElt) linkElt.style.display = "none"; } me.doExamination(hrapi, examInfo, examData, div_element, onclose, onsuccess); }; var doExaminationLink = absol._({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Thực hiện bài kiểm tra"}, on: { click: function(){ doExamination(); } } } }); var doExaminationBtn = module.e_learning.noneIconButton({ text: "Thực hiện bài kiểm tra", onclick: function(){ doExamination(); } }); var s_success = false; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) { buttonlist.push({ class: "single-button-header", child: sendMailBtn }); if (examInfo.content.stage == "plan") { } else if (examInfo.content.stage == "question") { } else if (examInfo.content.stage == "question_success") { buttonlist.push(mockExaminationBtn); } else if (examInfo.content.stage == "ongoing") { } else if (examInfo.content.stage == "evaluating") { } else { } } if (teacher.indexOf(div_element.currentEmp.firstid) != -1) { if (examInfo.content.stage == "question") { } else if (examInfo.content.stage == "question_success") { buttonlist.push(mockExaminationBtn); } else if (examInfo.content.stage == "evaluating"){ } } if (student.indexOf(div_element.currentEmp.firstid) != -1){ if (examInfo.content.stage == "ongoing") { if (examData.student[div_element.currentEmp.firstid]){ s_success = examData.student[div_element.currentEmp.firstid].success; if (!s_success) buttonlist.push({ class: "single-button-header", child: doExaminationBtn }); } } } var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var nav_items; if (student.indexOf(div_element.currentEmp.firstid) != -1) { nav_items = [ {text: "Thông tin chung", value: "general_information"} ]; if (examInfo.content.stage == "ongoing" || examInfo.content.stage == "finish") nav_items.push({text: "Câu hỏi", value: "question"}); } if (teacher.indexOf(div_element.currentEmp.firstid) != -1){ nav_items = [ {text: "Thông tin chung", value: "general_information"}, {text: "Giáo viên chấm điểm", value: "teacher"}, {text: "Thí sinh", value: "student"} ]; if (examInfo.content.stage != "plan") nav_items.push({text: "Câu hỏi", value: "question"}); } if (div_element.isAdmin) { nav_items = [ {text: "Thông tin chung", value: "general_information"}, {text: "Phân quyền", value: "privilege"}, {text: "Giáo viên chấm điểm", value: "teacher"}, {text: "Thí sinh", value: "student"}, {text: "Câu hỏi", value: "question"} ]; } var nav = absol.buildDom({ tag:'mknavigator', style: { display:'inline-block'// or 'block' }, props: { items: nav_items, value: "exercise" }, on:{ press: function(event){ rightCtn.off('scroll', scrollRightFunc);// prevent loop if (sectionList[this.value]) sectionList[this.value].scrollIntoView(); setTimeout(function(){ rightCtn.on('scroll', scrollRightFunc ); }, 10); } } }); var scrollRightFunc = function(){ var elt; var bound = rightCtn.getBoundingClientRect(); var eltBound; var nearestEltId; var nearestDistance = 100000000; var distance; for (var i in sectionList){ elt = sectionList[i]; eltBound = elt.getBoundingClientRect(); distance = 1000000; if (eltBound.top <= bound.top){ if (eltBound.bottom >= bound.bottom){ distance = -1e6; } else if (bound.top - eltBound.top < 30){ distance = eltBound.top - bound.bottom;//negative } else if (eltBound.bottom > bound.top){ distance = bound.top - eltBound.top; } } else if (eltBound.top < bound.bottom){ distance = eltBound.top - bound.bottom;//negative } else { distance = Math.abs(bound.top - eltBound.top) } if (nearestDistance > distance){ nearestDistance = distance; nearestEltId = i; } } nav.value = nearestEltId; }; var rightChild = []; generalInfoDiv = absol._({ style: { paddingLeft: "10px" } }); var makeGeneralData = function(content){ var table = DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({text: content.name})] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Nhóm"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({text: div_element.database.examination_category.items[div_element.database.examination_category.getIndex(content.category)].content.name})] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Giai đoạn"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({text: div_element.stageDict[content.stage]})] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Mô tả"}, { attrs: {style: {minHeight: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ child: {text: content.comment} })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hiển thị nhận xét trả lời"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ tag: "switch", props: { disabled: true, checked: content.feedbackDisplay } })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thứ tự câu hỏi ngẫu nhiên"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ tag: "switch", props: { disabled: true, checked: content.orderRandom } })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thời gian chấm điểm (giờ)"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ child: {text: content.evaluationTime} })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thời gian bắt đầu kiểm tra"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ child: {text: module.e_learning.getDateTimeView(content.startTime)} })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Thời lượng (phút)"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ child: {text: content.duration} })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Được phép bắt đầu trễ (phút)"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ child: {text: content.delay} })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Xếp loại (%)"}, { attrs: {style: {width: "500px", paddingLeft: "10px"}}, children: [absol._({ child: me.ratingData(content.ratingScale, true) })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {height: "30px", paddingLeft: "10px"}}, children: [absol._({ tag: "switch", props: { disabled: true, checked: content.active } })] } ] ] }); generalInfoDiv.clearChild(); generalInfoDiv.addChild(table); } makeGeneralData(examInfo.content); rightChild.push(absol.buildDom({ attr: { "data-sectionid": "general_information" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Thông tin chung" }, }, { class: 'mk-section-header-right', style: { display: div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 ? "" : "none" }, child: { tag: "a", child: {text: "Sửa"}, on: { click: function(){ var currentStage = examInfo.content.stage; var onsave = function(value){ delete value.key; examInfo.content = value; if (currentStage == value.stage) { makeGeneralData(examInfo.content); } else { frameList.removeLast(); me.examinationEdit(hrapi, examInfo, div_element, onsave, onabort); } }; var onabort_edit = function(){ }; var t_content = EncodingClass.string.duplicate(examInfo.content); t_content.key = examInfo.key; me.examinationAddNew(hrapi, t_content, onsave, onabort_edit); } } } } ] }), generalInfoDiv ] })); var privilegeDiv = absol._({}); var makePrivilege = function(content){ var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var cur = { value: -item.id, text: item.name }; var items = []; if (item.children) items = items.concat(getEmployeeItems(item.children)); if (item.employees) item.employees.forEach((item2) => { // if (item2.available) items.push({ items.push({ value: item2.firstid, text: item2.fullname, isLeaf: true }); }); cur.items = items; data.push(cur); }); return data; }; var empItems = getEmployeeItems(div_element.database.orgs.items); var editPriv = absol._({ tag: "multichecktreeleafmenu", props: { items: empItems, values: content.editPriv ? content.editPriv : [], enableSearch: true, disabled: true } }); var viewPriv = absol._({ tag: "multichecktreemenu", props: { items: empItems, values: content.viewPriv ? content.viewPriv : [], enableSearch: true, disabled: true } }); var st = absol._({ style: { paddingLeft: "10px" }, child: [ { style: { fontWeight: "bold" }, child: {text: "Nhân viên nào được xem bài kiểm tra này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: viewPriv } ] }, { style: { paddingTop: "10px", fontWeight: "bold" }, child: {text: "Nhân viên nào được sửa bài kiểm tra này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: editPriv } ] } ] }); privilegeDiv.clearChild(); privilegeDiv.addChild(st); }; makePrivilege({ editPriv: examInfo.content.editPriv, viewPriv: examInfo.content.viewPriv }); if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 || editPriv.indexOf(div_element.currentEmp.firstid) != -1)rightChild.push(absol.buildDom({ attr: { "data-sectionid": "privilege" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Phân quyền" }, }, { class: 'mk-section-header-right', child: { tag: "a", child: {text: "Sửa"}, style: { display: div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 ? "" : "none" }, on: { click: function(){ var onsave = function(value){ examInfo.content.editPriv = value.editPriv; examInfo.content.viewPriv = value.viewPriv; makePrivilege({ editPriv: examInfo.content.editPriv, viewPriv: examInfo.content.viewPriv }); }; var onabort = function(){ }; me.privilegeEdit(hrapi, examInfo, div_element.currentEmp.firstid, onsave, onabort, div_element.database.orgs.items); } } } } ] }), privilegeDiv ] })); ////////////////////////// var teacherDiv = absol._({}); var makeTeacher = function(teacher){ if (!teacher) teacher = []; var data = []; var getEmployeeItems = function(orgs, data, path){ orgs.forEach((item, i) => { // var cur = { // value: -item.id, // text: item.name // }; // var items = []; if (item.employees) item.employees.forEach((item2) => { if (teacher.indexOf(item2.firstid) != -1) { var cells = [ { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(DOMElement.span({attrs: {className: "as-dt-row-index"}})); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: item2.fullname} })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: path + "\\ " + item.name} })); } } ]; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) cells.push({ render: function(tdElt) { tdElt.addChild(absol._({ tag: "span", class: ['mdi', 'mdi-minus-circle', 'card-icon-remove'], on: { click: function(){ module.e_learning.deleteConfirm("Xóa giáo viên", "Bạn muốn xóa giáo viên " + item2.fullname + " khỏi bài kiểm tra").then(function(){ teacher = teacher.filter(function(elt){ return elt != item2.firstid; }) saveFunc(examInfo, "teacher", teacher).then(function(){ var x = tableView.rowOf(row) x.remove(); }); }); } } })); } }); var row = { cells: cells }; row.id = item2.firstid; data.push(row); } }); if (item.children) getEmployeeItems(item.children, data, path != "" ? path + "\\ " + item.name : item.name); // cur.items = items; // data.push(cur); }); }; getEmployeeItems(div_element.database.orgs.items, data, ""); var header = [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Bộ phận"} } ]; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) header.push({}); var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: header } ] }, body: { rows: data } } } } }); var st = absol._({ style: { paddingLeft: "10px" }, child: tableView }); teacherDiv.clearChild(); teacherDiv.addChild(st); }; makeTeacher(examInfo.content.teacher); if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 || teacher.indexOf(div_element.currentEmp.firstid) != -1) rightChild.push(absol.buildDom({ attr: { "data-sectionid": "teacher" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Giáo viên chấm điểm" }, }, { class: 'mk-section-header-right', child: { tag: "a", child: {text: "Thêm"}, style: { display: div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 ? "" : "none" }, on: { click: function(){ var onsave = function(value){ examInfo.content.teacher = value; makeTeacher(examInfo.content.teacher); }; var onabort = function(){ }; me.teacherEdit(hrapi, examInfo, div_element.currentEmp.firstid, onsave, onabort, div_element.database.orgs.items); } } } } ] }), teacherDiv ] })); /////////////////////// ////////////////// Thí sinh var studentDiv = absol._({}); var makeStudent = function(student){ var scoreTotal = 0; examData.questions.content.forEach((item, i) => { item.questions.forEach((item2, i) => { scoreTotal += item2.score; }); }); if (!student) student = []; var data = []; var getEmployeeItems = function(orgs, data, path){ orgs.forEach((item, i) => { if (item.employees) item.employees.forEach((item2) => { if (student.indexOf(item2.firstid) != -1) { var sumScore = 0; var ratingText = ""; if (examData.student[item2.firstid]) { if (examData.student[item2.firstid].score) { var keys = Object.keys(examData.student[item2.firstid].score); keys.forEach((item, i) => { sumScore += examData.student[item2.firstid].score[item].score; }); } var percent = parseInt((sumScore / scoreTotal * 100), 10); var ratingScale = examInfo.content.ratingScale; for (var i = 0; i < ratingScale.length; i++) { if (i == 0) { if (percent >= ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } else if (i == ratingScale.length - 1) { if (percent > ratingScale[i].min) { ratingText = ratingScale[i].text; break; } } else { if (percent > ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } } } var cells = [ { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(DOMElement.span({attrs: {className: "as-dt-row-index"}})); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: item2.fullname} })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: path + "\\ " + item.name} })); } }, { style: { textAlign: "center" }, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: sumScore.toString()} })); } }, { style: { textAlign: "center" }, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: ratingText} })); } } ]; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) cells.push({ render: function(tdElt) { var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_vert" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { anchor:[2,5,3,4], getMenuProps: function(){ var quickMenuItems = [ { text: "Thực hiện lại", extendClasses: ["bsc-quickmenu"], icon: absol._({ tag: "span", class: ['mdi', 'mdi-undo'] }), cmd: function(){ module.e_learning.deleteConfirm("Làm lại bài kiểm tra", "Bạn muốn thí sinh \"" + item2.fullname + "\" làm lại bài kiểm tra").then(function(){ var deleteResult = function(){ var exc2 = function(questions){ return new Promise(function(rs, rj){ var subFunc = function(idx){ hrapi.table.delete("examination_details_" + examInfo.key, "student_result_" + item2.firstid + "_" + questions[idx].ident, function(a, b){ if (a){ if (idx < questions.length - 1) subFunc(idx + 1); else {rs();} } else { rj([a, b]); } }) } subFunc(0); }); } var exc = function(idx){ exc2(examData.questions.content[idx].questions).then(function(){ if (idx < examData.questions.content.length - 1) exc(idx + 1); else { ModalElement.close(-1); frameList.removeLast(); me.examinationEdit(hrapi, examInfo, div_element, onsave, onabort); } }, function(err){ ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(err); }) }; exc(0); }; var deleteScore = function(){ hrapi.table.delete("examination_details_" + examInfo.key, "student_score_" + item2.firstid, function(a, b){ if (a){ deleteResult(); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(a, b); } }) }; var deleteEvaluated = function(){ hrapi.table.delete("examination_details_" + examInfo.key, "student_evaluated_" + item2.firstid, function(a, b){ if (a){ deleteScore(); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(a, b); } }) }; var deleteStartTime = function(){ hrapi.table.delete("examination_details_" + examInfo.key, "student_start_time_" + item2.firstid, function(a, b){ if (a){ deleteEvaluated(); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(a, b); } }) }; ModalElement.show_loading(); hrapi.table.delete("examination_details_" + examInfo.key, "student_success_" + item2.firstid, function(a, b){ if (a){ deleteStartTime(); } else { ModalElement.alert({message: "Có lỗi xảy ra"}); console.log(a, b); } }) }) } }, { text: "Xóa", extendClasses: ["bsc-quickmenu"], icon: absol._({ tag: "span", class: ['mdi', 'mdi-minus-circle', 'card-icon-remove'] }), cmd: function(){ module.e_learning.deleteConfirm("Xóa thí sinh", "Bạn muốn xóa thí sinh \"" + item2.fullname + "\" khỏi bài kiểm tra").then(function(){ student = student.filter(function(elt){ return elt != item2.firstid; }) saveFunc(examInfo, "student", student).then(function(){ var x = tableView.rowOf(row) x.remove(); }); }) } } ]; return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } }); var row = { cells: cells }; row.id = item2.firstid; data.push(row); } }); if (item.children) getEmployeeItems(item.children, data, path != "" ? path + "\\ " + item.name : item.name); // cur.items = items; // data.push(cur); }); }; getEmployeeItems(div_element.database.orgs.items, data, "", []); var header = [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Bộ phận"} }, { child: {text: "Điểm"} }, { child: {text: "Xếp loại"} } ]; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) header.push({}); var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: header } ] }, body: { rows: data } } } } }); var st = absol._({ style: { paddingLeft: "10px" }, child: tableView }); studentDiv.clearChild(); studentDiv.addChild(st); }; makeStudent(examInfo.content.student); div_element.makeStudent = makeStudent; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 || viewPriv.indexOf(div_element.currentEmp.firstid) != -1 || teacher.indexOf(div_element.currentEmp.firstid) != -1) rightChild.push(absol.buildDom({ attr: { "data-sectionid": "student" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Thí sinh" }, }, { class: 'mk-section-header-right', child: { tag: "a", child: {text: "Thêm"}, style: { display: div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 ? "" : "none" }, on: { click: function(){ var onsave = function(value){ examInfo.content.student = value; makeStudent(examInfo.content.student); }; var onabort = function(){ }; me.studentEdit(hrapi, examInfo, div_element.currentEmp.firstid, onsave, onabort, div_element.database.orgs.items); } } } } ] }), studentDiv ] })); ///////////////////// if ( div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 || viewPriv.indexOf(div_element.currentEmp.firstid) != -1 || (teacher.indexOf(div_element.currentEmp.firstid) != -1 && examInfo.content.stage != "plan") || (student.indexOf(div_element.currentEmp.firstid) != -1 && (examInfo.content.stage == "ongoing" || examInfo.content.stage == "finish" || examInfo.content.stage == "evaluated")) ) { var links = [ { class: 'mk-section-header-name', child: { text: "Câu hỏi" }, } ]; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) { if (examInfo.content.stage == "question") { links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Sửa"}, on: { click: function(){ var onsave = function(value){ examData.questions = value; makeQuesionData(EncodingClass.string.duplicate(value.content)); }; var onabort = function(task){ if (task == "question_success") changeStageToQuestionSuccess(); }; me.questionEdit(hrapi, examInfo, examData, div_element, onsave, onabort); } } } }); // links.push({ // class: 'mk-section-header-right', // child: { // tag: "a", // child: {text: "Hoàn thành câu hỏi"}, // on: { // click: function(){ // changeStageToQuestionSuccess(this); // } // } // } // }); } if (examInfo.content.stage == "plan") { // links.push({ // class: 'mk-section-header-right', // child: { // tag: "a", // child: {text: "Xây dựng câu hỏi"}, // on: { // click: function(){ // changeStageToQuestion(this); // } // } // } // }); } else if (examInfo.content.stage == "question_success") { links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Làm thử bài kiểm tra"}, on: { click: function(){ mockExamination(); } } } }); } else if (examInfo.content.stage == "ongoing") { // links.push({ // class: 'mk-section-header-right', // child: { // tag: "a", // child: {text: "Đang chấm điểm"}, // on: { // click: function(){ // changeStageToEvaluating(this); // } // } // } // }); } else if (examInfo.content.stage == "evaluating") { links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Chấm điểm"}, on: { click: function(){ var self = this; var onclose = function(){ }; var onsuccess = function(){ changeStageToFinish(self); }; me.evaluatingExamination(hrapi, examInfo, examData, div_element, onclose, onsuccess); } } } }); // links.push({ // class: 'mk-section-header-right', // child: { // tag: "a", // child: {text: "Chấm điểm xong"}, // on: { // click: function(){ // changeStageToFinish(this); // } // } // } // }); } links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "In câu hỏi"}, on: { click: function(){ me.printQuestion(hrapi, examInfo, examData, div_element); } } } }); } else if (teacher.indexOf(div_element.currentEmp.firstid) != -1) { if (examInfo.content.stage == "question") { links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Sửa"}, on: { click: function(){ var onsave = function(value){ examData.questions = value; makeQuesionData(EncodingClass.string.duplicate(value.content)); }; var onabort = function(){ changeStageToQuestionSuccess(); }; me.questionEdit(hrapi, examInfo, examData, div_element, onsave, onabort); } } } }); // links.push({ // class: 'mk-section-header-right', // child: { // tag: "a", // child: {text: "Hoàn thành câu hỏi"}, // on: { // click: function(){ // changeStageToQuestionSuccess(this); // } // } // } // }); } else if (examInfo.content.stage == "question_success") { links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Làm thử bài kiểm tra"}, on: { click: function(){ mockExamination(); } } } }); } else if (examInfo.content.stage == "evaluating"){ links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Chấm điểm"}, on: { click: function(){ var self = this; var onclose = function(){ }; var onsuccess = function(){ changeStageToFinish(self); }; me.evaluatingExamination(hrapi, examInfo, examData, div_element, onclose, onsuccess); } } } }); } // links.push({ // class: 'mk-section-header-right', // child: { // tag: "a", // child: {text: "In câu hỏi"}, // on: { // click: function(){ // me.printQuestion(hrapi, examInfo, examData, div_element); // } // } // } // }); } else if (student.indexOf(div_element.currentEmp.firstid) != -1){ if (examInfo.content.stage == "ongoing" && !s_success) { links.push(doExaminationLink); } } var chartDiv = absol._({ style: { textAlign: "center" } }); var questionDiv = absol._({ style: { paddingTop: "20px", userSelect: "none" } }); var questionView = absol._({ child: [ chartDiv, questionDiv ] }); var sIndex = student.indexOf(div_element.currentEmp.firstid); if (sIndex != -1) { if (examInfo.content.stage == "ongoing") { if (s_success) { questionDiv.addChild(absol._({ style: { color: "red" }, child: {text: "Đã thực hiện xong bài kiểm tra. Chờ kết quả chấm điểm"} })); } } else if (examInfo.content.stage == "finish" || examInfo.content.stage == "evaluated") { var PoserEvaluation = absol.poser.PoserEvaluation; var viewer = new PoserEvaluation( { hasScroller: false, hasSection: true } ); mPoserView = viewer.getView(); if (examData.student[div_element.currentEmp.firstid]) { if (!examData.student[div_element.currentEmp.firstid].result) { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Chưa thực hiện bài kiểm tra"}})); } else if (examData.student[div_element.currentEmp.firstid].score) { chartDiv.addChild(me.makeResultChart(examData.questions.content, examData.student[div_element.currentEmp.firstid], examInfo.content.ratingScale, div_element.employeeDict[div_element.currentEmp.firstid])); } else { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Bài làm chưa được chấm điểm"}})); } } else { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Chưa thực hiện bài kiểm tra"}})); } questionDiv.addChild(mPoserView); var studentData = { sections: examData.questions.content }; if (examData.student[div_element.currentEmp.firstid] && examData.student[div_element.currentEmp.firstid].result) studentData.result = examData.student[div_element.currentEmp.firstid].result; else studentData.result = {}; viewer.setData(studentData); if (examData.student[div_element.currentEmp.firstid] && examData.student[div_element.currentEmp.firstid].score) viewer.setEvaluation(examData.student[div_element.currentEmp.firstid].score); } } else { var mPoserView; if (examInfo.content.stage == "finish" || examInfo.content.stage == "evaluated") { var cbbItems = []; for (var i = 0; i < examInfo.content.student.length; i++){ if (div_element.employeeDict[examInfo.content.student[i]]){ cbbItems.push({value: examInfo.content.student[i], text: div_element.employeeDict[examInfo.content.student[i]].fullname + " (" + div_element.employeeDict[examInfo.content.student[i]].code + ")"}); } } if (cbbItems.length > 0) { var studentData = { sections: examData.questions.content }; var cbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: cbbItems }, on: { change: function(){ if (examData.student[this.value] && examData.student[this.value].result) studentData.result = examData.student[this.value].result; else studentData.result = {}; viewer.setData(studentData); if (examData.student[this.value] && examData.student[this.value].score) viewer.setEvaluation(examData.student[this.value].score); chartDiv.clearChild() if (examData.student[this.value]) { if (!examData.student[this.value].result){ chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Chưa thực hiện bài kiểm tra"}})); } else if (examData.student[this.value].score) { chartDiv.addChild(me.makeResultChart(examData.questions.content, examData.student[this.value], examInfo.content.ratingScale, div_element.employeeDict[this.value])); } else { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Bài làm chưa được chấm điểm"}})); } } else { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Chưa thực hiện bài kiểm tra"}})); } } } }); var PoserEvaluation = absol.poser.PoserEvaluation; var viewer = new PoserEvaluation( { hasScroller: false, hasSection: true } ); mPoserView = viewer.getView(); if (examData.student[cbbItems[0].value]) { if (!examData.student[cbbItems[0].value].result) { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Chưa thực hiện bài kiểm tra"}})); } else if (examData.student[cbbItems[0].value].score) { chartDiv.addChild(me.makeResultChart(examData.questions.content, examData.student[cbbItems[0].value], examInfo.content.ratingScale, div_element.employeeDict[cbbItems[0].value])); } else { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Bài làm chưa được chấm điểm"}})); } } else { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Chưa thực hiện bài kiểm tra"}})); } if (examData.student[cbbItems[0].value] && examData.student[cbbItems[0].value].result) studentData.result = examData.student[cbbItems[0].value].result; else studentData.result = {}; viewer.setData(studentData); if (examData.student[cbbItems[0].value] && examData.student[cbbItems[0].value].score) viewer.setEvaluation(examData.student[cbbItems[0].value].score); links.splice(1, 0, { class: 'mk-section-header-right', child: cbb }); links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Export"}, on: { click: function(){ me.exportData(hrapi, examInfo); } } } }); questionDiv.addChild(mPoserView); } else { chartDiv.addChild(absol._({style: {color: "red", fontSize: "18px"}, child: {text: "Không có thí sinh"}})); } } else { var PoserViewer = absol.poser.PoserViewer; var viewer = new PoserViewer( { hasScroller: false, readOnly: true } ); mPoserView = viewer.getView(); var makeQuesionData = function(t_content){ if (t_content) { t_content.forEach((item, i) => { item.questions.forEach((item2, i) => { delete item2.correct_answer; }); }); viewer.setData(t_content); } else viewer.setData([]); } makeQuesionData(EncodingClass.string.duplicate(examData.questions.content)); questionDiv.addChild(mPoserView); } } rightChild.push(absol.buildDom({ attr: { "data-sectionid": "question" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: links }), questionView ] })); } /////////////////////// var rightCtn = absol.buildDom({ class: 'mk-main-right', style: { paddingBottom: "var(--footer-margin)" }, child: rightChild }); var data_ctn = absol._({ class: 'mk-main', style: { height: '100%' }, child: [ { class: 'mk-main-left-ctn', child: [nav] }, rightCtn ] }); var sectionList = {}; absol.$("div", rightCtn, function(elt){ var id = elt.getAttribute("data-sectionid"); if (!id) return; sectionList[id] = elt; }); var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: buttonlist } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); } if (!div_element.database) { div_element.database = {}; var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("examination_category", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.id] = orgContent; orgContent.employees.forEach((item, i) => { item.orgName = orgContent.name; employees.push(item); }); // employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); rs({ orgs: retval, employees: employees }); }); }); }), new Promise(function(rs, rj){ hrapi.templates.getEmails(function(r, s){ if (r) rs(s); else rj(s); }) }) ] Promise.all(loadDB).then(function(rs){ db_content.examination_category = rs[0]; db_content.examination_category.unshift({key: "general_group", content: { name: "Nhóm chung", comment: "", active: true }}); db_content.orgs = rs[3].orgs; db_content.employees = rs[3].employees; db_content.email_templates = rs[4]; me.makeDatabaseContent(div_element, db_content); div_element.database.email_templates.getIndex = function(id){ for (var j = 0; j < div_element.database.email_templates.items.length; j++){ if (div_element.database.email_templates.items[j].id == id) return j; } return -1; }; div_element.isAdmin = rs[1]; div_element.currentEmp = rs[2]; var stageItems = [ {value: "plan", text: "Kế hoạch"}, {value: "question", text: "Xây dựng câu hỏi"}, {value: "question_success", text: "Hoàn thành câu hỏi"}, {value: "ongoing", text: "Thực hiện kiểm tra"}, {value: "evaluating", text: "Thực hiện chấm điểm"}, {value: "evaluated", text: "Chấm điểm xong"}, {value: "finish", text: "Kết thúc"}, {value: "cancel", text: "Hủy"} ] var stageDict = {}; stageItems.forEach((item, i) => { stageDict[item.value] = item.text; }); div_element.stageItems = [{value: "all", text: "Tất cả"}].concat(stageItems); div_element.stageDict = stageDict; div_element.employeeDict = {}; div_element.database.employees.items.forEach((item, i) => { div_element.employeeDict[item.firstid] = item; }); run(); }); } else { run(); } } } (module, retval); // function: hrplugins.keeview.examination.examinationMobileTable var v174 = function(module, me) { return function (hrapi, div_element, onclose) { var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.database = {}; var db_content = {}; var redraw = function(){ frameList.removeLast(); div_element.database = {}; db_content = {}; run(); } var run = function(){ hrapi.table.select("examination_category", function(s, value){ if (!s) { ModalElement.alert({message: value}); return; } value.unshift({key: "general_group", content: { name: "Nhóm chung", comment: "", active: true }}); db_content.examination_category = value; var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("examination", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.firstid] = orgContent; orgContent.employees.forEach((item, i) => { item.orgName = orgContent.name; employees.push(item); }); // employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); rs({ orgs: retval, employees: employees }); }); }); }), new Promise(function(rs, rj){ hrapi.templates.getEmails(function(r, s){ if (r) rs(s); else rj(s); }) }) ]; var stageItems = [ {value: "plan", text: "Kế hoạch"}, {value: "question", text: "Xây dựng câu hỏi"}, {value: "question_success", text: "Hoàn thành câu hỏi"}, {value: "ongoing", text: "Thực hiện kiểm tra"}, {value: "evaluating", text: "Thực hiện chấm điểm"}, {value: "evaluated", text: "Chấm điểm xong"}, {value: "finish", text: "Kết thúc"}, {value: "cancel", text: "Hủy"} ] var stageDict = {}; stageItems.forEach((item, i) => { stageDict[item.value] = item.text; }); Promise.all(loadDB).then(function(rs){ ModalElement.close(-1); db_content.examination = rs[0]; db_content.orgs = rs[3].orgs; db_content.employees = rs[3].employees; db_content.email_templates = rs[4]; me.makeDatabaseContent(div_element, db_content); div_element.database.email_templates.getIndex = function(id){ for (var j = 0; j < div_element.database.email_templates.items.length; j++){ if (div_element.database.email_templates.items[j].id == id) return j; } return -1; }; div_element.isAdmin = rs[1]; div_element.currentEmp = rs[2]; var categoryItems = div_element.database.examination_category.items.map(function(elt){ return { value: elt.key, text: elt.content.name }; }); categoryItems.unshift({value: "all", text: "Tất cả nhóm bài kiểm tra"}); var categoryCbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: categoryItems }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); div_element.groupItems = categoryItems; div_element.stageDict = stageDict; div_element.stageItems = [{value: "all", text: "Tất cả giai đoạn"}].concat(stageItems); var stageCbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: [{value: "all", text: "Tất cả"}].concat(stageItems) }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); var dict = { examination: {}, examination_category: {}, stage: stageDict, }; div_element.employeeDict = {}; div_element.database.employees.items.forEach((item, i) => { div_element.employeeDict[item.firstid] = item; }); div_element.database.examination.items.forEach((item, i) => { dict.examination[item.key] = item.content; }); div_element.database.examination_category.items.forEach((item, i) => { dict.examination_category[item.key] = item.content; }); var doExamination = function(content, icon){ div_element.viewIcon = icon; me.examinationMobileView(hrapi, content, div_element); }; var generateData = function(){ var data = []; div_element.database.examination.items.forEach(function(elt){ if (categoryCbb.value != "all" && elt.content.category != categoryCbb.value) return; if (stageCbb.value != "all" && elt.content.stage != stageCbb.value) return; if (!dict.examination[elt.key]) return; if (!elt.content.active && !div_element.isAdmin) return; if (elt.content.stage != "ongoing") return; var student = []; if (elt.content.student) { student = elt.content.student; } if ( student.indexOf(div_element.currentEmp.firstid) == -1 ) return; var icon = DOMElement.div({ attrs: { className: "card-icon-cover", onclick: function(){ doExamination(elt, icon); } }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "visibility" })] }); var cells = [ { innerHTML: elt.content.name, render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: elt.content.name}, on: { click: function(){ doExamination(elt, icon); } } })); } }, { style: {width: "40px"}, render: function(tdElt){ tdElt.addChild(icon); } } ]; var row = { cells: cells }; data.push(row); }); var tableView = absol.buildDom({ tag: "dynamictable", props: { adapter: { data: { head: { rows: [] }, body: { rows: data } } } } }); tableView.attachSearchInput(inputsearchbox); return tableView; }; var commands = []; commands.push({ icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "search" }), cmd: function(){ header.searchMode(true); } }); var inputsearchbox = absol.buildDom({ tag: 'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: LanguageModule.text("txt_search") } }); var header = absol.buildDom({ tag: 'headerbarwithsearch', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: LanguageModule.text("txt_examination"), commands: commands }, data:{ searchInput: inputsearchbox }, on: { action: function(){ onclose(); }, command: function(event){ event.commandItem.cmd(); } } }); div_element.addChild(frameList); var container = absol._({ child: generateData() }); var singlePage = absol.buildDom({ tag: 'tabframe', child:[ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [container] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) }); }; ModalElement.show_loading(); hrapi.table.create("examination_category", (s, r) => { if (!s) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); console.log(r); return; } hrapi.table.create("examination", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } run(); }) }); } } (module, retval); // function: hrplugins.keeview.examination.examinationMobileView var v175 = function(module, me) { return function (hrapi, content, div_element) { var examInfo = content; var run = function(){ hrapi.table.select("examination_details_" + examInfo.key, function(r, s){ if (r){ run2(s); } else { onabort(s); } }) } var run2 = function(content) { var teacher = []; if (examInfo.content.teacher) { teacher = examInfo.content.teacher; } var student = []; if (examInfo.content.student) { var student = examInfo.content.student; } var examData = { questions: {}, student: {}, teacher: {} }; student.forEach((item, i) => { examData.student[item] = {}; }); content.forEach((item, i) => { if (item.key == "questions") examData.questions = item.content; else if (item.key.startsWith("student_success_")) { if (!examData.student[item.key.substr(16)]) return; examData.student[item.key.substr(16)].success = item.content; } else if (item.key.startsWith("student_evaluated_")) { if (!examData.student[item.key.substr(18)]) return; examData.student[item.key.substr(18)].evaluated = item.content; } else if (item.key.startsWith("student_result_")) { var str = item.key.substr(15); var k = str.indexOf("_"); var studentid = str.substr(0, k); var qIdent = str.substr(k + 1); if (!examData.student[studentid]) return; if (!examData.student[studentid].result) examData.student[studentid].result = {}; examData.student[studentid].result[qIdent] = {ident: qIdent, value: item.content}; } else if (item.key.startsWith("student_score_")) { if (!examData.student[item.key.substr(14)]) return; examData.student[item.key.substr(14)].score = item.content; } else if (item.key.startsWith("student_start_time_")) { if (!examData.student[item.key.substr(19)]) return; examData.student[item.key.substr(19)].startTime = item.content; } else if (item.key.startsWith("student_completed_time_")) { if (!examData.student[item.key.substr(23)]) return; examData.student[item.key.substr(23)].completedTime = item.content; } }); var editPriv = []; if (examInfo.content.editPriv) editPriv = examInfo.content.editPriv; var viewPriv = []; if (examInfo.content.viewPriv) viewPriv = examInfo.content.viewPriv; var doExamination = function(){ var onclose = function(r){ console.log(r); } var onsuccess = function(){ div_element.viewIcon.style.display = "none"; // if (linkElt) linkElt.style.display = "none"; } me.doExaminationMobile(hrapi, examInfo, examData, div_element, onclose, onsuccess); }; if (!examData.student[div_element.currentEmp.firstid].success) doExamination(); else { var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var commands = []; var header = absol.buildDom({ tag: 'headerbarwithsearch', props: { actionIcon: DOMElement.i({ attrs: { className: "material-icons" }, text: "arrow_back_ios" }), title: LanguageModule.text("txt_examination"), commands: commands }, data:{ searchInput: absol._({}) }, on: { action: function(){ frameList.removeLast(); }, command: function(event){ event.commandItem.cmd(); } } }); var container = absol._({ child: { style: { color: "red" }, child: {text: "Đã thực hiện xong bài kiểm tra. Chờ kết quả chấm điểm"} } }); var singlePage = absol.buildDom({ tag: 'tabframe', child:[ header, DOMElement.div({ attrs: { className: "card-mobile-content" }, children: [container] }) ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } run(); } } (module, retval); // function: hrplugins.keeview.examination.examinationTable var v74 = function(module, me) { return function (hrapi, div_element, onclose) { var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.database = {}; var db_content = {}; var redraw = function(){ frameList.removeLast(); div_element.database = {}; db_content = {}; run(); } var run = function(){ hrapi.table.select("examination_category", function(s, value){ if (!s) { ModalElement.alert({message: value}); return; } // if (value.length == 0) { // ModalElement.alert({message: "Chưa tạo nhóm bài kiểm tra"}); // hrapi.users.isAdmin((s, isAdmin) => { // if (!s) { // ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); // rj(isAdmin); // return; // } // div_element.isAdmin = isAdmin; // showImportBtn(); // }); // return; // } value.unshift({key: "general_group", content: { name: "Nhóm chung", comment: "", active: true }}); db_content.examination_category = value; var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("examination", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.firstid] = orgContent; orgContent.employees.forEach((item, i) => { item.orgName = orgContent.name; employees.push(item); }); orgContent.all_employees = orgContent.employees.map(function(cur){return cur.firstid}); // employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); orgContent.all_employees = orgContent.all_employees.concat(item.all_employees); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); rs({ orgs: retval, employees: employees, orgDict: orgDict }); }); }); }), new Promise(function(rs, rj){ hrapi.templates.getEmails(function(r, s){ if (r) rs(s); else rj(s); }) }) ]; var stageItems = [ {value: "plan", text: "Kế hoạch"}, {value: "question", text: "Xây dựng câu hỏi"}, {value: "question_success", text: "Hoàn thành câu hỏi"}, {value: "ongoing", text: "Thực hiện kiểm tra"}, {value: "evaluating", text: "Thực hiện chấm điểm"}, {value: "evaluated", text: "Chấm điểm xong"}, {value: "finish", text: "Kết thúc"}, {value: "cancel", text: "Hủy"} ] var stageDict = {}; stageItems.forEach((item, i) => { stageDict[item.value] = item.text; }); Promise.all(loadDB).then(function(rs){ ModalElement.close(-1); db_content.examination = rs[0]; db_content.orgs = rs[3].orgs; db_content.employees = rs[3].employees; div_element.orgDict = rs[3].orgDict; db_content.email_templates = rs[4]; me.makeDatabaseContent(div_element, db_content); div_element.database.email_templates.getIndex = function(id){ for (var j = 0; j < div_element.database.email_templates.items.length; j++){ if (div_element.database.email_templates.items[j].id == id) return j; } return -1; }; div_element.isAdmin = rs[1]; div_element.currentEmp = rs[2]; var categoryItems = div_element.database.examination_category.items.map(function(elt){ return { value: elt.key, text: elt.content.name }; }); categoryItems.unshift({value: "all", text: "Tất cả nhóm bài kiểm tra"}); var categoryCbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: categoryItems }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); div_element.groupItems = categoryItems; div_element.stageDict = stageDict; div_element.stageItems = [{value: "all", text: "Tất cả giai đoạn"}].concat(stageItems); var stageCbb = absol._({ tag: "selectmenu", props: { enableSearch: true, items: [{value: "all", text: "Tất cả"}].concat(stageItems) }, on: { change: function(){ container.clearChild(); container.addChild(generateData()); } } }); var dict = { examination: {}, examination_category: {}, stage: stageDict, }; div_element.employeeDict = {}; div_element.database.employees.items.forEach((item, i) => { div_element.employeeDict[item.firstid] = item; }); div_element.database.examination.items.forEach((item, i) => { dict.examination[item.key] = item.content; }); div_element.database.examination_category.items.forEach((item, i) => { dict.examination_category[item.key] = item.content; }); var editFunc = function(content){ var onclose = function(value){ redraw(); }; var onsave = function(){ } me.examinationEdit(hrapi, content, div_element, onsave, onclose); }; var exFunc = function(content){ me.exportExaminationRow(hrapi, content); }; var generateData = function(){ var data = []; div_element.database.examination.items.forEach(function(elt){ if (categoryCbb.value != "all" && elt.content.category != categoryCbb.value) return; if (stageCbb.value != "all" && elt.content.stage != stageCbb.value) return; if (!dict.examination[elt.key]) return; if (!elt.content.active && !div_element.isAdmin) return; var teacher = []; if (elt.content.teacher) { teacher = elt.content.teacher; } var student = []; if (elt.content.student) { student = elt.content.student; } var editPriv = []; if (elt.content.editPriv) { elt.content.editPriv.forEach(function(elt){ if (elt > 0) editPriv.push(elt); else { editPriv = editPriv.concat(div_element.orgDict[-elt].all_employees); } }) // editPriv = elt.content.editPriv; } var viewPriv = []; if (elt.content.viewPriv) { elt.content.viewPriv.forEach(function(elt){ if (elt > 0) viewPriv.push(elt); else { viewPriv = viewPriv.concat(div_element.orgDict[-elt].all_employees); } }) // viewPriv = elt.content.viewPriv; } if ( !div_element.isAdmin && teacher.indexOf(div_element.currentEmp.firstid) == -1 && student.indexOf(div_element.currentEmp.firstid) == -1 && editPriv.indexOf(div_element.currentEmp.firstid) == -1 && viewPriv.indexOf(div_element.currentEmp.firstid) == -1 ) return; // var configFunc = function(content){ // var onclose = function(value){ // }; // var onsave = function(){ // } // me.configSendMail(hrapi, content, div_element, onsave, onclose); // }; var delFunc = function(content){ var title = "Xóa bài kiểm tra"; var message = "Bạn có chắc chắn xóa bài kiểm tra \"" + content.content.name + "\""; module.e_learning.deleteConfirm(title, message).then(function(){ hrapi.table.delete("examination", content.key, function(){ hrapi.table.drop("examination_details_" + content.key, function(s, x){ if (s) { div_element.database.examination.items = div_element.database.examination.items.filter(function(elt){ return elt.key != content.key; }); delete dict.examination[content.key]; var x = tableView.rowOf(row) x.remove(); } else console.log(s, x); }) }) }); } var cells = [ { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild( absol._({ tag: "span", class: ["as-dt-row-index", 'hr-table-cell-link'], on: { click: function(){ editFunc(elt); } } }) ); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: elt.content.name}, on: { click: function(){ editFunc(elt); } } })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: dict.examination_category[elt.content.category].name}, on: { click: function(){ editFunc(elt); } } })); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: dict.stage[elt.content.stage]}, on: { click: function(){ editFunc(elt); } } })); } }, { style: {textAlign: "center"}, render: function(elt){ return function(tdElt){ tdElt.addChild(absol._({ tag: "switch", style: { fontSize: "var(--switch-fontsize)" }, props: { disabled: true, checked: elt.content.active } })); } }(elt) }, { style: {width: "40px"}, render: function(tdElt){ var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_vert" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { getMenuProps: function(){ var quickMenuItems = []; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) { quickMenuItems.push({ text: "Sửa", extendClasses: ["bsc-quickmenu"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "edit" }), cmd: function(){ editFunc(elt); } }); quickMenuItems.push({ text: "Export", extendClasses: ["bsc-quickmenu"], icon: absol._({ class: ["mdi", "mdi-export"] }), cmd: function(){ exFunc(elt); } }); // quickMenuItems.push({ // text: "Thiết lập gửi mail", // extendClasses: ["bsc-quickmenu"], // icon: absol._({ // tag: "i", // class: ["mdi", "mdi-cog-outline"] // }), // cmd: function(){ // configFunc(elt); // } // }); quickMenuItems.push({ text: "Xóa", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "delete" }), cmd: function(){ delFunc(elt); } }); } else { quickMenuItems.push({ text: "Xem", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "visibility" }), cmd: function(){ editFunc(elt); } }); } return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } } ]; var row = { cells: cells }; data.push(row); }); var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Nhóm"} }, { child: {text: "Giai đoạn"} }, { child: {text: "Hoạt động"} }, {} ] } ] }, body: { rows: data } } } } }); tableView.attachSearchInput(inputsearchbox); return tableView; }; var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: "Tìm kiếm..." } }); var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); var addBtn = module.e_learning.noneIconButton({ text: "Thêm", onclick: function(){ var onsave = function(value){ var x = { key: value.key.toString() }; delete value.key; x.content = value; dict.examination[x.key] = x.content; div_element.database.examination.items.push(x); container.clearChild(); container.addChild(generateData()); editFunc(x); }; var onabort = function(){ }; me.examinationAddNew(hrapi, {}, onsave, onabort) } }); var exportFunc = function(){ me.exportExaminationData(hrapi); } var exportBtn = module.e_learning.noneIconButton({ text: "Export", onclick: function(){ exportFunc(); } }); var importFunc = function(){ me.importExaminationData(hrapi).then(function(){ redraw(); }, function(err){console.log(err)}); } var importBtn = module.e_learning.noneIconButton({ text: "Import", onclick: function(){ importFunc(); } }); div_element.addChild(frameList); var container = absol._({ child: generateData() }); var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", style: { display: div_element.isAdmin ? "" : "none" }, child: addBtn }, // { // class: "single-button-header", // style: {display: div_element.isAdmin ? "" : "none"}, // child: exportBtn // }, { class: "single-button-header", style: {display: div_element.isAdmin ? "" : "none"}, child: importBtn }, { class: "single-button-header", child: categoryCbb }, { class: "single-button-header", child: stageCbb }, { class: "single-button-header", child: inputsearchbox } ] } }, container ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) }); }; ModalElement.show_loading(); var showImportBtn = function() { var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); var importFunc = function(){ me.importExaminationData(hrapi).then(function(){ redraw(); }, function(err){console.log(err)}); } var importBtn = module.e_learning.noneIconButton({ text: "Import", onclick: function(){ importFunc(); } }); div_element.addChild(frameList); var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", style: {display: div_element.isAdmin ? "" : "none"}, child: importBtn } ] } } ] }); frameList.addChild(singlePage); singlePage.requestActive(); } hrapi.table.create("examination_category", (s, r) => { if (!s) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); console.log(r); return; } hrapi.table.create("examination", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } run(); }) }); } } (module, retval); // function: hrplugins.keeview.examination.exportData var v122 = function(module, me) { return function (hrapi, examination) { var makeRatingText = function(percent){ var ratingText = ""; var ratingScale = examination.content.ratingScale; for (var i = 0; i < ratingScale.length; i++) { if (i == 0) { if (percent >= ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } else if (i == ratingScale.length - 1) { if (percent > ratingScale[i].min) { ratingText = ratingScale[i].text; break; } } else { if (percent > ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } } return ratingText; }; ModalElement.show_loading(); hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.id] = orgContent; orgContent.employees.forEach((item, i) => { item.departmentName = orgContent.name; employees.push(item); }); // employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); var temp1 = { orgs: retval, employees: employees }; var empdict = {}; temp1.employees.forEach(function(a){empdict[a.firstid] = a}); var excelData = []; hrapi.table.select("examination_details_" + examination.key, function(r1,details){ console.log(r1, details); var examData = { questions: {}, student: {}, teacher: {} }; examination.content.student.forEach((item, i) => { examData.student[item] = { startTime: new Date() }; }); details.forEach((item, i) => { if (item.key == "questions") examData.questions = item.content; else if (item.key.startsWith("student_success_")) { if (!examData.student[item.key.substr(16)]) return; examData.student[item.key.substr(16)].success = item.content; } else if (item.key.startsWith("student_evaluated_")) { if (!examData.student[item.key.substr(18)]) return; examData.student[item.key.substr(18)].evaluated = item.content; } else if (item.key.startsWith("student_result_")) { var str = item.key.substr(15); var k = str.indexOf("_"); var studentid = str.substr(0, k); var qIdent = str.substr(k + 1); if (!examData.student[studentid]) return; if (!examData.student[studentid].result) examData.student[studentid].result = {}; examData.student[studentid].result[qIdent] = {ident: qIdent, value: item.content}; } else if (item.key.startsWith("student_score_")) { if (!examData.student[item.key.substr(14)]) return; examData.student[item.key.substr(14)].score = item.content; } else if (item.key.startsWith("student_start_time_")) { if (!examData.student[item.key.substr(19)]) return; examData.student[item.key.substr(19)].startTime = item.content; } else if (item.key.startsWith("student_completed_time_")) { if (!examData.student[item.key.substr(23)]) return; examData.student[item.key.substr(23)].completedTime = item.content; } }); excelData.push({row:0, col: 0, value: "Stt"}); excelData.push({row:0, col: 1, value: "Tên nhân viên"}); excelData.push({row:0, col: 2, value: "Bộ phận"}); excelData.push({row:0, col: 3, value: "Thời gian làm bài"}); var rIndex = 5; details[0].content.content.forEach(function(cur1, idx){ excelData.push({row:0, col: rIndex++, value: "Điểm section " + cur1.section.name}); excelData.push({row:0, col: rIndex++, value: "Điểm thiết kế section " + cur1.section.name}); excelData.push({row:0, col: rIndex++, value: "Kết quả section " + cur1.section.name}); excelData.push({row:0, col: rIndex++, value: "Xếp loại section " + cur1.section.name}); }); rIndex++; excelData.push({row:0, col: rIndex++, value: "Tổng điểm"}); excelData.push({row:0, col: rIndex++, value: "Tổng điểm thiết kế"}); excelData.push({row:0, col: rIndex++, value: "Kết quả"}); excelData.push({row:0, col: rIndex++, value: "Xếp loại"}); var eIndex = 1; var run = function(empid, pIndex){ if (!examData.student[empid] || !examData.student[empid].score) return; if (!empdict[empid]) return; excelData.push({row:eIndex, col: 0, value: eIndex}); excelData.push({row:eIndex, col: 1, value: empdict[empid].fullname}); excelData.push({row:eIndex, col: 2, value: empdict[empid].departmentName}); excelData.push({row:eIndex, col: 3, value: examData.student[empid].startTime}); var total = 0; var examTotal = 0; var examResult = []; var rIndex = 5; details[0].content.content.forEach(function(cur1, idx){ var sub = 0; var examSub = 0; cur1.questions.forEach(function(cur2){ examSub += cur2.score; sub += examData.student[empid].score[cur2.ident].score; }); // excelData.push({row:eIndex, col: rIndex++, value: sub}); total += sub; examTotal += examSub; var percent = parseInt((sub / examSub * 1000), 10)/ 1000; examResult.push({ sub: sub, percent: percent, design: examSub, ratingText: makeRatingText(percent * 100) }); }) examResult.forEach((item, i) => { excelData.push({row:eIndex, col: rIndex++, value: item.sub}); excelData.push({row:eIndex, col: rIndex++, value: item.design}); excelData.push({row:eIndex, col: rIndex++, value: item.percent, numFmt: '0.0%'}); excelData.push({row:eIndex, col: rIndex++, value: item.ratingText}); }); rIndex++; excelData.push({row:eIndex, col: rIndex++, value: total}); excelData.push({row:eIndex, col: rIndex++, value: examTotal}); var percent = parseInt((total / examTotal * 1000), 10)/ 1000; excelData.push({row:eIndex, col: rIndex++, value: percent, numFmt: '0.0%'}); excelData.push({row:eIndex, col: rIndex++, value: makeRatingText(percent *100)}); eIndex++; } examination.content.student.forEach(run); var exportData = { sheets: [{ name: examination.key, data: excelData }] }; console.log(exportData) var regex = /[^a-zA-Z0-9\sàáạảãâầấậẩẫăằắặẳẵÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴèéẹẻẽêềếệểễÈÉẸẺẼÊỀẾỆỂỄìíịỉĩÌÍỊỈĨòóọỏõôồốộổỗơờớợởỡÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠùúụủũưừứựửữÙÚỤỦŨƯỪỨỰỬỮỳýỵỷỹỲÝỴỶỸđđĐ]+/g; var examName = examination.content.name.replace(regex, ''); var startWorker = function(result, fileName = "score_" + examName + "_" + me.getDateToExport(new Date()) + ".xlsx") { var w; if(typeof(Worker) !== "undefined") { if(typeof(w) == "undefined") { w = new Worker(window.domain + "exceljs.js"); w.postMessage(result); } w.onmessage = function(event) { var data = event.data; if(data.name == "end") { var link = document.createElement('a'); link.href = window.URL.createObjectURL(data.data); link.download = fileName; link.click(); ModalElement.close(-1); } } } else { console.log("Sorry, your browser does not support Web Workers..."); } } startWorker(exportData); }); }); }); } } (module, retval); // function: hrplugins.keeview.examination.exportExaminationData var v167 = function(module, me) { return function (hrapi) { ModalElement.show_loading(); var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("examination_category", function(s, examination_category){ if (!s || examination_category.length == 0) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); rj(); } else rs(examination_category); }) }), new Promise(function(rs, rj){ hrapi.table.select("examination", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(); } else { // rs(value); var loadDetail = []; value.forEach((item, i) => { item.content.editPriv = []; item.content.viewPriv = []; item.content.student = []; item.content.teacher = []; item.content.emailConfig = {}; item.content.stage = "question"; delete item.content.lastmodified; delete item.content.lastmodifiedtime; loadDetail.push(new Promise(function(ok, err){ hrapi.table.select("examination_details_" + item.key, function(s, examination_details){ if (!s) { err(); } else { for (var i = 0; i< examination_details.length; i++){ if (examination_details[i].key == "questions"){ var t = {}; t[item.key] = {content: examination_details[i].content.content}; ok(t); break; } } } }) })) }); Promise.all(loadDetail).then(function(content){ rs({ examination: value, details: content }); }, function(err){console.log(err);}) } }) }), new Promise(function(rs, rj){ hrapi.table.select("question_pool", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(); } else { // rs(value); var loadDetail = []; value.forEach((item, i) => { item.content.editPriv = []; item.content.viewPriv = []; delete item.content.lastmodified; delete item.content.lastmodifiedtime; loadDetail.push(new Promise(function(ok, err){ hrapi.table.select("question_pool_details_" + item.key, function(s, question_pool_details){ if (!s) { err(); } else { var t = {}; t[item.key] = question_pool_details[0].content; t[item.key].editPriv = []; t[item.key].viewPriv = []; delete t[item.key].lastmodified; delete t[item.key].lastmodifiedtime; ok(t); } }) })) }); Promise.all(loadDetail).then(function(content){ rs({ question_pool: value, details: content }); }, function(err){console.log(err);}) } }) }), ]; Promise.all(loadDB).then(function(retval){ ModalElement.close(-1); let dataStr = JSON.stringify({ group: retval[0], content: retval[1], question_pool: retval[2] }); let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr); let exportFileDefaultName = 'data.json'; let linkElement = document.createElement('a'); linkElement.setAttribute('href', dataUri); linkElement.setAttribute('download', exportFileDefaultName); linkElement.click(); },function(err){console.log(err)}) } } (module, retval); // function: hrplugins.keeview.examination.exportExaminationRow var v169 = function(module, me) { return function (hrapi, content) { ModalElement.show_loading(); var loadDB = new Promise(function(rs, rj){ hrapi.table.select("examination", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(); } else { // rs(value); var loadDetail = []; value.forEach((item, i) => { item.content.editPriv = []; item.content.viewPriv = []; item.content.student = []; item.content.teacher = []; item.content.emailConfig = {}; item.content.stage = "question"; delete item.content.lastmodified; delete item.content.lastmodifiedtime; loadDetail.push(new Promise(function(ok, err){ hrapi.table.select("examination_details_" + item.key, function(s, examination_details){ if (!s) { err(); } else { for (var i = 0; i< examination_details.length; i++){ if (examination_details[i].key == "questions"){ var t = {}; t[item.key] = {content: examination_details[i].content.content}; ok(t); break; } } } }) })) }); Promise.all(loadDetail).then(function(content){ rs({ examination: value, details: content }); }, function(err){console.log(err);}) } }) }) loadDB.then(function(retval){ ModalElement.close(-1); var data = { group: [], content: { examination: [], details: retval.details }, question_pool: {question_pool: [], details: []} }; for (var i = 0; i < retval.examination.length; i++){ if (retval.examination[i].key == content.key){ retval.examination[i].content.category = "general_group"; data.content.examination.push(retval.examination[i]); break; } } console.log(data); let dataStr = JSON.stringify(data); let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr); let exportFileDefaultName = 'data.json'; let linkElement = document.createElement('a'); linkElement.setAttribute('href', dataUri); linkElement.setAttribute('download', exportFileDefaultName); linkElement.click(); },function(err){console.log(err)}) } } (module, retval); // function: hrplugins.keeview.examination.exportQuestionPool var v170 = function(module, me) { return function (hrapi, content) { ModalElement.show_loading(); var loadDB = new Promise(function(rs, rj){ hrapi.table.select("question_pool", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(); } else { // rs(value); var loadDetail = []; value.forEach((item, i) => { item.content.editPriv = []; item.content.viewPriv = []; delete item.content.lastmodified; delete item.content.lastmodifiedtime; loadDetail.push(new Promise(function(ok, err){ hrapi.table.select("question_pool_details_" + item.key, function(s, question_pool_details){ if (!s) { err(); } else { var t = {}; t[item.key] = question_pool_details[0].content; t[item.key].editPriv = []; t[item.key].viewPriv = []; delete t[item.key].lastmodified; delete t[item.key].lastmodifiedtime; ok(t); } }) })) }); Promise.all(loadDetail).then(function(content){ rs({ question_pool: value, details: content }); }, function(err){console.log(err);}) } }) }); loadDB.then(function(retval){ ModalElement.close(-1); var data = { group: [], content: { examination: [], details: [] }, question_pool: { question_pool: [], details: retval.details } }; for (var i = 0; i < retval.question_pool.length; i++){ if (retval.question_pool[i].key == content.key){ data.question_pool.question_pool.push(retval.question_pool[i]); break; } } console.log(data); let dataStr = JSON.stringify(data); let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr); let exportFileDefaultName = 'data.json'; let linkElement = document.createElement('a'); linkElement.setAttribute('href', dataUri); linkElement.setAttribute('download', exportFileDefaultName); linkElement.click(); },function(err){console.log(err)}) } } (module, retval); // function: hrplugins.keeview.examination.getDateToExport var v140 = function(module, me) { return function (timesend) { if (!timesend) return ""; var res = ""; var month, day, year, hour, minute; month = timesend.getMonth() + 1; day = timesend.getDate(); year = timesend.getFullYear(); hour = timesend.getHours(); minute = timesend.getMinutes(); if (month < 10) { month = "0" + month; } if (day < 10) { day = "0" + day; } res += year; res += day; res += month; return res; } } (module, retval); // function: hrplugins.keeview.examination.groupCategory var v64 = function(module, me) { return function (hrapi, div_element, onsuccess) { var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); hrapi.table.create("examination_category", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } hrapi.table.select("examination_category", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); console.log(value); return; } hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } var holderForSort = value.map(function(item){ item.content.key = item.key; return { item: item.content, val: absol.string.nonAccentVietnamese(item.content.name.toLowerCase()) } }); holderForSort.sort(function(a, b){ if (a.val < b.val) return -1; if (a.val > b.val) return 1; return 0; }); var examination_category = holderForSort.map(function(holder){ return holder.item; }); var redrawTableFunc = function(){ var data = []; var makeRow = function(elt){ var cells = [{ style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(DOMElement.span({attrs: {className: "as-dt-row-index"}})); } }]; cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: elt.name} })); } }); cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", child: {text: elt.comment} })); } }); cells.push({ render: function(tdElt){ tdElt.addChild(absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: elt.active, disabled: elt.key == "general_group" } })); } }); if (isAdmin && elt.key != "general_group") cells.push({ style: {width: "40px"}, render: function(tdElt){ var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_vert" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { getMenuProps: function(){ var quickMenuItems = []; quickMenuItems.push({ text: "Sửa", extendClasses: "bsc-quickmenu", icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "edit" }), cmd: function(content){ return function(){ addFunc(content); } }(elt) }); quickMenuItems.push({ text: "Xóa", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "delete" }), cmd: function(elt){ return function(){ module.e_learning.deleteConfirm("Xóa nhóm bài kiểm tra", "Nhóm bài kiểm tra " + elt.name + " sẽ bị xóa ?").then(function(){ hrapi.table.delete("examination_category", elt.key, function(){ examination_category = examination_category.filter(function(cur){ return cur.key != elt.key; }); var x = tableView.rowOf(row) x.remove(); }); }) }; }(elt) }); return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } }); else cells.push({}); var row = { cells: cells } return row; } var row; examination_category.unshift({ key: "general_group", name: "Nhóm chung", comment: "", active: true }); for (var i = 0; i < examination_category.length; i++) { row = makeRow(examination_category[i]); data.push(row); } var header = [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Mô tả"} }, { child: {text: "Hoạt động"} } ]; if (isAdmin) header.push({}); var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: header } ] }, body: { rows: data } } } } }); var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: "Tìm kiếm..." } }); tableView.attachSearchInput(inputsearchbox); var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ onsuccess(); } }); var addFunc = function(content){ var onsave = function(retval) { if (!content.key){ examination_category.push(retval); } else { for (var i = 0; i < examination_category.length; i++) { if (examination_category[i].key == retval.key) { examination_category[i] = retval; break; } } } // frameList.removeLast(); // me.groupCategory(hrapi, div_element, onsuccess); redrawTableFunc(); }; var onabort = function(rs){ console.log(rs); }; me.groupCategoryEdit(hrapi, content, div_element, onsave, onabort) }; var addBtn = module.e_learning.noneIconButton({ text: "Thêm", onclick: function(){ var content = {}; addFunc(content); } }); div_element.addChild(frameList); var singlePage = absol._({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", style: { display: isAdmin ? "" : "none" }, child: addBtn } ] } }, { child: tableView } ] }); frameList.addChild(singlePage); singlePage.requestActive(); }; redrawTableFunc(); }); }); }); } } (module, retval); // function: hrplugins.keeview.examination.groupCategoryEdit var v72 = function(module, me) { return function (hrapi, content, div_element, onsave, onabort) { var name = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.name ? content.name : "" } }); var comment = absol._({ tag: "textarea", class: "cardSimpleTextarea", style: { width: "400px" }, props: { value: content.comment ? content.comment : "" } }); var active = absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: content.active !== undefined ? content.active : true } }); var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); } }); var saveFunc = function() { var value = { name: name.value.trim(), comment: comment.value.trim(), active: active.checked } if (value.name == "") { ModalElement.alert({ message: "Chưa nhập tên", func: function(){ name.focus(); } }) return; } var key; if (content.key) key = content.key; else key = (new Date()).getTime(); ModalElement.show_loading(); hrapi.table.update("examination_category", key, value, (s,r) => { ModalElement.close(-1); if (s) { value.key = key; onsave(value); } else onabort(r); }); }; var saveBtn = module.e_learning.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var data_ctn = absol._({ child: DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {paddingLeft: "10px"}}, children: [name] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Mô tả"}, { attrs: {style: {paddingLeft: "10px"}}, children: [comment] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {paddingLeft: "10px"}}, children: [active] } ] ] }) }) var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn } ] } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.examination.importExaminationData var v168 = function(module, me) { return function (hrapi) { return new Promise(function(resolve, reject){ var importFunc = function(content){ ModalElement.show_loading(); var dict = {}; content.content.details.forEach(function(elt){ dict = Object.assign(dict, elt); }) content.content.details = dict; dict = {}; content.question_pool.details.forEach(function(elt){ dict = Object.assign(dict, elt); }) content.question_pool.details = dict; console.log(content); // return; var firstid; var run6 = function(elt){ return new Promise(function(rs, rj){ elt.content.creator = firstid; elt.content.createdtime = new Date(elt.content.createdtime); hrapi.table.update("question_pool", elt.key, elt.content, function(s, r){ if (s) { hrapi.table.create("question_pool_details_" + elt.key, function(s1, r1){ if (s1) { content.question_pool.details[elt.key].creator = firstid; content.question_pool.details[elt.key].createdtime = new Date(elt.content.createdtime); hrapi.table.update("question_pool_details_" + elt.key, elt.key, content.question_pool.details[elt.key], function(s2, r2){ if (s2) { rs() } else rj(["update", "question_pool_details_" + elt.key, r2]); }); } else rj(["question_pool_details_" + elt.key, r1]); }); } else rj(["question_pool", r]); }); }); } var run5 = function(idx){ if (idx < content.question_pool.question_pool.length) { run6(content.question_pool.question_pool[idx]).then(function(){ run5(idx+1); }, function(err){ content.question_pool.question_pool.forEach(function(elt){ hrapi.table.delete("question_pool", elt.key, function(s, r){ }); hrapi.table.drop("question_pool_details_" + elt.key, function(s, r){ }); }); reject(err); }) } else { ModalElement.close(-1); ModalElement.alert({message: "success", func: function(){resolve()}}); } } var run4 = function(elt){ return new Promise(function(rs, rj){ elt.content.creator = firstid; elt.content.createdtime = new Date(elt.content.createdtime); elt.content.startTime = new Date(elt.content.startTime); hrapi.table.update("examination", elt.key, elt.content, function(s, r){ if (s) { hrapi.table.create("examination_details_" + elt.key, function(s1, r1){ if (s1) { hrapi.table.update("examination_details_" + elt.key, "questions", content.content.details[elt.key], function(s2, r2){ if (s2) { rs() } else rj(["update", "examination_details_" + elt.key, r2]); }); } else rj(["examination_details_" + elt.key, r1]); }); } else rj(["examination", r]); }); }); } var run3 = function(idx){ if (idx < content.content.examination.length) { run4(content.content.examination[idx]).then(function(){ run3(idx+1); }, function(err){ content.content.examination.forEach(function(elt){ hrapi.table.delete("examination", elt.key, function(s, r){ }); hrapi.table.drop("examination_details_" + elt.key, function(s, r){ }); }); reject(err); }) } else { run5(0); } } var run2 = function(elt){ return new Promise(function(rs, rj){ hrapi.table.update("examination_category", elt.key, elt.content, function(s, r){ if (s) rs() else rj(["examination_category", r]); }); }); } var run = function(idx){ if (idx < content.group.length) { run2(content.group[idx]).then(function(){ run(idx+1); }, function(err){ content.group.forEach(function(elt){ hrapi.table.delete("examination_category", elt.key, function(s, r){ }); }); reject(err); }) } else run3(0); } // run(0); hrapi.table.create("examination_category", (s, r) => { if (!s) { ModalElement.alert({message: "Chưa tạo nhóm bài học"}); reject(r); return; } hrapi.table.create("question_pool", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); reject(r); return; } hrapi.table.create("examination", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); reject(r); return; } hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); reject(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); reject(currentEmp); return; } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); reject(currentEmp); return; } firstid = currentEmp.firstid; run(0); }); }); }) }) }); }; var selector = absol._({ tag: "input", props: {type: "file", accept: ".json"}, on: { change: function(event){ var file = event.target.files[0]; const reader = new FileReader(); reader.addEventListener('load', (event) => { var content = event.target.result; var intern = JSON.parse(content); importFunc(intern); }); reader.readAsText(file); } } }); selector.click(); }) } } (module, retval); // function: hrplugins.keeview.examination.importFromExamination var v89 = function(module, me) { return function (hrapi, content) { return new Promise(function(resolve, reject){ hrapi.table.select("examination", function(s, r){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); reject(s, r); return; } var items = []; r.forEach((item, i) => { if (item.key != content.key) { items.push({ value: item.key, text: item.content.name }); } }); var examinationData; items.unshift({value: "select", text: "Chọn bài kiểm tra"}); var selected = { sections:[], questions: {} }; var countText = absol._({}); var cbb = absol._({ tag: "selectmenu", props: { items: items }, on: { change: function(){ selected = { sections:[], questions: {} }; tableContainer.clearChild(); if (this.value == "select") return; getQuestion(this.value); } } }); var count = 0; var selectedCount = 0; var getQuestion = function(key){ ModalElement.show_loading(); hrapi.table.select("examination_details_" + key, function(s, r){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); reject(s, r); return; } var questions; for (var i = 0; i < r.length; i++) { if (r[i].key == "questions") { questions = r[i].content; break; } } ModalElement.close(-1); var data = []; var makeQuesion = function(ctn, idx){ var children = []; ctn.forEach((item, i) => { var checkbox = absol._({ tag: "checkbox", on: { change: function(){ if (!this.checked){ this.parentChecbox.checked = false; selected.questions[idx] = selected.questions[idx].filter(function(elt){ return elt != i; }) selectedCount--; selected.sections = selected.sections.filter(function(elt){ return elt != idx; }); } else { selectedCount++; selected.questions[idx].push(i); } checkbox.name.clearChild(); checkbox.name.addChild(absol._({text: checkbox.nameText + " (" + selected.questions[idx].length + "/" + checkbox.sectionCount + ")"})); countText.clearChild(); countText.addChild(absol._({text: "Tên " + "(" + selectedCount + "/" + count + ")"})); } } }); children.push({ cells: [ { children: checkbox }, { text: item.content.length > 200 ? (item.content.substr(0, 200) + "...") : item.content } ], checkbox: checkbox }) }); return children; }; if (!questions.content) return; examinationData = questions.content; questions.content.forEach((item, idx) => { selected.questions[idx] = []; count += item.questions.length; var nameText = item.section.name.length > 200 ? (item.section.name.substr(0, 200) + "...") : item.section.name; var name = absol._({ child: {text: nameText + " (" + 0 + "/" + item.questions.length + ")"} }); var children = makeQuesion(item.questions, idx); var checkbox = absol._({ tag: "checkbox", on: { change: function(){ if (this.checked){ selected.sections.push(idx); // selected.questions[idx] = []; children.forEach((item2, i) => { if (item2.checkbox.checked == false){ item2.checkbox.checked = true; selected.questions[idx].push(i); selectedCount++; } }); name.clearChild(); name.addChild(absol._({text: nameText + " (" + item.questions.length + "/" + item.questions.length + ")"})); } else { selected.sections = selected.sections.filter(function(elt){ return elt != idx; }); selectedCount -= selected.questions[idx].length; selected.questions[idx] = []; children.forEach((item2, i) => { item2.checkbox.checked = false; }); name.clearChild(); name.addChild(absol._({text: nameText + " (" + 0 + "/" + item.questions.length + ")"})); } countText.clearChild(); countText.addChild(absol._({text: "Tên " + "(" + selectedCount + "/" + count + ")"})); } } }); children.forEach((item2, i) => { item2.checkbox.parentChecbox = checkbox; item2.checkbox.nameText = nameText; item2.checkbox.name = name; item2.checkbox.sectionCount = item.questions.length; }); data.push({ cells: [ { children: checkbox }, { children: name } ], children: children }); }); countText.addChild(absol._({text: "Tên " + "(" + selectedCount + "/" + count + ")"})); var tableView = DOMElement.treetable({ attrs: { style: { width: "100%" } }, header: [ {attrs: {style: {width: "40px"}}}, {children: countText} ], data: data }); tableContainer.addChild(tableView); }); } var tableContainer = absol._({ class: "cardsimpletableclass" }); ModalElement.showWindow({ title: "Chọn câu hỏi", bodycontent: absol._({ child: [ { style: { paddingBottom: "10px" }, child: [ { tag: "span", style: { verticalAlign: "middle", paddingRight: "20px" }, child: {text: "Bài kiểm tra"} }, cbb ] }, { style: { paddingBottom: "10px" }, child: countText }, { child: tableContainer } ] }), buttonlist: [ { text: "OK", onclick: function(){ var retval = { sections: [], questions: [] }; selected.sections.forEach((item, i) => { var t = EncodingClass.string.duplicate(examinationData[item]); delete t.section.ident; t.questions.forEach((item, i) => { delete item.ident; }); retval.sections.push(t); }); var keys = Object.keys(selected.questions); keys.forEach((item, i) => { if (selected.sections.indexOf(parseInt(item)) != -1) return; selected.questions[item].forEach((item2, i2) => { var t = EncodingClass.string.duplicate(examinationData[item].questions[item2]); delete t.ident; retval.questions.push(t); }); }); resolve(retval); ModalElement.closeAll(); } }, { text: "Hủy", onclick: function(){ resolve(null); ModalElement.closeAll(); } } ] }) }) }); } } (module, retval); // function: hrplugins.keeview.examination.importFromQuestionPool var v90 = function(module, me) { return function (hrapi, content) { return new Promise(function(resolve, reject){ hrapi.table.select("question_pool", function(s, r){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); reject(s, r); return; } var items = []; r.forEach((item, i) => { if (item.key != content.key) { items.push({ value: item.key, text: item.content.name }); } }); var questionPoolData; items.unshift({value: "select", text: "Chọn ngân hàng câu hỏi"}); var selected = { sections:[], questions: {} }; var countText = absol._({}); var cbb = absol._({ tag: "selectmenu", props: { items: items }, on: { change: function(){ selected = { sections:[], questions: {} }; tableContainer.clearChild(); if (this.value == "select") return; getQuestion(this.value); } } }); var count = 0; var selectedCount = 0; var getQuestion = function(key){ ModalElement.show_loading(); hrapi.table.select("question_pool_details_" + key, function(s, r){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); reject(s, r); return; } ModalElement.close(-1); var data = []; var makeQuesion = function(ctn, idx){ var children = []; ctn.forEach((item, i) => { var checkbox = absol._({ tag: "checkbox", on: { change: function(){ if (!this.checked){ this.parentChecbox.checked = false; selected.questions[idx] = selected.questions[idx].filter(function(elt){ return elt != i; }) selectedCount--; selected.sections = selected.sections.filter(function(elt){ return elt != idx; }); } else { selectedCount++; selected.questions[idx].push(i); } checkbox.name.clearChild(); checkbox.name.addChild(absol._({text: checkbox.nameText + " (" + selected.questions[idx].length + "/" + checkbox.sectionCount + ")"})); countText.clearChild(); countText.addChild(absol._({text: "Tên " + "(" + selectedCount + "/" + count + ")"})); } } }); children.push({ cells: [ { children: checkbox }, { text: item.content.length > 200 ? (item.content.substr(0, 200) + "...") : item.content } ], checkbox: checkbox }) }); return children; }; if (!r[0].content.questions) return; questionPoolData = r[0].content.questions; r[0].content.questions.forEach((item, idx) => { selected.questions[idx] = []; count += item.questions.length; var nameText = item.section.name.length > 200 ? (item.section.name.substr(0, 200) + "...") : item.section.name; var name = absol._({ child: {text: nameText + " (" + 0 + "/" + item.questions.length + ")"} }); var children = makeQuesion(item.questions, idx); var checkbox = absol._({ tag: "checkbox", on: { change: function(){ if (this.checked){ selected.sections.push(idx); // selected.questions[idx] = []; children.forEach((item2, i) => { if (item2.checkbox.checked == false){ item2.checkbox.checked = true; selected.questions[idx].push(i); selectedCount++; } }); name.clearChild(); name.addChild(absol._({text: nameText + " (" + item.questions.length + "/" + item.questions.length + ")"})); } else { selected.sections = selected.sections.filter(function(elt){ return elt != idx; }); selectedCount -= selected.questions[idx].length; selected.questions[idx] = []; children.forEach((item2, i) => { item2.checkbox.checked = false; }); name.clearChild(); name.addChild(absol._({text: nameText + " (" + 0 + "/" + item.questions.length + ")"})); } countText.clearChild(); countText.addChild(absol._({text: "Tên " + "(" + selectedCount + "/" + count + ")"})); } } }); children.forEach((item2, i) => { item2.checkbox.parentChecbox = checkbox; item2.checkbox.nameText = nameText; item2.checkbox.name = name; item2.checkbox.sectionCount = item.questions.length; }); data.push({ cells: [ { children: checkbox }, { children: name } ], children: children }); }); countText.addChild(absol._({text: "Tên " + "(" + selectedCount + "/" + count + ")"})); var tableView = DOMElement.treetable({ attrs: { style: { width: "100%" } }, header: [ {attrs: {style: {width: "40px"}}}, {children: countText} ], data: data }); tableContainer.addChild(tableView); }); } var tableContainer = absol._({ class: "cardsimpletableclass" }) ModalElement.showWindow({ title: "Chọn câu hỏi", bodycontent: absol._({ child: [ { style: { paddingBottom: "10px" }, child: [ { tag: "span", style: { verticalAlign: "middle", paddingRight: "20px" }, child: {text: "Ngân hàng câu hỏi"} }, cbb ] }, { child: tableContainer } ] }), buttonlist: [ { text: "OK", onclick: function(){ var retval = { sections: [], questions: [] }; selected.sections.forEach((item, i) => { var t = EncodingClass.string.duplicate(questionPoolData[item]); delete t.section.ident; t.questions.forEach((item, i) => { delete item.ident; }); retval.sections.push(t); }); var keys = Object.keys(selected.questions); keys.forEach((item, i) => { if (selected.sections.indexOf(parseInt(item)) != -1) return; selected.questions[item].forEach((item2, i2) => { var t = EncodingClass.string.duplicate(questionPoolData[item].questions[item2]); delete t.ident; retval.questions.push(t); }); }); resolve(retval); ModalElement.closeAll(); } }, { text: "Hủy", onclick: function(){ resolve(null); ModalElement.closeAll(); } } ] }) }) }); } } (module, retval); // function: hrplugins.keeview.examination.makeDatabaseContent var v73 = function(module, me) { return function (host, content) { var i, keys; keys = Object.keys(content); keys.forEach(function(item, i){ host.database[item] = {}; host.database[item].items = content[item]; host.database[item].getIndex = function(id){ for (var j = 0; j < host.database[item].items.length; j++){ if (host.database[item].items[j].key == id) return j; } return -1; } }); } } (module, retval); // function: hrplugins.keeview.examination.makeResultChart var v102 = function(module, me) { return function (questionData, examData, ratingScale, empContent) { var chartData = { correct: 0, almost_correct: 0, incorrect: 0, no_answer: 0 } var score = 0; var scoreTotal = 0; var count = 0; var questions = []; questionData.forEach((item, k) => { item.questions.forEach((question, idx) => { count++; scoreTotal += question.score; score += examData.score[question.ident].score; if (examData.score[question.ident].score >= question.score){ chartData.correct++; } else if (examData.score[question.ident].score > 0) chartData.almost_correct++; else { switch (question.type) { case "multiple_choice": case "checkboxes": if (!examData.result[question.ident] || examData.result[question.ident].value === null) chartData.no_answer++; else chartData.incorrect++; break; case "paragraph": case "short_answer": if (!examData.result[question.ident] || examData.result[question.ident].value == "") chartData.no_answer++; else chartData.incorrect++; break; } } }); }); var percent = parseInt((score / scoreTotal * 100), 10); var ratingText = ""; for (var i = 0; i < ratingScale.length; i++) { if (i == 0) { if (percent >= ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } else if (i == ratingScale.length - 1) { if (percent > ratingScale[i].min) { ratingText = ratingScale[i].text; break; } } else { if (percent > ratingScale[i].min && percent <= ratingScale[i].max) { ratingText = ratingScale[i].text; break; } } } var t = { total: count, arcs: [ { name: chartData.correct + " Trả lời đúng", value: chartData.correct, color: "#72bb53"}, { name: chartData.almost_correct + " Trả lời gần đúng", value: chartData.almost_correct, color: "#ffc957"}, { name: chartData.incorrect + " Trả lời sai", value: chartData.incorrect, color: "#e61610"}, { name: chartData.no_answer + " Không trả lời", value: chartData.no_answer, color: "#9c29b7"} ] }; var chart = absol._({ tag: 'tinycirclechart', style: { width: '250px', height: '100px' }, props: t }); var timeString; if (!examData.startTime && !examData.completedTime){ timeString = ""; } else if (!examData.completedTime) { timeString = module.e_learning.getDateTimeView2(examData.startTime) } else { timeString = module.e_learning.getTimeViewFromDateTime(examData.startTime) + " - " + module.e_learning.getDateTimeView2(examData.completedTime) } var retDiv = absol._({ class: "hr-intro-view-form", child: [ { style: { display: "inline-block", verticalAlign: "middle", paddingRight: "50px", textAlign: "initial" }, child: DOMElement.table({ data: [ [ { text: "Tên", attrs: { style: { paddingRight: "20px" } } }, { attrs: { style: { fontSize: "18px", fontWeight: "bold" } }, text: empContent.fullname } ], [{ attrs: { style: { height: "10px" } } }], [ { text: "Bộ phận", attrs: { style: { paddingRight: "20px" } } }, { attrs: { style: { fontSize: "18px", fontWeight: "bold" } }, text: empContent.orgName } ], [{ attrs: { style: { height: "10px" } } }], [ { text: "Thời gian làm bài", attrs: { style: { paddingRight: "20px" } } }, { attrs: { style: { fontSize: "18px", fontWeight: "bold" } }, text: timeString } ], [{ attrs: { style: { height: "10px" } } }], [ { text: "Điểm", attrs: { style: { paddingRight: "20px" } } }, { attrs: { style: { fontSize: "18px", fontWeight: "bold" } }, text: score + "/" + scoreTotal } ], [{ attrs: { style: { height: "10px" } } }], [ { text: "Kết quả", attrs: { style: { paddingRight: "20px" } } }, { attrs: { style: { fontSize: "18px", fontWeight: "bold" } }, text: percent + "%" } ], [{ attrs: { style: { height: "10px" } } }], [ { text: "Xếp loại", attrs: { style: { paddingRight: "20px" } } }, { attrs: { style: { fontSize: "18px", fontWeight: "bold" } }, text: ratingText } ] ] }) }, { style: { display: "inline-block", verticalAlign: "middle" }, child: chart } ] }) return retDiv; } } (module, retval); // function: hrplugins.keeview.examination.mockExamination var v136 = function(module, me) { return function (hrapi, content, examData, div_element, onclose, onsuccess) { var finish = false; var successBtn = module.e_learning.noneIconButton({ text: "Hoàn thành", onclick: function(){ var title = "Hoàn thành"; var message = "Bạn có chắc chắn đã hoàn thành bài kiểm tra"; module.e_learning.deleteConfirm(title, message).then(function(){ finish = true; frameList.removeLast(); onsuccess(); }); } }); var container = absol._({ class: "as-pseudo-align-child-center", style: { height: "100%" } }); var resultInfo = absol._({ style: { display: "inline-block", verticalAlign: "middle" } }); var timeInfo = absol._({ style: { display: "inline-block", verticalAlign: "middle" } }); var singlePage = absol.buildDom({ tag: "singlepage", class: "as-viewport-full", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: successBtn }, { class: "single-button-header", child: absol._({ style: { fontWeight: "bold" }, child: [resultInfo, timeInfo] }) } ] } }, { style: { paddingLeft: "10px", userSelect: "none", height: "100%" }, child: container } ] }); var viewer; var makeQuesion = function(){ container.removeClass("as-pseudo-align-child-center"); singlePage.removeClass("as-viewport-full"); var PoserViewer = absol.poser.PoserViewer; viewer = new PoserViewer( { hasScroller: false, hasSection: false } ); var saveTimeout = -1; viewer.on("resultchange", function(event){ var data = viewer.getResult(); answerCount = 0; t_content.forEach((item, i) => { item.questions.forEach((item2, i) => { if (data[item2.ident].value){ if (item2.type == "checkboxes" || item2.type == "paragraph" || item2.type == "short_answer") { if (data[item2.ident].value.length > 0) answerCount++; } else answerCount++; } }); }); resultInfo.clearChild(); resultInfo.addChild(absol._({text: "Câu hỏi đã làm: " + answerCount + "/" + count + "- Thời gian còn lại: "})); }); var mPoserView = viewer.getView(); var count = 0; var answerCount = 0; var result = {}; if (examData.student[div_element.currentEmp.firstid] && examData.student[div_element.currentEmp.firstid].result) { result = EncodingClass.string.duplicate(examData.student[div_element.currentEmp.firstid].result); } var t_content = []; if (examData.questions) { t_content = EncodingClass.string.duplicate(examData.questions.content); t_content.forEach((item, i) => { item.questions.forEach((item2, i) => { count++; if (result[item2.ident] && result[item2.ident].value !== null){ if (item2.type == "checkboxes" || item2.type == "paragraph" || item2.type == "short_answer") { if (result[item2.ident].value.length > 0) answerCount++; } else answerCount++; } delete item2.correct_answer; }); }); viewer.setData(t_content); viewer.setResult(result); } else viewer.setData([]); var t_time = new Date(); t_time.setMinutes(t_time.getMinutes() + content.content.duration); var clock = absol._({ tag: 'countdowntext', props: { finishTime: t_time, format: "standard", fps: 3 }, on: { finish: function(){ if (finish) return; frameList.removeLast(); onsuccess(); } } }); resultInfo.addChild(absol._({text: "Câu hỏi đã làm: " + answerCount + "/" + count + "- Thời gian còn lại: "})); timeInfo.addChild(clock); container.clearChild(); container.addChild(mPoserView); } makeQuesion(); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.examination.openExaminationByLink var v178 = function(module, me) { return function (hrapi, examinationid, div_element, onClose) { ModalElement.show_loading(); hrapi.table.select("examination_category", function(s, value){ if (!s) { ModalElement.alert({message: value}); return; } value.unshift({key: "general_group", content: { name: "Nhóm chung", comment: "", active: true }}); div_element.database = {}; var db_content = {}; db_content.examination_category = value; var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("examination", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.firstid] = orgContent; orgContent.employees.forEach((item, i) => { item.orgName = orgContent.name; employees.push(item); }); // employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); rs({ orgs: retval, employees: employees }); }); }); }), new Promise(function(rs, rj){ hrapi.templates.getEmails(function(r, s){ if (r) rs(s); else rj(s); }) }) ]; var stageItems = [ {value: "plan", text: "Kế hoạch"}, {value: "question", text: "Xây dựng câu hỏi"}, {value: "question_success", text: "Hoàn thành câu hỏi"}, {value: "ongoing", text: "Thực hiện kiểm tra"}, {value: "evaluating", text: "Thực hiện chấm điểm"}, {value: "evaluated", text: "Chấm điểm xong"}, {value: "finish", text: "Kết thúc"}, {value: "cancel", text: "Hủy"} ] var stageDict = {}; stageItems.forEach((item, i) => { stageDict[item.value] = item.text; }); ModalElement.show_loading(); Promise.all(loadDB).then(function(rs){ ModalElement.close(-1); db_content.examination = rs[0]; db_content.orgs = rs[3].orgs; db_content.employees = rs[3].employees; db_content.email_templates = rs[4]; me.makeDatabaseContent(div_element, db_content); div_element.database.email_templates.getIndex = function(id){ for (var j = 0; j < div_element.database.email_templates.items.length; j++){ if (div_element.database.email_templates.items[j].id == id) return j; } return -1; }; div_element.isAdmin = rs[1]; div_element.currentEmp = rs[2]; var dict = { examination: {}, examination_category: {}, stage: stageDict, }; div_element.employeeDict = {}; div_element.database.employees.items.forEach((item, i) => { div_element.employeeDict[item.firstid] = item; }); div_element.database.examination.items.forEach((item, i) => { dict.examination[item.key] = item.content; }); div_element.database.examination_category.items.forEach((item, i) => { dict.examination_category[item.key] = item.content; }); var run = function(){ hrapi.table.select("examination_details_" + examinationid, function(r, content){ if (r){ var examInfo = { key: examinationid, content: dict.examination[examinationid] }; var teacher = []; if (examInfo.content.teacher) { teacher = examInfo.content.teacher; } var student = []; if (examInfo.content.student) { var student = examInfo.content.student; } var examData = { questions: {}, student: {}, teacher: {} }; student.forEach((item, i) => { examData.student[item] = {}; }); content.forEach((item, i) => { if (item.key == "questions") examData.questions = item.content; else if (item.key.startsWith("student_success_")) { if (!examData.student[item.key.substr(16)]) return; examData.student[item.key.substr(16)].success = item.content; } else if (item.key.startsWith("student_evaluated_")) { if (!examData.student[item.key.substr(18)]) return; examData.student[item.key.substr(18)].evaluated = item.content; } else if (item.key.startsWith("student_result_")) { var str = item.key.substr(15); var k = str.indexOf("_"); var studentid = str.substr(0, k); var qIdent = str.substr(k + 1); if (!examData.student[studentid]) return; if (!examData.student[studentid].result) examData.student[studentid].result = {}; examData.student[studentid].result[qIdent] = {ident: qIdent, value: item.content}; } else if (item.key.startsWith("student_score_")) { if (!examData.student[item.key.substr(14)]) return; examData.student[item.key.substr(14)].score = item.content; } else if (item.key.startsWith("student_start_time_")) { if (!examData.student[item.key.substr(19)]) return; examData.student[item.key.substr(19)].startTime = item.content; } else if (item.key.startsWith("student_completed_time_")) { if (!examData.student[item.key.substr(23)]) return; examData.student[item.key.substr(23)].completedTime = item.content; } }); if (!examData.questions.content) examData.questions.content = []; var onSuccess = function(){ onClose(); } me.doExamination(hrapi, examInfo, examData, div_element, onClose, onSuccess); } else { me.examination.examinationTable(hrapi, div_element, onClose); } }) } run(); }, function(err){console.log(err);}) }); } } (module, retval); // function: hrplugins.keeview.examination.printQuestion var v134 = function(module, me) { return function (hrapi, examInfo, examData, div_element) { var printDiv = absol._({ style: { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", overflow: "auto", zIndex: 10000000, opacity: 0, pointerEvents: "none" } }); var PoserEditor = absol.poser.PoserEditor; var mPoserEditor = new PoserEditor({ hasScroller: false,//không cuộn hasTool: false,//không có cây, mình lấy ra để riêng hoặc không dùng tới questionTypes: ["multiple_choice", "checkboxes", "paragraph", "short_answer"] }); var mPoserEditorView = mPoserEditor.getView(); if (examData.questions.content) mPoserEditor.setData(examData.questions.content); else mPoserEditor.setData([]); printDiv.addChild(mPoserEditorView); document.body.appendChild(printDiv); setTimeout(function(){ mPoserEditor.downloadAsPdf({title: "Questionnaire-"+examInfo.content.name}); //printDiv.remove(); }, 200); } } (module, retval); // function: hrplugins.keeview.examination.privilegeEdit var v78 = function(module, me) { return function (hrapi, examInfo, currentEmpId, onsave, onabort, orgs, content) { var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var cur = { value: -item.firstid, text: item.name }; var items = []; if (item.children) items = items.concat(getEmployeeItems(item.children)); if (item.employees) item.employees.forEach((item2) => { // if (item2.available) items.push({ items.push({ value: item2.firstid, text: item2.fullname, isLeaf: true }); }); cur.items = items; data.push(cur); }); return data; }; var empItems = getEmployeeItems(orgs); var editPriv = absol._({ tag: "multichecktreeleafmenu", props: { items: empItems, values: examInfo.content.editPriv ? examInfo.content.editPriv : [], enableSearch: true } }); var viewPriv = absol._({ tag: "multichecktreemenu", props: { items: empItems, values: examInfo.content.viewPriv ? examInfo.content.viewPriv : [], enableSearch: true } }); var st = absol._({ child: [ { style: { fontWeight: "bold" }, child: {text: "Nhân viên nào được xem bài kiểm tra này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: viewPriv } ] }, { style: { paddingTop: "10px", fontWeight: "bold" }, child: {text: "Nhân viên nào được sửa bài kiểm tra này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: editPriv } ] } ] }); ModalElement.showWindow({ title: "Phân quyền", bodycontent: st, buttonlist: [ { text: "Lưu", onclick: function(){ var key = examInfo.key; examInfo.content.editPriv = editPriv.values; examInfo.content.viewPriv = viewPriv.values; examInfo.content.lastmodified = currentEmpId; examInfo.content.lastmodifiedtime = new Date(); ModalElement.show_loading(); hrapi.table.update("examination", key, examInfo.content, function(s, r){ ModalElement.closeAll(); if (s) if(onsave) { onsave({ editPriv: examInfo.content.editPriv, viewPriv: examInfo.content.viewPriv }); } else if(onabort) onabort(r); }); } }, { text: "Hủy", onclick: function(){ ModalElement.closeAll(); onabort(); } } ] }) } } (module, retval); // function: hrplugins.keeview.examination.questionEdit var v79 = function(module, me) { return function (hrapi, content, examData, div_element, onsave, onabort) { var closeBtn = module.e_learning.noneIconButton({ text: "Quay lại", onclick: function(){ frameList.removeLast(); onabort(); } }); var checkDuplicate = function(content){ var questions = []; content.forEach((item, i) => { questions = questions.concat(item.questions); }); var dict = {}; questions.forEach((item, i) => { // var t = EncodingClass.string.duplicate(item.content); // absol.string.nonAccentVietnamese(t.toLowerCase().replaceAll(" ", "")); if (!dict[item.content]) dict[item.content] = [i + 1]; else dict[item.content].push(i + 1); }); var keys = Object.keys(dict); var rs = []; keys.forEach((item, i) => { if (dict[item].length > 1) rs.push(dict[item]); }); return rs; }; var saveFunc = function() { ModalElement.show_loading(); var questionData = mPoserEditor.getData(); absol.$.replaceFileInObject(questionData, function(value, key, subObject){ return module.e_learning.uploadFle(value).then(function(result){ return window.domainFilesNew + result; }); }).then(function(retData){ var key = content.key; var duplicate = checkDuplicate(retData); if (duplicate.length > 0) { var message = "Các câu hỏi bị trùng: "; duplicate.forEach((item, i) => { if (i > 0) message += ", "; message += "[" + item.toString() + "]"; }); ModalElement.alert({message: message}); ModalElement.close(-1); return; } examData.questions.content = retData; examData.questions.lastmodified = div_element.currentEmp.firstid; examData.questions.lastmodifiedtime = new Date(); ModalElement.show_loading(); hrapi.table.update("examination_details_" + key, "questions", examData.questions, function(s, r){ ModalElement.closeAll(); if (s) if(onsave) { onsave(examData.questions); } else if(onabort) onabort(r); }); }); }; var saveBtn = module.e_learning.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var addQuestionBtn = module.e_learning.noneIconButton({ text: "Thêm câu hỏi", onclick: function(){ mPoserEditor.addNewQuestion({data: {content: ""}}); } }); var addQuestionFromExamBtn = absol._({ tag: 'ribbonbutton', class: "as-appearance-button", props: { text: 'Import', // icon: 'span.mdi.mdi-file-image-outline', items: [ { text: "Import từ bài kiểm tra", value: 'from_examination' }, { text: "Import từ ngân hàng câu hỏi", value: 'from_question_pool' } ] }, on: { select: function (event) { if (event.item.value == 'from_examination'){ me.importFromExamination(hrapi, content).then(function(value){ if (!value) return; value.sections.forEach((item, i) => { var t = EncodingClass.string.duplicate(item.section); delete t.ident; mPoserEditor.addNewSection({data: t}); item.questions.forEach((item2, i2) => { var t2 = EncodingClass.string.duplicate(item2); mPoserEditor.addNewQuestion({data: t2}); }); }); value.questions.forEach((item, i) => { var t = EncodingClass.string.duplicate(item); mPoserEditor.addNewQuestion({data: t}); }); }); } else { me.importFromQuestionPool(hrapi, content).then(function(value){ if (!value) return; value.sections.forEach((item, i) => { var t = EncodingClass.string.duplicate(item.section); delete t.ident; mPoserEditor.addNewSection({data: t}); item.questions.forEach((item2, i2) => { var t2 = EncodingClass.string.duplicate(item2); mPoserEditor.addNewQuestion({data: t2}); }); }); value.questions.forEach((item, i) => { var t = EncodingClass.string.duplicate(item); mPoserEditor.addNewQuestion({data: t}); }); }); } } } }); var questionSuccessBtn = module.e_learning.noneIconButton({ text: "Hoàn thành câu hỏi", onclick: function(){ onabort("question_success"); frameList.removeLast(); } }); var newSectionBtn = module.e_learning.noneIconButton({ text: "Thêm section", onclick: function(){ mPoserEditor.addNewSection({data: {name: ""}}); } }); var questionSortBtn = module.e_learning.noneIconButton({ text: "Sắp xếp câu hỏi", onclick: function(){ ModalElement.showWindow({ title: "Tree Editor", noPadding: true, bodycontent: DOMElement.div({ attrs: { style: { border: "1px solid #d6d6d6", padding: "10px" } }, children: [treeEditorView] }), buttonlist: [ { text: "Đóng", onclick: function(){ ModalElement.close(1); } } ] }); } }); var PoserEditor = absol.poser.PoserEditor; var mPoserEditor = new PoserEditor({ hasScroller: false,//không cuộn hasTool: false,//không có cây, mình lấy ra để riêng hoặc không dùng tới questionTypes: ["multiple_choice", "checkboxes", "paragraph", "short_answer"] }); var mPoserEditorView = mPoserEditor.getView(); if (examData.questions.content) mPoserEditor.setData(examData.questions.content); else mPoserEditor.setData([]); var treeEditorView = mPoserEditor.treeEditor.getView(); treeEditorView.addStyle("width", "600px"); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol._({ tag: "singlepage", child: [ { class: ["button-panel-header", "absol-single-page-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn }, { class: "single-button-header", child: addQuestionBtn }, { class: "single-button-header", child: newSectionBtn }, { class: "single-button-header", child: questionSortBtn }, { class: "single-button-header", child: addQuestionFromExamBtn }, { class: "single-button-header", child: questionSuccessBtn } ] } }, { style: { paddingTop: "10px" } }, { style: { marginBottom: "var(--footer-margin)" }, child: [ { child: mPoserEditorView } ] } ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.examination.questionPoolAddNew var v85 = function(module, me) { return function (hrapi, content, onsave, onabort) { hrapi.users.getCurrentId(function(s, userid){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } hrapi.orgs.getEmployeeByUserId(userid, (s1, currentEmp) => { if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); return; } if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); return; } var name = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "400px" }, props: { type: "text", value: content.name ? content.name : "" } }); var comment = absol._({ tag: "textarea", class: "cardSimpleTextarea", style: { width: "400px" }, props: { value: content.comment ? content.comment : "" } }); var active = absol._({ tag: "switch", style: { font: "var(--switch-fontsize)", margin: "auto" }, props: { checked: content.active !== undefined ? content.active : true } }); ModalElement.showWindow({ title: content.key ? "Sửa ngân hàng câu hỏi" : "Thêm ngân hàng câu hỏi", noPadding: true, bodycontent: DOMElement.table({ data: [ [ { text: "Tên" }, { attrs: { style: { paddingLeft: "10px" } }, children: [name] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Mô tả" }, { attrs: { style: { paddingLeft: "10px" } }, children: [comment] } ], [{attrs: {style: {height: "10px"}}}], [ { text: "Hoạt động" }, { attrs: { style: { paddingLeft: "10px" } }, children: [active] } ] ] }), buttonlist: [ { text: "Lưu", onclick: function(){ var value = { name: name.value.trim(), comment: comment.value.trim(), active: active.checked }; if (value.name == "") { ModalElement.alert({ message: "Chưa nhập tên", func: function(){ name.focus(); } }); return; } if (!content) content = {}; content.name = value.name; content.comment = value.comment; content.active = value.active; var key; if (!content.key) { key = (new Date()).getTime(); content.creator = currentEmp.firstid; content.createdtime = new Date(); ModalElement.show_loading(); hrapi.table.update("question_pool", key, content, function(s, r){ ModalElement.closeAll(); if (s) { hrapi.table.create("question_pool_details_" + key, (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } hrapi.table.update("question_pool_details_" + key, key, content, function(s, r){ ModalElement.closeAll(); if (s) { if(onsave) { content.key = key; onsave(content); } } else if(onabort) onabort(r); }); }) } else if(onabort) onabort(r); }); // content.key = key; } else { key = content.key; content.lastmodified = currentEmp.firstid; content.lastmodifiedtime = new Date(); var updateDetail = function(){ hrapi.table.select("question_pool_details_" + key, function(s, value){ if (s) { var keys = Object.keys(content); keys.forEach((item, i) => { if (item == "creator") return; if (item == "createdtime") return; if (item == "lastmodified") return; if (item == "lastmodifiedtime") return; if (item == "key") return; value[0].content[item] = content[item]; }); hrapi.table.update("question_pool_details_" + key, value[0].key, value[0].content, function(s, r){ ModalElement.closeAll(); if (s) { if(onsave) { content.key = key; onsave(content); } } else if(onabort) onabort(r); }); } else if(onabort) onabort(r); }) } hrapi.table.update("question_pool", key, content, function(s, r){ if (s) { updateDetail(); } else if(onabort) onabort(r); }); } } }, { text: "Hủy", onclick: function(){ ModalElement.closeAll(); onabort(); } } ] }); }); }); } } (module, retval); // function: hrplugins.keeview.examination.questionPoolEdit var v86 = function(module, me) { return function (hrapi, content, div_element, onsave, onabort) { var examInfo = content; var saveFunc = function(content, field, value) { return new Promise(function(rs, rj) { ModalElement.show_loading(); content.content[field] = value; content.content.lastmodified = div_element.currentEmp.firstid; content.content.lastmodifiedtime = new Date(); hrapi.table.update("question_pool_details_" + content.key, content.key, content.content, function(s, r){ if (s){ examInfo.content[field] = value; hrapi.table.update("question_pool", examInfo.key, examInfo.content, function(s, r){ if (s){ ModalElement.close(-1); rs() } else { ModalElement.alert({message: "update error"}); rj(); } }); } else { ModalElement.alert({message: "update error"}); rj(); } }); }) } var run = function(){ hrapi.table.select("question_pool_details_" + examInfo.key, function(r, s){ if (r){ run2(s[0]); } else { onabort(s); } }) } var run2 = function(content) { var editPriv = []; if (content.content.editPriv) editPriv = content.content.editPriv; var viewPriv = []; if (content.content.viewPriv) viewPriv = content.content.viewPriv; var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onabort("close"); } }); var buttonlist = [ { class: "single-button-header", child: closeBtn } ]; var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var nav_items = [ {text: "Thông tin chung", value: "general_information"}, {text: "Phân quyền", value: "privilege"}, {text: "Câu hỏi", value: "question"} ]; var nav = absol.buildDom({ tag:'mknavigator', style: { display:'inline-block'// or 'block' }, props: { items: nav_items, value: "exercise" }, on:{ press: function(event){ rightCtn.off('scroll', scrollRightFunc);// prevent loop if (sectionList[this.value]) sectionList[this.value].scrollIntoView(); setTimeout(function(){ rightCtn.on('scroll', scrollRightFunc ); }, 10); } } }); var scrollRightFunc = function(){ var elt; var bound = rightCtn.getBoundingClientRect(); var eltBound; var nearestEltId; var nearestDistance = 100000000; var distance; for (var i in sectionList){ elt = sectionList[i]; eltBound = elt.getBoundingClientRect(); distance = 1000000; if (eltBound.top <= bound.top){ if (eltBound.bottom >= bound.bottom){ distance = -1e6; } else if (bound.top - eltBound.top < 30){ distance = eltBound.top - bound.bottom;//negative } else if (eltBound.bottom > bound.top){ distance = bound.top - eltBound.top; } } else if (eltBound.top < bound.bottom){ distance = eltBound.top - bound.bottom;//negative } else { distance = Math.abs(bound.top - eltBound.top) } if (nearestDistance > distance){ nearestDistance = distance; nearestEltId = i; } } nav.value = nearestEltId; }; var rightChild = []; generalInfoDiv = absol._({ style: { paddingLeft: "10px" } }); var makeGeneralData = function(content){ var table = DOMElement.table({ data: [ [ {text: "Tên"}, { attrs: {style: {height: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({text: content.name})] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Mô tả"}, { attrs: {style: {minHeight: "30px", width: "500px", paddingLeft: "10px"}}, children: [absol._({ child: {text: content.comment} })] } ], [{attrs: {style: {paddingTop: "10px"}}}], [ {text: "Hoạt động"}, { attrs: {style: {height: "30px", paddingLeft: "10px"}}, children: [absol._({ tag: "switch", props: { disabled: true, checked: content.active } })] } ] ] }); generalInfoDiv.clearChild(); generalInfoDiv.addChild(table); } makeGeneralData(content.content); rightChild.push(absol.buildDom({ attr: { "data-sectionid": "general_information" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Thông tin chung" }, }, { class: 'mk-section-header-right', style: { display: div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 ? "" : "none" }, child: { tag: "a", child: {text: "Sửa"}, on: { click: function(){ var currentStage = content.content.stage; var onsave = function(value){ delete value.key; content.content = value; if (currentStage == value.stage) { makeGeneralData(content.content); } else { frameList.removeLast(); me.questionPoolEdit(hrapi, content, div_element, onsave, onabort); } }; var onabort_edit = function(){ }; var t_content = EncodingClass.string.duplicate(content.content); t_content.key = content.key; me.questionPoolAddNew(hrapi, t_content, onsave, onabort_edit); } } } } ] }), generalInfoDiv ] })); var privilegeDiv = absol._({}); var makePrivilege = function(content){ var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var cur = { value: -item.id, text: item.name }; var items = []; if (item.children) items = items.concat(getEmployeeItems(item.children)); if (item.employees) item.employees.forEach((item2) => { // if (item2.available) items.push({ items.push({ value: item2.id, text: item2.fullname, isLeaf: true }); }); cur.items = items; data.push(cur); }); return data; }; var empItems = getEmployeeItems(div_element.database.orgs.items); var editPriv = absol._({ tag: "multichecktreeleafmenu", props: { items: empItems, values: content.editPriv ? content.editPriv : [], enableSearch: true, disabled: true } }); var viewPriv = absol._({ tag: "multichecktreemenu", props: { items: empItems, values: content.viewPriv ? content.viewPriv : [], enableSearch: true, disabled: true } }); var st = absol._({ style: { paddingLeft: "10px" }, child: [ { style: { fontWeight: "bold" }, child: {text: "Nhân viên nào được xem bài kiểm tra này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: viewPriv } ] }, { style: { paddingTop: "10px", fontWeight: "bold" }, child: {text: "Nhân viên nào được sửa bài kiểm tra này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: editPriv } ] } ] }); privilegeDiv.clearChild(); privilegeDiv.addChild(st); }; makePrivilege({ editPriv: content.content.editPriv, viewPriv: content.content.viewPriv }); if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 || editPriv.indexOf(div_element.currentEmp.firstid) != -1)rightChild.push(absol.buildDom({ attr: { "data-sectionid": "privilege" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: [ { class: 'mk-section-header-name', child: { text: "Phân quyền" }, }, { class: 'mk-section-header-right', child: { tag: "a", child: {text: "Sửa"}, style: { display: div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 ? "" : "none" }, on: { click: function(){ var onsave = function(value){ content.content.editPriv = value.editPriv; content.content.viewPriv = value.viewPriv; examInfo.content.editPriv = value.editPriv; examInfo.content.viewPriv = value.viewPriv; makePrivilege({ editPriv: content.content.editPriv, viewPriv: content.content.viewPriv }); }; var onabort = function(){ }; var t_examInfo = EncodingClass.string.duplicate(examInfo); var t_content = EncodingClass.string.duplicate(content); me.questionPoolPrivilegeEdit(hrapi, t_content, div_element.currentEmp.firstid, onsave, onabort, div_element.database.orgs.items, t_examInfo); } } } } ] }), privilegeDiv ] })); if ( div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1 || viewPriv.indexOf(div_element.currentEmp.firstid) != -1 ) { var links = [ { class: 'mk-section-header-name', child: { text: "Câu hỏi" }, } ]; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) { links.push({ class: 'mk-section-header-right', child: { tag: "a", child: {text: "Sửa"}, on: { click: function(){ var onsave = function(value){ content.content = value.content; makeQuesionData(EncodingClass.string.duplicate(content.content.questions)) }; var onabort = function(){ }; var t_content = EncodingClass.string.duplicate(content); me.questionPoolQuestionaire(hrapi, div_element, t_content, onsave, onabort); } } } }); } var questionDiv = absol._({ child: mPoserView }); var PoserViewer = absol.poser.PoserViewer; var viewer = new PoserViewer( { hasScroller: false, readOnly: true } ); var mPoserView = viewer.getView(); questionDiv.addChild(mPoserView); var makeQuesionData = function(t_content){ if (t_content) { t_content[0].questions.forEach((item, i) => { delete item.correct_answer; }); viewer.setData(t_content); } else viewer.setData([]); } makeQuesionData(EncodingClass.string.duplicate(content.content.questions)); rightChild.push(absol.buildDom({ attr: { "data-sectionid": "question" }, child: [ absol.buildDom({ class: 'mk-section-header', style: { marginBottom: "10px" }, child: links }), questionDiv ] })); } /////////////////////// var rightCtn = absol.buildDom({ class: 'mk-main-right', style: { paddingBottom: "var(--footer-margin)" }, child: rightChild }); var data_ctn = absol._({ class: 'mk-main', style: { height: '100%' }, child: [ { class: 'mk-main-left-ctn', child: [nav] }, rightCtn ] }); var sectionList = {}; absol.$("div", rightCtn, function(elt){ var id = elt.getAttribute("data-sectionid"); if (!id) return; sectionList[id] = elt; }); var singlePage = absol.buildDom({ tag: "singlepage", class: ["as-viewport-full", "as-no-scroll", "cd-page-not-padding-right"], child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: buttonlist } }, data_ctn ] }); frameList.addChild(singlePage); singlePage.requestActive(); } if (!div_element.database) { div_element.database = {}; var loadDB = [ new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.id] = orgContent; employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); rs({ orgs: retval, employees: employees }); }); }); }) ] Promise.all(loadDB).then(function(rs){ db_content.orgs = rs[2].orgs; db_content.employees = rs[2].employees; me.makeDatabaseContent(div_element, db_content); div_element.isAdmin = rs[0]; div_element.currentEmp = rs[1]; run(); }); } else { run(); } } } (module, retval); // function: hrplugins.keeview.examination.questionPoolPrivilegeEdit var v91 = function(module, me) { return function (hrapi, content, currentEmpId, onsave, onabort, orgs, examInfo) { var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var cur = { value: -item.id, text: item.name }; var items = []; if (item.children) items = items.concat(getEmployeeItems(item.children)); if (item.employees) item.employees.forEach((item2) => { // if (item2.available) items.push({ items.push({ value: item2.id, text: item2.fullname, isLeaf: true }); }); cur.items = items; data.push(cur); }); return data; }; var empItems = getEmployeeItems(orgs); var editPriv = absol._({ tag: "multichecktreeleafmenu", props: { items: empItems, values: content.content.editPriv ? content.content.editPriv : [], enableSearch: true } }); var viewPriv = absol._({ tag: "multichecktreemenu", props: { items: empItems, values: content.content.viewPriv ? content.content.viewPriv : [], enableSearch: true } }); var st = absol._({ child: [ { style: { fontWeight: "bold" }, child: {text: "Nhân viên nào được xem ngân hàng câu hỏi này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: viewPriv } ] }, { style: { paddingTop: "10px", fontWeight: "bold" }, child: {text: "Nhân viên nào được sửa ngân hàng câu hỏi này"} }, { style: { paddingTop: "10px", paddingLeft: "20px" }, child: [ { style: { display: "inline-block", verticalAlign: "middle" }, child: {text: "Nhân viên: "}, }, { style: { display: "inline-block", verticalAlign: "middle", paddingLeft: "10px" }, child: editPriv } ] } ] }); ModalElement.showWindow({ title: "Phân quyền", bodycontent: st, buttonlist: [ { text: "Lưu", onclick: function(){ var key = content.key; content.content.editPriv = editPriv.values; content.content.viewPriv = viewPriv.values; examInfo.content.editPriv = editPriv.values; examInfo.content.viewPriv = viewPriv.values; examInfo.content.lastmodified = currentEmpId; examInfo.content.lastmodifiedtime = new Date(); ModalElement.show_loading(); hrapi.table.update("question_pool_details_" + key, key, content.content, function(s, r){ if (s) { hrapi.table.update("question_pool", key, examInfo.content, function(s, r){ ModalElement.closeAll(); if (s) if(onsave) { onsave({ editPriv: content.content.editPriv, viewPriv: content.content.viewPriv }); } else if(onabort) onabort(r); }); } else if(onabort) onabort(r); }); } }, { text: "Hủy", onclick: function(){ ModalElement.closeAll(); onabort(); } } ] }) } } (module, retval); // function: hrplugins.keeview.examination.questionPoolQuestionaire var v88 = function(module, me) { return function (hrapi, div_element, content, onsave, onabort) { var closeBtn = module.e_learning.noneIconButton({ text: "Quay lại", onclick: function(){ frameList.removeLast(); onabort(); } }); var checkDuplicate = function(content){ var questions = []; content.forEach((item, i) => { questions = questions.concat(item.questions); }); var dict = {}; questions.forEach((item, i) => { if (!dict[item.content]) dict[item.content] = [i + 1]; else dict[item.content].push(i + 1); }); var keys = Object.keys(dict); var rs = []; keys.forEach((item, i) => { if (dict[item].length > 1) rs.push(dict[item]); }); return rs; }; var saveFunc = function() { ModalElement.show_loading(); var questionData = mPoserEditor.getData(); absol.$.replaceFileInObject(questionData, function(value, key, subObject){ return module.e_learning.uploadFle(value).then(function(result){ return window.domainFilesNew + result; }); }).then(function(retData){ var duplicate = checkDuplicate(retData); var key = content.key; if (duplicate.length > 0) { var message = "Các câu hỏi bị trùng: "; duplicate.forEach((item, i) => { if (i > 0) message += ", "; message += "[" + item.toString() + "]"; }); ModalElement.alert({message: message}); ModalElement.close(-1); return; } content.content.questions = retData; content.content.lastmodified = div_element.currentEmp.firstid; content.content.lastmodifiedtime = new Date(); ModalElement.show_loading(); hrapi.table.update("question_pool_details_" + key, key, content.content, function(s, r){ ModalElement.closeAll(); if (s) if(onsave) { onsave(content); } else if(onabort) onabort(r); }); }); }; var saveBtn = module.e_learning.noneIconButton({ text: "Lưu", onclick: function(){ saveFunc(); } }); var addQuestionBtn = module.e_learning.noneIconButton({ text: "Thêm câu hỏi", onclick: function(){ mPoserEditor.addNewQuestion({data: {content: ""}}); } }); var addQuestionFromExamBtn = absol._({ tag: 'ribbonbutton', props: { text: 'Import', // icon: 'span.mdi.mdi-file-image-outline', items: [ { text: "Import từ bài kiểm tra", value: 'from_examination' }, { text: "Import từ ngân hàng câu hỏi", value: 'from_question_pool' } ] }, on: { select: function (event) { if (event.item.value == 'from_examination'){ me.importFromExamination(hrapi, content).then(function(value){ if (!value) return; value.sections.forEach((item, i) => { var t = EncodingClass.string.duplicate(item.section); delete t.ident; mPoserEditor.addNewSection({data: t}); item.questions.forEach((item2, i2) => { var t2 = EncodingClass.string.duplicate(item2); mPoserEditor.addNewQuestion({data: t2}); }); }); value.questions.forEach((item, i) => { var t = EncodingClass.string.duplicate(item); mPoserEditor.addNewQuestion({data: t}); }); }); } else { me.importFromQuestionPool(hrapi, content).then(function(value){ if (!value) return; value.sections.forEach((item, i) => { var t = EncodingClass.string.duplicate(item.section); delete t.ident; mPoserEditor.addNewSection({data: t}); item.questions.forEach((item2, i2) => { var t2 = EncodingClass.string.duplicate(item2); mPoserEditor.addNewQuestion({data: t2}); }); }); value.questions.forEach((item, i) => { var t = EncodingClass.string.duplicate(item); mPoserEditor.addNewQuestion({data: t}); }); }); } } } }); var newSectionBtn = module.e_learning.noneIconButton({ text: "Thêm section", onclick: function(){ mPoserEditor.addNewSection({data: {name: ""}}); } }); var questionSortBtn = module.e_learning.noneIconButton({ text: "Sắp xếp câu hỏi", onclick: function(){ ModalElement.showWindow({ title: "Tree Editor", noPadding: true, bodycontent: DOMElement.div({ attrs: { style: { border: "1px solid #d6d6d6", padding: "10px" } }, children: [treeEditorView] }), buttonlist: [ { text: "Đóng", onclick: function(){ ModalElement.close(1); } } ] }); } }); var PoserEditor = absol.poser.PoserEditor; var mPoserEditor = new PoserEditor({ hasScroller: false,//không cuộn hasTool: false,//không có cây, mình lấy ra để riêng hoặc không dùng tới }); var mPoserEditorView = mPoserEditor.getView(); if (content.content.questions) mPoserEditor.setData(content.content.questions); else mPoserEditor.setData([]); var treeEditorView = mPoserEditor.treeEditor.getView(); treeEditorView.addStyle("width", "600px"); var frameList = absol.$("frameview", div_element); if (!frameList) { frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.addChild(frameList); } var singlePage = absol._({ tag: "singlepage", child: [ { class: ["button-panel-header", "absol-single-page-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", child: saveBtn }, { class: "single-button-header", child: addQuestionBtn }, { class: "single-button-header", child: newSectionBtn }, { class: "single-button-header", child: questionSortBtn }, { class: "single-button-header", child: addQuestionFromExamBtn } ] } }, { style: { paddingTop: "10px" } }, { style: { marginBottom: "var(--footer-margin)" }, child: [ { child: mPoserEditorView } ] } ] }); frameList.addChild(singlePage); singlePage.requestActive(); } } (module, retval); // function: hrplugins.keeview.examination.questionPoolTable var v87 = function(module, me) { return function (hrapi, div_element, onclose) { var frameList = absol.buildDom({ tag: "frameview", class: "main-frame-view", style: { width: "100%", height: "100%" } }); div_element.database = {}; var db_content = {}; var redraw = function(){ frameList.removeLast(); db_content = {}; div_element.database = {}; run(); } var run = function(){ var loadDB = [ new Promise(function(rs, rj){ hrapi.table.select("question_pool", function(s, value){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu"}); rj(value); return; } rs(value); }); }), new Promise(function(rs, rj){ hrapi.users.isAdmin((s, isAdmin) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(isAdmin); return; } rs(isAdmin); }); }), new Promise(function(rs, rj){ hrapi.users.getCurrentId((s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(r); return; } hrapi.orgs.getEmployeeByUserId(r, (s1, currentEmp) => { if (!s1) { ModalElement.alert({message: "Lỗi tải dữ liệu người dùng"}); rj(currentEmp); } if (!currentEmp){ ModalElement.alert({message: "Tài khoản chưa có nhân viên liên kết"}); rj(currentEmp) return; } rs(currentEmp); }); }); }), new Promise(function(rs, rj){ hrapi.orgs.getCompaniesList(function(s, companies){ if (!s) { ModalElement.alert({message: "Lỗi tải dữ liệu sơ đồ tổ chức"}); return; } var loadOrgs = []; companies.forEach((item, i) => { loadOrgs.push(new Promise(function(rs, rj){ hrapi.orgs.getFullCompanyInfo(item.id, (r,s)=>{ if (r) rs(s); else rj(s); }); })); }); var employees = []; var orgDict = {}; var getEmployeesFunc = function(orgContent){ orgDict[orgContent.id] = orgContent; employees = employees.concat(orgContent.employees); orgContent.children.forEach((item, i) => { getEmployeesFunc(item); }); }; Promise.all(loadOrgs).then(function(retval){ retval.forEach((item, i) => { getEmployeesFunc(item); }); rs({ orgs: retval, employees: employees }); }); }); }) ]; Promise.all(loadDB).then(function(rs){ db_content.question_pool = rs[0]; db_content.orgs = rs[3].orgs; db_content.employees = rs[3].employees; me.makeDatabaseContent(div_element, db_content); div_element.isAdmin = rs[1]; div_element.currentEmp = rs[2]; var dict = { question_pool: {} }; div_element.database.question_pool.items.forEach((item, i) => { dict.question_pool[item.key] = item.content; }); var generateData = function(){ var data = []; div_element.database.question_pool.items.forEach(function(elt){ if (!dict.question_pool[elt.key]) return; var editPriv = []; if (elt.content.editPriv) editPriv = elt.content.editPriv; var viewPriv = []; if (elt.content.viewPriv) viewPriv = elt.content.viewPriv; if ( !div_element.isAdmin && editPriv.indexOf(div_element.currentEmp.firstid) == -1 && viewPriv.indexOf(div_element.currentEmp.firstid) == -1 ) return; var editFunc = function(content){ var onclose = function(value){ redraw(); }; var onsave = function(){ } me.questionPoolEdit(hrapi, content, div_element, onsave, onclose); }; var exFunc = function(content){ me.exportQuestionPool(hrapi, content); }; var delFunc = function(content){ hrapi.table.delete("question_pool", content.key, function(){ hrapi.table.drop("question_pool_details_" + content.key, function(){ div_element.database.question_pool.items = div_element.database.question_pool.items.filter(function(elt){ return elt.key != content.key; }); delete dict.question_pool[content.key]; var x = tableView.rowOf(row) x.remove(); }) }) } var cells = [ { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild( absol._({ tag: "span", class: ["as-dt-row-index", 'hr-table-cell-link'], on: { click: function(){ editFunc(elt); } } }) ); } }, { render: function(tdElt){ tdElt.addChild(absol._({ tag: "span", class: "hr-table-cell-link", child: {text: elt.content.name}, on: { click: function(){ editFunc(elt); } } })); } }, { style: {textAlign: "center"}, render: function(elt){ return function(tdElt){ tdElt.addChild(absol._({ tag: "switch", style: { fontSize: "var(--switch-fontsize)" }, props: { disabled: true, checked: elt.content.active } })); } }(elt) }, { style: {width: "40px"}, render: function(tdElt){ var qmenuButton = DOMElement.div({ attrs: { className: "card-icon-cover" }, children: [DOMElement.i({ attrs: { className: "material-icons bsc-icon-hover-black" }, text: "more_vert" })] }); absol.QuickMenu.toggleWhenClick(qmenuButton, { getMenuProps: function(){ var quickMenuItems = []; if (div_element.isAdmin || editPriv.indexOf(div_element.currentEmp.firstid) != -1) { quickMenuItems.push({ text: "Sửa", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "edit" }), cmd: function(){ editFunc(elt); } }); quickMenuItems.push({ text: "Export", extendClasses: ["bsc-quickmenu"], icon: absol._({ class: ["mdi", "mdi-export"] }), cmd: function(){ exFunc(elt); } }); quickMenuItems.push({ text: "Xóa", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "delete" }), cmd: function(){ delFunc(elt); } }); } else { quickMenuItems.push({ text: "Xem", extendClasses: ["bsc-quickmenu", "red"], icon: DOMElement.i({ attrs: { className: "material-icons" }, text: "visibility" }), cmd: function(){ editFunc(elt); } }); } return {items: quickMenuItems}; }, onSelect: function (item){ item.cmd(); } }, [3, 4]); tdElt.addChild(qmenuButton); } } ]; var row = { cells: cells }; data.push(row); }); var tableView = absol.buildDom({ tag: "dynamictable", class: "as-inline", props: { adapter: { data: { head: { rows: [ { cells: [ { child: {text: "STT"} }, { child: {text: "Tên"} }, { child: {text: "Hoạt động"} }, {} ] } ] }, body: { rows: data } } } } }); tableView.attachSearchInput(inputsearchbox); return tableView; }; var inputsearchbox = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: "Tìm kiếm..." } }); var closeBtn = module.e_learning.noneIconButton({ text: "Đóng", onclick: function(){ frameList.removeLast(); onclose(); } }); var addBtn = module.e_learning.noneIconButton({ text: "Thêm", onclick: function(){ var onsave = function(value){ var x = { key: value.key.toString() }; delete value.key; x.content = value; dict.question_pool[x.key] = x.content; div_element.database.question_pool.items.push(x); container.clearChild(); container.addChild(generateData()); }; var onabort = function(){ }; me.questionPoolAddNew(hrapi, {}, onsave, onabort) } }); var importFunc = function(){ me.importExaminationData(hrapi).then(function(){ redraw(); }, function(err){console.log(err)}); } var importBtn = module.e_learning.noneIconButton({ text: "Import", onclick: function(){ importFunc(); } }); div_element.addChild(frameList); var container = absol._({ child: generateData() }); var singlePage = absol.buildDom({ tag: "singlepage", child: [ { class: ["absol-single-page-header", "button-panel-header"], child: { style: { paddingLeft: "0px", paddingRight: "0px" }, class: "button-panel-header", child: [ { class: "single-button-header", child: closeBtn }, { class: "single-button-header", style: { display: div_element.isAdmin ? "" : "none" }, child: addBtn }, { class: "single-button-header", style: {display: div_element.isAdmin ? "" : "none"}, child: importBtn }, { class: "single-button-header", child: inputsearchbox } ] } }, container ] }); frameList.addChild(singlePage); singlePage.requestActive(); }, function(err){console.log(err);}) }; hrapi.table.create("question_pool", (s, r) => { if (!s) { ModalElement.alert({message: "Lỗi tạo DB"}); console.log(r); return; } run(); }) } } (module, retval); // function: hrplugins.keeview.examination.ratingData var v76 = function(module, me) { return function (content, isView) { if (!content || content.length == 0) content = [ { text: "Kém", min: 0, max: 50 }, { text: "Trung bình", min: 50, max: 65 }, { text: "Khá", min: 65, max: 85 }, { text: "Giỏi", min: 85, max: 100 } ]; var st = absol._({}); var lastRow; var makeRatingItem = function(item, idx, position){ var textElt, minElt, maxElt, removeIcon; textElt = absol._({ tag: "input", class: "cardsimpleInput", style: { width: "180px", display: "inline-block", margin: "0 10px", verticalAlign: "middle" }, props: { value: item.text, disabled: isView } }); minElt = absol._({ tag: "numberinput", class: "cardsimpleInput", style: { marginRight: "10px", width: "50px", display: "inline-block", textAlign: "right", verticalAlign: "middle" }, props: { value: item.min, disabled: true } }); minElt.$input.disabled = true; maxElt = absol._({ tag: "numberinput", class: "cardsimpleInput", style: { margin: "0 10px", width: "50px", display: "inline-block", textAlign: "right", verticalAlign: "middle" }, props: { value: item.max, disabled: isView }, on: { change: function(){ if (this.value > 100) this.value = 100; if (this.value <= item.min) { ModalElement.alert({ message: "Giá trị không hợp lệ", func: function(){ this.focus(); } }); return; } var t = evaluation_container.childNodes; if (t.length > idx + 1) { var removeItem = []; if (this.value == 100) { for (var i = idx + 1; i < t.length; i++) { removeItem.push(evaluation_container.childNodes[i]); } } else { var i = idx + 1; evaluation_container.childNodes[i].minElt.value = this.value; while (evaluation_container.childNodes[i].minElt.value > evaluation_container.childNodes[i].maxElt.value) { removeItem.push(evaluation_container.childNodes[i]); i++; evaluation_container.childNodes[i].minElt.value = this.value; } } removeItem.forEach((item, i) => { evaluation_container.removeChild(item); }); } } } }); removeIcon = absol._({ tag: "i", class: ['mdi', 'mdi-close', 'ep-button-icons'], style: { verticalAlign: "middle", display: (position == "first" || position == "last") ? "none" : isView ? "none" : "" }, props: { title: "Xóa" }, on: { click: function(){ evaluation_container.removeChild(curItem); evaluation_container.childNodes.forEach((item, i) => { if (i == 0) return; var x = evaluation_container.childNodes[i - 1].maxElt.value; console.log(x); item.minElt.value = x; }); } } }); var curItem; if (position == "last"){ curItem = absol._({ class: "ep-questionnaire-evaluation-items", child: [ // { // style: { // marginRight: "10px", // width: "50px", // display: "inline-block", // textAlign: "right", // verticalAlign: "middle" // } // }, // { // style: { // display: "inline-block", // padding: "0 10px", // verticalAlign: "middle", // lineHeight: "28px", // width: "40px", // textAlign: "center" // }, // // child: {text: item.min != 0 ? "<" : "<="} // }, minElt, { style: { display: "inline-block", padding: "0 10px", verticalAlign: "middle", lineHeight: "28px", width: "40px", textAlign: "center" }, child: {text: "<"} }, textElt ] }); lastRow = curItem; } else if (position == "first"){ curItem = absol._({ class: "ep-questionnaire-evaluation-items", child: [ { style: { marginRight: "10px", width: "50px", display: "inline-block", textAlign: "right", verticalAlign: "middle" } }, { style: { display: "inline-block", padding: "0 10px", verticalAlign: "middle", lineHeight: "28px", width: "40px", textAlign: "center" }, // child: {text: item.min != 0 ? "<" : "<="} }, textElt, { style: { display: "inline-block", padding: "0 10px", verticalAlign: "middle", lineHeight: "28px", width: "40px", textAlign: "center", }, child: {text: "<="} }, maxElt ] }); } else { curItem = absol._({ class: "ep-questionnaire-evaluation-items", child: [ minElt, { style: { display: "inline-block", padding: "0 10px", verticalAlign: "middle", lineHeight: "28px", width: "40px", textAlign: "center" }, child: {text: item.min != 0 ? "<" : "<="} }, textElt, { style: { display: "inline-block", padding: "0 10px", verticalAlign: "middle", lineHeight: "28px", width: "40px", textAlign: "center", }, child: {text: "<="} }, maxElt, removeIcon ] }); } curItem.minElt = minElt; curItem.maxElt = maxElt; curItem.getValue = function(){ var text, min, max; text = textElt.value.trim(); if (text == "") { ModalElement.alert({ message: "Chưa nhập tên xếp loại", func: function(){ textElt.focus(); } }); return undefined; } min = minElt.value; max = maxElt.value; if (max == 0) { ModalElement.alert({ message: "Chưa nhập giá trị lớn nhất", func: function(){ maxElt.value = ""; maxElt.focus(); } }); return undefined; } return { text: text, min: min, max: max }; } return curItem; }; var data = []; content.forEach(function(elt, idx){ data.push(makeRatingItem(elt, idx, (idx == 0) ? "first" : (idx == content.length - 1) ? "last" : "mid")); }); var evaluation_container = absol._({ child: data }); var addBtn = absol._({ style: { paddingTop: "10px", paddingBottom: "10px", }, child: { tag: "a", style: { color: "#147af6", cursor: "pointer", textDecoration: "underline", display: isView ? "none" : "" }, child: {text: "Thêm"}, on: { click: function(){ if (st.disabled == true) return; var t_content; var min = evaluation_container.childNodes[evaluation_container.childNodes.length - 2].getValue().max; t_content = {text: "", min: min, max: ""}; var t = makeRatingItem(t_content, evaluation_container.childNodes.length - 1, "mid"); evaluation_container.insertBefore(t, evaluation_container.lastChild); } } } }); st.addChild(evaluation_container); st.addChild(addBtn); st.getValue = function(){ var data = [], t; var evaluationItems = evaluation_container.childNodes; for (var i = 0; i < evaluationItems.length; i++){ t = evaluationItems[i].getValue(); if (t === undefined) return t; data.push(t); } return data; }; return st; } } (module, retval); // function: hrplugins.keeview.examination.ribbonButton var v101 = function(module, me) { return function (params) { return absol.buildDom({ tag: "ribbonbutton", class: "as-appearance-button", style: { minWidth: "var(--button-min-width)", height: "var(--button-height)", fontSize: "var(--button-title-font-size)", fontWeight: "var(--button-title-font-weight)" }, on: { select: params.select }, props:{ text: params.text, items: params.items } }); } } (module, retval); // function: hrplugins.keeview.examination.studentEdit var v81 = function(module, me) { return function (hrapi, examInfo, currentEmpId, onsave, onabort, orgs, content) { var data = []; if (!examInfo.content.student) examInfo.content.student = []; var student = examInfo.content.student; var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var children = []; if (item.employees) item.employees.forEach((item2) => { var checkbox = absol._({ tag: "checkbox", props: { checked: student.indexOf(item2.firstid) != -1 }, on: { change: function(){ if (this.checked) { student.push(item2.firstid); } else { student = student.filter(function(elt){ return elt != item2.firstid; }); t_c = checkbox.parentChecbox; while (t_c) { t_c.checked = false; t_c = t_c.parentChecbox; } } } } }); children.push({ cells: [ { style: { whiteSpace: "nowrap" }, render: function(tdElt){ tdElt.addChild(absol._({ class: "as-tree-table-toggle" })); tdElt.addChild(absol._({ tag: "span", child: {text: item2.fullname} })); } }, { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(checkbox); } } ], checkbox: checkbox, sortText: absol.string.nonAccentVietnamese(item2.fullname) }) }); children.sort(function(a, b){ if (a.sortText > b.sortText) return 1; if (a.sortText < b.sortText) return -1; return 0; }); if (item.children) { var t_item = getEmployeeItems(item.children); t_item.sort(function(a, b){ if (a.sortText > b.sortText) return 1; if (a.sortText < b.sortText) return -1; return 0; }); children = children.concat(t_item); } var orgchecked = true; if (children.length == 0) { orgchecked = false; } else { for (var i = 0; i < children.length; i++){ if (!children[i].cells[1].checked){ orgchecked = false; break; } } } var checkbox = absol._({ tag: "checkbox", props: { checked: orgchecked }, on: { change: function(){ if (this.checked) { // var t = EncodingClass.string.duplicate(children); t = children; if (t === undefined) t = []; while (t.length > 0) { var xs = []; t.forEach((item, i) => { item.checkbox.checked = true; item.checkbox.emit("change"); if (item.children) xs = xs.concat(item.children); }); t = xs; } } else { // var t = EncodingClass.string.duplicate(children); t = children; if (t === undefined) t = []; while (t.length > 0) { var xs = []; t.forEach((item, i) => { item.checkbox.checked = false; item.checkbox.emit("change"); if (item.children) xs = xs.concat(item.children); }); t = xs; } t_c = checkbox.parentChecbox; while (t_c) { t_c.checked = false; t_c = t_c.parentChecbox; } } } } }); if (children) children.forEach((item, i) => { item.checkbox.parentChecbox = checkbox; }); var cur = { cells: [ { style: { whiteSpace: "nowrap" }, render: function(tdElt){ tdElt.addChild(absol._({ class: "as-tree-table-toggle" })); tdElt.addChild(absol._({ tag: "span", child: {text: item.name} })); } }, { style: {textAlign: "center"}, render: function(tdElt){ tdElt.addChild(checkbox); } } ], subRows: children, checkbox: checkbox, sortText: absol.string.nonAccentVietnamese(item.name).toLowerCase() } data.push(cur); }); return data; }; var searchInput = absol.buildDom({ tag:'searchcrosstextinput', style: { width: "var(--searchbox-width)" }, props:{ placeholder: LanguageModule.text("txt_search") } }); console.log(123456); var tableView = absol._({ tag: "treetable", style: { width: "100%" }, props: { searchInput: searchInput, adapter: { data: { initOpened: true, head: { fixed: true, rows: [{ cells: [ {child: {text: "Tên"}, style: {minWidth: "400px"}}, {style: {width: "40px"}} ] }] }, body: { rows: getEmployeeItems(orgs) } } } } }) // var tableView = DOMElement.treetable({ // attrs: { // style: { // width: "100%" // } // }, // header: [ // {text: "Tên", attrs: {style: {minWidth: "400px"}}}, // {attrs: {style: {width: "40px"}}} // ], // data: getEmployeeItems(orgs) // }) ModalElement.showWindow({ title: "Thêm thí sinh", bodycontent: absol._({ class: "cardsimpletableclass", child: [ { child: searchInput }, { child: tableView } ] }), buttonlist: [ { text: "Lưu", onclick: function(){ var key = examInfo.key; examInfo.content.student = student; examInfo.content.lastmodified = currentEmpId; examInfo.content.lastmodifiedtime = new Date(); ModalElement.show_loading(); hrapi.table.update("examination", key, examInfo.content, function(s, r){ ModalElement.closeAll(); if (s) if(onsave) { onsave(student); } else if(onabort) onabort(r); }); } }, { text: "Hủy", onclick: function(){ ModalElement.closeAll(); onabort(); } } ] }) } } (module, retval); // function: hrplugins.keeview.examination.teacherEdit var v80 = function(module, me) { return function (hrapi, examInfo, currentEmpId, onsave, onabort, orgs, content) { var data = []; if (!examInfo.content.teacher) examInfo.content.teacher = []; var teacher = examInfo.content.teacher; var getEmployeeItems = function(orgs){ var data = []; orgs.forEach((item, i) => { var children = []; if (item.employees) item.employees.forEach((item2) => { children.push({ cells: [ { text: item2.fullname, attrs: { style: { whiteSpace: "nowrap" } } }, { attrs: { align: "center" }, children: absol._({ tag: "checkbox", props: { checked: teacher.indexOf(item2.firstid) != -1 }, on: { change: function(){ if (this.checked) { teacher.push(item2.firstid); } else { teacher = teacher.filter(function(elt){ return elt != item2.firstid; }); } } } }) } ], sortText: absol.string.nonAccentVietnamese(item2.fullname) }) }); children.sort(function(a, b){ if (a.sortText > b.sortText) return 1; if (a.sortText < b.sortText) return -1; return 0; }); if (item.children) { var t_item = getEmployeeItems(item.children); t_item.sort(function(a, b){ if (a.sortText > b.sortText) return 1; if (a.sortText < b.sortText) return -1; return 0; }); children = children.concat(t_item); // children = children.concat(getEmployeeItems(item.children)); } var cur = { cells: [ { text: item.name, attrs: { style: { whiteSpace: "nowrap" } } },{} ], children: children, sortText: absol.string.nonAccentVietnamese(item.name).toLowerCase() } data.push(cur); }); return data; }; var tableView = DOMElement.treetable({ attrs: { style: { width: "100%" } }, header: [ {text: "Tên", attrs: {style: {minWidth: "400px"}}}, {attrs: {style: {width: "40px"}}} ], data: getEmployeeItems(orgs) }) ModalElement.showWindow({ title: "Thêm giáo viên chấm điểm ", bodycontent: absol._({ class: "cardsimpletableclass", child: tableView }), buttonlist: [ { text: "Lưu", onclick: function(){ var key = examInfo.key; examInfo.content.teacher = teacher; examInfo.content.lastmodified = currentEmpId; examInfo.content.lastmodifiedtime = new Date(); ModalElement.show_loading(); hrapi.table.update("examination", key, examInfo.content, function(s, r){ ModalElement.closeAll(); if (s) if(onsave) { onsave(teacher); } else if(onabort) onabort(r); }); } }, { text: "Hủy", onclick: function(){ ModalElement.closeAll(); onabort(); } } ] }) } } (module, retval); retval.configSendMail = v99; retval.doExamination = v82; retval.doExaminationMobile = v176; retval.evaluatingExamination = v83; retval.evaluatingExaminationDetail = v84; retval.examinationAddNew = v75; retval.examinationConfigMail = v100; retval.examinationEdit = v77; retval.examinationMobileTable = v174; retval.examinationMobileView = v175; retval.examinationTable = v74; retval.exportData = v122; retval.exportExaminationData = v167; retval.exportExaminationRow = v169; retval.exportQuestionPool = v170; retval.getDateToExport = v140; retval.groupCategory = v64; retval.groupCategoryEdit = v72; retval.importExaminationData = v168; retval.importFromExamination = v89; retval.importFromQuestionPool = v90; retval.makeDatabaseContent = v73; retval.makeResultChart = v102; retval.mockExamination = v136; retval.openExaminationByLink = v178; retval.printQuestion = v134; retval.privilegeEdit = v78; retval.questionEdit = v79; retval.questionPoolAddNew = v85; retval.questionPoolEdit = v86; retval.questionPoolPrivilegeEdit = v91; retval.questionPoolQuestionaire = v88; retval.questionPoolTable = v87; retval.ratingData = v76; retval.ribbonButton = v101; retval.studentEdit = v81; retval.teacherEdit = v80; return retval; } } (module)) (); // function: hrplugins.keeview.about var v34 = function(module, me) { return function (div_element) { div_element.appendChild(DOMElement.br()); } } (module, retval); retval.e_learning = v35; retval.examination = v63; retval.about = v34; return retval; } (); //# sourceURL=codecenter:///codecenter/host.php/hrplugins/keeview.js?