123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966 |
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title></title>
- <%@include file="../../../include.jsp" %>
- <script type="text/javascript" src="<%=path%>/scripts/business/exercise/examineManagement/questionBankAddEdit.js"></script>
- <style type="text/css">
- .answer_content{
- margin-left:5px;
- }
- .add_table_style {
- border-collapse: separate;
- }
- .option_table_style{
- border-style:solid;
- border-width:1px;
- border-color:#cdcaca;
- margin:0px 20px 0px 0px;
- border-collapse:collapse;
- width: 600px;
- }
- </style>
- <script type="text/javascript">
- var fd_id = "<%=request.getParameter("fd_id")%>";
- var versionId = "<%=request.getParameter("versionId")%>"//版本号id
- //取得用户真实名字
- var realName = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
- //部门id
- var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
- //部门id
- var unitId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- //部门名称
- var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
- //父部门id
- var parentId = top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
- var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var opt_type = 1;
- var answer_option = '';
- var answer_sum = 4;
- $(function(){
-
- $("#goback").hover(function(){
- $(this).attr("src","/nwyj/images/temp/back_hover.png");
- },function(){
- $(this).attr("src","/nwyj/images/temp/back.png");
- });
-
- $("#QUESTION_CLASSIFY_603").initCanstSelect("BM_ECM_TRAIN_EXAMINE_QUESTION_CLASSIFY");//内容类别
- $("#QUESTION_TYPE_603").initCanstSelect("BM_ECM_TRAIN_EXAMINE_QUESTION_TYPE");//题目类型
- //$("#QUESTION_SCORE_603").initCanstSelect("BM_ECM_TRAIN_EXAMINE_QUESTION_SCORE");//分值
-
- //修改表单
- if(!(fd_id=="null"||fd_id=="")){
- $("#titleShow").text("修改考试题目");
-
- var url = $.pathname() + '/ws/crud/CRUDService/getDataById/';
- var params = {
- classid : '603',
- objectID : fd_id
- };
- $.request.query(url,params,function(data){
- var questionType = data.QUESTION_TYPE_603;//题目类型
- var question_answer = data.QUESTION_ANSWER_603;//答案
- if(questionType==4){
- answer_sum = getAnswerCount(question_answer.split("|").length);//获取答案数量
- }else{
- answer_sum = getAnswerCount(0);
- }
- opt_type = data.ANSWER_TYPE_603;
- answer_option = data.ANSWER_OPTION_603;//答案选项类型
- createAnswerDomByType(data.QUESTION_TYPE_603,1);//创建表格
- $('#editForm').ajaxWrite({data:data});
- checkedByAnswer(question_answer,data.QUESTION_TYPE_603);//勾选答案
- checkApplicableType(data.APPLICABLE_OBJECT_603);//勾选适用对象
- answerType(data.ANSWER_TYPE_603);//勾选选项类型
- /* var question_score = data.QUESTION_SCORE_603;//题目得分
- if(questionType ==4){
- var score = question_score.split("|");
- $("#QUESTION_SCORE_603").val(score[0]);
- $("#opt_input").val(score[1].split(",").length)
- } */
- //查询子表选项内容并赋值
- var url = $.pathname() + '/ws/Examine/ExamineManagementService/getAnswerNum/';
- var params = {
- question_id : fd_id
- };
-
- //if(questionType!=3){//当题目类型不是判断题时
- $.ajax({
- url:url,
- data:params,
- type : 'post',
- dataType:"json",
- success:function(data){
- if(questionType == 4){
- var fd_ids_604 = "";
- for (var i = 0; i < data.length; i++) {
- var $option = $("#option_"+data[i].OPTION+"_"+data[i].OPTION_INDEX);
-
- if($option){
- $option.parent().find(".answer_content").val(data[i].OPTION_CONTENT);
- $option.parent().find(".answer_id").val(data[i].FD_OBJECTID);
- //把每个单项分赋值
- //$option.parent().parent().parent().find("input[name='score_option_"+data[i].OPTION_INDEX+"']").val(question_score.split("|")[1].split(",")[data[i].OPTION_INDEX-1]);
- }
- //$(".answer_content").eq(i).val(data[i].OPTION_CONTENT);
- fd_ids_604 += data[i].FD_OBJECTID + ",";
- }
- fd_ids_604 = fd_ids_604.substring(0, fd_ids_604.length-1);
- $("#FD_OBJECTID604").val(fd_ids_604);//保存四个选项主键,用于修改时定位到数据库记录
-
- }else{
- var fd_ids_604 = "";
- for (var i = 0; i < data.length; i++) {
- var $option = $("#option_"+data[i].OPTION);
- if($option){
- if(opt_type == 1){
- $option.parent().find(".answer_content").val(data[i].OPTION_CONTENT)
- }else{
- //$option.parent().find("#uploadify").val(data[i].OPTION_CONTENT);
- $option.parent().find("#file_name").val(data[i].OPTION_CONTENT)
- }
- }
- //$(".answer_content").eq(i).val(data[i].OPTION_CONTENT);
- fd_ids_604 += data[i].FD_OBJECTID + ",";
- }
- fd_ids_604 = fd_ids_604.substring(0, fd_ids_604.length-1);
- $("#FD_OBJECTID604").val(fd_ids_604);//保存四个选项主键,用于修改时定位到数据库记录
- }
-
- },
- error:function(){
- top.Dialog.alert("访问服务失败!");
- }
- });
- //}
- });
-
- }else{//新增
- $("#titleShow").text("新增考试题目");
- $("#INPUT_NAME_603").val(realName);
- $("#INPUT_PERSON_DEPT_603").val(deptId);
- $("#INPUT_PERSON_UNIT_603").val(unitId);
- $("#INPUT_TIME_603").val(getDateTime());
- $("#INPUT_NAME_ID_603").val(userId);
- $("#QUESTION_VERSION_ID_603").val(versionId);
- createAnswerDomByType("1",0);
- }
-
-
- });
-
- function getAnswerCount(opt_sum){//选项个数
- var str = 0;
- $.ajax({
- url:$.pathname() + '/ws/Examine/ExamineManagementService/getAnswerNum/',
- data:{question_id : fd_id},
- type : 'post',
- dataType:"json",
- async:false,
- success:function(data){
- if(opt_sum == 0){
- str = data.length;
- }else{
- var arr = new Array();
- for(var j=0;j<opt_sum;j++){//初始化
- arr[j]=0;
- }
- for(var i=0;i<data.length;i++){
- arr[data[i].OPTION_INDEX-1]++;
- }
- str = arr;
- }
- }
- });
- return str;
- }
-
- var is_add = 0;//判断是否添加了inut
- //根据题目类型创建答案选项节点
- function createAnswerDomByType(type,isEdit){/***isEdit 0:新增 1:修改***/
- if(type=="4"){
- $(".answer_con_dom").remove();//先清空容器
- $(".option_table_style").parent().parent().remove();
- if(is_add == 0){
- $("#answer_opt").append("<input type='text' value='4' id='opt_input' inputMode='numberOnly' maxlength='1' style='height:20px;width:60px;text-align:center;'/><label> 个选项答案</label>");
- is_add ++;
- }
- }else{
- $(".answer_con_dom").remove();
- $("#answer_opt").children().remove();
- is_add = 0;
- $(".option_table_style").parent().parent().remove();//先清空容器
- }
-
- /*******修改页面*******/
- if(isEdit == 1){
- if(opt_type==1){//文字选项
- if(type=="1"){//单选题
- if(answer_sum==2){
- $("#answer_opt").parent().after(textInput2('B','radio','block','none')).after(textInput1('A','radio'));
- }else if(answer_sum==3){
- $("#answer_opt").parent().after(textInput2('C','radio','block','none'))
- .after(textInput2('B','radio','none','none')).after(textInput1('A','radio'));
- }else if(answer_sum==4){
- $("#answer_opt").parent().after(textInput2('D','radio','block','block'))
- .after(textInput2('C','radio','none','none')).after(textInput2('B','radio','none','none')).after(textInput1('A','radio'));
-
- }else if(answer_sum==5){
- $("#answer_opt").parent().after(textInput2('E','radio','block','block')).after(textInput2('D','radio','none','none'))
- .after(textInput2('C','radio','none','none')).after(textInput2('B','radio','none','none')).after(textInput1('A','radio'));
-
- }else if(answer_sum==6){
- $("#answer_opt").parent().after(textInput2('F','radio','block','block')).after(textInput2('E','radio','none','none')).after(textInput2('D','radio','none','none'))
- .after(textInput2('C','radio','none','none')).after(textInput2('B','radio','none','none')).after(textInput1('A','radio'));
-
- }else if(answer_sum==7){
- $("#answer_opt").parent().after(textInput2('G','radio','block','block')).after(textInput2('F','radio','block','block')).after(textInput2('E','radio','none','none'))
- .after(textInput2('D','radio','none','none')).after(textInput2('C','radio','none','none')).after(textInput2('B','radio','none','none')).after(textInput1('A','radio'));
- }
-
- }else if(type=="2"){//多选题
-
- if(answer_sum==2){
- $("#answer_opt").parent().after(textInput2('B','checkbox','block','none')).after(textInput1('A','checkbox'));
- }else if(answer_sum==3){
- $("#answer_opt").parent().after(textInput2('C','checkbox','block','none'))
- .after(textInput2('B','checkbox','none','none')).after(textInput1('A','checkbox'));
- }else if(answer_sum==4){
- $("#answer_opt").parent().after(textInput2('D','checkbox','block','block'))
- .after(textInput2('C','checkbox','none','none')).after(textInput2('B','checkbox','none','none')).after(textInput1('A','checkbox'));
-
- }else if(answer_sum==5){
- $("#answer_opt").parent().after(textInput2('E','checkbox','block','block')).after(textInput2('D','checkbox','none','none'))
- .after(textInput2('C','checkbox','none','none')).after(textInput2('B','checkbox','none','none')).after(textInput1('A','checkbox'));
-
- }else if(answer_sum==6){
- $("#answer_opt").parent().after(textInput2('F','checkbox','block','block')).after(textInput2('E','checkbox','none','none')).after(textInput2('D','checkbox','none','none'))
- .after(textInput2('C','checkbox','none','none')).after(textInput2('B','checkbox','none','none')).after(textInput1('A','checkbox'));
-
- }else if(answer_sum==7){
- $("#answer_opt").parent().after(textInput2('G','checkbox','block','block')).after(textInput2('F','checkbox','block','block')).after(textInput2('E','checkbox','none','none'))
- .after(textInput2('D','checkbox','none','none')).after(textInput2('C','checkbox','none','none')).after(textInput2('B','checkbox','none','none')).after(textInput1('A','checkbox'));
- }
- }
-
- /*******情景选择题******/
- if(type == "4"){//情景选择题
- var option = answer_option.split("|");
- var self = $("#answer_opt").parent();
- for(var i=option.length-1;i>=0;i--){
- var val = '';
- if(option[i] ==1){
- val = 'radio';
- }else{
- val = 'checkbox';
- }
- self.after(textInput3(val,i+1,option[i],answer_sum[i]))
- }
- //$("#answer_opt").parent().after(textInput3('checkbox',2)).after(textInput3('radio',1))
- }
-
- }else{//图片选项
- if(type=="1"){//单选题
- if(answer_sum==2){
- $("#answer_opt").parent().after(fileInput2('B','radio','block','none')).after(fileInput1('A','radio'));
- }else if(answer_sum==3){
- $("#answer_opt").parent().after(fileInput2('C','radio','block','none'))
- .after(fileInput2('B','radio','none','none')).after(fileInput1('A','radio'));
- }else if(answer_sum==4){
- $("#answer_opt").parent().after(fileInput2('D','radio','block','block'))
- .after(fileInput2('C','radio','none','none')).after(fileInput2('B','radio','none','none')).after(fileInput1('A','radio'))
-
- }else if(answer_sum==5){
- $("#answer_opt").parent().after(fileInput2('E','radio','block','block')).after(fileInput2('D','radio','none','none'))
- .after(fileInput2('C','radio','none','none')).after(fileInput2('B','radio','none','none')).after(fileInput1('A','radio'));
-
- }else if(answer_sum==6){
- $("#answer_opt").parent().after(fileInput2('F','radio','block','block')).after(fileInput2('E','radio','none','none')).after(fileInput2('D','radio','none','none'))
- .after(fileInput1('C','radio','none','none')).after(fileInput2('B','radio','none','none')).after(fileInput1('A','radio'));
-
- }else if(answer_sum==7){
- $("#answer_opt").parent().after(fileInput2('G','radio','block','block')).after(fileInput2('F','radio','block','block')).after(fileInput2('E','radio','none','none'))
- .after(fileInput2('D','radio','none','none')).after(fileInput2('C','radio','none','none')).after(fileInput2('B','radio','none','none')).after(fileInput1('A','radio'));
- }
-
- }else if(type=="2"){//多选题
-
- if(answer_sum==2){
- $("#answer_opt").parent().after(fileInput2('B','checkbox','block','none')).after(fileInput1('A','checkbox'));
- }else if(answer_sum==3){
- $("#answer_opt").parent().after(fileInput2('C','checkbox','block','none'))
- .after(fileInput2('B','checkbox','block','none')).after(fileInput1('A','checkbox'));
- }else if(answer_sum==4){
- $("#answer_opt").parent().after(fileInput2('D','checkbox','block','block'))
- .after(fileInput2('C','checkbox','none','none')).after(fileInput2('B','checkbox','block','none')).after(fileInput1('A','checkbox'))
-
- }else if(answer_sum==5){
- $("#answer_opt").parent().after(fileInput2('E','checkbox','block','block')).after(fileInput2('D','checkbox','none','none'))
- .after(fileInput2('C','checkbox','none','none')).after(fileInput2('B','checkbox','block','none')).after(fileInput1('A','checkbox'));
-
- }else if(answer_sum==6){
- $("#answer_opt").parent().after(fileInput2('F','checkbox','block','block')).after(fileInput2('E','checkbox','none','none')).after(fileInput2('D','checkbox','none','none'))
- .after(fileInput1('C','checkbox','none','none')).after(fileInput2('B','checkbox','block','none')).after(fileInput1('A','checkbox'));
-
- }else if(answer_sum==7){
- $("#answer_opt").parent().after(fileInput2('G','checkbox','block','block')).after(fileInput2('F','checkbox','block','block')).after(fileInput2('E','checkbox','none','none'))
- .after(fileInput2('D','checkbox','none','none')).after(fileInput2('C','checkbox','none','none')).after(fileInput2('B','checkbox','block','none')).after(fileInput1('A','checkbox'));
- }
- }
- }
-
- if(type =="3" ||type =="4"){
- $("#option_word").attr("disabled","disabled");
- $("#option_picture").attr("disabled","disabled");
- }else{
- $("#option_word").removeAttr("disabled");
- $("#option_picture").removeAttr("disabled");
- }
- }else{
- /*****新增页面*******/
- if(opt_type==1){//文字选项
- if(type=="1"){//单选题
-
- $("#answer_opt").parent().after(textInput2('D','radio','block','block'))
- .after(textInput2('C','radio','none','none')).after(textInput2('B','radio','none','none')).after(textInput1('A','radio'))
- }else if(type=="2"){//多选题
-
- $("#answer_opt").parent().after(textInput2('D','checkbox','block','block'))
- .after(textInput2('C','checkbox','none','none')).after(textInput2('B','checkbox','none','none')).after(textInput1('A','checkbox'));
- }
-
- }else{//图片选项
- if(type=="1"){//单选题
-
- $("#answer_opt").parent().after(fileInput2('D','radio','block','block'))
- .after(fileInput2('C','radio','none','none')).after(fileInput2('B','radio','none','none')).after(fileInput1('A','radio'))
- }else if(type=="2"){//多选题
-
- $("#answer_opt").parent().after(fileInput2('D','checkbox','block','block'))
- .after(fileInput2('C','checkbox','none','none')).after(fileInput2('B','checkbox','none','none')).after(fileInput1('A','checkbox'));
- }
- }
-
- if(type == "4"){//情景选择题
- var num = $("#opt_input").val();
- for(var i=num;i>=1;i--){
- $("#answer_opt").parent().after(textInput3('radio',i,1,4))
- }
- //$("#answer_opt").parent().after(textInput3('radio',2,1)).after(textInput3('radio',1,1))
- }
- }
-
- if(type=="3"){//判断题
- $("#answer_opt").parent().after("<tr class='answer_con_dom'>"+
- "<td align='right' width='15%' ><span class='star'>*</span>选项:</td>"+
- "<td width='35%'>"+
- "<input type='radio' value='A' id='option_A' name='OPTIONS' /><label>A</label> <label>正确</label>"+
- "</td>"+
- "</tr>"+
- "<tr class='answer_con_dom'>"+
- "<td align='right' width='15%' ></td>"+
- "<td width='35%'>"+
- "<input type='radio' value='B' id='option_B' name='OPTIONS' /><label>B</label> <label>错误</label>"+
- "</td><td colspan='2'></td>"+
- "</tr>");
- }
-
- if(type =="3" ||type =="4"){
- $("#option_word").attr("checked","checked");
- $("#option_word").attr("disabled","disabled");
- $("#option_picture").attr("disabled","disabled");
- }else{
- $("#option_word").removeAttr("disabled");
- $("#option_picture").removeAttr("disabled");
- }
-
- //再添加绑定点击事件,点击新增一行
- $("input[name=add_btn]").on("click",function(value){
- var self = $(this);
- var val = self.parent().prev().children().eq(1).text();//当前选项值
- if(val == 'B'){
- self.parent().next().children().attr('style','display:block');
- }
- var parentTr = self.parent().parent();
- var cloneTr = parentTr.clone(true);
- parentTr.after(cloneTr);
- if(opt_type == 1){//文字选项
- parentTr.next().children().eq(1).find(".answer_id").val("");
- parentTr.next().children().eq(1).find(".textinput").val("");
- parentTr.next().children().eq(1).find("[name='OPTIONS']").attr('checked',false);
- }else{
- parentTr.next().children().eq(1).find("[name='OPTIONS']").attr('checked',false);
- parentTr.next().children().eq(1).find("#uploadify").val("");
- parentTr.next().children().eq(1).find("#file_name").val("");
- }
-
- var opt = parentTr.next().children().eq(1).find("[name='OPTIONS']");//克隆后改变选项值
- var flag = optionVal(val);
- opt.val(flag);
- opt.attr('id','option_'+flag)
- opt.next().text(flag)
- setHight();
- self.attr('style','display:none');
- self.parent().next().children().attr('style','display:none');
- if(flag == 'G'){
- parentTr.next().children().eq(2).remove();
- }
- });
- //绑定删除点击事件
- $("input[name=delete_btn]").on("click",function(){
- var flag = $(this).parent().prev().prev().children().eq(1).text();//当前选项值
- if(flag != 'C'){
- $(this).parent().parent().prev().children().eq(3).children().attr('style','display:block');
- }
- $(this).parent().parent().prev().children().eq(2).children().attr('style','display:block');
-
- $(this).parent().parent().remove();
-
- setHight();
- });
-
- //上传文件
- $(".uploadFile").on("click",function(){
- var self = $(this);
- var fileObj =$(this).parent().find(".uploadify")[0].files[0]; // 获取文件对象
- var FileController ="../../../../ws/uploadForm/FileUpDownService/indexUpLoad"; // 接收上传文件的后台地址
- var size = fileObj.size;
- var suffix = fileObj.name.split('.');
- var suffixName = suffix[suffix.length-1].toLowerCase();
-
- if(suffixName!="jpg"&&suffixName!="jpeg"&&suffixName!="png"&&suffixName!="gif"){
- top.Dialog.alert('请上传jpg、jpeg、png、gif格式!');
- return;
- }
- if(size == 0){
- top.Dialog.alert('不能上传空文件!');
- return;
- }
- if(fileObj){
- // FormData 对象
- var form = new FormData();
- form.append("file", fileObj);// 文件对象
-
- // XMLHttpRequest 对象
- var xhr = new XMLHttpRequest();
- xhr.open("post", FileController, true);
- xhr.onload = function () {
- self.prev().val(xhr.responseText);
- top.Dialog.alert('上传成功!')
- //console.log('--------'+xhr.responseText);
- };
- xhr.send(form);
- }else{
- top.Dialog.alert('请选择文件!');//弹出提示
- }
-
- });
-
- //删除文件
- $(".delFile").on("click",function(){
- $(this).parent().find("#uploadify").val('');
- $(this).parent().find("#file_name").val('');
- top.Dialog.alert('删除成功!')
- });
-
- //预览图片
- $(".preview").on('click',function(){
- var url = $(this).parent().find("#file_name").val();
- preview(url);
- })
-
- //情景选择题增加按钮
- $("input[name=add_btn_qj]").on("click",function(){
- var self = $(this);
- var val = self.parent().prev().children().eq(1).text();//当前选项值
- if(val == 'B'){
- self.parent().next().children().attr('style','display:block');
- }
- var parentTr = self.parent().parent();
- var cloneTr = parentTr.clone(true);
- parentTr.after(cloneTr);
- parentTr.next().children().eq(0).find(".answer_id").val("");
- parentTr.next().children().eq(0).find(".textinput").val("");
- parentTr.next().children().eq(0).find("[name^='OPTIONS_']").attr('checked',false);
-
- var opt = parentTr.next().children().eq(0).find("[name^='OPTIONS_']");//克隆后改变选项值
- var flag = optionVal(val);
- opt.val(flag);
- opt.attr('id','option_'+flag)
- opt.next().text(flag)
- setHight();
- self.attr('style','display:none');
- self.parent().next().children().attr('style','display:none');
- if(flag == 'G'){
- parentTr.next().children().eq(1).remove();
- parentTr.next().children().eq(1).attr('colspan','2');
- }
- });
- //情景选择题删除按钮
- $("input[name=delete_btn_qj]").on("click",function(){
- var flag = $(this).parent().prev().prev().children().eq(1).text();//当前选项值
- if(flag != 'C'){
- $(this).parent().parent().prev().children().eq(2).children().attr('style','display:block');
- }
- $(this).parent().parent().prev().children().eq(1).children().attr('style','display:block');//
-
- $(this).parent().parent().remove();
-
- setHight();
- });
- $("#opt_input").bind("change",function(){
- var val = $("#opt_input").val();
- if(val < 2){
- $("#opt_input").val(2);//情景选择题最少两个选择
- }
- createAnswerDomByType("4",0);
- })
- //情景选择题中单选多选按钮
- $(".opt_type_radio").bind("change",function(){
- /* var self = $(this);
- var radio_type = self.val();// 单选or多选
- var index = self.parent().children().eq(0).val();
- self.parent().children().find(".opt_type_radio").removeAttr("checked",false);
- self.attr("checked",true);
- var Tr = self.parent().parent().parent();
- Tr.children().eq(0).nextAll().remove();
- if(radio_type == 1){
- Tr.append(textInput4("radio",index));;
- }else{
- Tr.append(textInput4("checkbox",index));
- } */
- var self = $(this);
- var radio_type = self.val();// 单选or多选
- self.parent().children().find(".opt_type_radio").removeAttr("checked",false);
- self.attr("checked",true);
- if(radio_type == 1){
- var $dom = self.parent().parent().nextAll().children().find("input[name^=OPTIONS_]")
- for(var i=0;i<$dom.length;i++){
- $dom.eq(i)[0].type = "radio";
- }
- }else{
- var $dom = self.parent().parent().nextAll().children().find("input[name^=OPTIONS_]")
- for(var i=0;i<$dom.length;i++){
- $dom.eq(i)[0].type = "checkbox";
- }
- }
-
- setHight();
- });
- setHight();
- }
-
- function textInput1(char,type){
- var title = ""
- if(char == 'A'){
- title = "<span class='star'>*</span>选 项:";
- }
- var str = "<tr class='answer_con_dom'>"+
- "<td align='right' width='15%' >"+title+"</td>"+
- "<td width='22%'>"+
- "<input type='"+type+"' value='"+char+"' id='option_"+char+"' name='OPTIONS' /><label>"+char+"</label>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:90%;'>"+
- "</td><td colspan='2'></td>"+
- "</tr>"
- return str;
- }
-
- function textInput2(char,type,add_type,del_type){//例:A、radio、none、block
- var str = "<tr class='answer_con_dom'>"+
- "<td align='right' width='15%' ></td>"+
- "<td width='22%'>"+
- "<input type='"+type+"' value='"+char+"' id='option_"+char+"' name='OPTIONS' /><label>"+char+"</label>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:90%;'>"+
- "</td><td width='4%'><input type='button' width='65%' name='add_btn' value='再添加' style='display:"+add_type+"'/></td>"+
- "<td><input type='button' width='35%' name='delete_btn' value='删除' style='display:"+del_type+"'/></td>"+
- "</tr>"
- return str;
- }
- //情景选择题textInput
- function textInput3(type,index,radio_type,sum){//index表格序号 radio_type 1:单选 2:多选 sum 个数
- var title = "";
- var radio = "<input type='radio' value='1' class='opt_type_radio' name='opt_type_"+index+"' checked='checked' /><label>单选</label>"+
- "<input type='radio' value='2' class='opt_type_radio' name='opt_type_"+index+"' /><label>多选</label>";
- if(index == 1){
- title = "<span class='star'>*</span>选项:";
- }
- if(radio_type == 2){
- radio = "<input type='radio' value='1' class='opt_type_radio' name='opt_type_"+index+"' /><label>单选</label>"+
- "<input type='radio' value='2' class='opt_type_radio' name='opt_type_"+index+"' checked='checked'/><label>多选</label>";
- }
- var str = "<tr >"+
- "<td align='right' width='15%' >"+title+"</td>"+
- "<td width='22%'>"+
- "<table class='option_table_style'>"+
- "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<input type='hidden' value = '"+index+"'>"+
- radio+
- "</td><td colspan='2'>第"+index+"个选项答案</td>"+
- "</tr>";
- if(sum == 2){
- str += textInput5(type,'A',index)+textInput6(type,'B',index,'block','none');
- }
- if(sum == 3){
- //str += textInput5(type,'A',index)+textInput5(type,'B',index)+textInput6(type,'C',index,'block','none');
- str += textInput5(type,'A',index)+textInput6(type,'B',index,'none','none')+textInput6(type,'C',index,'block','block');
- }
- if(sum == 4){
- str += textInput5(type,'A',index)+textInput6(type,'B',index,'none','none')+textInput6(type,'C',index,'none','none')+textInput6(type,'D',index,'block','block');
- }
- if(sum == 5){
- str += textInput5(type,'A',index)+textInput6(type,'B',index,'none','none')+textInput6(type,'C',index,'none','none')+textInput6(type,'D',index,'none','none')+
- textInput6(type,'E',index,'block','block');
- }
- if(sum == 6){
- str += textInput5(type,'A',index)+textInput6(type,'B',index,'none','none')+textInput6(type,'C',index,'none','none')+textInput6(type,'D',index,'none','none')+
- textInput6(type,'E',index,'none','none')+textInput6(type,'F',index,'block','block');
- }
- if(sum == 7){
- str += textInput5(type,'A',index)+textInput6(type,'B',index,'none','none')+textInput6(type,'C',index,'none','none')+textInput6(type,'D',index,'none','none')+
- textInput6(type,'E',index,'none','none')+textInput6(type,'F',index,'none','none')+textInput6(type,'G',index,'none','block');
- }
-
- /* str += "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<label style='margin:0px 0px 5px 5px'>单项分值:</label>"+
- "<input class='validate[required] textinput' type='text' name='score_option_"+index+"' value='' inputMode='numberOnly' maxlength='2' style='width:30%;text-align: center;'/>"+
- "</td><td colspan='2'></td>"+
- "</tr>"+
- "</table>"+
- "</td>"+
- "</tr>" */
- str +="</table></td><td colspan='2'></td>";
- return str;
- }
- //情景选择题textInput
- function textInput4(type,index){
- var str = "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<input type='"+type+"' value='A' id='option_A_"+index+"' name='OPTIONS_"+index+"' /><label>A</label>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:85%;'>"+
- "</td><td colspan='2'></td>"+
- "</tr>"+
- "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<input type='"+type+"' value='B' id='option_B_"+index+"' name='OPTIONS_"+index+"' /><label>B</label>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:85%;'>"+
- "</td><td colspan='2'></td>"+
- "</tr>"+
- "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<input type='"+type+"' value='C' id='option_C_"+index+"' name='OPTIONS_"+index+"' /><label>C</label>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:85%;'>"+
- "</td><td width='4%'><input type='button' width='65%' name='add_btn_qj' value='再添加' style='display:none'/></td>"+
- "<td><input type='button' width='35%' name='delete_btn_qj' value='删除' style='display:none'/></td>"+
- "</tr>"+
- "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<input type='"+type+"' value='D' id='option_D_"+index+"' name='OPTIONS_"+index+"' /><label>D</label>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:85%;'>"+
- "</td><td width='4%'><input type='button' width='65%' name='add_btn_qj' value='再添加' style='display:block'/></td>"+
- "<td><input type='button' width='35%' name='delete_btn_qj' value='删除' style='display:block'/></td>"+
- "</tr>";
- /* "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<label style='margin:0px 0px 5px 5px'>单项分值:</label>"+
- "<input class='validate[required] textinput' type='text' name='score_option_"+index+"' value='' inputMode='numberOnly' maxlength='2' style='width:30%;text-align: center;'/>"+
- "</td><td colspan='2'></td>"+
- "</tr>" */
- return str;
- }
-
- function textInput5(type,char,index){
- var str = "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<input type='"+type+"' value='"+char+"' id='option_"+char+"_"+index+"' name='OPTIONS_"+index+"' /><label>"+char+"</label>"+
- "<input class='answer_id' type='hidden' value='' maxlength='80' style='width:85%;'>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:85%;'>"+
- "</td><td colspan='2'></td>"+
- "</tr>";
- return str;
- }
-
- function textInput6(type,char,index,add_type,del_type){
- var str = "<tr class='answer_con_dom'>"+
- "<td width='70%'>"+
- "<input type='"+type+"' value='"+char+"' id='option_"+char+"_"+index+"' name='OPTIONS_"+index+"' /><label>"+char+"</label>"+
- "<input class='answer_id' type='hidden' value='' maxlength='80' style='width:85%;'>"+
- "<input class='validate[required] answer_content textinput' type='text' value='' maxlength='80' style='width:85%;'>"+
- "</td><td width='4%'><input type='button' width='65%' name='add_btn_qj' value='再添加' style='display:"+add_type+"'/></td>"+
- "<td><input type='button' width='35%' name='delete_btn_qj' value='删除' style='display:"+del_type+"'/></td>"+
- "</tr>"
- return str;
- }
-
- function fileInput1(char,type){
- var title = ""
- if(char == 'A'){
- title = "<span class='star'>*</span>选 项:";
- }
- var str = "<tr class='answer_con_dom'>"+
- "<td align='right' width='15%' >"+title+"</td>"+
- "<td width='22%' colspan='2'>"+
- "<input type='"+type+"' value='"+char+"' id='option_"+char+"' name='OPTIONS' /><label>"+char+"</label>"+
- "<input type='file' name='uploadify' class='uploadify' style='margin:0 10px 0 10px'/>"+
- "<input type='hidden' id='file_name' />"+
- "<input type='button' value='上传' style='margin-right:10px' class='uploadFile'/>"+
- "<input type='button' value='重置' style='margin-right:10px' class='delFile'/>"+
- "<input type='button' value='预览' class='preview'/>"+
- "</td><td colspan='2'></td>"+
- "</tr>"
- return str;
- }
-
- function fileInput2(char,type,add_type,del_type){
- var str = "<tr class='answer_con_dom'>"+
- "<td align='right' width='15%' ></td>"+
- "<td width='22%' colspan='2'>"+
- "<input type='"+type+"' value='"+char+"' id='option_"+char+"' name='OPTIONS' /><label>"+char+"</label>"+
- "<input type='file' name='uploadify' class='uploadify' style='margin:0 10px 0 10px' />"+
- "<input type='hidden' id='file_name' />"+
- "<input type='button' value='上传' style='margin-right:10px' class='uploadFile'/>"+
- "<input type='button' value='重置' style='margin-right:10px' class='delFile'/>"+
- "<input type='button' value='预览' class='preview'/>"+
- "</td><td width='4%'><input type='button' width='65%' name='add_btn' value='再添加' style='display:"+add_type+"'/></td>"+
- "<td><input type='button' width='35%' name='delete_btn' value='删除' style='display:"+del_type+"'/></td>"+
- "</tr>"
- return str;
- }
-
- //选项值
- function optionVal(opt){
- var word = ['A','B','C','D','E','F','G'];
- for(var i=0;i<word.length;i++){
- if(word[i]==opt){
- return word[i+1];
- break;
- }
- }
- }
-
- //根据答案选择选项,answer格式为"A,D"、情景选择题格式为"A,D|A,B"
- function checkedByAnswer(answer,type){
- if(type == 4){
- var str = answer.split("|");
- for(var i=1;i<=str.length;i++){
- var val = str[i-1].split(",");
- for(var j=0;j<val.length;j++){
- if(val[j].indexOf("A")>-1){
- $("input[name=OPTIONS_"+i+"]").eq(0).attr("checked","checked");
- }
- if(val[j].indexOf("B")>-1){
- $("input[name=OPTIONS_"+i+"]").eq(1).attr("checked","checked");
- }
- if(val[j].indexOf("C")>-1){
- $("input[name=OPTIONS_"+i+"]").eq(2).attr("checked","checked");
- }
- if(val[j].indexOf("D")>-1){
- $("input[name=OPTIONS_"+i+"]").eq(3).attr("checked","checked");
- }
- if(val[j].indexOf("E")>-1){
- $("input[name=OPTIONS_"+i+"]").eq(4).attr("checked","checked");
- }
- if(val[j].indexOf("F")>-1){
- $("input[name=OPTIONS_"+i+"]").eq(5).attr("checked","checked");
- }
- if(val[j].indexOf("G")>-1){
- $("input[name=OPTIONS_"+i+"]").eq(6).attr("checked","checked");
- }
- }
- }
-
- }else{
- if(answer.indexOf("A")>-1){
- $("input[name=OPTIONS]").eq(0).attr("checked","checked");
- }
- if(answer.indexOf("B")>-1){
- $("input[name=OPTIONS]").eq(1).attr("checked","checked");
- }
- if(answer.indexOf("C")>-1){
- $("input[name=OPTIONS]").eq(2).attr("checked","checked");
- }
- if(answer.indexOf("D")>-1){
- $("input[name=OPTIONS]").eq(3).attr("checked","checked");
- }
- if(answer.indexOf("E")>-1){
- $("input[name=OPTIONS]").eq(4).attr("checked","checked");
- }
- if(answer.indexOf("F")>-1){
- $("input[name=OPTIONS]").eq(5).attr("checked","checked");
- }
- if(answer.indexOf("G")>-1){
- $("input[name=OPTIONS]").eq(6).attr("checked","checked");
- }
- }
-
- }
-
- /***图片预览***/
- function preview(url){
- var diag = new top.Dialog();
- var src_url = url
- diag.Title = '图片预览';
- diag.URL = $.pathname() + '/page/business/exercise/examineManagement/previewPicture.jsp?src_url='+src_url ;
- diag.Width = 400; //宽度
- diag.Height = 300; //高度
- diag.show();
- }
-
- //获得当前系统时间:年月日时分秒
- function getDateTime(){
- var s="";
- var d = new Date();
- var vYear = d.getFullYear();
- var vMon = d.getMonth() + 1;
- var vDay = d.getDate();
- var h = d.getHours();
- var m = d.getMinutes();
- var se = d.getSeconds();
- s=vYear+"-"+(vMon<10 ? "0" + vMon : vMon)+"-"+(vDay<10 ? "0"+ vDay : vDay)+" "+(h<10 ? "0"+ h : h)+":"+(m<10 ? "0" + m : m)+":"+(se<10 ? "0" +se : se);
- return s;
- }
-
- function changeQuestionType(){
- var question_type = $("#QUESTION_TYPE_603").val();
- if(question_type==""){
- question_type ="1";
- }
- createAnswerDomByType(question_type,0)
- }
-
- function radio_click(type){
- var question_type = $("#QUESTION_TYPE_603").val();
- if(question_type==''){
- question_type = '1';
- }
- opt_type = type;
- createAnswerDomByType(question_type,0)
- }
-
- function radio_click_qj(index){
-
- }
-
- function checkApplicableType(applicable_type){
-
- if(applicable_type.indexOf("1")>-1){
- $("[name='applicable_type']").eq(0).attr("checked","checked");
- }
- if(applicable_type.indexOf("2")>-1){
- $("[name='applicable_type']").eq(1).attr("checked","checked");
- }
- if(applicable_type.indexOf("3")>-1){
- $("[name='applicable_type']").eq(2).attr("checked","checked");
- }
- if(applicable_type.indexOf("4")>-1){
- $("[name='applicable_type']").eq(3).attr("checked","checked");
- }
- }
-
- function answerType(answer_type){
- if(answer_type=="1"){
- $("[name='opt_type']").eq(0).attr("checked","checked");
- opt_type = 1;
- }
- if(answer_type=="2"){
- $("[name='opt_type']").eq(1).attr("checked","checked");
- opt_type = 2;
- }
- }
-
- </script>
- </head>
-
- <body class="bd" align="center" >
- <div id="formContent" class="d_ground">
- <div class="title" align="center"><a href="javascript:;"><img id='goback' class="back" align="left" alt="返回" src="/nwyj/images/temp/back.png" ></img></a><font class="title_font" id="titleShow"></font></div>
- <form id="editForm">
- <input name="classid" id="603Class" value="603" type="hidden" />
- <input type="hidden" name="FD_OBJECTID603" value=""/>
- <input name="INPUT_NAME_603" id="INPUT_NAME_603" value="0" type="hidden"><!-- 出题人姓名 -->
- <input name="INPUT_NAME_ID_603" id="INPUT_NAME_ID_603" type="hidden"><!-- 出题人id -->
- <input name="INPUT_TIME_603" id="INPUT_TIME_603" type="hidden"><!-- 出题时间 -->
- <input name="INPUT_PERSON_UNIT_603" id="INPUT_PERSON_UNIT_603" type="hidden"><!-- 出题人所在单位 -->
- <input name="INPUT_PERSON_DEPT_603" id="INPUT_PERSON_DEPT_603" type="hidden"><!-- 出题人所在部门-->
- <input name="QUESTION_ANSWER_603" id="QUESTION_ANSWER_603" type="hidden"><!-- 出题人所在部门-->
- <input name="APPLICABLE_OBJECT_603" id="APPLICABLE_OBJECT_603" type="hidden"><!-- 适用对象 -->
- <input name="ANSWER_TYPE_603" id="ANSWER_TYPE_603" type="hidden"><!-- 答案类型 -->
- <input name="ANSWER_OPTION_603" id="ANSWER_OPTION_603" type="hidden"><!-- 情景选择题答案按钮选项 -->
- <input name="QUESTION_VERSION_ID_603" id="QUESTION_VERSION_ID_603" type="hidden"><!-- 版本号-->
- <!-- 保存和重置 -->
- <div class="button_jl">
- <input value="保存后继续新增" type="button"id="saveAndAgain" />
- <input value="保存" type="button"id="save" />
- <input value="重置" type="button" onclick="formReset()"/>
- <!-- <input value="放弃" type="button"id="giveUp" /> -->
- </div><br />
-
- <fieldset class="fieldset">
- <legend class="legend">基本信息:</legend>
- <table class="add_table_style" >
- <tr>
- <td align="right" width="15%" ><span class="star">*</span>内容类别:</td>
- <td width="35%"><select class="validate[required] selectWidth " swidth="69%" id="QUESTION_CLASSIFY_603" name="QUESTION_CLASSIFY_603" prompt="请选择" boxHeight="300">
- </select></td>
- </tr>
- <tr>
- <td align="right" width="15%" ><span class="star">*</span>题目类型:</td>
- <td width="35%"><select class="validate[required] selectWidth " swidth="69%" id="QUESTION_TYPE_603" name="QUESTION_TYPE_603" prompt="请选择" onchange="changeQuestionType();" >
- </select></td>
- </tr>
- <tr>
- <td align="right" width="15%"><!-- <span class="star">*</span> -->内容来源:</td>
- <td width="35%"><input name="EXAMINATION_CONTENT_603" id="EXAMINATION_CONTENT_603" type="text" value="" maxlength="300" style="width:460px;"></td>
- </tr>
- <tr>
- <td align="right" width="15%" ><span class="star">*</span>题目名称:</td>
- <td width="35%"><!-- <input name="QUESTION_NAME_603" class="validate[required]" id="QUESTION_NAME_603" type="text" value="" maxlength="200" style="width:78%;height:40px"> -->
- <textarea rows="5" cols="40" style="width:460px" name="QUESTION_NAME_603" class="validate[required]" id="QUESTION_NAME_603" maxlength="300"></textarea>
- </td>
- </tr>
- <tr >
- <td align="right" width="15%" ><span class="star">*</span>适用对象:</td>
- <td width="35%">
- <input type="checkbox" value="1" id="option_1" name="applicable_type" /><label>Ⅰ类</label>
- <input type="checkbox" value="2" id="option_2" name="applicable_type" /><label>Ⅱ类</label>
- <input type="checkbox" value="3" id="option_3" name="applicable_type" /><label>Ⅲ类</label>
- <input type="checkbox" value="4" id="option_4" name="applicable_type" /><label>Ⅳ类</label>
- </td>
- </tr>
- <tr >
- <td align="right" width="15%" ><span class="star">*</span>选项类型:</td>
- <td width="35%">
- <input type='radio' value='1' id='option_word' name='opt_type' checked="checked" onclick="radio_click(1)" /><label>文字</label>
- <input type='radio' value='2' id='option_picture' name='opt_type' onclick="radio_click(2)"/><label>图片</label>
- </td>
- </tr>
- <tr style="display: none;">
- <td align="right" width="15%" ></td>
- <td width="35%" id="answer_opt">
- </td><!-- 用于情景选择题答案选项 -->
- </tr>
- <!-- <tr>
- <td align="right" width="15%" ><span class="star">*</span>分 值:</td>
- <td width="35%"><select class="validate[required] selectWidth " swidth="78%" id="QUESTION_SCORE_603" name="QUESTION_SCORE_603" prompt="请选择" ></select>
- <input type='text' class="validate[required]" id="QUESTION_SCORE_603" name="QUESTION_SCORE_603" inputMode='numberOnly' maxlength='2' style="width:20%;text-align: center;"/><label> 分</label>
- </td>
- </tr> -->
- </table>
- </fieldset>
- </form>
-
- <form id="editFormSub">
- <input name="classid" id="604Class" value="604" type="hidden" />
- <input type="hidden" name="FD_OBJECTID604" id="FD_OBJECTID604" value=""/>
- <input name="OPTION_604" id="OPTION_604" value="0" type="hidden"/><!-- 选项 -->
- <input name="QUESTION_ID_604" id="QUESTION_ID_604" type="hidden"/><!-- 主表主键 -->
- <input name="OPTION_CONTENT_604" id="OPTION_CONTENT_604" type="hidden"/><!-- 选项内容-->
- <input name="OPTION_INDEX_604" id="OPTION_INDEX_604" type="hidden"/><!-- 选项位置-->
- </form>
- </div>
- </body>
|