//已分配的课程打勾
function checkboxselected(status) {
    var userkey = $("#userkey").val();
    getAjax("GetUserCE.ashx", "key=" + userkey + "&&status=" + status, function (rs) {
        if (rs != "-1") {
            var obj = strToJson(rs); //异步查询所有已分配的课程 
            var item = objcheck();
            //双for循环遍历 将已分配的默认true
            for (var i = 0; i < obj.length; i++) {
                for (var j = 0; j < item.length; j++) {
                    if (item[j].value == obj[i].CEId) {
                        item[j].checked = true;
                        var node = item[j].parentNode.parentNode.childNodes;
                        for (var a = 1; a <= node.length; a++) {
                            if (node[a] == undefined) {
                                continue;
                            }
                            node[a].setAttribute("class", "selected");
                        }
                    }
                }
            }
        }
    }
            );
}
//获取checkbox对象
function objcheck() {
    var item = document.getElementsByName("checkbox");
    return item;
} //获取字符串转换json对象
function strToJson(str) {
    return JSON.parse(str);
}

//分配课程保存
function addRightCE() {
    var arrt = new Array();
    if (CheckboxValue() != "") {
        var userkey = $("#userkey").val();
        var key = CheckboxValue();

        getAjax('AddUserCE.ashx', "key=" + key + "&&userkey=" + userkey + "&&status=0", function (rs) {
            if (rs == 1) {
                showTipsMsg("操作成功", 1500, 4);
                this.close();
            } else {
                showTipsMsg("操作失败", 1500, 5);
            }
        });

    } else {
        alert("至少选择一门课程");
    }
}
function addRightExam() {
    var arrt = new Array();
    if (CheckboxValue() != "") {
        var userkey = $("#userkey").val();
        var key = CheckboxValue();
        getAjax('AddUserCE.ashx', "key=" + key + "&&userkey=" + userkey + "&&status=1", function (rs) {
            if (rs == 1) {
                showTipsMsg("操作成功", 1500, 4);
                this.close();
            } else {
                showTipsMsg("操作失败", 1500, 5);
            }
        });
    } else {
        alert("至少选择一份试卷");
    }
}