From 30ba6c6ec8d227636ef4dafe7b5de877b2a0722b Mon Sep 17 00:00:00 2001 From: zm <zm@iemsoft.cn> Date: Fri, 25 Sep 2020 18:49:48 +0800 Subject: [PATCH] 知识点未完 --- we254/addons/fy_teacher/mobile/index/edit.php | 80 ++++++++++++++++++++++++++++++++------- 1 files changed, 65 insertions(+), 15 deletions(-) diff --git a/we254/addons/fy_teacher/mobile/index/edit.php b/we254/addons/fy_teacher/mobile/index/edit.php index 140b3f1..de47593 100644 --- a/we254/addons/fy_teacher/mobile/index/edit.php +++ b/we254/addons/fy_teacher/mobile/index/edit.php @@ -87,23 +87,73 @@ $data['lesson_type'] = 5; $data['knowledge_pid'] = intval($_GPC['know_pid']); $data['knowledge_id'] = intval($_GPC['know_cid']); - $know_parent_name = trim($_GPC['know_parent_name']); - $know_name = trim($_GPC['know_name']); + $know_arr = array(); - if(empty($data['knowledge_pid'])){ - message("请选择专题!"); + 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) ){ + message("请输入知识点【{know_name}】对应的专题名称!"); + break; + } + if (!empty($know_parent_name) && empty($know_name) ){ + message("请输入专题【{know_parent_name}】对应的知识点名称!"); + break; + } + $know_arr[] = array( + 'know_parent_name' => $know_parent_name, + 'know_name' => $know_name); } - if($data['knowledge_pid']=="-1" && empty($know_parent_name)){ - message("请输入要添加的专题名称!"); - } - if($data['knowledge_pid']=="-1" && empty($know_name)){ - message("请输入要添加的知识点名称!"); - } - if($data['knowledge_pid']!="-1" && empty($data['knowledge_id'])){ - message("请选择知识点!"); - } - if($data['knowledge_id']=="-1" && empty($know_name)){ - message("请输入要添加的知识点名称!"); + + 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 = array( + 'uniacid' => $_W['uniacid'], + 'name' => $know_arr['know_parent_name'][$key], + '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'] + ); + + // 如果添加的专题名称存在,则取出专题id,作为新添加知识点的parentid + if($know_parent){ + $know['parentid'] = $know_parent[0]['id']; + }else{ + pdo_insert("fy_lesson_knowledge_point", $know); + $new_know_pid = pdo_insertid(); + if($new_know_pid){ + $know['parentid'] = $new_know_pid; + } + } + + // 添加知识点 + $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; + }else{ + message("添加专题知识点失败,请联系管理员!"); + } + } // 先插入添加的专题和知识点 -- Gitblit v1.8.0