we254/addons/fy_teacher/mobile/index/edit.php
@@ -85,13 +85,16 @@ // 知识点课 if($type=="5"){ $data['lesson_type'] = 5; $data['knowledge_pid'] = intval($_GPC['know_pid']); $data['knowledge_id'] = intval($_GPC['know_cid']); $data['knowledge_pid'] = $_GPC['know_pid']; $data['knowledge_id'] = $_GPC['know_cid']; $know_arr = array(); foreach ($_GPC['know_parent_name'] as $key => $row) { $know_parent_name = trim($_GPC['know_parent_name'][$key]); $know_name = trim($_GPC['know_name'][$key]); if (empty($know_parent_name) && empty($know_name) ){ continue; } if (empty($know_parent_name) && !empty($know_name) ){ message("请输入知识点【{know_name}】对应的专题名称!"); break; @@ -107,12 +110,12 @@ foreach ($know_arr as $key => $row) { // 验证要添加的专题名称是否已经存在 $know_parent = pdo_get("fy_lesson_knowledge_point", array('catalog_id_1'=>$data['pid'],'catalog_id_2'=>$data['cid'],'name'=>$know_parent_name, 'parentid'=>0)); $know_parent = pdo_get("fy_lesson_knowledge_point", array('catalog_id_1'=>$data['pid'],'catalog_id_2'=>$data['cid'],'name'=>$know_arr[$key]['know_parent_name'], 'parentid'=>0)); // 添加专题 $know = array( 'uniacid' => $_W['uniacid'], 'name' => $know_arr['know_parent_name'][$key], 'name' => $know_arr[$key]['know_parent_name'], 'ico' => "", 'link' => "", 'link_pc' => "", @@ -130,110 +133,52 @@ // 如果添加的专题名称存在,则取出专题id,作为新添加知识点的parentid if($know_parent){ $know['parentid'] = $know_parent[0]['id']; $know['parentid'] = $know_parent['id']; }else{ pdo_insert("fy_lesson_knowledge_point", $know); $new_know_pid = pdo_insertid(); if($new_know_pid){ $know['parentid'] = $new_know_pid; }else{ message("添加专题失败,请联系客服为您添加!"); } } // 添加知识点 $know['name'] = $know_arr['know_name'][$key]; pdo_insert("fy_lesson_knowledge_point", $know); $new_know_cid = pdo_insertid(); // 成功添加专题和知识点时,将新的专题和知识点ID添加到课程中 if($new_know_pid && $new_know_cid){ $data['knowledge_pid'] = $new_know_pid; $data['knowledge_id'] = $new_know_cid; if(empty($know['parentid'])){ message("获取专题失败,请重试或联系客服!"); } // 验证要添加的知识点名称是否已经存在 $know_record = pdo_get("fy_lesson_knowledge_point", array('catalog_id_1'=>$data['pid'],'catalog_id_2'=>$data['cid'],'name'=>$know_arr[$key]['know_name'], 'parentid'=>$know['parentid'])); if($know_record){ $data['knowledge_id'] .= ','.$know_record['id']; }else{ message("添加专题知识点失败,请联系管理员!"); } } // 先插入添加的专题和知识点 if($data['knowledge_pid']=="-1" ){ // 验证要添加的专题名称是否已经存在 $know_parent = pdo_get("fy_lesson_knowledge_point", array('catalog_id_1'=>$data['pid'],'catalog_id_2'=>$data['cid'],'name'=>$know_parent_name, 'parentid'=>0)); if($know_parent){ message("已经存在要添加的专题名称【{$know_parent_name}】。"); } // 添加专题 $know = array( 'uniacid' => $_W['uniacid'], 'name' => $know_parent_name, 'ico' => "", 'link' => "", 'link_pc' => "", 'parentid' => 0, 'displayorder' => 0, 'is_hot' => 0, 'is_show' => 1, 'search_show' => 1, 'addtime' => time(), 'catalog_id_1' => $data['pid'], 'catalog_id_2' => $data['cid'], 'teacher_created_flag' => 1, 'created_by' => $_SESSION[$uniacid.'_teacher_id'] ); pdo_insert("fy_lesson_knowledge_point", $know); $new_know_pid = pdo_insertid(); if($new_know_pid){ // 添加知识点 $know['name'] = $know_name; $know['parentid'] = $new_know_pid; // 要添加的知识点名称如果不存在,则添加知识点 $know['name'] = $know_arr[$key]['know_name']; pdo_insert("fy_lesson_knowledge_point", $know); $new_know_cid = pdo_insertid(); } // 成功添加专题和知识点时,将新的专题和知识点ID添加到课程中 if($new_know_pid && $new_know_cid){ $data['knowledge_pid'] = $new_know_pid; $data['knowledge_id'] = $new_know_cid; }else{ message("添加专题知识点失败,请联系管理员!"); // 成功添加专题和知识点时,将新的专题和知识点ID添加到课程中 if($new_know_cid){ $data['knowledge_id'] .= ','.$new_know_cid; }else{ message("添加知识点失败,请联系客服为您添加!"); } } }elseif($data['knowledge_id']=="-1" ){ // 验证要添加的专题名称是否已经存在 $know_child = pdo_get("fy_lesson_knowledge_point", array('catalog_id_1'=>$data['pid'],'catalog_id_2'=>$data['cid'],'name'=>$know_name, 'parentid'=>$data['knowledge_pid'])); if($know_child){ message("已经存在要添加的知识点名称【{$know_name}】。"); } // 去掉知识点id最后一位的逗号 if(substr($data['knowledge_id'],0,1)==','){ $data['knowledge_id'] = substr($data['knowledge_id'],1); } // 根据知识点id查询出所有属的所有上级id(专题id) if(count($data['knowledge_id'])>0){ $know_parent = pdo_fetchall("select distinct parentid from ims_fy_lesson_knowledge_point where id in(".$data['knowledge_id'].") ", array()); foreach($know_parent as $item){ $data['knowledge_pid'] .= ','.$item['parentid']; } } // 在原有的专题下,只添加知识点 $know = array( 'uniacid' => $_W['uniacid'], 'name' => $know_name, 'ico' => "", 'link' => "", 'link_pc' => "", 'parentid' => $data['knowledge_pid'], 'displayorder' => 0, 'is_hot' => 0, 'is_show' => 1, 'search_show' => 1, 'addtime' => time(), 'catalog_id_1' => $data['pid'], 'catalog_id_2' => $data['cid'], 'teacher_created_flag' => 1, 'created_by' => $_SESSION[$uniacid.'_teacher_id'] ); // 添加知识点 pdo_insert("fy_lesson_knowledge_point", $know); $new_know_cid = pdo_insertid(); // 成功知识点时,将知识点ID添加到课程中 if($new_know_cid){ $data['knowledge_id'] = $new_know_cid; }else{ message("添加知识点失败,请联系管理员!"); } if(substr($data['knowledge_pid'],0,1)==','){ $data['knowledge_pid'] = substr($data['knowledge_pid'],1); } } we254/addons/fy_teacher/template/mobile/css/xmenu/xmenu.css
@@ -187,19 +187,21 @@ margin: 2px; overflow: hidden; position: relative; background-color: #F57900; } .a-btn-text { color: #D7565B; color: #FFFFFF; display: block; font-size: 12px; font-size: 15px; text-align:center; line-height: 16px; padding:5px; text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5); /*text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);*/ } .a-btn:hover { background: none repeat scroll 0 0 #FFFFFF; background: none repeat scroll 0 0 #f58e26; box-shadow: 0 0 9px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(188, 188, 188, 0.1); } .a-btn:hover .a-btn-symbol { we254/addons/fy_teacher/template/mobile/index/edit.html
@@ -118,7 +118,7 @@ <a id="selectpos" href="javascript:void(0);" class="button bg-blue"><span>选择知识点</span></a> <a id="addKonw" href="javascript:void(0);" class="button bg-blue"><span>+新增知识点</span></a> </div> <input type="hidden" value="" id="selectposhidden" /> <input type="hidden" value="" id="know_cid" name="know_cid" /> </div> <div id="m1" class="xmenu" style="display: none;"> <div class="select-info"> @@ -126,7 +126,7 @@ <ul> </ul> <a name="menu-confirm" href="javascript:void(0);" class="a-btn"> <span class="a-btn-text">确定</span> <span class="a-btn-text">确认选择</span> </a> </div> <dl id="know_dl"> @@ -542,7 +542,7 @@ width :600, eventType: "click", //事件类型 支持focus click hover dropmenu:"#m1",//弹出层 hiddenID : "selectposhidden"//隐藏域ID hiddenID : "know_cid"//隐藏域ID }); }); @@ -580,7 +580,10 @@ //添加专题&知识点 $("#addKonw").click(function addKnowParent() { if($("input[name='know_parent_name[]']").length >=5){ alert("添加的专题知识点数量不能超过5个。"); return false; } var spec_html = ''; //$("#knowdiv").empty(); spec_html += '<div id="add_know_parent" class="input-group w60">'; @@ -591,38 +594,6 @@ spec_html += '</div>'; $("#knowdiv").append(spec_html); }); //添加知识点 function addKnow() { if($("#add_know_parent").length>0){ $("#add_know_parent").empty(); } if($("#add_know").length>0){ $("#add_know").show(); }else{ var spec_html = ''; $("#knowdiv").empty(); spec_html += '<div id="add_know" class="input-group w60">'; spec_html += ' <span class="input-group-addon">+知识点名称</span>'; spec_html += ' <input type="text" class="input" id="know_name" name="know_name">'; spec_html += '</div>'; $("#knowdiv").append(spec_html); } $("#know_child").hide(); } // 知识点下拉列表选择变化时 $("#know_child").change(function(){ var know_cid = $(this).children('option:selected').val(); // -1时为:添加新知识点 if(know_cid == -1){ addKnow(); $("#add_know_div").show(); }else{ $("#add_know_div").hide(); } }); //添加规格按钮 @@ -646,10 +617,10 @@ <script type="text/javascript"> var category = {php echo json_encode($catList);}; var know = {php echo json_encode($knowList);}; var pid = {php echo $lesson['pid']?$lesson['pid']:0}; var know_pid = {php echo $lesson['knowledge_pid']?$lesson['knowledge_pid']:0}; var html = '<option value="0">请选择一级分类</option>'; var htmlKnow = '<option value="0">请选择专题</option>'; var pid = {php echo $lesson['pid']?("'".$lesson['pid']."'"):"''"}; var know_pid = {php echo $lesson['knowledge_pid']?("'".$lesson['knowledge_pid']."'"):"''"}; var html = ''; var htmlKnow = ''; $(function(){ $("#category_parent").find("option[value='"+pid+"']").attr("selected",true); document.getElementById("category_parent").onchange(); @@ -687,7 +658,7 @@ }else{ for(var i in know){ chtml += '<dt id="' + know[i].id + '" class="open" >' + know[i].name + ' <a href="#" onclick="alert(123);">aaa</a></dt>'; chtml += '<dt id="' + know[i].id + '" class="open" >' + know[i].name + '</dt>'; chtml += '<dd style="padding-bottom: 0px;padding-top:0px;">'; chtml += ' <ul>'; var child = know[i].child; @@ -707,16 +678,16 @@ width :600, eventType: "click", //事件类型 支持focus click hover dropmenu:"#m1",//弹出层 hiddenID : "selectposhidden"//隐藏域ID hiddenID : "know_cid"//隐藏域ID }); $("span","#selectpos").text('+选择知识点'); $("#selectposhidden").val(''); $("#know_cid").val(''); $("#names").val(''); $("ul",".select-info").html(''); if(selected_ids_arr.length>0){ $("#selectposhidden").val(selected_ids_arr.join(',')); $("#know_cid").val(selected_ids_arr.join(',')); $("#names").val(selected_names_arr.join(',')); } /* if(!isnull(know_ids)){ @@ -795,14 +766,10 @@ return false; } <?php if($type=='5'){ ?> if($("#selectposhidden").val()=='' || $("#selectposhidden").val()==','){ alert('请选择知识点'); return false; } var know_name_arr = $("input[name='know_name[]']"); var know_parent_name_arr = $("input[name='know_parent_name[]']"); for(var i in know_name_arr){ var add_cnt = 0; for(var i=0;i<know_name_arr.length;i++){ if(know_name_arr[i].value.trim() != '' && know_parent_name_arr[i].value.trim() == ''){ alert("请输入专题名称"); know_parent_name_arr[i].focus(); @@ -813,7 +780,15 @@ know_name_arr[i].focus(); return false; } if(know_parent_name_arr[i].value.trim() != '' && know_name_arr[i].value.trim() != ''){ add_cnt++; } } if(($("#know_cid").val()=='' || $("#know_cid").val()==',') && add_cnt==0){ alert('请选择知识点'); return false; } <?php } ?> we254/addons/fy_teacher/template/mobile/js/xmenu/jquery-xmenu.js
@@ -14,7 +14,7 @@ eventType: "click", //事件类型,其他可选参数有:click, focus dropmenu:".xmenu",//弹出层div hiddenID : "selectposhidden",//隐藏域ID emptytext: "+选择知识点" emptytext: "" }; $.fn.xMenu = function(options) {