1888 lines
80 KiB
JavaScript
1888 lines
80 KiB
JavaScript
/*
|
||
* Quesition 함수 정의
|
||
*
|
||
*
|
||
*
|
||
*/
|
||
|
||
window.kon = window.kon || {}
|
||
|
||
kon.qu = (function () {
|
||
var hard_list = ""
|
||
function allreset() {
|
||
qd = ""
|
||
mtop.innerHTML = ""
|
||
mcontent.innerHTML = ""
|
||
ctable.innerHTML = ""
|
||
cleftdiv.innerHTML = ""
|
||
crightdiv.innerHTML = ""
|
||
removeallTinymce();
|
||
if($("#question_dialog").dialog("isOpen")) {
|
||
$("#question_dialog").dialog("close")
|
||
}
|
||
if($("#data_dialog").dialog("isOpen")) {
|
||
$("#data_dialog").dialog("close")
|
||
}
|
||
}
|
||
|
||
/* Question.asp 에서 문항 버튼 클릭 시 문항 리스트 및 기능 버튼 반환 */
|
||
function list(qid) {
|
||
allreset();
|
||
var param = setparam("s", "QUESTIONLIST", { "PKEY": code });
|
||
questionlist = ajax_returnData(ajaxUrl, param);
|
||
tr = [],
|
||
//2022-03-29 서성완 선택 삭제 추가
|
||
btnnode = ["문항 등록", "순서 변경","번역 양식","선택 삭제","문항 검색"].map(function (e, id) {
|
||
|
||
if (id === 0) {
|
||
return createnode("BUTTON", e, { "class": gstyle.btn.success, "type": "button", "onClick": "kon.qu.fnNew()" })
|
||
} else if(id===1) {
|
||
return createnode("BUTTON", e, { "class": gstyle.btn.primary, "type": "button", "onClick": "kon.qu.fn_make_ChangeOrder()" })
|
||
} else if(id===2) {
|
||
return createnode("BUTTON", e, { "class": gstyle.btn.warning, "type": "button", "onClick": "kon.qu.fn_translate_form()" })
|
||
}else if(id===3) { //2022-03-29 서성완 선택 삭제 추가
|
||
return createnode("BUTTON", e, { "class": gstyle.btn.danger, "type": "button", "onClick": "kon.qu.fn_chkdelete_form()" })
|
||
}
|
||
else if(id===4) {
|
||
var listid = ID();
|
||
var input = createnode("input","",{"type":"text","list":listid,"id":"question_search_list" ,"style":"width:120px;","class":"ml-1","placeholder":e,"autocomplete":"off"});
|
||
var dlist = questionlist.map(function(ele){return createnode("option", ele.QID + "[" + ele.variable + "]" ,{"value":ele.QID})});
|
||
var datalist = createnode("datalist",dlist,{"id":listid});
|
||
return createnode("SPAN",[input,datalist],{"class":"p-2"});
|
||
}
|
||
})
|
||
|
||
tr.push(createnode("TR", [{ "element": "TD", "text": [{ "element": "i", "text": "", "attr": { "class": "fa fa-list", "aria-hidden": "true" } }], "attr": { "class": "table-light" }, "thisText": "문항 목록 " }]))
|
||
|
||
questionlist.forEach(function (element) {
|
||
var trStyle = {}
|
||
btn_list = fn_make_button(element.QID)
|
||
var text = "<p class='m-0'>"+element.QID + ' [' + element.variable + '] ' + element.explain+"</p>";
|
||
text += "<div class='p-1 m-1 border rounded bg-light' style='font-size:.7rem'>"+element.title+"</div>";
|
||
var td = createnode("TD",btn_list,{ "class": "project_function" });
|
||
$(td).prepend(text);
|
||
var ttr = createnode("TR",[td], trStyle);
|
||
if( element.QID === qid )
|
||
ttr.setAttribute("data-focus","true");
|
||
|
||
tr.push(ttr);
|
||
})
|
||
ctable.appendM(tr)
|
||
}
|
||
|
||
function fn_translate_form(){ /*설문 번역 업로드 양식 출력 */
|
||
var param = setparam("s","QUESTION_LANGUAGE_FORM",{"PKEY":code});
|
||
var data = ajax_returnData(ajaxUrl,param);
|
||
var transform_structure = []
|
||
var toText = createnode("DIV","");
|
||
data.forEach(function(v,i){
|
||
toText.innerHTML = v["title"];
|
||
var df = {"QID":v["QID"],"문번":v["variable"],"타입":"title","코드":"","내용(본문)":toText.innerText,"내용(번역)":""}
|
||
transform_structure.push(df)
|
||
|
||
if(v["description"].trim() !== "") {
|
||
toText.innerHTML = v["description"]
|
||
df = {"QID":v["QID"],"문번":v["variable"],"타입":"description","코드":"","내용(본문)":toText.innerText,"내용(번역)":""};
|
||
transform_structure.push(df);
|
||
}
|
||
if(typeof v["dataset"] === "object") {
|
||
Object.keys(v["dataset"]).forEach(function(k1,index){
|
||
var ds = v["dataset"][k1];
|
||
Object.keys(ds).forEach(function(k2,id2){
|
||
var df = ""
|
||
if(k1 !== "open")
|
||
df = {"QID":v["QID"],"문번":v["variable"],"타입":k1,"코드":ds[k2].value,"내용(본문)":ds[k2].label,"내용(번역)":""};
|
||
else {
|
||
if(ds[k2].prev) {
|
||
df = {"QID":v["QID"],"문번":v["variable"],"타입":k1+"_prev","코드":k2,"내용(본문)":ds[k2].prev,"내용(번역)":""};
|
||
transform_structure.push(df);
|
||
}
|
||
if(ds[k2].after) {
|
||
df = {"QID":v["QID"],"문번":v["variable"],"타입":k1+"_after","코드":k2,"내용(본문)":ds[k2].after,"내용(번역)":""};
|
||
transform_structure.push(df);
|
||
}
|
||
var df = {"QID":v["QID"],"문번":v["variable"],"타입":k1,"코드":k2,"내용(본문)":ds[k2].label,"내용(번역)":""};
|
||
}
|
||
transform_structure.push(df);
|
||
});
|
||
})
|
||
}
|
||
|
||
if(typeof v["datagroup"] === "object") {
|
||
Object.keys(v["datagroup"]).forEach(function(k1,index){
|
||
var ds = v["datagroup"][k1];
|
||
Object.keys(ds).forEach(function(k2,id2){
|
||
Object.keys(ds[k2]).forEach(function(k3,i){
|
||
ds[k2][k3].forEach(function(item,index){
|
||
df = {"QID":v["QID"],"문번":v["variable"],"타입":k1 + "_" + k2 + "_" + k3,"코드":index,"내용(본문)":item.label,"내용(번역)":""};
|
||
transform_structure.push(df);
|
||
})
|
||
})
|
||
})
|
||
});
|
||
}
|
||
})
|
||
exportExcel(transform_structure,code + " 번역");
|
||
}
|
||
|
||
function fn_make_button(code) { /* 문항 기능 버튼 반환 함수 */
|
||
return question_function.map(function (element) {
|
||
return { "element": "button", "text": element.name, "attr": { "class": element.class, "data-code": code, "onClick": element.fn } }
|
||
})
|
||
}
|
||
|
||
function fn_make_ChangeOrder() { /* 순서 바꾸는 프레임 만들기 */
|
||
if (questionlist.length === 0) return false;
|
||
$("#preview_prj").html("")
|
||
|
||
var table = createnode("table", "", { "class": "table table-sm table-bordered", "style": "width:500px;margin:auto" })
|
||
var tr = createnode("TR",
|
||
[{
|
||
"element": "TD",
|
||
"text": [
|
||
{ "element": "button", "text": "저장", "attr": { "class": gstyle.btn.fsuccess + " float-right", "id": "saveorder" } },
|
||
{ "element": "button", "text": "취소", "attr": { "class": gstyle.btn.fdanger + " float-right", "id": "cancelorder" } }
|
||
],
|
||
"attr": { "colspan": "2", "class": "text-center table-info" }
|
||
|
||
}
|
||
])
|
||
var orderlist = [{ "QORDER": 0, "variable": "처음으로" }]
|
||
table.appendChild(tr)
|
||
orderlist = orderlist.concat(questionlist)
|
||
orderlist.push({ "QORDER": 99999, "variable": "END" });
|
||
orderlist.forEach(function (e, eid) {
|
||
var b = Array(2).fill().map(function (_x, trid) {
|
||
var td = Array(2).fill().map(function (_x, tdid) {
|
||
var icon1 = createnode("i", "", { "class": "fa fa-arrow-left", "aria-hidden": "true" })
|
||
if (trid === 0) {
|
||
var att = { "data-order": e.QORDER, "rowspan": "2" }
|
||
att["class"] = !eid || (e.QORDER == 99999 ? "true" : "setd");
|
||
if (tdid & 1)
|
||
return createnode("TD", e.variable + " - " + (e.explain || ""), att)
|
||
} else {
|
||
if (!tdid & e.QORDER != 99999)
|
||
return createnode("TD", [icon1], { "class": "indent_td", "data-order": e.QORDER, "rowspan": "2" })
|
||
}
|
||
})
|
||
|
||
td = td.filter(function (ele) { return ele ? true : false })
|
||
return createnode("TR", td)
|
||
});
|
||
table.appendM(b)
|
||
});
|
||
|
||
$("#preview_prj").append(table)
|
||
}
|
||
|
||
//2022-03-29 서성완 선택 삭제 프레임 만들기 시작
|
||
function fn_chkdelete_form() {
|
||
if (questionlist.length === 0) return false;
|
||
$("#preview_prj").html("")
|
||
|
||
var table = createnode("table", "", { "class": "table table-sm table-bordered", "style": "width:500px;margin:auto" })
|
||
var tr = createnode("TR",
|
||
[{
|
||
"element": "TD",
|
||
"text": [
|
||
{ "element": "button", "text": "삭제", "attr": { "class": gstyle.btn.fdanger + " float-right", "id": "deletesave" } }
|
||
|
||
],
|
||
"attr": { "colspan": "2", "class": "text-center table-info", "style": "background-image: repeating-linear-gradient( -45deg, yellow, yellow 30px, black 30px, black 60px );" }
|
||
}
|
||
])
|
||
var orderlist = [{ "QORDER": 0, "QID": "처음으로" }]
|
||
table.appendChild(tr)
|
||
orderlist = orderlist.concat(questionlist)
|
||
orderlist.push({ "QORDER": 99999, "QID": "END" });
|
||
orderlist.forEach(function (e, eid) {
|
||
var b = Array(2).fill().map(function (_x, trid) {
|
||
var td = Array(2).fill().map(function (_x, tdid) {
|
||
var icon1 = createnode("i", "", { "class": "fa fa-arrow-left", "aria-hidden": "true" })
|
||
if (trid === 0) {
|
||
var att = { "data-order": e.QORDER, "rowspan": "2" , "value": e.QID}
|
||
att["class"] = !eid || (e.QORDER == 99999 ? "true" : "setd");
|
||
if (tdid & 1){
|
||
var vName = "";
|
||
var explain = "";
|
||
// 문항 번호, 문항 명
|
||
if(e.variable != undefined){
|
||
vName = " ["+e.variable+"]";
|
||
}
|
||
// 필요없는 값 안보이게
|
||
if(e.explain != undefined && e.explain != ""){
|
||
explain = " - " + e.explain;
|
||
}
|
||
return createnode("TD", e.QID + vName + explain, att)
|
||
}
|
||
}
|
||
})
|
||
|
||
td = td.filter(function (ele) { return ele ? true : false })
|
||
return createnode("TR", td)
|
||
});
|
||
table.appendM(b)
|
||
});
|
||
|
||
$("#preview_prj").append(table)
|
||
}
|
||
/// 선택 삭제 프레임 만들기 끝
|
||
|
||
function fn_make_question_view(type, va, target) { /* 문항 정보에 맞게 우측 페이지 재구성 */
|
||
switch (type) {
|
||
case "title":
|
||
var title = createnode("div", "", { "id": "example_" + type, "class": "list-group-item bg-info text-white border-0" })
|
||
title.innerHTML = va;
|
||
target.appendChild(title);
|
||
break;
|
||
case "description":
|
||
var des = createnode("div", "", { "id": "example_" + type, "class": "list-group-item border-0 m-1" });
|
||
des.innerHTML = va;
|
||
target.appendChild(des);
|
||
break;
|
||
|
||
case "variable": case "explain":
|
||
if(registerType==="modify") { /* 수정일 경우 */
|
||
if($("#q"+type).val() === "") { /* 문항 명과 문항 설명이 비어있다면 입력되어있는 값으로 삽입 */
|
||
$("#q" + type).val(va);
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
case "dataset": // 단수, 복수, 오픈 , 순위
|
||
var code = ["single", "multi", "open", "scale"]
|
||
var exampleData = ""
|
||
|
||
code.forEach(function (ele) {
|
||
var example = va[ele]
|
||
if (!example) return true; //single이나 multi가 없을 경우
|
||
exampleData = (exampleData !== "") ? exampleData.concat(getObjexample(example, ele)) : getObjexample(example, ele)
|
||
});
|
||
|
||
if (exampleData === "") return false;
|
||
|
||
if (va["rank"]) {
|
||
|
||
var table = createnode("table", "", { "class": gstyle.stable.sm });
|
||
var tr = [
|
||
// 2025-11-25 권민서 설정한 순위 범위를 글자로 표기 (추가)
|
||
createnode(
|
||
"td",
|
||
`전체 선택 범위: ${va["rank"]["val"]}순위`,
|
||
{ "class": "text-center" }
|
||
),
|
||
createnode(
|
||
"td",
|
||
`필수 선택 범위: ${va["rank"]["max"]}순위`,
|
||
{ "class": "text-center" }
|
||
)
|
||
// 2025-11-25 권민서 설정한 순위 범위를 글자로 표기 (끝)
|
||
|
||
// 2025-11-25 권민서 기존 table 형태로 순위 전체 범위만 표기한 코드 주석처리
|
||
// createnode(
|
||
// "TR",
|
||
// Array(+va["rank"]["val"]).fill("순위").map(function (ele, id) {
|
||
// return createnode("TD", (id + 1) + ele)
|
||
// }),
|
||
// { "class": "text-center" }
|
||
// ),
|
||
// createnode(
|
||
// "TR",
|
||
// Array(+va["rank"]["val"]).fill("---").map(function (ele, id) {
|
||
// return createnode("TD", ele)
|
||
// }),
|
||
// { "class": "text-center" }
|
||
// )
|
||
]
|
||
table.appendM(tr);
|
||
target.appendChild(table);
|
||
}
|
||
var examplediv = fn_make_preview_data(exampleData, va["attr"])
|
||
target.appendChild(examplediv);
|
||
|
||
break;
|
||
default:
|
||
}
|
||
}
|
||
|
||
function getCode(e) { /* 코드 반환 및 code 변경 */
|
||
if(e)
|
||
qid = e.getAttribute("data-code");
|
||
else
|
||
qid = event.target.getAttribute("data-code");
|
||
if (qid) prev = qid
|
||
return qid;
|
||
}
|
||
|
||
function fn_makeFrame() { /* 문항 만든 프레임 틀에 넣는 함수 */
|
||
mtop.appendM(btnnode)
|
||
cleftdiv.appendChild(ctable);
|
||
mcontent.appendM([cleftdiv,crightdiv])
|
||
}
|
||
|
||
function fn_make_dropdownList() { /* 문항 드롭다운 메뉴 */
|
||
var list_group = [{
|
||
"element": "ul",
|
||
"text": [],
|
||
"attr": { "class": "list-group list-group-flush" }
|
||
}];
|
||
return {
|
||
qtitle: function () {
|
||
list_group[0].text.push({ "element": "li", "text": "질문", "attr": { "class": "list-group-item", "data-menu": "title" } })
|
||
list_group[0].text.push({ "element": "li", "text": "안내문", "attr": { "class": "list-group-item", "data-menu": "description" } })
|
||
},
|
||
qcode: function () {
|
||
list_group[0].text.push({ "element": "li", "text": "단수 추가", "attr": { "class": "list-group-item", "data-menu": "single" } })
|
||
list_group[0].text.push({ "element": "li", "text": "복수 추가", "attr": { "class": "list-group-item", "data-menu": "multi" } })
|
||
list_group[0].text.push({ "element": "li", "text": "척도 추가", "attr": { "class": "list-group-item", "data-menu": "scale" } })
|
||
list_group[0].text.push({ "element": "li", "text": "자유 응답", "attr": { "class": "list-group-item", "data-menu": "open" } })
|
||
},
|
||
qattr: function () {
|
||
list_group[0].text.push({ "element": "li", "text": "속성 추가", "attr": { "class": "list-group-item", "data-menu": "attr" } })
|
||
list_group[0].text.push({ "element": "li", "text": "속성 옵션", "attr": { "class": "list-group-item", "data-menu": "attroption" } })
|
||
list_group[0].text.push({ "element": "li", "text": "순위 추가", "attr": { "class": "list-group-item", "data-menu": "rank" } })
|
||
},
|
||
add_text: function () {
|
||
list_group[0].text.push({ "element": "p", "text": "입력란 앞", "attr": {} })
|
||
list_group[0].text.push({ "element": "INPUT", "text": "입력란 앞", "attr": { "type": "text", "class": "form-control", "data-text": "prev" } })
|
||
list_group[0].text.push({ "element": "p", "text": "입력란 뒤", "attr": {} })
|
||
list_group[0].text.push({ "element": "INPUT", "text": "입력란 앞", "attr": { "type": "text", "class": "form-control", "data-text": "after" } })
|
||
},
|
||
register: function () {
|
||
qtype = "register"
|
||
$(".dropbox , #makebox").remove();
|
||
fn_make_createMenu()
|
||
},
|
||
getList: function () {
|
||
return [{ "element": "ul", "text": list_group, "attr": { "class": "list-group list-group-flush menulist" } }]
|
||
}
|
||
}
|
||
}
|
||
|
||
function fnModify(e, types) { /* 문항 수정 */
|
||
$(".selectedquestion").removeClass("selectedquestion")
|
||
$(e).closest("td").addClass("selectedquestion");
|
||
registerType = "modify"
|
||
qid = getCode(e);
|
||
fn_getQuestionData();
|
||
return fn_make_Register(types);
|
||
}
|
||
|
||
function fnDelete() { /* 문항 삭제 */
|
||
var data = {}
|
||
qid = getCode();
|
||
data["QID"] = qid;
|
||
data["PKEY"] = code;
|
||
var param = setparam("d", "QUESTION", data)
|
||
var param2 = setparam("u","QORDER_OPTIMIZE",data);
|
||
var param3 = setparam("u","QNUMBER",data);
|
||
if (confirm("문항을 삭제하시겠습니까?")) {
|
||
$.loadScript("project/"+code+"/js/hard_func.js", function(e){
|
||
var text = e.split(/\n/g);
|
||
var trim_text = text.map(function(v){ return v.trim()})
|
||
var sc = trim_text.indexOf("case \""+ qid + "\" :"); // start_index
|
||
var ec = "" // end_index
|
||
if(sc > 0) {
|
||
ec = trim_text.indexOf("break;//"+qid,sc+1);
|
||
text.splice(sc,(ec-sc)+1);
|
||
ajax_call("./include/ajax_func.asp",{"COMMAND":"WRITEHARDTEXT","PKEY":code,"TEXT":text.join("\n")});
|
||
}
|
||
});
|
||
|
||
ajax_call(ajaxUrl, param); /* 삭제 */
|
||
ajax_call(ajaxUrl,setparam("u","VARIABLE_MATCH",{"PKEY":code})); // 변수와 qid 매칭 json 변경
|
||
ajax_call(ajaxUrl, param2); /* 순서 최적화 */
|
||
ajax_call(ajaxUrl, param3, "성공적으로 삭제했습니다."); /* 문항 개수 변경 */
|
||
|
||
allreset();
|
||
list();
|
||
fn_makeFrame();
|
||
fnNew()
|
||
}
|
||
}
|
||
|
||
function fnCopy() {
|
||
$(".selectedquestion").removeClass("selectedquestion")
|
||
$(event.target).closest("td").addClass("selectedquestion");
|
||
registerType = "new"
|
||
qid = getCode();
|
||
fn_getQuestionData();
|
||
fn_make_Register("1");
|
||
}
|
||
|
||
function fnNew() { /* 문항 신규 등록 */
|
||
registerType = "new"
|
||
qd = ""
|
||
if (qid) {
|
||
prev = qid;
|
||
qid = "";
|
||
}
|
||
fn_make_Register("1");
|
||
}
|
||
|
||
function fn_getQuestionData() {
|
||
var param = setparam("s", "QUESTION", { "QID": qid, "PKEY": code })
|
||
qd = ajax_returnData(ajaxUrl, param);
|
||
}
|
||
|
||
function fn_make_preview_data(data, attrf) {
|
||
var scaletable = undefined;
|
||
var wrapper = createnode("div", "", { "class": "list-group" });
|
||
|
||
if (attrf) {
|
||
var attr = attrf,
|
||
table = createnode("table", "", { "class": gstyle.stable.sm }),
|
||
tr = createnode("TR", ""),
|
||
th = "",
|
||
example_type = "";
|
||
|
||
var attrheader = get(qd, ["datagroup", "attr", "header"]) || {};
|
||
|
||
if (!isEmptyObject(attrheader)) {
|
||
Object.keys(attrheader).forEach(function(key,id){
|
||
var tr = createnode("TR", "");
|
||
attrheader[key].forEach(function(element){
|
||
tr.appendChild(createnode("TH", element.label, { "colspan": element.cols , "rowspan" : element.rows }));
|
||
});
|
||
|
||
if(Object.keys(attrheader).length !== id+1) {
|
||
table.appendChild(tr);
|
||
} else {
|
||
th = specificObject(data, "text");
|
||
example_type = specificObject(data, "qtype");
|
||
th.forEach(function (ele, id) {
|
||
tr.appendChild(createnode("TH", ele, { "class": "example_" + example_type[id] }))
|
||
})
|
||
table.appendChild(tr);
|
||
}
|
||
})
|
||
} else {
|
||
tr.appendChild(createnode("TH", "항목"))
|
||
th = specificObject(data, "text");
|
||
example_type = specificObject(data, "qtype");
|
||
|
||
th.forEach(function (ele, id) {
|
||
tr.appendChild(createnode("TH", ele, { "class": "example_" + example_type[id] }))
|
||
})
|
||
table.appendChild(tr);
|
||
}
|
||
|
||
Object.keys(attr).forEach(function (key, index) {
|
||
tr = createnode("TR", "")
|
||
var prevlabel = get(qd, ["datagroup", "attr", "prev", index]);
|
||
var afterlabel = get(qd, ["datagroup", "attr", "after", index]);
|
||
|
||
if (prevlabel) {
|
||
prevlabel.forEach(function (ele) {
|
||
tr.appendChild(createnode("TH", ele.label, { "rowspan": ele.rows ,"colspan" : ele.cols }));
|
||
})
|
||
}
|
||
tr.appendChild(createnode("TD", attr[key]["label"], { "class": "example_attr" }))
|
||
|
||
if (afterlabel) {
|
||
afterlabel.forEach(function (ele) {
|
||
tr.appendChild(createnode("TH", ele.label, { "rowspan": ele.rows,"colspan" : ele.cols }));
|
||
})
|
||
}
|
||
|
||
data.forEach(function (dob) {
|
||
tr.appendChild(createnode("TD", [{ "element": "INPUT", "text": "", "attr": { "type": dob.type } }], { "style": "text-align:center" }))
|
||
})
|
||
|
||
table.appendChild(tr);
|
||
});
|
||
wrapper.appendChild(table);
|
||
|
||
} else {
|
||
|
||
data.forEach(function (dob, index) {
|
||
var input_item = []
|
||
var thistype = dob.type
|
||
|
||
if (dob.qtype === "scale") {
|
||
if (!scaletable) {
|
||
scaletable = createnode("TABLE", "", { "class": gstyle.stable.sm });
|
||
scaletable.appendChild(createnode("TR", ""))
|
||
scaletable.appendChild(createnode("TR", ""))
|
||
}
|
||
$(scaletable).find("TR:first").append(createnode("TD", dob["text"]));
|
||
$(scaletable).find("TR:last").append(createnode("TD", [createnode("INPUT", "", { "type": "radio" })], ""));
|
||
} else {
|
||
if (thistype === "text" || thistype === "number") {
|
||
input_item.push({
|
||
"element": "DIV",
|
||
"text": dob.text,
|
||
"attr": { "class": "list-group-item" }
|
||
})
|
||
input_item.push(make_input_text(dob, "test"))
|
||
} else {
|
||
input_item.push(form_inline_input(thistype, "qq" + index, dob.text))
|
||
|
||
if (dob.etc == "1") {
|
||
input_item.push({
|
||
"element": "INPUT",
|
||
"text": "",
|
||
"attr": { "type": "text" }
|
||
})
|
||
}
|
||
}
|
||
wrapper.appendChild(
|
||
createnode("DIV",
|
||
input_item
|
||
, { "class": "list-group-item example_" + dob.qtype }
|
||
)
|
||
)
|
||
}
|
||
})
|
||
}
|
||
if (scaletable) wrapper.appendChild(scaletable);
|
||
|
||
return wrapper
|
||
}
|
||
|
||
|
||
function getObjexample(example, ele) {/* 각 타입별 문항 속성 지정 */
|
||
var exampleData = []
|
||
Object.keys(example).forEach(function (key) {
|
||
var exampleObj = {}
|
||
if (ele === "single") {
|
||
exampleObj["type"] = "radio"
|
||
exampleObj["text"] = example[key]["label"]
|
||
exampleObj["etc"] = example[key]["etc"]
|
||
|
||
} else if (ele === "multi") {
|
||
exampleObj["type"] = "checkbox"
|
||
exampleObj["text"] = example[key]["label"]
|
||
exampleObj["etc"] = example[key]["etc"]
|
||
|
||
} else if (ele === "open") {
|
||
fn_open_option(exampleObj, example[key])
|
||
} else if (ele === "scale") {
|
||
exampleObj["type"] = "radio"
|
||
exampleObj["text"] = example[key]["label"]
|
||
exampleObj["col"] = example[key]["col"]
|
||
}
|
||
|
||
exampleObj["qtype"] = ele
|
||
exampleData.push(exampleObj);
|
||
})
|
||
return exampleData;
|
||
}
|
||
|
||
function fn_open_option(target, data) {
|
||
var option = data["option"];
|
||
target["text"] = data["label"];
|
||
target["prev"] = data["prev"];
|
||
target["after"] = data["after"];
|
||
|
||
// 2025-06-26 권민서 - 기능 추가 및 수정
|
||
switch (option) {
|
||
case "han":
|
||
target["type"] = "text";
|
||
target["onkeyup"] = "value = value.replace(/[^ㄱ-ㅎㅏ-ㅣ가-힣\\s]/g,'')";
|
||
target["onchange"] = "value = value.replace(/[^ㄱ-ㅎㅏ-ㅣ가-힣\\s]/g, '')";
|
||
break;
|
||
case "inputEnglishOnly":
|
||
target["type"] = "text";
|
||
target["onkeyup"] = "value = value.replace(/[^a-zA-Z\\s]/g, '')";
|
||
target["onchange"] = "value = value.replace(/[^a-zA-Z\\s]/g, '')";
|
||
break;
|
||
case "num":
|
||
target["type"] = "number";
|
||
target["onkeyup"] = "value = value.replace(/[^0-9]/g,'')";
|
||
target["onchange"] = "value = value.replace(/[^0-9]/g,'')";
|
||
break;
|
||
case "inputHangulWithSymbols":
|
||
target["type"] = "text";
|
||
target["onkeyup"] = "value = value.replace(/[^ㄱ-ㅎㅏ-ㅣ가-힣\\s!@#\\$%\\^&\\*\\(\\)_\\+=\\-\\.,]/g, '')";
|
||
target["onchange"] = "value = value.replace(/[^ㄱ-ㅎㅏ-ㅣ가-힣\\s!@#\\$%\\^&\\*\\(\\)_\\+=\\-\\.,]/g, '')";
|
||
break;
|
||
case "inputEnglishWithSymbols":
|
||
target["type"] = "text";
|
||
target["onkeyup"] = "value = value.replace(/[^a-zA-Z\\s!@#\\$%\\^&\\*\\(\\)_\\+=\\-\\.,]/g, '')";
|
||
target["onchange"] = "value = value.replace(/[^a-zA-Z\\s!@#\\$%\\^&\\*\\(\\)_\\+=\\-\\.,]/g, '')";
|
||
break;
|
||
case "inputTelNumber":
|
||
target["type"] = "text";
|
||
target["data-option"] = "inputTelNumber";
|
||
break;
|
||
case "tel":
|
||
target["type"] = "number";
|
||
target["onkeyup"] = "value = value.replace(/[^0-9]/g,'')";
|
||
break;
|
||
}
|
||
|
||
if (!target["type"]) target["type"] = "text";
|
||
if (!target["onkeyup"]) target["onkeyup"] = "";
|
||
return target;
|
||
}
|
||
|
||
function fn_make_Register(types) { /* 문항 등록 창 */
|
||
removeallTinymce();
|
||
crightdiv.textContent = "";
|
||
var table = createnode("table", "", { "class": gstyle.stable.sm });
|
||
var tr
|
||
var td
|
||
var focustd = ""
|
||
/* 1 row */
|
||
td = ["문항 명", "문항 설명", "저 장"].map(function (text, id) {
|
||
var td = createnode("TD", text);
|
||
if (id === 0) $(td).css("width", "120px");
|
||
return td;
|
||
})
|
||
tr = createnode("TR", td, "");
|
||
table.appendChild(tr);
|
||
|
||
/* 2 row */
|
||
td = ["qvariable", "qexplain"].map(function (idinfo, id) {
|
||
return createnode("TD", [createnode("INPUT", "", { "type": "text", "class": "form-control", "id": idinfo,"autocomplete":"off" })]);
|
||
})
|
||
|
||
td[0].addEventListener("keyup",function(e){
|
||
e.target.value = e.target.value.replace(/[^0-9A-Za-z]/g,"");
|
||
});
|
||
|
||
focustd = td[0]
|
||
|
||
tr = createnode("TR", td, "");
|
||
td = createnode("TD", [createnode("BUTTON", "저 장", { "type": "button", "class": "form-control btn btn-outline-success", "id": "questionSave" })])
|
||
tr.appendChild(td)
|
||
table.appendChild(tr);
|
||
|
||
/* 3 row */
|
||
var listdiv = [
|
||
{ "text": "질문", "id": "qtitle" },
|
||
{ "text": "보기", "id": "qcode" },
|
||
{ "text": "속성", "id": "qattr" }
|
||
/* ,{ "text": "일괄등록", "id": "register" } */
|
||
|
||
];
|
||
|
||
menudiv = listdiv.map(function (element, id) {
|
||
if (id === 3)
|
||
return createnode("div", element.text, { "class": "col-2 menubar", "id": element.id });
|
||
else
|
||
return createnode("div", element.text, { "class": "col-1 menubar", "id": element.id });
|
||
})
|
||
|
||
var row = createnode("div", menudiv, { "class": "row" });
|
||
var div = createnode("div", [row], { "class": "container-fluid h-100 " });
|
||
td = createnode("TD", [div], { "colspan": "3", "class": "menubar_group" });
|
||
|
||
tr = createnode("TR", [td], "");
|
||
table.appendChild(tr);
|
||
|
||
if(types === "1") {
|
||
crightdiv.appendChild(table);
|
||
crightdiv.appendChild(createnode("DIV", "", { "id": "questionPreview", "class": "container-fluid border p-1 rounded shadow-sm" }));
|
||
fn_make_inputFrame(); /* 설문 미리보기 창 만들기 */
|
||
$(focustd).find("input").focus()
|
||
} else {
|
||
|
||
return table;
|
||
}
|
||
|
||
}
|
||
|
||
function fn_make_inputFrame() { /* 설문 미리보기 창 */
|
||
getById("questionPreview").textContent = "";
|
||
var col = createnode("DIV", "", { "class": "col-12 list-group border rounded p-1 shadow-sm" })
|
||
var data = qd || {};
|
||
|
||
Object.keys(data).forEach(function (key) {
|
||
fn_make_question_view(key, data[key], col); /* 설문 문항 정보에 맞게 프레임 출력 */
|
||
});
|
||
|
||
var row = createnode("DIV", [{ "element": "DIV", "text": "", "attr": { "class": "row" } }])
|
||
row.appendChild(col);
|
||
$("#questionPreview").append(row)
|
||
}
|
||
|
||
function fn_make_dropdown() { /* 문항 등록 창 드롭다운 메뉴 */
|
||
$(".dropbox").remove();
|
||
var target = event.target;
|
||
var targetId = target.getAttribute("id");
|
||
if (dl == targetId) {
|
||
dl = "";
|
||
return false;
|
||
}
|
||
dl = targetId;
|
||
var position = getOffset(target);
|
||
var droplist = fn_make_dropdownList();
|
||
droplist[targetId]();
|
||
var drop_box = createnode("DIV", droplist.getList(), {
|
||
"style": "position:absolute;top:" + (position.top + 30) + "px;left:" + position.left + "px;z-index:10000;padding:2px",
|
||
"class": "dropbox shadow-sm bg-white rounded"
|
||
});
|
||
|
||
$("body").append(drop_box);
|
||
}
|
||
|
||
function fn_add_open() { /* 오픈 추가 */
|
||
var element = fn_make_open_menu({});
|
||
makebox.appendChild(element)
|
||
}
|
||
|
||
function fn_make_open_menu(data) { /* 오픈 추가시 등록 창 */
|
||
|
||
function fn_make_open_detail(od){
|
||
if(!od) od = {}
|
||
var select = {
|
||
"element": "SELECT",
|
||
"text": [
|
||
// 2025-06-26 권민서 - 옵션 추가 및 수정
|
||
{ "element": "option", "text": "모두", "attr": { "value": "all" } },
|
||
{ "element": "option", "text": "한글만", "attr": { "value": "han"} },
|
||
{ "element": "option", "text": "영어만", "attr": { "value": "inputEnglishOnly" } },
|
||
{ "element": "option", "text": "숫자만", "attr": { "value": "num" } },
|
||
{ "element": "option", "text": "한글 + 기호", "attr": { "value": "inputHangulWithSymbols" } },
|
||
{ "element": "option", "text": "영어 + 기호", "attr": { "value": "inputEnglishWithSymbols" } },
|
||
{ "element": "option", "text": "연락처", "attr": { "value": "inputTelNumber" } }
|
||
],
|
||
"attr": { "class": "form-control optiontype", "style": "width:130px;display:inline-block" }
|
||
}
|
||
|
||
var range_text
|
||
if (od.min || od.max) {
|
||
range_text = od.min + "~" + od.max
|
||
} else {
|
||
range_text = ""
|
||
}
|
||
|
||
var input = [
|
||
{
|
||
"element": "INPUT",
|
||
"text": "",
|
||
"attr": { "class": "form-control labels", "value": od.label || "", "style": "display:inline-block;width:150px;" }
|
||
},
|
||
{
|
||
"element": "BUTTON",
|
||
"text": "삭제",
|
||
"attr": { "class": " btn btn-danger btn-sm open_delete", "style": "margin:5px", "type": "button" }
|
||
},
|
||
{
|
||
"element": "div",
|
||
"text": [
|
||
input_box({ "type": "checkbox", "class": "must m-1", "text": "필수 응답" }, od.must === "0" ? "false" : "true"),
|
||
select
|
||
],
|
||
"attr": { "class": "d-inline p-2" }
|
||
},
|
||
{
|
||
"element": "INPUT",
|
||
"text": "",
|
||
"attr": { "style": "margin:5px;width:80px", "class": "range_text", "type": "text", "value": range_text, "placeholder": "범위설정" }
|
||
},
|
||
{
|
||
"element": "INPUT",
|
||
"text": "",
|
||
"attr": { "style": "margin:5px;width:80px", "class": "prev_text", "type": "text", "value": od.prev || "", "placeholder": "입력란 앞" }
|
||
},
|
||
{
|
||
"element": "INPUT",
|
||
"text": "",
|
||
"attr": { "style": "margin:5px;width:80px", "class": "after_text", "type": "text", "value": od.after || "", "placeholder": "입력란 뒤" }
|
||
}
|
||
]
|
||
|
||
if(od.option) {
|
||
select.text.some(function(e){
|
||
if(e.attr.value === od.option) e.attr["selected"] = "true";
|
||
});
|
||
}
|
||
|
||
// if (od.option) {
|
||
// select.text.forEach(function(e) {
|
||
// if (e.attr.value === od.option.trim()) {
|
||
// e.attr.selected = "selected";
|
||
// } else {
|
||
// delete e.attr.selected;
|
||
// }
|
||
// });
|
||
// }
|
||
|
||
// 2025-11-27 (권민서) select 변경될 때마다 범위설정 input 활성화/비활성화 시작
|
||
setTimeout(function () {
|
||
$(".makebox_" + qtype).each(function () {
|
||
var $select = $(this).find("select.optiontype");
|
||
var $range = $(this).find("input.range_text");
|
||
|
||
if ($select.val() === "inputTelNumber") $range.prop("disabled", true).val("");
|
||
else $range.prop("disabled", false);
|
||
|
||
$select.on("change", function () {
|
||
if ($(this).val() === "inputTelNumber") $range.prop("disabled", true).val("");
|
||
else $range.prop("disabled", false);
|
||
});
|
||
});
|
||
}, 0);
|
||
// 2025-11-27 (권민서) select 변경될 때마다 범위설정 input 활성화/비활성화 끝
|
||
|
||
return createnode("DIV", input, { "class": "makebox_" + qtype });
|
||
}
|
||
|
||
if (get(data,["dataset","open"])) {
|
||
return Object.keys(data.dataset.open).map(function (key) {
|
||
return fn_make_open_detail(data.dataset.open[key])
|
||
})
|
||
} else {
|
||
return fn_make_open_detail()
|
||
}
|
||
|
||
}
|
||
|
||
function fn_make_createMenu(menu_title) { /* 메뉴 선택 시 */
|
||
var value
|
||
var text
|
||
var element = []
|
||
dl = ""
|
||
removeallTinymce();
|
||
switch (qtype) {
|
||
case "title": case "description":
|
||
value = qd ? prevValue() : ""
|
||
var des_content = ""
|
||
des_content += "<p class='m-1'>문번 가져오기</p>"
|
||
des_content += "<p class='m-1'>- 단수 => [#문번#]</p>"
|
||
des_content += "<p class='m-1'> - 복수 => 문번의 num을 선택 시 나옴 [#문번,(num)(num)#], 문번의 선택된 모든 응답 [#문번, all#] </p>"
|
||
des_content += "<p class='m-1'> - 구분자 => 보기에 구분자가 있는 경우 [#문번,(SPLIT)-(num)#]</p>"
|
||
des_content += "<p class='m-0 text-primary'>* 예시 A1 단수 문항 => [#A1#] // 복수 문항 => [#A1,(1)(2)#], [#A1,all#] // 구분자 [#A1,@-1#] </p>"
|
||
text = [
|
||
{
|
||
"element": "p",
|
||
"text": menu_title || event.target.innerText,
|
||
"attr": { "class": "text-primary" }
|
||
},
|
||
{
|
||
"element": "small",
|
||
"text": des_content,
|
||
"attr": { "class": "text-danger" }
|
||
}
|
||
]
|
||
element.push(createnode("textarea", value, { "id": "makebox_" + qtype}))
|
||
break;
|
||
case "single": case "multi": case "attr": case "scale":
|
||
value = qd ? prevValue() : ""
|
||
text = [
|
||
{
|
||
"element": "p",
|
||
"text": menu_title || event.target.innerText,
|
||
"attr": { "class": "text-primary" }
|
||
},
|
||
{
|
||
"element": "small",
|
||
"text": "* 아래 창에 복사 붙여넣기 혹은 직접 기입해주세요. (문항 구분 : 줄바꿈)",
|
||
"attr": { "class": "text-danger" }
|
||
}
|
||
]
|
||
element.push(createnode("DIV", "", { "id": "makebox_" + qtype, "contentEditable": "true", "class": "m-2 p-1 border border-dark write_example" }));
|
||
element[0].innerText = value;
|
||
break;
|
||
case "open":
|
||
text = [
|
||
{
|
||
"element": "p",
|
||
"text": menu_title || event.target.innerText,
|
||
"attr": { "class": "text-primary" }
|
||
},
|
||
];
|
||
|
||
|
||
element.push(fn_make_open_menu(qd))
|
||
|
||
break;
|
||
case "attroption":
|
||
value = qd ? prevValue("attr") : ""
|
||
|
||
if (!value) {
|
||
alert("속성을 먼저 추가해주세요.");
|
||
return false;
|
||
}
|
||
var example = []
|
||
Object.keys(qd.dataset).forEach(function(key){
|
||
if(key ==="attr") return false;
|
||
var set = qd.dataset[key]
|
||
example = example.concat(Object.keys(set).map(function(ele){ return set[ele].label }));
|
||
})
|
||
|
||
|
||
text = [
|
||
{
|
||
"element": "p",
|
||
"text": menu_title || event.target.innerText,
|
||
"attr": { "class": "text-primary" }
|
||
},
|
||
{
|
||
"element": "small",
|
||
"text": "* 아래 창에 복사 붙여넣기 혹은 직접 기입해주세요. (문항 구분 : 숫자 형식 기호 또는 줄바꿈 )",
|
||
"attr": { "class": "text-danger" }
|
||
}
|
||
];
|
||
|
||
var table = createnode("table", "", { "class": gstyle.stable.sm, "id": "attrtable" })
|
||
var attrheader = get(qd, ["datagroup", "attr", "header"]) || {};
|
||
var prev = get(qd, ["datagroup", "attr", "prev"]);
|
||
var after = get(qd, ["datagroup", "attr", "after"]);
|
||
|
||
if (!isEmptyObject(attrheader)) {
|
||
Object.keys(attrheader).forEach(function(key,id){
|
||
var headertr = createnode("TR", "",{ "class": "header" });
|
||
attrheader[key].forEach(function(element){
|
||
headertr.appendChild(createnode("TH", element.label, { "colspan": element.cols , "rowspan" : element.rows }));
|
||
});
|
||
if(Object.keys(attrheader).length !== id+1) {
|
||
table.appendChild(headertr);
|
||
} else {
|
||
if(example.length > 0) {
|
||
example.forEach(function(e){
|
||
headertr.appendChild(createnode("TH",e, { "data-cell": "none" }))
|
||
})
|
||
}
|
||
table.appendChild(headertr);
|
||
}
|
||
})
|
||
} else {
|
||
var headertr = createnode("TR", "",{ "class": "header" });
|
||
headertr.appendChild(createnode("TH", "항목"))
|
||
if(example.length > 0) {
|
||
example.forEach(function(e){
|
||
headertr.appendChild(createnode("TH",e, { "data-cell": "none" }))
|
||
})
|
||
}
|
||
table.appendChild(headertr);
|
||
}
|
||
|
||
var bodytr = value.split("\n").map(function (text, index) {
|
||
var td = [];
|
||
if (prev) {
|
||
if (prev[index]) {
|
||
prev[index].forEach(function (obj) {
|
||
td.push(createnode("TD", obj.label, { "rowspan": obj.rows, "colspan": obj.cols }))
|
||
})
|
||
}
|
||
}
|
||
td.push(createnode("TD", text, { "data-cell": "none", "class" : "bogi" }));
|
||
if (after) {
|
||
if (after[index]) {
|
||
after[index].forEach(function (obj) {
|
||
td.push(createnode("TD", obj.label, { "rowspan": obj.rows, "colspan": obj.cols }))
|
||
})
|
||
}
|
||
}
|
||
|
||
if(example.length > 0)
|
||
td = td.concat( Array(example.length).fill().map(function(e){ return createnode("TD","", { "data-cell": "none","class" : "qbox" })}) );
|
||
|
||
return createnode("TR", td);
|
||
})
|
||
|
||
table.appendM(bodytr)
|
||
|
||
var mc = make_container(["col-12 p-2 border"]);
|
||
var btngroup = Array(3).fill().map(function () { return createnode("div", "", { "class": "btn-group btn-group-sm", "role": "group", "style": "margin:3px" }) });
|
||
btngroup[0].innerText = "사전문구"
|
||
btngroup[0].appendChild(createnode("button", "추가", { "name": "pre", "class": "btn btn-success" }));
|
||
btngroup[0].appendChild(createnode("button", "삭제", { "name": "predelete", "class": "btn btn-danger" }));
|
||
btngroup[1].innerText = "사후문구"
|
||
btngroup[1].appendChild(createnode("button", "추가", { "name": "after", "class": "btn btn-success" }))
|
||
btngroup[1].appendChild(createnode("button", "삭제", { "name": "afterdelete", "class": "btn btn-danger" }))
|
||
btngroup[2].innerText = "머리글"
|
||
btngroup[2].appendChild(createnode("button", "추가", { "name": "header", "class": "btn btn-success" }))
|
||
btngroup[2].appendChild(createnode("button", "삭제", { "name": "headerdelete", "class": "btn btn-danger" }))
|
||
|
||
|
||
mc.getcolList()[0].appendM(btngroup)
|
||
mc.getcolList()[0].appendChild(table);
|
||
kon.exceltable.setTable(table);
|
||
element.push(mc.getcontainer());
|
||
break;
|
||
|
||
case "rank":
|
||
value = qd ? prevValue() : ""
|
||
text = [
|
||
{
|
||
"element": "p",
|
||
"text": menu_title || event.target.innerText,
|
||
"attr": { "class": "text-primary" }
|
||
},
|
||
{
|
||
"element": "small",
|
||
"text": "* 필수 범위 입력 시 해당 순위까지만 필수 응답. ",
|
||
"attr": { "class": "text-danger" }
|
||
}
|
||
]
|
||
|
||
/*
|
||
var select = {
|
||
"element": "SELECT",
|
||
"text": [],
|
||
"attr": { "class": "form-control", "style": "width:130px;display:inline-block" }
|
||
}
|
||
|
||
for (var i = 0; i < 10; i++)
|
||
select.text.push({ "element": "option", "text": i + "순위", "attr": { "value": i } })
|
||
*/
|
||
|
||
//20260313 박준성 랭크 최대 순위 select -> input 으로 변경
|
||
var select = {
|
||
"element": "INPUT",
|
||
"text": [],
|
||
"attr": { "type": "number", "name": "rank_num", "class": "form-control", "placeholder": "랭크 순위", "style": "width:130px;display:inline-block" }
|
||
}
|
||
|
||
element.push(createnode("DIV",
|
||
[
|
||
select,
|
||
{ "element": "INPUT", "text": "", "attr": { "type": "number", "placeholder": "필수 범위", "name": "rank_max", "class": "form-control m-1", "style": "width:130px;display:inline-block" } }
|
||
]
|
||
, { "id": "makebox_" + qtype }
|
||
)
|
||
);
|
||
|
||
break;
|
||
default:
|
||
}
|
||
makebox = createnode("div","",{ "id": "makebox", "class": "border border-info p-2" })
|
||
|
||
text.forEach(function(ele){
|
||
var element = createnode(ele.element, "", ele.attr);
|
||
element.innerHTML = ele.text;
|
||
makebox.appendChild(element)
|
||
})
|
||
makebox.appendChild(createnode("hr","",{"class":"m-1"}))
|
||
// 권민서 2025.11.19. id=saveBtn 추가
|
||
makebox.appendChild(createnode("BUTTON","저장",{ "class": "btn btn-primary btn-sm", "id": "saveBtn", "style": "margin:5px", "type": "button", "onclick": "kon.qu.exampleSave()" }))
|
||
|
||
if (qtype === "open")
|
||
makebox.appendChild(createnode("BUTTON", "추가", { "class": " btn btn-success btn-sm ", "style": "margin:5px", "type": "button", "onclick": "kon.qu.fn_add_open()" }))
|
||
|
||
for (var icnt = 0; icnt < element.length; icnt++) {
|
||
makebox.appendM(element[icnt]);
|
||
}
|
||
|
||
getById("questionPreview").insertAdjacentElement("beforebegin", makebox);
|
||
$(makebox).find("div[id^=makebox_]").focus()
|
||
|
||
// 2025-08-29 권민서 주석
|
||
// if (qtype === "title" || qtype === "description") makeTinymce("makebox_" + qtype);
|
||
|
||
// 2025-08-29 권민서 특수기호 모달 팝업 추가
|
||
if (qtype === "title" || qtype === "description") {
|
||
$('#specialCharPopup').hide();
|
||
$('button#saveBtn').after('<div id="specialCharBackdrop" class="btn btn-sm" style="margin:5px; background-color: #F4ED47" type="button" onclick="kon.qu.openSpecialCharPopup()">특수기호</div>');
|
||
makeTinymce("makebox_" + qtype);
|
||
} else {
|
||
$('#specialCharPopup').hide();
|
||
}
|
||
}
|
||
|
||
|
||
function prevValue(type) { /* 이전 값 있으면 가져오기 */
|
||
var text = ""
|
||
var this_type = type || qtype // 명시된 type이 없을 경우 qtype
|
||
switch (this_type) {
|
||
case "title": case "description":
|
||
text = qd[this_type];
|
||
break;
|
||
case "single": case "multi": case "attr": case "scale":
|
||
var data = qd["dataset"][this_type]
|
||
|
||
if (!data) break;
|
||
|
||
text = [];
|
||
Object.keys(data).forEach(function (key) {
|
||
var datatext = data[key]["label"]
|
||
//20220124 박준성 value가 key랑 다르면 Value|Label //구분자 수정
|
||
if(key != data[key]["value"]){
|
||
datatext = data[key]["value"] + "|" + datatext;
|
||
}
|
||
//20220124 박준성
|
||
|
||
if (data[key]["etc"] === "1")
|
||
datatext = datatext + "{T}"
|
||
|
||
if(data[key]["none"] === "1")
|
||
datatext = datatext + "{N}"
|
||
if(data[key]["except"] === "1")
|
||
datatext = datatext + "{E}"
|
||
text.push(datatext);
|
||
})
|
||
text = text.join("\n")
|
||
break;
|
||
case "open":
|
||
var data = qd["dataset"][this_type]
|
||
break;
|
||
}
|
||
return text
|
||
}
|
||
|
||
function exampleSave() { /* 문항 수정사항을 페이지 내에 갱신 하고 DB에 저장시킬 변수에 담음 ( 단수 추가, 복수 추가 ... 등) */
|
||
var dobj = {}
|
||
var bools = true;
|
||
var data
|
||
var text
|
||
var target
|
||
var table
|
||
|
||
if (!qd) {
|
||
qd = {}
|
||
qd["title"] = ""
|
||
qd["description"] = ""
|
||
qd["dataset"] = {}
|
||
} else {
|
||
if(!qd["dataset"]) qd["dataset"] = {}
|
||
}
|
||
|
||
switch (qtype) {
|
||
case "single": case "multi": case "attr":
|
||
text = document.getElementById("makebox_" + qtype).innerText;
|
||
data = [];
|
||
|
||
target = document.getElementById("makebox_" + qtype);
|
||
table = $(target).find("table");
|
||
if (table.length > 0) {
|
||
table.find("td").each(function (id, ele) {
|
||
data.push(ele.innerText.replace(/\n/gi," "));
|
||
})
|
||
} else {
|
||
data = text.split("\n");
|
||
}
|
||
|
||
|
||
data = data.filter(function (inner) { return inner.trim() !== "" });
|
||
|
||
data.forEach(function (label, code) {
|
||
//20220124 박준성 레이블에 |가 있으면 스플릿 후 [0]은 value, [1] label
|
||
var valueCode = String(code+1);
|
||
if(label.indexOf("|") > -1){ //구분자 수정
|
||
var lableArray = label.split('|');
|
||
valueCode = lableArray[0];
|
||
label = lableArray[1];
|
||
}
|
||
//20220124 박준성
|
||
|
||
if (data.indexOf(label, code + 1) > -1) {
|
||
|
||
bools = false;
|
||
return false;
|
||
}
|
||
dobj[code + 1] = {}
|
||
label = label.trim()
|
||
|
||
if (regex_test(global.pattern.etc, label)) {
|
||
label = label.replace(global.pattern.etc, "");
|
||
dobj[code + 1]["etc"] = "1";
|
||
} else {
|
||
dobj[code + 1]["etc"] = "0";
|
||
}
|
||
if(qtype === "multi") {
|
||
if(regex_test(global.pattern.none, label)) {
|
||
label = label.replace(global.pattern.none, "");
|
||
dobj[code+1]["none"] = "1"
|
||
} else {
|
||
dobj[code+1]["none"] = "0"
|
||
}
|
||
}
|
||
/* 무조건 출력 하는 문항 */
|
||
if(regex_test(global.pattern.except, label)) {
|
||
label = label.replace(global.pattern.except, "");
|
||
dobj[code+1]["except"] = "1"
|
||
} else {
|
||
dobj[code+1]["except"] = "0"
|
||
}
|
||
dobj[code + 1]["label"] = label;
|
||
//dobj[code + 1]["value"] = String(code+1);
|
||
//20220124 박준성 value가 있어야 하는 곳에 value값
|
||
dobj[code + 1]["value"] = valueCode;
|
||
});
|
||
|
||
if (!bools) {
|
||
//alert("중복된 값은 입력하실 수 없습니다.");
|
||
//return false;
|
||
console.log("중복된 값은 입력하실 수 없습니다."); //-- 20210901 hwkim
|
||
}
|
||
|
||
if (!qd.dataset[qtype]) qd.dataset[qtype] = {}
|
||
qd.dataset[qtype] = dobj
|
||
|
||
break;
|
||
case "scale":
|
||
target = document.getElementById("makebox_" + qtype);
|
||
table = $(target).find("table");
|
||
|
||
if (table.length > 0) {
|
||
data = []
|
||
table.find("tr:first td").each(function (id, ele) {
|
||
var row = {}
|
||
row.label = ele.innerText.replace(/\n/gi," ")
|
||
row.value = String(id + 1)
|
||
if (ele.colSpan !== 1) row.col = ele.colSpan
|
||
data.push(row);
|
||
})
|
||
|
||
} else {
|
||
text = document.getElementById("makebox_" + qtype).innerText;
|
||
data = text.split("\n");
|
||
}
|
||
|
||
data.forEach(function (value, code) {
|
||
if(code===0 && value==="") return true;
|
||
dobj[code + 1] = {};
|
||
|
||
if (typeof (value) === "object")
|
||
dobj[code + 1] = value
|
||
else {
|
||
//20220124 박준성
|
||
var valueCode = String(code+1);
|
||
if(value.indexOf("|") > -1){
|
||
var valueArray = value.split('|');
|
||
valueCode = valueArray[0];
|
||
value = valueArray[1];
|
||
}
|
||
dobj[code + 1]["label"] = value;
|
||
dobj[code + 1]["value"] = valueCode;
|
||
//20220124 박준성 value가 있어야 하는 곳에 value값
|
||
//dobj[code + 1]["label"] = value;
|
||
//dobj[code + 1]["value"] = String(code + 1) ;
|
||
}
|
||
|
||
});
|
||
|
||
if (!qd.dataset[qtype]) qd.dataset[qtype] = {}
|
||
qd.dataset[qtype] = dobj
|
||
break;
|
||
|
||
case "rank":
|
||
qd.dataset[qtype] = {}
|
||
qd.dataset[qtype].val = $("#makebox_rank input[name=rank_num]").val() //20260313 박준성 랭크 최대 순위 select -> input 으로 변경
|
||
qd.dataset[qtype].max = $("input[name=rank_max]").val().trim() === "" ? qd.dataset[qtype].val : $("input[name=rank_max]").val();
|
||
if(qd.dataset[qtype].val === "0") {
|
||
delete qd.dataset[qtype]
|
||
}
|
||
break;
|
||
case "title": case "description":
|
||
if (!qd[qtype]) qd[qtype] = ""
|
||
qd[qtype] = tinymce.get("makebox_" + qtype).getContent();
|
||
break;
|
||
case "open":
|
||
$("#makebox .makebox_open").each(function (id, ele) {
|
||
dobj[id + 1] = {};
|
||
var target = dobj[id + 1];
|
||
var ele = $(ele);
|
||
|
||
target["label"] = ele.find(".labels").val();
|
||
|
||
target["option"] = [];
|
||
if (ele.find(".must").prop("checked"))
|
||
target["must"] = "1";
|
||
else
|
||
target["must"] = "0";
|
||
|
||
target["option"] = ele.find("select").val();
|
||
if (ele.find(".range_text").val().trim()) {
|
||
var range = ele.find(".range_text").val().trim().split("~");
|
||
range[0] === "" ? target["min"] = "" : target["min"] = range[0]
|
||
range[1] === "" ? target["max"] = "" : target["max"] = range[1]
|
||
}
|
||
if (ele.find(".prev_text").val().trim()) target["prev"] = ele.find(".prev_text").val().trim()
|
||
if (ele.find(".after_text").val().trim()) target["after"] = ele.find(".after_text").val().trim()
|
||
})
|
||
|
||
if (!qd.dataset[qtype]) qd.dataset[qtype] = {}
|
||
qd.dataset[qtype] = dobj;
|
||
break;
|
||
|
||
case "attroption":
|
||
var table = document.getElementById("attrtable");
|
||
var paf = true; // 이전 이후 분기 true 이전, false 이후
|
||
var qda;
|
||
|
||
qda = getasmake(qd, ["datagroup", "attr"]);
|
||
|
||
qda["prev"] = {};
|
||
qda["after"] = {};
|
||
qda["header"] = {};
|
||
|
||
$(table).find(".header").each(function (id, ele) {
|
||
qda["header"][id] = [];
|
||
$(ele).find("th:not([data-cell=none]), td:not([data-cell=none])").each(function(id2,item){
|
||
qda["header"][id].push({ "label": item.innerText.replace(/\n/gi," "), "rows": item.rowSpan || 1, "cols": item.colSpan || 1 });
|
||
})
|
||
|
||
})
|
||
|
||
$(table).find("tr:not(.header)").each(function (id, element) {
|
||
paf = true;
|
||
$(element).find("td").each(function (idx, ele) {
|
||
if (ele.getAttribute("data-cell") === "none") {
|
||
paf = false;
|
||
return true;
|
||
}
|
||
var target = paf ? qda["prev"] : qda["after"]
|
||
if (!target[id]) target[id] = []
|
||
target[id].push({ "label": ele.innerText.replace(/\n/gi," "), "rows": ele.rowSpan || 1, "cols": ele.colSpan || 1 })
|
||
})
|
||
})
|
||
|
||
break;
|
||
/* case "register":
|
||
var bundle = getById("bundle_up")
|
||
kon.op.setTarget($(bundle));
|
||
kon.op.removeTag();
|
||
kon.op.optimize_html();
|
||
qd = kon.op.analysis_html(bundle);
|
||
break; */
|
||
}
|
||
|
||
Object.keys(qd.dataset).forEach(function (key) {
|
||
if (Object.keys(qd.dataset[key]).length == 0)
|
||
delete qd.dataset[key]
|
||
})
|
||
removeallTinymce()
|
||
getById("makebox").remove();
|
||
fn_make_inputFrame()
|
||
}
|
||
|
||
// 2025-07-31 권민서 특수기호 팝업창 추가 시작
|
||
function insertTextAtCursor(containerEl, text) {
|
||
const doc = containerEl.ownerDocument || document;
|
||
const win = doc.defaultView || window;
|
||
const sel = win.getSelection();
|
||
if (!sel || sel.rangeCount === 0) {
|
||
containerEl.innerHTML += text;
|
||
return;
|
||
}
|
||
const range = sel.getRangeAt(0);
|
||
if (!containerEl.contains(range.commonAncestorContainer)) {
|
||
containerEl.innerHTML += text;
|
||
return;
|
||
}
|
||
range.deleteContents();
|
||
const textNode = document.createTextNode(text);
|
||
range.insertNode(textNode);
|
||
range.setStartAfter(textNode);
|
||
range.setEndAfter(textNode);
|
||
sel.removeAllRanges();
|
||
sel.addRange(range);
|
||
}
|
||
|
||
function openSpecialCharPopup() {
|
||
if (!document.getElementById("specialCharPopupStyles")) {
|
||
const style = document.createElement("style");
|
||
style.id = "specialCharPopupStyles";
|
||
style.textContent = `
|
||
.special-overlay {
|
||
position: fixed;
|
||
top: 0; left: 0; right: 0; bottom: 0;
|
||
background: rgba(0,0,0,0);
|
||
z-index: 2147483647 !important;
|
||
}
|
||
.special-button {
|
||
background: linear-gradient(145deg, #fff9c4, #fff176);
|
||
color: #5c4b00;
|
||
padding: 6px 10px;
|
||
margin: 4px;
|
||
border: none;
|
||
border-radius: 8px;
|
||
font-weight: bold;
|
||
font-size: 12px;
|
||
transition: all 0.3s ease;
|
||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||
cursor: pointer;
|
||
}
|
||
.special-button:hover {
|
||
transform: scale(1.05);
|
||
box-shadow: 0 12px 24px rgba(0,0,0,0.25);
|
||
}
|
||
.special-popup {
|
||
position: absolute;
|
||
background: rgba(255, 255, 255, 0.15);
|
||
border-radius: 20px;
|
||
padding: 24px 20px 20px 20px;
|
||
backdrop-filter: blur(14px) saturate(180%);
|
||
-webkit-backdrop-filter: blur(14px) saturate(180%);
|
||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
|
||
z-index: 2147483647 !important;
|
||
display: grid;
|
||
grid-template-columns: repeat(5, 1fr);
|
||
gap: 6px;
|
||
max-width: 300px;
|
||
}
|
||
.popup-close {
|
||
position: absolute;
|
||
top: 1px;
|
||
right: 8px;
|
||
background: none;
|
||
border: none;
|
||
font-size: 18px;
|
||
font-weight: bold;
|
||
color: #333;
|
||
cursor: pointer;
|
||
}
|
||
`;
|
||
document.head.appendChild(style);
|
||
}
|
||
|
||
document.getElementById("specialCharOverlay")?.remove();
|
||
|
||
const overlay = document.createElement("div");
|
||
overlay.id = "specialCharOverlay";
|
||
overlay.className = "special-overlay";
|
||
|
||
const popup = document.createElement("div");
|
||
popup.id = "specialCharPopup";
|
||
popup.className = "special-popup";
|
||
|
||
const closeBtn = document.createElement("button");
|
||
closeBtn.className = "popup-close";
|
||
closeBtn.innerHTML = "×";
|
||
closeBtn.onclick = () => overlay.remove();
|
||
popup.appendChild(closeBtn);
|
||
|
||
const options = ["·", "•", "●", "◯", "▪", "▫", "◼", "▢", "◀", "◁", "▶", "▷", "◆", "◇", "×", "÷", "*", "※", "±", "←", "→", "↑", "↓", "↔", "↕", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"];
|
||
options.forEach(char => {
|
||
const btn = document.createElement("button");
|
||
btn.type = "button";
|
||
btn.textContent = char;
|
||
btn.className = "special-button";
|
||
btn.onclick = () => {
|
||
let textarea;
|
||
if (qtype === "title") textarea = document.querySelector("#makebox_title_ifr")?.contentWindow?.document?.body;
|
||
else if (qtype === "description") textarea = document.querySelector("#makebox_description_ifr")?.contentWindow?.document?.body;
|
||
if (textarea) insertTextAtCursor(textarea, char);
|
||
overlay.remove();
|
||
};
|
||
popup.appendChild(btn);
|
||
});
|
||
|
||
overlay.addEventListener("click", function (e) {
|
||
if (e.target === overlay) overlay.remove();
|
||
});
|
||
|
||
overlay.appendChild(popup);
|
||
document.body.appendChild(overlay);
|
||
|
||
const backdrop = document.getElementById("specialCharBackdrop");
|
||
if (backdrop) {
|
||
const rect = backdrop.getBoundingClientRect();
|
||
popup.style.position = "absolute";
|
||
popup.style.top = `${rect.top + window.scrollY}px`;
|
||
popup.style.left = `${rect.right + 10 + window.scrollX}px`;
|
||
} else {
|
||
popup.style.top = "20%";
|
||
popup.style.left = "60%";
|
||
}
|
||
|
||
overlay.style.zIndex = "2147483647";
|
||
popup.style.zIndex = "2147483647";
|
||
}
|
||
// 권민서 특수기호 팝업 기능 끝
|
||
|
||
function fn_save(types) { /* DB에 저장 */
|
||
var param = ""
|
||
var param2 = ""
|
||
var data = {}
|
||
var totalcount = 1
|
||
param = registerType == "modify" ? setparam("u", "QUESTION") : setparam("i", "QUESTION")
|
||
param2 = setparam("u", "STRUCTURE")
|
||
|
||
param["PKEY"] = code;
|
||
param2["PKEY"] = code;
|
||
|
||
if (registerType === "new") {
|
||
var cparam = setparam("s", "MAXID", { "PKEY": code });
|
||
var max = ajax_returnData(ajaxUrl, cparam);
|
||
qid = "Q" + max[0].maxid;
|
||
param["Qorder"] = max[0].maxorder;
|
||
data["qgroup"] = ""
|
||
data["rota"] = ""
|
||
} else {
|
||
data["qgroup"] = qd.qgroup
|
||
data["rota"] = qd.rota
|
||
}
|
||
|
||
param["QID"] = qid
|
||
param2["QID"] = qid
|
||
|
||
|
||
|
||
data["variable"] = replaceAll($("#qvariable").val(), "'", global.text.rquota)
|
||
data["explain"] = replaceAll($("#qexplain").val(), "'", global.text.rquota);
|
||
|
||
if (!data["variable"].trim()) {
|
||
alert("변수명은 필수로 입력해주세요.");
|
||
return false;
|
||
}
|
||
if (!qd.title) {
|
||
alert("질문은 필수로 입력해주세요.");
|
||
return false;
|
||
}
|
||
|
||
data["title"] = qd.title || "";
|
||
data["stype"] = qd.stype || ""
|
||
data["description"] = qd.description || ""
|
||
data["dataset"] = qd.dataset || ""
|
||
data["datagroup"] = qd.datagroup || ""
|
||
|
||
|
||
|
||
var be_attr = (+qd.dataset.hasOwnProperty("attr"))
|
||
var be_rank = (+qd.dataset.hasOwnProperty("rank"))
|
||
var be_multi = (+qd.dataset.hasOwnProperty("multi"))
|
||
var be_open = (+qd.dataset.hasOwnProperty("open"))
|
||
var be_single = (+qd.dataset.hasOwnProperty("single"))
|
||
var be_scale = (+qd.dataset.hasOwnProperty("scale"))
|
||
|
||
if (be_single && be_scale) {
|
||
alert("단수 보기와 척도 보기는 중복하실 수 없습니다.");
|
||
return false;
|
||
}
|
||
|
||
if (!be_attr) { data["datagroup"] = "" }
|
||
|
||
if (be_attr) {
|
||
data["qtype"] = "attr";
|
||
data["stype"] = "AM1";
|
||
Object.keys(qd.dataset).forEach(function(key){
|
||
if(key !== "multi" && key !=="open" ) return false; /* 복수 문항 아웃 */
|
||
var dataset = qd.dataset[key];
|
||
data["dataset"][key] = {};
|
||
Object.keys(dataset).forEach(function(v){
|
||
data["dataset"][key][totalcount] = dataset[v];
|
||
totalcount++
|
||
})
|
||
})
|
||
|
||
} else if (be_rank) {
|
||
data["qtype"] = "rank";
|
||
data["stype"] = "RM1";
|
||
} else {
|
||
if (!(be_multi || be_open || be_single || be_scale)) {
|
||
data["qtype"] = "description";
|
||
data["stype"] = "DM1";
|
||
} else {
|
||
if (be_multi + be_open + be_single + be_scale > 1) {
|
||
data["qtype"] = "com";
|
||
data["stype"] = "CM1";
|
||
Object.keys(qd.dataset).forEach(function(key){
|
||
if(key !== "multi" && key !=="open" ) return false;
|
||
var dataset = qd.dataset[key];
|
||
data["dataset"][key] = {}
|
||
Object.keys(dataset).forEach(function(v){
|
||
data["dataset"][key][totalcount] = dataset[v];
|
||
totalcount++
|
||
})
|
||
})
|
||
} else {
|
||
if (be_single) {
|
||
data["qtype"] = "single"
|
||
data["stype"] = "SM2";
|
||
}
|
||
else if (be_multi) {
|
||
data["qtype"] = "multi"
|
||
data["stype"] = "MM2";
|
||
}
|
||
else if (be_open) {
|
||
data["qtype"] = "open"
|
||
data["stype"] = "OM1";
|
||
}
|
||
else if (be_scale) {
|
||
data["qtype"] = "scale"
|
||
data["stype"] = "SCM1";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if(registerType === "new") {
|
||
data["option"] = ""
|
||
} else {
|
||
if(data["qtype"] !== qd.qtype)
|
||
data["option"] = "";
|
||
else {
|
||
data["stype"] = qd.stype;
|
||
data["option"] = qd.option;
|
||
}
|
||
}
|
||
|
||
var structure = question_structure(qid, qd.dataset)
|
||
param2["structure"] = structure.code;
|
||
param2["structure"] = JSON.stringify(param2["structure"]);
|
||
|
||
param2["linfo"] = structure.label;
|
||
param2["linfo"] = replaceAll(JSON.stringify(param2["linfo"]),"'",global.text.rquota);
|
||
|
||
param["JSON"] = replaceAll(JSON.stringify(data), "'", global.text.rquota);
|
||
|
||
|
||
ajax_call(ajaxUrl, param, "성공적으로 저장했습니다.");
|
||
|
||
ajax_call(ajaxUrl, param2);
|
||
ajax_call(ajaxUrl, setparam("u", "QNUMBER", { "PKEY": code })); // 순서 변경
|
||
ajax_call(ajaxUrl,setparam("u","VARIABLE_MATCH",{"PKEY":code})); // 변수와 qid 매칭 json 변경
|
||
|
||
if(types === "1") {
|
||
list(qid);
|
||
fn_makeFrame();
|
||
var scrollto = $("tr[data-focus=true]").position().top - 40
|
||
cleftdiv.scrollTop = scrollto
|
||
if(registerType === "new") {
|
||
fnNew()
|
||
} else {
|
||
var fnumber = questionlist.findIndex(function(item){if(item.QID === qid) return true});
|
||
if(fnumber === questionlist.length -1){
|
||
fnNew()
|
||
} else {
|
||
fnModify(document.querySelector(".question_list[data-code="+questionlist[fnumber+1].QID+"]"),"1");
|
||
}
|
||
}
|
||
} else {
|
||
$("#changemodal-close").trigger("click");
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
function bundle_upload() { /* 문항 DB 세팅 - 일괄 업로드 용 */
|
||
var param = ""
|
||
var param2 = ""
|
||
var data = {}
|
||
param = registerType == "modify" ? setparam("u", "QUESTION") : setparam("i", "QUESTION")
|
||
param2 = setparam("u", "STRUCTURE")
|
||
|
||
data["qgroup"] = ""
|
||
data["rota"] = ""
|
||
|
||
param["PKEY"] = code;
|
||
param2["PKEY"] = code;
|
||
|
||
var cparam = setparam("s", "MAXID", { "PKEY": code });
|
||
var max = ajax_returnData(ajaxUrl, cparam);
|
||
qid = "Q" + max[0].maxid;
|
||
param["Qorder"] = max[0].maxorder;
|
||
|
||
param["QID"] = qid;
|
||
param2["QID"] = qid;
|
||
|
||
|
||
data["variable"] = qd.variable;
|
||
data["explain"] = "";
|
||
data["title"] = qd.title || "";
|
||
data["stype"] = qd.stype || "";
|
||
data["description"] = qd.description || "";
|
||
data["dataset"] = qd.dataset || "";
|
||
data["datagroup"] = qd.datagroup || "";
|
||
data["qtype"] = qd.qtype || "";
|
||
data["option"] = "";
|
||
|
||
var structure = question_structure(qid, qd.dataset)
|
||
param2["structure"] = structure.code;
|
||
param2["structure"] = JSON.stringify(param2["structure"]);
|
||
|
||
param2["linfo"] = structure.label;
|
||
param2["linfo"] = replaceAll(JSON.stringify(param2["linfo"]),"'",global.text.rquota);
|
||
|
||
param["JSON"] = replaceAll(JSON.stringify(data), "'", global.text.rquota);
|
||
|
||
ajax_call(ajaxUrl, param);
|
||
ajax_call(ajaxUrl, param2);
|
||
ajax_call(ajaxUrl, setparam("u", "QNUMBER", { "PKEY": code }));
|
||
|
||
return Promise.resolve();
|
||
}
|
||
|
||
/* 문항 변수 구조 선언 */
|
||
function question_structure(qid, data) {
|
||
var attr = data["attr"];
|
||
var structure = {
|
||
"code" : [
|
||
|
||
],
|
||
"label" : {
|
||
|
||
}
|
||
}
|
||
|
||
if (data["rank"]) {
|
||
for (i = 1; i <= (+data["rank"].val); i++) {
|
||
structure.code.push(qid + "_" + i);
|
||
if(data["multi"]) {
|
||
Object.keys(data["multi"]).forEach(function(key){
|
||
if(!structure.label[qid+"_"+i]) structure.label[qid+"_"+i] = {}
|
||
structure.label[qid+"_"+i][String(data["multi"][key].value)] = data["multi"][key].label
|
||
})
|
||
}
|
||
}
|
||
if(data["multi"]) {
|
||
Object.keys(data["multi"]).forEach(function(key){
|
||
if(data["multi"][key].etc === "1"){
|
||
structure.code.push("T"+qid+"_"+data["multi"][key].value);
|
||
structure.label["T"+qid+"_"+data["multi"][key].value] = qid+"_"+data["multi"][key].value + "기타"
|
||
}
|
||
})
|
||
}
|
||
return structure;
|
||
}
|
||
|
||
Object.keys(data).forEach(function (key) {
|
||
if (key === "attr") return true;
|
||
if (key === "single" || key === "scale"){
|
||
structure.code.push(qid);
|
||
Object.keys(data[key]).forEach(function(keyx){
|
||
if(!structure.label[qid]) structure.label[qid] = {}
|
||
structure.label[qid][String(data[key][keyx].value)] = data[key][keyx].label
|
||
if(data[key][keyx].etc === "1") {
|
||
//20220124 박준성 value가 있어야 하는 곳에 value값
|
||
structure.code.push("T"+qid+"_"+String(data[key][keyx].value));
|
||
structure.label["T"+qid+"_"+String(data[key][keyx].value)] = data[key][keyx].label +"(기타)"
|
||
//20220124 박준성
|
||
/*
|
||
structure.code.push("T"+qid+"_"+keyx);
|
||
structure.label["T"+qid+"_"+keyx] = data[key][keyx].label +"(기타)"
|
||
*/
|
||
}
|
||
})
|
||
}
|
||
else if (key === "open" || key ==="multi" ) {
|
||
Object.keys(data[key]).forEach(function (key2) {
|
||
//20220124 박준성 value가 있어야 하는 곳에 value값
|
||
var sValue = key2;
|
||
if(key ==="multi"){
|
||
sValue = String(data[key][key2].value);
|
||
}
|
||
structure.code.push(qid + "_" + sValue);
|
||
|
||
if(!structure.label[qid + "_" + sValue]) structure.label[qid + "_" + sValue] = {}
|
||
if(key === "multi") {
|
||
structure.label[qid + "_" + sValue][String(data[key][key2].value)] = data[key][key2].label;
|
||
} else {
|
||
structure.label[qid + "_" + sValue] = "open";
|
||
}
|
||
if(data[key][key2].etc === "1") {
|
||
structure.code.push("T"+qid + "_" + sValue);
|
||
structure.label["T"+qid + "_" + sValue] = data[key][key2].label + "(기타)";
|
||
}
|
||
//20220124 박준성
|
||
})
|
||
}
|
||
/*
|
||
else if (key === "open" || key ==="multi" ) {
|
||
Object.keys(data[key]).forEach(function (key2) {
|
||
structure.code.push(qid + "_" + key2);
|
||
|
||
if(!structure.label[qid + "_" + key2]) structure.label[qid + "_" + key2] = {}
|
||
if(key === "multi") {
|
||
structure.label[qid + "_" + key2][String(data[key][key2].value)] = data[key][key2].label;
|
||
} else {
|
||
structure.label[qid + "_" + key2] = "open";
|
||
}
|
||
if(data[key][key2].etc === "1") {
|
||
structure.code.push("T"+qid + "_" + key2);
|
||
structure.label["T"+qid + "_" + key2] = data[key][key2].label + "(기타)";
|
||
}
|
||
})
|
||
}
|
||
*/
|
||
});
|
||
if (attr) {
|
||
var attr_structure = {
|
||
"code" : [
|
||
|
||
],
|
||
"label" : {
|
||
|
||
}
|
||
}
|
||
/* 속성 코드 => 구조 테이블용 */
|
||
//20220124 박준성 value가 있어야 하는 곳에 value값
|
||
$.each(attr, function (i,e) {
|
||
structure.code.forEach(function (ele) {
|
||
attr_structure.code.push(ele + "_" + e.value)
|
||
})
|
||
})
|
||
/*
|
||
Object.keys(attr).forEach(function (key) {
|
||
structure.code.forEach(function (ele) {
|
||
attr_structure.code.push(ele + "_" + key)
|
||
})
|
||
})
|
||
*/
|
||
/* 속성 라벨 => 구조 테이블용 */
|
||
$.each(attr,function (i,e) {
|
||
Object.keys(structure.label).forEach(function (ele) {
|
||
attr_structure.label[ele + "_" + e.value] = structure.label[ele];
|
||
})
|
||
})
|
||
/*
|
||
Object.keys(attr).forEach(function (key) {
|
||
Object.keys(structure.label).forEach(function (ele) {
|
||
attr_structure.label[ele + "_" + key] = structure.label[ele];
|
||
})
|
||
})
|
||
*/
|
||
/* 속성 기타 => 구조 테이블용 */
|
||
Object.keys(attr)
|
||
.filter(function(key){
|
||
if(attr[key].etc === "1") return true;
|
||
})
|
||
.forEach(function(key){
|
||
attr_structure.code.push(qid + "_" + attr[key].value + "_AT")
|
||
attr_structure.label[qid + "_" + attr[key].value + "_AT"] = attr[key].label + "_기타"
|
||
/*
|
||
attr_structure.code.push(qid + "_" + key + "_AT")
|
||
attr_structure.label[qid + "_" + key + "_AT"] = attr[key].label + "_기타"
|
||
*/
|
||
});
|
||
//20220124 박준성
|
||
return attr_structure
|
||
} else {
|
||
return structure
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
var module = {
|
||
allreset: allreset, // 전체 초기화
|
||
list: list, // 데이터 리스트
|
||
fn_make_question_view: fn_make_question_view, /* 문항 미리보기 프레임 구성 */
|
||
getCode: getCode, /* 코드 가져오고 설정 */
|
||
fn_makeFrame: fn_makeFrame, /* 문항 만든 프레임 틀에 넣는 함수 */
|
||
fn_make_dropdownList: fn_make_dropdownList, /* 문항 만들기 드롭다운 리스트 */
|
||
fn_make_button: fn_make_button, /* 문항 기능 버튼 생성 */
|
||
fnModify: fnModify, /* 수정 */
|
||
fnDelete: fnDelete,/* 삭제 */
|
||
fnCopy:fnCopy,/* 복사 */
|
||
fnNew: fnNew, /* 신규등록 */
|
||
fn_getQuestionData: fn_getQuestionData, /* 문항 수정 시 기존 데이터 가져오기 */
|
||
fn_make_preview_data: fn_make_preview_data, /* 미리보기 중 보기 및 속성 만들기 */
|
||
getObjexample: getObjexample, /* 단수, 복수, 오픈 보기들 가져오기 */
|
||
fn_open_option: fn_open_option, /* 오픈 문항 추가시 조건 부여 */
|
||
fn_make_Register: fn_make_Register, /* 등록창 만들기 */
|
||
fn_make_inputFrame: fn_make_inputFrame, /* 문항 미리보기 창 생성 */
|
||
fn_make_dropdown: fn_make_dropdown, /* 드롭다운 메뉴들 만듬 */
|
||
fn_make_open_menu: fn_make_open_menu, /* 오픈 문항 메뉴 */
|
||
fn_make_createMenu: fn_make_createMenu, /* 문항 생성 */
|
||
fn_add_open: fn_add_open, /* 오픈 문항 추가 */
|
||
prevValue: prevValue, /* 이전 값 가져오기 */
|
||
fn_save: fn_save, /* 문항 DB에 저장 */
|
||
exampleSave: exampleSave, /* 수정사항 저장 */
|
||
openSpecialCharPopup: openSpecialCharPopup, /* 2025-07-31 권민서 추가 특수문자 입력 팝업 */
|
||
fn_make_ChangeOrder: fn_make_ChangeOrder, /* 문항 순서 변경 */
|
||
bundle_upload: bundle_upload, /* 일괄 업로드 */
|
||
fn_translate_form:fn_translate_form, /* 번역 양식 다운 */
|
||
fn_chkdelete_form:fn_chkdelete_form, /* 2022-03-29 서성완 선택 삭제 추가 */
|
||
/* variable */
|
||
hard_list : hard_list /* 하드코딩 리스트 */
|
||
}
|
||
|
||
return module
|
||
|
||
})();
|